lifanagju_citu hai 6 meses
pai
achega
8f3897068a
Modificáronse 2 ficheiros con 41 adicións e 3 borrados
  1. 12 0
      api/vip.js
  2. 29 3
      pagesA/vip/index.vue

+ 12 - 0
api/vip.js

@@ -36,3 +36,15 @@ export const handleUnBlockEnterprise = async (enterpriseId) => {
     }
   })
 }
+
+// 套餐列表
+export const getMembershipPackageList = async (enterpriseId) => {
+  return request({
+    url: 'app-api/menduner/system/user-package/list',
+    method: 'GET',
+    custom: {
+      showLoading: false,
+      auth: false
+    }
+  })
+}

+ 29 - 3
pagesA/vip/index.vue

@@ -10,7 +10,7 @@
       <view class="nameBox">
 				<view class="name font-weight-bold font-size-16">{{ baseInfo?.name || userInfo?.phone }}</view>
 				<view class="vipInfo font-size-14">
-          14天双周卡将于{{ remaining }}后过期
+          {{ pName }}将于{{ remaining }}后过期
         </view>
       </view>
     </view>
@@ -36,6 +36,7 @@
 import { userStore } from '@/store/user'
 import { ref, computed, watch } from 'vue'
 import { getUserAvatar } from '@/utils/avatar'
+import { getMembershipPackageList } from '@/api/vip'
 
 const useUserStore = userStore()
 const baseInfo = computed(() => useUserStore?.baseInfo)
@@ -52,6 +53,7 @@ const listKeys = list.map(e => e.key)
 const menuList = ref([])
 watch(() => userInfo.value?.entitlement, 
   (newVal) => {
+    // if (newVal) getPName()
     if (newVal && listKeys?.length) {
       listKeys.forEach(key => {
         const item = list.find(e => e.key === key)
@@ -78,14 +80,38 @@ const remaining = computed(() => {
   return day < 1 ? '今天' : Math.floor(day) + '天'
 })
 
-
 // 列表跳转
 const handleToLink = (item) => {
 	uni.navigateTo({
 		url: item.path
 	})
 }
+const pName = ref('')
+let getPNameNum = 0 
+const getPName = () => {
+  if (!useUserStore.userInfo?.vipFlag) {
+    getPNameNum++
+    if (getPNameNum > 6)
+    setTimeout(() => { getPName() }, 1000);
+    return
+  }
+  memberList.value.forEach(e => {
+    if (e.id && e.id.toString() === useUserStore.userInfo?.vipFlag?.toString()) pName.value = e.name
+  })
+}
 
+const memberList = ref([])
+const getMemberList = async () => {
+  try {
+    const res = await getMembershipPackageList()
+    if (!res?.data?.length) return uni.showToast({ title: '查询数据失败,请重试', icon: 'none' })
+    memberList.value = res.data
+    getPName()
+  } catch (error) {
+    uni.showToast({ title: '查询数据失败,请重试', icon: 'none' })
+  }
+}
+getMemberList()
 
 </script>
 <style lang="scss" scoped>
@@ -124,7 +150,7 @@ const handleToLink = (item) => {
       color: #724d2b;
     }
     .vipInfo {
-      color: #211000;
+      color: #572a00;
     }
   }
 }