member.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view>
  3. <u-navbar :custom-back="back" title="会员中心"></u-navbar>
  4. <view v-show="!loading">
  5. <view class="empty-page" v-if="!isOpenMember">
  6. <image src="../../static/icon/huiyuan1.png" mode=""></image>
  7. <text style="color: #303030;font-weight: 800;font-size: 32rpx;margin-top: 25rpx;">创建会员中心</text>
  8. <text style="color: #888888;font-size: 26rpx;margin-top: 20rpx;">设置积分价值、积分规则</text>
  9. <text style="color: #888888;font-size: 26rpx;margin-top: 10rpx;">实时查看会员信息和积分情况</text>
  10. <view @click="$jump('/pages/member/add')" class="cu-btn btn-bg-color round" style="width: 48%;height: 80rpx;position: fixed;bottom: 40%;">
  11. <u-icon name="plus-circle-fill" size="40"></u-icon>
  12. <text class="margin-left-10 text-lg">创建会员中心</text>
  13. </view>
  14. </view>
  15. <block v-else>
  16. <view class="top-menu">
  17. <!-- <view class="leftFixed"> 1 积分等于 {{detail.pointUnitValue}} 元</view> -->
  18. <view class="u-flex u-row-between">
  19. <view class="item">
  20. <text>{{detail.memberNum}}</text>
  21. <text>会员数量</text>
  22. </view>
  23. <view class="item">
  24. <text>{{detail.totalPointValue}}</text>
  25. <text>积分总价值</text>
  26. </view>
  27. </view>
  28. <view class="u-m-t-50 u-flex u-col-center u-row-center">
  29. <text class="u-font-24 u-m-r-20">规则:消费 1 元赠送 {{detail.pointUnitValue}} 元</text>
  30. <view class="cu-btn bg-white sm round" @click="changeRule" style="padding: 10rpx 20rpx;">
  31. 更改规则
  32. </view>
  33. </view>
  34. </view>
  35. <view class="padding-20 text-bold text-xl">
  36. <text>会员列表</text>
  37. </view>
  38. <view class="card">
  39. <view class="flex tableTitle">
  40. <view class="area1 title">
  41. 会员信息
  42. </view>
  43. <view class="area2 title">
  44. 积分数
  45. </view>
  46. <view class="area3 title">
  47. 价值
  48. </view>
  49. </view>
  50. <mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  51. :down="downOption" :up="upOption">
  52. <view class="item" v-for="(item,index) in dataList" :key="index" @click="jumpDetail(item)">
  53. <view class="area1 flex text-bold">
  54. <image class="img-avatar"
  55. :src="item.avatar">
  56. </image>
  57. <view class="center padding-left-10">
  58. <text>{{item.nickName}}</text>
  59. </view>
  60. </view>
  61. <view class="area2 center text-bold text-lg"
  62. style="justify-content: flex-start;margin-left: 10rpx;color: #F37A1E;">
  63. <image class="img-points" src="../../static/icon/points-value.png"></image>
  64. <text class="margin-left-10">{{$digital.keepTwoDecimal(item.pointTotal)}}</text>
  65. </view>
  66. <view class="area3 center text-lg">
  67. <text class="text-price text-bold">{{$digital.keepTwoDecimal(item.pointValue)}}</text>
  68. </view>
  69. </view>
  70. </mescroll-body>
  71. </view>
  72. </block>
  73. <view v-if="isOpenMember&&$isNotEmpty(detail.memberNum)">
  74. <view class="" style="height: 40rpx;"></view>
  75. <view class="footer-fixed center bg-white padding-top-20" :style="{'paddingBottom':safeAreaBottom}" >
  76. <view @click="$jump('/pages/notice/notice')" class="cu-btn bg-btn radius" style="width: 80%;height: 80rpx;">
  77. <u-icon name="chat" size="40"></u-icon>
  78. <text class="margin-left-10">群发消息</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <u-popup v-model="showPopup" mode="center" border-radius="20">
  84. <view class="u-popup-content">
  85. <text>更改积分规则</text>
  86. <u-form>
  87. <u-form-item label-width="170" label="消费1元赠送">
  88. <u-input type="digit" height="50" :border="true" :clearable="false" v-model="sendPointUnit" placeholder="请输入积分数"/>
  89. <view slot="right" class="cu-tag btn-bg-color radius">
  90. 积分
  91. </view>
  92. </u-form-item>
  93. </u-form>
  94. <u-button size="medium" shape="circle" :custom-style="customStyle1" @click="update">确定</u-button>
  95. <u-button size="medium" shape="circle" :custom-style="customStyle2" @click="showPopup=false">取消</u-button>
  96. </view>
  97. </u-popup>
  98. <toast ref="toast" ></toast>
  99. <loading ref="loading" type="3" />
  100. </view>
  101. </template>
  102. <script>
  103. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  104. export default {
  105. mixins: [MescrollMixin],
  106. data() {
  107. return {
  108. loading:true,
  109. isOpenMember: false,
  110. detail: {},
  111. dataList: [],
  112. height:'300px',
  113. downOption: {
  114. use: false,
  115. auto: false // 不自动加载
  116. },
  117. upOption: {
  118. use: true,
  119. auto: false // 不自动加载
  120. },
  121. showPopup:false,
  122. //消费一元赠送的积分值
  123. sendPointUnit:'',
  124. customStyle1:{
  125. padding:'40rpx',
  126. backgroundColor:'#F39248',
  127. color:'#fff',
  128. marginBottom:'20rpx',
  129. width:'350rpx'
  130. },
  131. customStyle2:{
  132. padding:'40rpx',
  133. width:'350rpx'
  134. },
  135. }
  136. },
  137. watch:{
  138. mescroll(){
  139. if (this.isOpenMember) {
  140. this.mescroll.resetUpScroll();
  141. }
  142. }
  143. },
  144. onReady() {
  145. this.getElInfo()
  146. },
  147. onLoad() {
  148. this.$refs.loading.showLoading()
  149. this.fetchMemberInfo()
  150. },
  151. methods: {
  152. changeRule(){
  153. uni.navigateTo({
  154. url:"./add?type='change'"
  155. })
  156. },
  157. back(){
  158. uni.reLaunch({
  159. url:"/pages/index/index"
  160. })
  161. },
  162. update(){
  163. let params = {
  164. id: this.vuex_shopId,
  165. sendPointUnit:this.sendPointUnit
  166. }
  167. this.$api.shop.submit(params).then(res => {
  168. this.fetchMemberInfo()
  169. this.showPopup = false
  170. })
  171. },
  172. async getElInfo() {
  173. let rectInfo = await this.$u.getRect('.tableTitle');
  174. this.height=this.$u.sys().windowHeight - rectInfo.top + 'px'
  175. },
  176. async fetchMemberInfo(){
  177. let params={
  178. shopId:this.vuex_shopId
  179. }
  180. let res=await this.$api.shop.memberInfo(params)
  181. if (res.data.isOpenMember == 1) {
  182. this.isOpenMember = true
  183. this.detail = res.data
  184. }else{
  185. this.loading=false
  186. this.$refs.loading.hide()
  187. }
  188. },
  189. downCallback() {
  190. setTimeout(()=>{
  191. this.mescroll.resetUpScroll();
  192. },800)
  193. },
  194. upCallback(mescroll) {
  195. let params = {
  196. shopId: this.vuex_shopId,
  197. current: mescroll.num,
  198. size: 30,
  199. //商店会员
  200. type:'SHOP'
  201. }
  202. try {
  203. this.$api.member.list(params).then(res => {
  204. let data = res.data.records
  205. let total = res.data.total
  206. mescroll.endBySize(data.length, total);
  207. if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  208. this.dataList = this.dataList.concat(data); //追加新数据
  209. this.loading=false
  210. this.$refs.loading.hide()
  211. })
  212. } catch (e) {
  213. this.loading=false
  214. this.$refs.loading.hide()
  215. this.mescroll.endErr()
  216. }
  217. },
  218. jumpDetail(item){
  219. let params={
  220. userId:item.userId,
  221. id:item.id
  222. }
  223. uni.navigateTo({
  224. url:"/pages/member/detail"+this.$u.queryParams(params)
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .bg-btn{
  232. background-color: #F39248;
  233. color: #FFFFFF;
  234. }
  235. .empty-page {
  236. height: 600rpx;
  237. display: flex;
  238. justify-content: center;
  239. flex-direction: column;
  240. align-items: center;
  241. image {
  242. width: 160rpx;
  243. height: 160rpx;
  244. margin-bottom: 20rpx;
  245. }
  246. }
  247. .top-menu {
  248. border-radius: 20rpx;
  249. margin: 20rpx 20rpx;
  250. padding: 40rpx;
  251. background-image: linear-gradient(to right, #272A46, #30355D);
  252. color: #fff;
  253. position: relative;
  254. .leftFixed{
  255. padding:0 10rpx;
  256. font-size: 22rpx;
  257. height: 40rpx;
  258. line-height: 40rpx;
  259. background-color: $color;
  260. color: #fff;
  261. position: absolute;
  262. top: 20rpx;
  263. left: 0;
  264. border-top-right-radius: 25px;
  265. border-bottom-right-radius: 25px;
  266. }
  267. .item {
  268. display: flex;
  269. flex-direction: column;
  270. text-align: center;
  271. align-items: center;
  272. justify-content: center;
  273. flex:1;
  274. margin-top: 40rpx;
  275. text:first-child {
  276. margin-bottom: 5rpx;
  277. color: #FFFFFF;
  278. font-weight: 800;
  279. font-size: 38rpx;
  280. }
  281. text:last-child {
  282. font-size: 26rpx;
  283. color: #D0D4EE;
  284. }
  285. }
  286. }
  287. .u-popup-content{
  288. display: flex;
  289. flex-direction: column;
  290. align-items: center;
  291. padding: 30rpx;
  292. u-form{
  293. margin: 60rpx 0;
  294. width: 500rpx;
  295. }
  296. }
  297. .card {
  298. width: 100%;
  299. background-color: #FFFFFF;
  300. padding: 30rpx;
  301. font-size: 26rpx;
  302. .text-area {
  303. display: flex;
  304. justify-content: flex-start;
  305. align-items: center;
  306. }
  307. .title {
  308. padding-left: 20rpx;
  309. color: #666666;
  310. }
  311. .area1 {
  312. width: 50%;
  313. }
  314. .area2 {
  315. width: 30%;
  316. }
  317. .area3 {
  318. width: 20%;
  319. }
  320. .item {
  321. padding: 30rpx 20rpx;
  322. display: flex;
  323. border-bottom: 1rpx solid #DDDDDD;
  324. .img-avatar {
  325. width: 70rpx;
  326. height: 70rpx;
  327. border-radius: 50%;
  328. }
  329. .img-points {
  330. width: 35rpx;
  331. height: 35rpx;
  332. }
  333. }
  334. }
  335. </style>