Browse Source

简历剩余刷新次数

lifanagju_citu 6 months ago
parent
commit
1630d00957
1 changed files with 33 additions and 7 deletions
  1. 33 7
      pagesA/vip/index.vue

+ 33 - 7
pagesA/vip/index.vue

@@ -18,7 +18,7 @@
     <view class="card">
       <uni-list>
         <uni-list-item
-          v-for="item in list"
+          v-for="item in menuList"
           :clickable="true"
           :key="item.title"
           :title="item.title"
@@ -34,14 +34,44 @@
 
 <script setup>
 import { userStore } from '@/store/user'
-import { ref, computed } from 'vue'
+import { ref, computed, watch } from 'vue'
 import { getUserAvatar } from '@/utils/avatar'
 
-
 const useUserStore = userStore()
 const baseInfo = computed(() => useUserStore?.baseInfo)
 const userInfo = computed(() => useUserStore?.userInfo)
 
+let list = [
+	{	title: '简历刷新次数', key: 'resumeRefreshCount', show: true,	path: '/pagesA/vip/template/index'	},					
+	{	title: '简历模板', key: 'resumeTemplate', show: false,	path: '/pagesA/vip/template/index'	},					
+	{	title: '屏蔽企业', key: 'viewersList', show: false,	path: '/pagesA/vip/blockEnt/index'	},			
+]
+const listKeys = list.map(e => e.key)
+
+// 权益列表
+const menuList = ref([])
+watch(() => userInfo.value?.entitlement, 
+  (newVal) => {
+    if (newVal && listKeys?.length) {
+      listKeys.forEach(key => {
+        if (key === 'resumeRefreshCount') { // 简历刷新次数
+          const item = list.find(e => e.key === key)
+          item.rightTex = '剩余 ' + (newVal[key] ? newVal[key] : 0) + ' 次'
+        }
+        else if (newVal[key]) {
+          const item = list.find(e => e.key === key)
+          if (item) item.show = true
+        }
+      })
+      menuList.value = list.filter(e => e.show)
+    }
+  },
+  {
+    // deep: true,
+    immediate: true
+  }
+)
+
 const remaining = computed(() => {
   if (!userInfo.value?.vipExpireDate) return '0'
   const diffInMs =  (userInfo.value?.vipExpireDate-0) - new Date().getTime()
@@ -49,10 +79,6 @@ const remaining = computed(() => {
   return day < 1 ? '今天' : Math.floor(day) + '天'
 })
 
-const list = ref([
-	{	title: '简历模板',	path: '/pagesA/vip/template/index'	},					
-	{	title: '屏蔽企业',	path: '/pagesA/vip/blockEnt/index'	},			
-])
 
 // 列表跳转
 const handleToLink = (item) => {