vip.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="container">
  3. <view class="vipBox">
  4. <view class="userInfo">
  5. <image class="userPhoto" :src="userInfo.avatar"></image>
  6. <view class="name">
  7. {{ userInfo.nickname }}
  8. </view>
  9. </view>
  10. <view class="vip">
  11. <view class="vipLive">
  12. <span class="color1">VIP</span>
  13. <span class="color1" style="margin-left: 10rpx">{{ userInfo.userLevel }}</span>
  14. </view>
  15. <view class="tip" style="font-size: 20rpx; margin: 10rpx 0">
  16. 离升级还有{{ userInfo.nextLevelLeftAmount || 0 }}元 ({{ userInfo.consumeAmount || 0 }}/{{
  17. userInfo.nextLevelAmount || 0
  18. }})
  19. </view>
  20. <view class="progress">
  21. <view class="progressActive" :style="'width:' + progressWidth + '%'"></view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="title">权益说明</view>
  26. <view class="vipBox" style="display: flex; align-items: center" v-for="(item, index) in vipRule" :key="index">
  27. <view class="left vipLive">
  28. <span class="color1">VIP</span>
  29. <span class="color1" style="margin-left: 10rpx">{{ item.vipLevel }}</span>
  30. </view>
  31. <view class="right">
  32. <view class="row">获得条件:累计消费{{ item.minAmount }}元</view>
  33. <view class="row" style="color: #969696">权益说明:达标获得{{ item.rewardOneIntegral }}积分奖励</view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { userInfoApi, vipRuleApi } from '@/api/user.js'
  40. export default {
  41. data() {
  42. return {
  43. userInfo: {},
  44. vipRule: [],
  45. }
  46. },
  47. onShow() {
  48. this.getUserInfo()
  49. this.getVipRule()
  50. },
  51. computed: {
  52. progressWidth() {
  53. let num = 0
  54. let consumeAmount = this.userInfo.consumeAmount || 0
  55. let nextLevelAmount = this.userInfo.nextLevelAmount || 0
  56. num = (consumeAmount / nextLevelAmount) * 100
  57. num = num.toFixed(0)
  58. return num
  59. },
  60. },
  61. methods: {
  62. getUserInfo() {
  63. userInfoApi().then(res => {
  64. this.userInfo = res.data
  65. })
  66. },
  67. getVipRule() {
  68. vipRuleApi().then(res => {
  69. this.vipRule = res.data
  70. })
  71. },
  72. },
  73. }
  74. </script>
  75. <style scoped lang="scss">
  76. .container {
  77. background: linear-gradient(#ff8b45 0%, #ff9859 36%, #ffb9a9 100%);
  78. overflow: auto;
  79. .color1 {
  80. background: linear-gradient(116deg, #fef5e4 0%, #f89eb2 62%, #aa91da 100%);
  81. -webkit-background-clip: text;
  82. -webkit-text-fill-color: transparent;
  83. }
  84. .vipBox {
  85. margin: 30rpx;
  86. // background: #272833;
  87. background: linear-gradient(160deg, #fef5e4 0%, #272833 36%, #717171 100%);
  88. border-radius: 20rpx;
  89. color: #fef7e4;
  90. padding: 30rpx;
  91. .right {
  92. margin-left: 20rpx;
  93. font-size: 24rpx;
  94. .row {
  95. margin: 10rpx 0;
  96. }
  97. }
  98. .userInfo {
  99. display: flex;
  100. align-items: center;
  101. margin-bottom: 20rpx;
  102. .userPhoto {
  103. width: 12vw;
  104. height: 12vw;
  105. border-radius: 50%;
  106. position: relative;
  107. background: #dedede;
  108. }
  109. .name {
  110. margin-left: 20rpx;
  111. font-weight: 600;
  112. font-size: 28rpx;
  113. }
  114. }
  115. .vipLive {
  116. font-size: 40rpx;
  117. font-weight: 600;
  118. }
  119. .vip {
  120. .progress {
  121. margin: 10rpx 0;
  122. width: 100%;
  123. height: 12rpx;
  124. background: #fff;
  125. border-radius: 6rpx;
  126. }
  127. .progressActive {
  128. width: 0%;
  129. height: 100%;
  130. border-radius: 6rpx;
  131. background: linear-gradient(116deg, #fef5e4 0%, #f89eb2 62%, #aa91da 100%);
  132. }
  133. }
  134. }
  135. .title {
  136. margin: 40rpx 30rpx 20rpx 30rpx;
  137. font-weight: 600;
  138. color: #fff;
  139. }
  140. }
  141. </style>