member.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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.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. </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. changeRule(){
  142. uni.navigateTo({
  143. url:"./add?type='change'"
  144. })
  145. },
  146. back(){
  147. uni.reLaunch({
  148. url:"/pages/index/index"
  149. })
  150. },
  151. update(){
  152. let params = {
  153. id: this.vuex_shopId,
  154. sendPointUnit:this.sendPointUnit
  155. }
  156. this.$api.shop.submit(params).then(res => {
  157. this.fetchMemberInfo()
  158. this.showPopup = false
  159. })
  160. },
  161. async getElInfo() {
  162. let rectInfo = await this.$u.getRect('.tableTitle');
  163. this.height=this.$u.sys().windowHeight - rectInfo.top + 'px'
  164. },
  165. async fetchMemberInfo(){
  166. let params={
  167. shopId:this.vuex_shopId
  168. }
  169. let res=await this.$api.shop.memberInfo(params)
  170. if (res.data.isOpenMember == 1) {
  171. this.isOpenMember = true
  172. this.detail = res.data
  173. }
  174. },
  175. downCallback() {
  176. setTimeout(()=>{
  177. this.mescroll.resetUpScroll();
  178. },800)
  179. },
  180. upCallback(mescroll) {
  181. let params = {
  182. shopId: this.vuex_shopId,
  183. current: mescroll.num,
  184. size: mescroll.size,
  185. //商店会员
  186. type:'SHOP'
  187. }
  188. try {
  189. this.$api.member.list(params).then(res => {
  190. let data = res.data.records
  191. let total = res.data.total
  192. mescroll.endBySize(data.length, total);
  193. if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  194. this.dataList = this.dataList.concat(data); //追加新数据
  195. })
  196. } catch (e) {
  197. this.mescroll.endErr()
  198. }
  199. },
  200. jumpDetail(item){
  201. let params={
  202. userId:item.userId,
  203. id:item.id
  204. }
  205. uni.navigateTo({
  206. url:"/pages/member/detail"+this.$u.queryParams(params)
  207. })
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. .empty-page {
  214. height: 600rpx;
  215. display: flex;
  216. justify-content: center;
  217. flex-direction: column;
  218. align-items: center;
  219. image {
  220. width: 160rpx;
  221. height: 160rpx;
  222. margin-bottom: 20rpx;
  223. }
  224. }
  225. .top-menu {
  226. border-radius: 20rpx;
  227. margin: 20rpx 20rpx;
  228. padding: 40rpx;
  229. background-image: linear-gradient(to right, #272A46, #30355D);
  230. color: #fff;
  231. position: relative;
  232. .leftFixed{
  233. padding:0 10rpx;
  234. font-size: 22rpx;
  235. height: 40rpx;
  236. line-height: 40rpx;
  237. background-color: $color;
  238. color: #fff;
  239. position: absolute;
  240. top: 20rpx;
  241. left: 0;
  242. border-top-right-radius: 25px;
  243. border-bottom-right-radius: 25px;
  244. }
  245. .item {
  246. display: flex;
  247. flex-direction: column;
  248. text-align: center;
  249. align-items: center;
  250. justify-content: center;
  251. flex:1;
  252. margin-top: 40rpx;
  253. text:first-child {
  254. margin-bottom: 5rpx;
  255. color: #FFFFFF;
  256. font-weight: 800;
  257. font-size: 38rpx;
  258. }
  259. text:last-child {
  260. font-size: 26rpx;
  261. color: #D0D4EE;
  262. }
  263. }
  264. }
  265. .u-popup-content{
  266. display: flex;
  267. flex-direction: column;
  268. align-items: center;
  269. padding: 30rpx;
  270. u-form{
  271. margin: 60rpx 0;
  272. width: 500rpx;
  273. }
  274. }
  275. .card {
  276. width: 100%;
  277. background-color: #FFFFFF;
  278. padding: 30rpx;
  279. font-size: 26rpx;
  280. .text-area {
  281. display: flex;
  282. justify-content: flex-start;
  283. align-items: center;
  284. }
  285. .title {
  286. padding-left: 20rpx;
  287. color: #666666;
  288. }
  289. .area1 {
  290. width: 50%;
  291. }
  292. .area2 {
  293. width: 30%;
  294. }
  295. .area3 {
  296. width: 20%;
  297. }
  298. .item {
  299. padding: 30rpx 20rpx;
  300. display: flex;
  301. border-bottom: 1rpx solid #DDDDDD;
  302. .img-avatar {
  303. width: 70rpx;
  304. height: 70rpx;
  305. border-radius: 50%;
  306. }
  307. .img-points {
  308. width: 35rpx;
  309. height: 35rpx;
  310. }
  311. }
  312. }
  313. </style>