index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!-- vip权益 -->
  2. <template>
  3. <view class="box">
  4. <!-- vip信息 -->
  5. <view class="vipBox">
  6. <view class="avatar">
  7. <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img-box">
  8. <image src="/static/svg/vip.svg" class="vipIcon"></image>
  9. </view>
  10. <view class="nameBox">
  11. <view class="name font-weight-bold font-size-16">{{ baseInfo?.name || userInfo?.phone }}</view>
  12. <view class="vipInfo font-size-14">
  13. 14天双周卡将于{{ remaining }}后过期
  14. </view>
  15. </view>
  16. </view>
  17. <view style="height: 20rpx; background-color: #f8f8fa;"></view>
  18. <view class="card">
  19. <uni-list>
  20. <uni-list-item
  21. v-for="item in menuList"
  22. :clickable="true"
  23. :key="item.title"
  24. :title="item.title"
  25. showArrow
  26. :rightText="item.rightTex || ''"
  27. @click="handleToLink(item)"
  28. >
  29. </uni-list-item>
  30. </uni-list>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import { userStore } from '@/store/user'
  36. import { ref, computed, watch } from 'vue'
  37. import { getUserAvatar } from '@/utils/avatar'
  38. const useUserStore = userStore()
  39. const baseInfo = computed(() => useUserStore?.baseInfo)
  40. const userInfo = computed(() => useUserStore?.userInfo)
  41. let list = [
  42. { title: '简历刷新次数', key: 'resumeRefreshCount', show: true, path: '/pagesA/vip/template/index' },
  43. { title: '简历模板', key: 'resumeTemplate', show: false, path: '/pagesA/vip/template/index' },
  44. { title: '屏蔽企业', key: 'viewersList', show: true, path: '/pagesA/vip/blockEnt/index' },
  45. ]
  46. const listKeys = list.map(e => e.key)
  47. // 权益列表
  48. const menuList = ref([])
  49. watch(() => userInfo.value?.entitlement,
  50. (newVal) => {
  51. if (newVal && listKeys?.length) {
  52. listKeys.forEach(key => {
  53. const item = list.find(e => e.key === key)
  54. if (!item || item.show) return
  55. //
  56. if (key === 'resumeRefreshCount') { // 简历刷新次数
  57. item.rightTex = '剩余 ' + (newVal[key] ? newVal[key] : 0) + ' 次'
  58. }
  59. else if (newVal[key]) item.show = true
  60. })
  61. menuList.value = list.filter(e => e.show)
  62. }
  63. },
  64. {
  65. // deep: true,
  66. immediate: true
  67. }
  68. )
  69. const remaining = computed(() => {
  70. if (!userInfo.value?.vipExpireDate) return '0'
  71. const diffInMs = (userInfo.value?.vipExpireDate-0) - new Date().getTime()
  72. const day = diffInMs / (1000 * 60 * 60 * 24)
  73. return day < 1 ? '今天' : Math.floor(day) + '天'
  74. })
  75. // 列表跳转
  76. const handleToLink = (item) => {
  77. uni.navigateTo({
  78. url: item.path
  79. })
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .vipBox {
  84. // color: #a18a0f;
  85. padding: 80rpx 50rpx;
  86. display: flex;
  87. background: linear-gradient(121deg,#fde2c2 29.02%,#c19164 104.03%);
  88. .avatar{
  89. position: relative;
  90. width: 100rpx;
  91. height: 100rpx;
  92. margin: 0;
  93. .img-box {
  94. width: 100%;
  95. height: 100%;
  96. border: 2rpx solid #ccc;
  97. border-radius: 50%;
  98. border: 1px solid gold;
  99. }
  100. .vipIcon {
  101. position: absolute;
  102. width: 50%;
  103. height: 50%;
  104. bottom: 0;
  105. right: 0;
  106. transform: translate(0, 30%);
  107. }
  108. }
  109. .nameBox {
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: space-around;
  113. margin-left: 30rpx;
  114. .name {
  115. color: #724d2b;
  116. }
  117. .vipInfo {
  118. color: #211000;
  119. }
  120. }
  121. }
  122. :deep(.uni-list-item) {
  123. height: 120rpx !important;
  124. line-height: 120rpx !important;
  125. }
  126. :deep(.uni-list-item__content-title) {
  127. font-size: 32rpx !important;
  128. font-weight: 500;
  129. }
  130. </style>