member.vue 7.8 KB

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