userVip.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view class="member-center">
  3. <!-- 头部背景 -->
  4. <view class="bg-user-gradual-green" style="background-image: url(https://kxmalls.oss-cn-hangzhou.aliyuncs.com/bg/bg.png);">
  5. <view :style="'height:'+statusBarHeight+'px;'"></view>
  6. <view class="flex align-center justify-center" style="height: 88rpx;font-size: 36rpx;">
  7. 会员中心
  8. </view>
  9. </view>
  10. <!-- 会员等级轮播 -->
  11. <view class="margin-lr bg-white shadow" style="border-radius: 16rpx;margin-top: -40rpx;">
  12. <swiper class="swiper" indicator-dots="true" @change="swiperChange">
  13. <block v-for="(item, index) in vipList" :key="index">
  14. <swiper-item>
  15. <view class="swiper-item" :style="{background: getLevelBgColor(index)}">
  16. <view class="flex align-center">
  17. <image :src="item.icon" mode="aspectFit" style="width: 80rpx;height: 80rpx;"></image>
  18. <view class="level-info">
  19. <view class="name">{{ item.name }}</view>
  20. <view class="discount">可享受商品折扣: {{ item.discount / 10 }}折</view>
  21. </view>
  22. </view>
  23. <view class="nav acea-row" v-if="item.grade == grade">
  24. <view style="width: 30%;float:left;" class="item" v-for="(task, taskIndex) in vipComplete" :key="taskIndex">
  25. <view class="num">{{ task.newNumber }}</view>
  26. <view>{{ task.realName }}</view>
  27. </view>
  28. </view>
  29. <view class="lock" v-if="item.grade > grade">
  30. <text class="iconfont icon-quanxianguanlisuozi"></text>该会员等级尚未解锁
  31. </view>
  32. <view class="lock" v-if="item.grade < grade">
  33. <text class="iconfont icon-xuanzhong1"></text>已解锁更高等级
  34. </view>
  35. </view>
  36. </swiper-item>
  37. </block>
  38. </swiper>
  39. </view>
  40. <!-- 会员升级要求 -->
  41. <view class="margin-lr bg-white shadow" style="border-radius: 16rpx;margin-top: 20rpx;">
  42. <view class="title acea-row row-between-wrapper padding">
  43. <view style="float: left">
  44. <text class="iconfont icon-jingyanzhi"></text>会员升级要求
  45. </view>
  46. <view class="num">
  47. <text class="current">{{ taskCount }}</text>
  48. /{{ vipRequire.length }}
  49. </view>
  50. </view>
  51. <view class="list padding-lr padding-bottom">
  52. <view class="item margin-bottom" v-for="(task, index) in vipComplete" :key="index">
  53. <view class="top acea-row row-between-wrapper">
  54. <view class="name">
  55. {{ task.name }}
  56. <text class="iconfont icon-wenti" v-if="task.illustrate" @click="showGrow(task)"></text>
  57. </view>
  58. <view :style="{color: task.finish ? '#8AD62A' : '#999'}">
  59. {{ task.finish ? "已满足条件" : "未满足条件" }}
  60. </view>
  61. </view>
  62. <view class="cu-progress margin-top-sm">
  63. <view class="bg-red" :style="{width: task.speed + '%'}"></view>
  64. </view>
  65. <view class="experience acea-row row-between-wrapper margin-top-sm">
  66. <view>{{ task.taskTypeTitle }}</view>
  67. <view>
  68. <text class="num">{{ task.newNumber }}</text>
  69. /{{ task.number }}
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 成长值说明弹窗 -->
  76. <view class="growthValue" :class="growthValue === false ? 'on' : ''">
  77. <view class="pictrue">
  78. <image :src="`${$VUE_APP_RESOURCES_URL}/images/value.jpg`" />
  79. <text class="iconfont icon-guanbi3" @click="growthTap"></text>
  80. </view>
  81. <view class="conter">{{ illustrate }}</view>
  82. </view>
  83. <view class="mask" :hidden="growthValue" @click="growthTap"></view>
  84. </view>
  85. </template>
  86. <script>
  87. export default {
  88. data() {
  89. return {
  90. statusBarHeight: 88,
  91. vipList: [], // 等级列表
  92. vipRequire: [], // 等级要求
  93. vipComplete: [], // 完成情况
  94. taskCount: 0, // 已完成任务数
  95. grade: 0, // 当前会员等级
  96. growthValue: true, // 成长值说明显示状态
  97. illustrate: "", // 成长值说明内容
  98. activeIndex: 0 // 当前轮播索引
  99. };
  100. },
  101. onLoad() {
  102. this.getSystemInfo();
  103. this.getVipData();
  104. this.detection();
  105. },
  106. methods: {
  107. // 获取系统信息
  108. getSystemInfo() {
  109. try {
  110. const res = uni.getSystemInfoSync();
  111. this.statusBarHeight = res.statusBarHeight;
  112. } catch (e) {
  113. console.error(e);
  114. }
  115. },
  116. // 获取会员数据
  117. getVipData() {
  118. this.$api.request('get', 'user/userLevel/grade').then(res => {
  119. this.vipList = res.data.list;
  120. this.vipRequire = res.data.task.list;
  121. this.vipComplete = res.data.task.task;
  122. this.taskCount = res.data.task.reachCount;
  123. this.grade = res.data.grade;
  124. }).catch(err => {
  125. uni.showToast({
  126. title: err.msg || err.response.data.msg || err.response.data.message,
  127. icon: "none",
  128. duration: 2000
  129. });
  130. });
  131. },
  132. // 检查升级
  133. detection() {
  134. this.$api.request('get', 'user/userLevel/detection').then(res => {
  135. });
  136. },
  137. // 轮播切换
  138. swiperChange(e) {
  139. this.activeIndex = e.detail.current;
  140. this.getTask();
  141. },
  142. // 获取任务数据
  143. getTask() {
  144. const levelId = this.vipList[this.activeIndex]?.id;
  145. if (!levelId) return;
  146. this.$api.request('get', 'user/userLevel/task/'+levelId, {
  147. levelId: levelId
  148. }).then(res => {
  149. this.vipRequire = res.data.list;
  150. this.vipComplete = res.data.task;
  151. this.taskCount = res.data.reachCount;
  152. }).catch(err => {
  153. uni.showToast({
  154. title: err.msg || err.response.data.msg || err.response.data.message,
  155. icon: "none",
  156. duration: 2000
  157. });
  158. });
  159. },
  160. // 显示成长值说明
  161. showGrow(task) {
  162. this.illustrate = task.illustrate;
  163. this.growthValue = false;
  164. },
  165. // 关闭成长值说明
  166. growthTap() {
  167. this.growthValue = true;
  168. },
  169. // 获取等级背景色
  170. getLevelBgColor(index) {
  171. const colors = [
  172. 'linear-gradient(to right, #FF9A9E, #FAD0C4)',
  173. 'linear-gradient(to right, #A1C4FD, #C2E9FB)',
  174. 'linear-gradient(to right, #84FAB0, #8FD3F4)',
  175. 'linear-gradient(to right, #FFC3A0, #FFAFBD)'
  176. ];
  177. return colors[index % colors.length];
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="less">
  183. .member-center {
  184. background-color: #f1f1f1;
  185. min-height: 100vh;
  186. padding-bottom: 30rpx;
  187. .bg-user-gradual-green {
  188. background-repeat: no-repeat;
  189. background-size: 100%;
  190. color: #fff;
  191. height: 260rpx;
  192. width: 750rpx;
  193. }
  194. .shadow {
  195. box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0.1);
  196. }
  197. .swiper {
  198. height: 280rpx;
  199. .swiper-item {
  200. height: 240rpx;
  201. padding: 20rpx;
  202. border-radius: 16rpx;
  203. color: #fff;
  204. display: flex;
  205. flex-direction: column;
  206. justify-content: space-between;
  207. .level-info {
  208. margin-left: 20rpx;
  209. .name {
  210. font-size: 36rpx;
  211. font-weight: bold;
  212. }
  213. .discount {
  214. font-size: 24rpx;
  215. margin-top: 10rpx;
  216. }
  217. }
  218. .nav {
  219. margin-top: 20rpx;
  220. .item {
  221. flex: 1;
  222. text-align: center;
  223. font-size: 24rpx;
  224. .num {
  225. font-size: 32rpx;
  226. font-weight: bold;
  227. margin-bottom: 10rpx;
  228. }
  229. }
  230. }
  231. .lock {
  232. margin-top: 20rpx;
  233. text-align: center;
  234. font-size: 24rpx;
  235. .iconfont {
  236. margin-right: 10rpx;
  237. }
  238. }
  239. }
  240. }
  241. .title {
  242. font-size: 30rpx;
  243. font-weight: bold;
  244. border-bottom: 1rpx solid #f1f1f1;
  245. .iconfont {
  246. margin-right: 10rpx;
  247. color: #8AD62A;
  248. }
  249. .num {
  250. font-size: 26rpx;
  251. color: #999;
  252. .current {
  253. color: #8AD62A;
  254. font-weight: bold;
  255. }
  256. }
  257. }
  258. .list {
  259. .item {
  260. padding: 20rpx 0;
  261. border-bottom: 1rpx solid #f1f1f1;
  262. .name {
  263. font-size: 28rpx;
  264. color: #333;
  265. .iconfont {
  266. margin-left: 10rpx;
  267. color: #999;
  268. }
  269. }
  270. .cu-progress {
  271. height: 10rpx;
  272. background-color: #f1f1f1;
  273. border-radius: 5rpx;
  274. .bg-red {
  275. background-color: #8AD62A;
  276. height: 100%;
  277. border-radius: 5rpx;
  278. }
  279. }
  280. .experience {
  281. font-size: 24rpx;
  282. color: #999;
  283. .num {
  284. color: #8AD62A;
  285. font-weight: bold;
  286. }
  287. }
  288. }
  289. }
  290. .growthValue {
  291. position: fixed;
  292. top: 50%;
  293. left: 50%;
  294. width: 600rpx;
  295. height: 800rpx;
  296. transform: translate(-50%, -50%);
  297. background-color: #fff;
  298. z-index: 999;
  299. border-radius: 16rpx;
  300. opacity: 0;
  301. visibility: hidden;
  302. transition: all 0.3s;
  303. &.on {
  304. opacity: 1;
  305. visibility: visible;
  306. }
  307. .pictrue {
  308. position: relative;
  309. image {
  310. width: 100%;
  311. height: 300rpx;
  312. border-radius: 16rpx 16rpx 0 0;
  313. }
  314. .iconfont {
  315. position: absolute;
  316. top: 20rpx;
  317. right: 20rpx;
  318. font-size: 40rpx;
  319. color: #fff;
  320. }
  321. }
  322. .conter {
  323. padding: 30rpx;
  324. font-size: 28rpx;
  325. color: #666;
  326. line-height: 1.6;
  327. }
  328. }
  329. .mask {
  330. position: fixed;
  331. top: 0;
  332. left: 0;
  333. right: 0;
  334. bottom: 0;
  335. background-color: rgba(0, 0, 0, 0.5);
  336. z-index: 998;
  337. }
  338. }
  339. </style>