index.vue 10.0 KB

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