多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

472 lines
13 KiB

2 years ago
  1. <template>
  2. <view>
  3. <global-loading />
  4. <view
  5. class="memberCenter"
  6. v-if="isShow"
  7. >
  8. <view
  9. class="memberBg"
  10. :style="{backgroundImage:'url('+memberListData[activeIndex].memberLevelBackground+')', 'padding-top': paddingTop + 'px'}"
  11. >
  12. <view
  13. class="member-top"
  14. :style="{'top': topHeight + 'px'}"
  15. >
  16. <view class="memberTopInfo">
  17. <view class="backBox">
  18. <image
  19. src="https://ceres.zkthink.com/static/images/back_img04.png"
  20. class="back"
  21. @click="back"
  22. ></image>
  23. </view>
  24. <view class="memberTit fs30 font-color-FFF">会员中心</view>
  25. </view>
  26. </view>
  27. <view class="memberBox">
  28. <view class="posBox">
  29. <view class="memberBoxTop">
  30. <view class="memberTopPos">
  31. <swiper
  32. class="swiper pro-box"
  33. next-margin="30rpx"
  34. previous-margin="30rpx"
  35. :current="activeIndex"
  36. :indicator-dots="false"
  37. :autoplay="false"
  38. @change="swiperChange"
  39. >
  40. <swiper-item
  41. class="pro-item-warp"
  42. v-for="(item, index) in memberListData"
  43. :key="index"
  44. >
  45. <view class="box">
  46. <view
  47. class="memberTopBg"
  48. :style="{backgroundImage:'url('+item.memberLevelBackground+')'}"
  49. >
  50. <view class="flex-display flex-sp-between">
  51. <view class="nameBox">
  52. <view class="name fs36">{{ memberData.name }}</view>
  53. <view class="level">
  54. <image :src="item.memberLevelIcon"></image>
  55. </view>
  56. </view>
  57. <view class="avatarBox">
  58. <image :src="memberData.headImage"></image>
  59. </view>
  60. </view>
  61. <view class="growing">
  62. <view class="growingValue flex-display flex-sp-between">
  63. <label class="fs24 fs-weight-400 font-color-333">当前会员成长值
  64. {{ memberData.growth }}</label>
  65. <label
  66. class="fs24 fs-weight-400 font-color-333 mar-left-20"
  67. v-if="nextGrowth !== 0 && nextGrowth !== item.growth"
  68. >{{ nextGrowth }}</label>
  69. </view>
  70. <view
  71. class="progressBar"
  72. v-if="memberData.growth < nextGrowth"
  73. >
  74. <view style="width: 100%">
  75. <progress
  76. activeColor="#FFEBC4"
  77. :percent="getPercent(memberData.growth, nextGrowth)"
  78. active
  79. stroke-width="2"
  80. />
  81. </view>
  82. </view>
  83. <view
  84. class="currentName"
  85. v-else
  86. >
  87. 以超越该等级
  88. </view>
  89. <!-- <view class="flex-display flex-sp-between">-->
  90. <!-- <label class="fs24 font-color-71521B">{{memberData.memberLevelName}}</label>-->
  91. <!-- <label class="fs24 font-color-71521B">{{memberData.nextLevelName}}</label>-->
  92. <!-- </view>-->
  93. </view>
  94. </view>
  95. </view>
  96. </swiper-item>
  97. </swiper>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="equity">
  103. <view class="equityBox">
  104. <view class="equityTit">我的权益</view>
  105. <view class="equityList">
  106. <view
  107. class="equityItem"
  108. v-for="item of equityList"
  109. :key="item.memberId"
  110. >
  111. <image :src="item.memberIcon"></image>
  112. <view class="fs26">{{ item.memberName }}</view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view class="signIn">
  118. <view class="signInList">
  119. <view class="signTit fs30 font-color-333">快速成长</view>
  120. <view class="signInBox">
  121. <view class="signItem flex-items flex-sp-between">
  122. <view class="itemLeft flex-items">
  123. <view class="leftIcon">
  124. <image src="https://ceres.zkthink.com/static/img/member/memberList2.png"></image>
  125. </view>
  126. <view class="leftInfo">
  127. <label class="fs28 font-color-333">购物</label>
  128. <view class="fs24 font-color-999">购买商品获取相应成长值</view>
  129. </view>
  130. </view>
  131. <view
  132. class="rightBtn"
  133. @click="goToShopping"
  134. >去购物
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. </template>
  144. <script>
  145. const NET = require('../../utils/request')
  146. const API = require('../../config/api')
  147. export default {
  148. name: "index",
  149. data() {
  150. return {
  151. memberData: {},
  152. equityList: [],
  153. levelInfo: {},
  154. isShow: false,
  155. memberListData: [],
  156. nextGrowth: 0,
  157. activeIndex: 0,
  158. topHeight: 10,
  159. paddingTop: 50
  160. }
  161. },
  162. onLoad() {
  163. // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
  164. let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  165. this.topHeight = menuButtonInfo.top
  166. this.paddingTop = this.paddingTop + this.topHeight
  167. // #endif
  168. // #ifdef APP
  169. this.topHeight = 50
  170. this.paddingTop = 100
  171. // #endif
  172. // 定时器防止app一开始进入时页面混乱问题
  173. setTimeout(() => {
  174. this.getMemberShipList()
  175. }, 200)
  176. this.memberData = uni.getStorageSync('storage_userInfo');
  177. this.getMemberByMemberLevel()
  178. this.getMemberList()
  179. },
  180. methods: {
  181. swiperChange(item) {
  182. this.activeIndex = item.detail.current
  183. let num = 0
  184. num = this.activeIndex + 1
  185. if (num === this.memberListData.length) {
  186. this.nextGrowth = this.memberListData[this.activeIndex].growth
  187. } else {
  188. this.nextGrowth = this.memberListData[this.activeIndex + 1].growth
  189. }
  190. this.equityList = this.memberListData[this.activeIndex].membershipList
  191. },
  192. getMemberList() {
  193. NET.request(API.memberList, {}, 'GET').then(res => {
  194. this.memberListData = res.data
  195. this.memberListData.forEach((item, index) => {
  196. if (item.memberLevelId === this.memberData.memberLevelId) {
  197. this.activeIndex = index
  198. let num = 0
  199. num = this.activeIndex + 1
  200. if (num === this.memberListData.length) {
  201. this.nextGrowth = this.memberListData[this.activeIndex].growth
  202. } else {
  203. this.nextGrowth = this.memberListData[this.activeIndex + 1].growth
  204. }
  205. this.equityList = this.memberListData[this.activeIndex].membershipList
  206. }
  207. })
  208. }).catch(res => {
  209. })
  210. },
  211. getMemberShipList() {
  212. // 获取会员信息
  213. // uni.showLoading({
  214. // mask: true,
  215. // title: '加载中...',
  216. // })
  217. NET.request(API.getMemberShipList, {}, 'GET').then(res => {
  218. uni.hideLoading()
  219. this.equityList = res.data
  220. this.isShow = true
  221. }).catch(res => {
  222. })
  223. },
  224. // 去首页
  225. goToShopping() {
  226. uni.switchTab({
  227. url: '../../pages/tabbar/index/index'
  228. })
  229. },
  230. getPercent(num, total) {
  231. num = parseFloat(num);
  232. total = parseFloat(total);
  233. if (isNaN(num) || isNaN(total)) {
  234. return "-";
  235. }
  236. return total <= 0 ? "0%" : Math.round((num / total) * 10000) / 100.0;
  237. },
  238. // 获取会员等级
  239. getMemberByMemberLevel() {
  240. NET.request(`${ API.getMemberByMemberLevel }/${ this.memberData.memberLevelId }`, {}, 'GET').then(res => {
  241. this.levelInfo = res.data
  242. uni.setStorageSync('storage_levelInfo', this.levelInfo);
  243. }).catch(res => {
  244. })
  245. },
  246. // 返回上一级
  247. back() {
  248. uni.navigateBack()
  249. }
  250. }
  251. }
  252. </script>
  253. <style
  254. lang="scss"
  255. scoped
  256. >
  257. .memberCenter {
  258. background-size: contain;
  259. min-height: 800rpx;
  260. .memberBg {
  261. background-repeat: no-repeat;
  262. padding-top: 50rpx;
  263. }
  264. .memberBox {
  265. width: 100%;
  266. //background: #523e3a;
  267. border-radius: 25rpx;
  268. background-size: contain;
  269. position: relative;
  270. box-sizing: border-box;
  271. .memberBoxTop {
  272. position: relative;
  273. .memberTopPos {
  274. overflow: hidden;
  275. .pro-box {
  276. height: 300rpx;
  277. }
  278. .swiper {
  279. .box {
  280. height: 300rpx;
  281. padding: 4rpx 10rpx;
  282. }
  283. }
  284. }
  285. .memberTopBg {
  286. background-size: cover;
  287. background-repeat: no-repeat;
  288. border-radius: 30rpx;
  289. padding: 40rpx 30rpx 30rpx 30rpx;
  290. box-shadow: 0 0 5rpx rgba(90, 90, 90, .5);
  291. height: 290rpx;
  292. .currentName {
  293. font-size: 26rpx;
  294. margin-top: 50rpx;
  295. color: #71521B;
  296. }
  297. }
  298. }
  299. .avatarBox {
  300. image {
  301. width: 110rpx;
  302. height: 110rpx;
  303. border: 5rpx solid #FFFFFF;
  304. border-radius: 50%;
  305. }
  306. }
  307. .nameBox {
  308. .name {
  309. color: #333333;
  310. margin-right: 30rpx;
  311. margin-bottom: 10rpx;
  312. }
  313. .level {
  314. image {
  315. width: 172rpx;
  316. height: 50rpx;
  317. }
  318. }
  319. }
  320. .growing {
  321. .growingValue {
  322. margin-top: 30rpx;
  323. }
  324. .progressBar {
  325. height: 20rpx;
  326. width: 100%;
  327. margin: 20rpx 0;
  328. }
  329. }
  330. }
  331. .equity {
  332. border-radius: 25rpx 25rpx 0 0;
  333. padding: 30rpx;
  334. background: #F8F8F8;
  335. margin-top: 50rpx;
  336. .equityBox {
  337. background: #FFFFFF;
  338. min-height: 326rpx;
  339. border-radius: 20rpx;
  340. padding: 10rpx 30rpx 30rpx 30rpx;
  341. .equityTit {
  342. font-weight: bold;
  343. height: 92rpx;
  344. line-height: 92rpx;
  345. }
  346. .equityList {
  347. border-top: 2rpx solid #F3F4F5;
  348. display: flex;
  349. flex-flow: wrap;
  350. padding-top: 30rpx;
  351. text-align: center;
  352. .equityItem {
  353. width: 25%;
  354. color: #666666;
  355. image {
  356. width: 92rpx;
  357. height: 92rpx;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. .signIn {
  364. padding: 0 30rpx 30rpx 30rpx;
  365. background: #F8F8F8;
  366. .signInList {
  367. background: #FFFFFF;
  368. border-radius: 20rpx;
  369. padding: 0 30rpx 30rpx 30rpx;
  370. .signTit {
  371. font-weight: bold;
  372. height: 92rpx;
  373. line-height: 92rpx;
  374. }
  375. .signInBox {
  376. .signItem {
  377. border-top: 2rpx solid #F3F4F5;
  378. padding: 30rpx 0;
  379. .itemLeft {
  380. image {
  381. width: 92rpx;
  382. height: 92rpx;
  383. margin-right: 30rpx;
  384. }
  385. }
  386. }
  387. .rightBtn {
  388. width: 160rpx;
  389. height: 58rpx;
  390. line-height: 58rpx;
  391. background: #333333;
  392. border-radius: 10rpx;
  393. color: #FFEBC4;
  394. text-align: center;
  395. }
  396. }
  397. }
  398. }
  399. .member-top {
  400. width: 100%;
  401. position: fixed;
  402. z-index: 99;
  403. left: 0;
  404. .memberTopInfo {
  405. position: relative;
  406. width: 100%;
  407. height: 60rpx;
  408. display: flex;
  409. align-items: center;
  410. justify-content: center;
  411. }
  412. .backBox {
  413. position: absolute;
  414. left: 10rpx;
  415. top: 0rpx;
  416. .back {
  417. width: 50rpx;
  418. height: 50rpx;
  419. padding: 0rpx 10rpx;
  420. }
  421. }
  422. }
  423. }
  424. </style>
  425. <style>
  426. page {
  427. background: #F8F8F8;
  428. }
  429. .progressBar /deep/ .uni-progress-bar {
  430. background-color: rgb(235, 235, 235, 0.6) !important;
  431. height: 5rpx !important;
  432. border-radius: 22rpx;
  433. }
  434. .progressBar /deep/ .uni-progress-bar .uni-progress-inner-bar {
  435. border-radius: 22rpx;
  436. }
  437. </style>