member.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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">1积分等于{{detail.pointUnitValue}}元</view>
  14. <view class="u-flex u-row-between">
  15. <view class="item">
  16. <text>{{detail.memberNum}}</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元赠送{{detail.sendPointUnit}}积分</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?userId='+item.userId)">
  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. <u-form-item label-width="180" label="消费1元赠送">
  72. <u-input
  73. v-model="sendPointUnit"
  74. border="true"
  75. border-color="#eaeaea"
  76. type="number"
  77. :clearable="false"
  78. placeholder="请输入积分数"
  79. />
  80. <view slot="right" style="color: #D18C42;">积分</view>
  81. </u-form-item>
  82. </u-form>
  83. <u-button size="medium" shape="circle" :custom-style="customStyle1" @click="update">确定</u-button>
  84. <u-button size="medium" shape="circle" :custom-style="customStyle2" @click="showPopup=false">取消</u-button>
  85. </view>
  86. </u-popup>
  87. </view>
  88. </template>
  89. <script>
  90. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  91. export default {
  92. mixins: [MescrollMixin],
  93. data() {
  94. return {
  95. isOpenMember: false,
  96. detail: {},
  97. dataList: [],
  98. height:'300px',
  99. downOption: {
  100. use: true,
  101. auto: false // 不自动加载
  102. },
  103. upOption: {
  104. use: true,
  105. auto: false // 不自动加载
  106. },
  107. showPopup:false,
  108. //消费一元赠送的积分值
  109. sendPointUnit:'',
  110. customStyle1:{
  111. backgroundColor:'#D18C42',
  112. color:'#fff',
  113. marginBottom:'20rpx',
  114. width:'400rpx'
  115. },
  116. customStyle2:{
  117. width:'400rpx'
  118. },
  119. }
  120. },
  121. watch:{
  122. mescroll(){
  123. if (this.isOpenMember) {
  124. this.mescroll.resetUpScroll();
  125. }
  126. }
  127. },
  128. onReady() {
  129. this.getElInfo()
  130. },
  131. onLoad() {
  132. this.fetchMemberInfo()
  133. },
  134. methods: {
  135. update(){
  136. let params = {
  137. id: this.vuex_shopId,
  138. sendPointUnit:this.sendPointUnit
  139. }
  140. this.$api.shop.submit(params).then(res => {
  141. this.fetchMemberInfo()
  142. this.showPopup = false
  143. })
  144. },
  145. async getElInfo() {
  146. let rectInfo = await this.$u.getRect('.tableTitle');
  147. this.height=this.$u.sys().windowHeight - rectInfo.top + 'px'
  148. },
  149. fetchMemberInfo(){
  150. let params={
  151. shopId:this.vuex_shopId
  152. }
  153. this.$api.shop.memberInfo(params).then(res=>{
  154. if (res.data.isOpenMember == 1) {
  155. this.isOpenMember = true
  156. this.detail = res.data
  157. }
  158. })
  159. },
  160. downCallback() {
  161. setTimeout(()=>{
  162. this.mescroll.resetUpScroll();
  163. },800)
  164. },
  165. upCallback(mescroll) {
  166. let params = {
  167. shopId: this.vuex_shopId,
  168. current: mescroll.num,
  169. size: mescroll.size,
  170. //商店会员
  171. type:2
  172. }
  173. try {
  174. this.$api.member.list(params).then(res => {
  175. let data = res.data.records
  176. let total = res.data.total
  177. mescroll.endBySize(data.length, total);
  178. if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  179. this.dataList = this.dataList.concat(data); //追加新数据
  180. })
  181. } catch (e) {
  182. this.mescroll.endErr()
  183. }
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .btn-bg-color {
  190. background-color: #EE9230;
  191. color: #FFFFFF;
  192. }
  193. .empty-page {
  194. height: 50vh;
  195. display: flex;
  196. justify-content: center;
  197. flex-direction: column;
  198. align-items: center;
  199. color: #CCCCCC;
  200. image {
  201. width: 120rpx;
  202. height: 120rpx;
  203. margin-bottom: 20rpx;
  204. }
  205. }
  206. .top-menu {
  207. border-radius: 20rpx;
  208. margin: 30rpx 20rpx;
  209. padding: 50rpx;
  210. background-image: linear-gradient(to right, #272A46, #30355D);
  211. color: #fff;
  212. position: relative;
  213. .leftFixed{
  214. padding:0 10rpx;
  215. font-size: 22rpx;
  216. height: 40rpx;
  217. line-height: 40rpx;
  218. background-color: $color;
  219. color: #fff;
  220. position: absolute;
  221. top: 20rpx;
  222. left: 0;
  223. border-top-right-radius: 25px;
  224. border-bottom-right-radius: 25px;
  225. }
  226. .item {
  227. display: flex;
  228. flex-direction: column;
  229. text-align: center;
  230. align-items: center;
  231. justify-content: center;
  232. flex:1;
  233. margin-top: 30rpx;
  234. text:first-child {
  235. margin-bottom: 10rpx;
  236. color: #FFFFFF;
  237. font-weight: 800;
  238. font-size: 40rpx;
  239. }
  240. text:last-child {
  241. font-size: 26rpx;
  242. color: #D0D4EE;
  243. }
  244. }
  245. }
  246. .u-popup-content{
  247. display: flex;
  248. flex-direction: column;
  249. align-items: center;
  250. padding: 30rpx;
  251. u-form{
  252. margin: 60rpx 0;
  253. width: 500rpx;
  254. }
  255. }
  256. .card {
  257. width: 100%;
  258. background-color: #FFFFFF;
  259. padding: 30rpx;
  260. font-size: 26rpx;
  261. .text-area {
  262. display: flex;
  263. justify-content: flex-start;
  264. align-items: center;
  265. }
  266. .title {
  267. padding-left: 20rpx;
  268. color: #666666;
  269. }
  270. .area1 {
  271. width: 50%;
  272. }
  273. .area2 {
  274. width: 30%;
  275. }
  276. .area3 {
  277. width: 20%;
  278. }
  279. .item {
  280. padding: 30rpx 20rpx;
  281. display: flex;
  282. border-bottom: 1rpx solid #DDDDDD;
  283. .img-avatar {
  284. width: 70rpx;
  285. height: 70rpx;
  286. border-radius: 50%;
  287. }
  288. .img-points {
  289. width: 35rpx;
  290. height: 35rpx;
  291. }
  292. }
  293. }
  294. </style>