member.vue 7.9 KB

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