多租户商城-商户小程序端
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.

477 lines
13 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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="http://36.138.125.206:8081/ceres-local-file/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">
  51. <view class="avatarBox">
  52. <image :src="memberData.headImage"></image>
  53. </view>
  54. <view class="nameBox">
  55. <view class="name fs28 font-color-252744">{{ memberData.name }}</view>
  56. <view class="level">
  57. <image :src="item.memberLevelIcon"></image>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="growing">
  62. <view class="growingValue flex-display flex-sp-between">
  63. <label class="fs28 fs-weight-400 font-color-252744">当前会员成长值
  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="#252744"
  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="fs24">{{ item.memberName }}</view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view class="signIn">
  118. <view class="signInList">
  119. <view class="signTit fs28 font-color-252744">快速成长</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="http://36.138.125.206:8081/ceres-local-file/static/img/member/memberList2.png"></image>
  125. </view>
  126. <view class="leftInfo">
  127. <label class="fs28 font-color-252744">购物</label>
  128. <view class="fs24 font-color-90919C">购买商品获取相应成长值</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-left: 20rpx;
  311. margin-bottom: 10rpx;
  312. }
  313. .level {
  314. image {
  315. width: 172rpx;
  316. height: 50rpx;
  317. margin-left: 20rpx;
  318. }
  319. }
  320. }
  321. .growing {
  322. .growingValue {
  323. margin-top: 30rpx;
  324. }
  325. .progressBar {
  326. height: 20rpx;
  327. width: 100%;
  328. margin: 20rpx 0;
  329. }
  330. }
  331. }
  332. .equity {
  333. border-radius: 25rpx 25rpx 0 0;
  334. padding: 30rpx;
  335. background: #F8F8F8;
  336. margin-top: 50rpx;
  337. .equityBox {
  338. background: #FFFFFF;
  339. min-height: 326rpx;
  340. border-radius: 20rpx;
  341. padding: 10rpx 30rpx 30rpx 30rpx;
  342. .equityTit {
  343. font-weight: bold;
  344. height: 92rpx;
  345. line-height: 92rpx;
  346. font-size: 28rpx;
  347. color: #252744;
  348. }
  349. .equityList {
  350. border-top: 2rpx solid #F3F4F5;
  351. display: flex;
  352. flex-flow: wrap;
  353. padding-top: 30rpx;
  354. text-align: center;
  355. .equityItem {
  356. width: 25%;
  357. color: #252744;
  358. image {
  359. width: 92rpx;
  360. height: 92rpx;
  361. }
  362. }
  363. }
  364. }
  365. }
  366. .signIn {
  367. padding: 0 30rpx 30rpx 30rpx;
  368. background: #F8F8F8;
  369. .signInList {
  370. background: #FFFFFF;
  371. border-radius: 20rpx;
  372. padding: 0 30rpx 30rpx 30rpx;
  373. .signTit {
  374. font-weight: bold;
  375. height: 92rpx;
  376. line-height: 92rpx;
  377. }
  378. .signInBox {
  379. .signItem {
  380. border-top: 2rpx solid #F3F4F5;
  381. padding: 30rpx 0;
  382. .itemLeft {
  383. image {
  384. width: 92rpx;
  385. height: 92rpx;
  386. margin-right: 30rpx;
  387. }
  388. }
  389. }
  390. .rightBtn {
  391. width: 160rpx;
  392. height: 64rpx;
  393. line-height: 64rpx;
  394. background: #252744;
  395. border-radius: 10rpx;
  396. font-size: 24rpx;
  397. border-radius: 40rpx;
  398. color: #ffffff;
  399. text-align: center;
  400. }
  401. }
  402. }
  403. }
  404. .member-top {
  405. width: 100%;
  406. position: fixed;
  407. z-index: 99;
  408. left: 0;
  409. .memberTopInfo {
  410. position: relative;
  411. width: 100%;
  412. height: 60rpx;
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. }
  417. .backBox {
  418. position: absolute;
  419. left: 10rpx;
  420. top: 0rpx;
  421. .back {
  422. width: 50rpx;
  423. height: 50rpx;
  424. padding: 0rpx 10rpx;
  425. }
  426. }
  427. }
  428. }
  429. </style>
  430. <style>
  431. page {
  432. background: #F8F8F8;
  433. }
  434. .progressBar /deep/ .uni-progress-bar {
  435. background-color: rgb(235, 235, 235, 0.6) !important;
  436. height: 5rpx !important;
  437. border-radius: 22rpx;
  438. }
  439. .progressBar /deep/ .uni-progress-bar .uni-progress-inner-bar {
  440. border-radius: 22rpx;
  441. }
  442. </style>