From b1364a616a8fa31e684fa1a1eedc1cb9cfc85240 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Tue, 31 Mar 2026 17:30:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(BD=E7=9A=84=E5=A2=9E=E9=80=81=E7=A4=BC?= =?UTF-8?q?=E7=89=A9=E9=A1=B5):=20=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/BDCenter/ItemDistribution.vue | 84 +++++++++++++------------ 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/src/views/BDCenter/ItemDistribution.vue b/src/views/BDCenter/ItemDistribution.vue index 9eb577a..3a7b37d 100644 --- a/src/views/BDCenter/ItemDistribution.vue +++ b/src/views/BDCenter/ItemDistribution.vue @@ -32,6 +32,7 @@
@@ -153,7 +154,12 @@ import { onMounted, ref, computed } from 'vue' import { showWarning, showSuccess } from '@/utils/toast.js' import { useI18n } from 'vue-i18n' -import { getBDPropsList, giveProps, hasSendGiftsPermission } from '@/api/bdCenter' +import { + getSendGiftsPermissionList, + getBDPropsList, + giveProps, + hasSendGiftsPermission, +} from '@/api/bdCenter' import { searchUser } from '@/api/userInfo' import GeneralHeader from '@/components/GeneralHeader.vue' @@ -161,24 +167,7 @@ import maskLayer from '@/components/MaskLayer.vue' const { t, locale } = useI18n() -const tabList = ref([ - { - id: 1, - name: 'frames', - }, - { - id: 2, - name: 'vehicles', - }, - // { - // id: 3, - // name: 'chat_box', - // }, - // { - // id: 4, - // name: 'theme', - // }, -]) +const tabList = ref([]) const activeIndex = ref(0) const currentTab = ref('frames') //选中名字 @@ -220,13 +209,37 @@ const underlineStyle = computed(() => { const targetUserId = ref('') -// 检查是否有赠送某个栏目商品的资格 -const getHasSendVIPPermission = async (propsType) => { - const response = await hasSendGiftsPermission(propsType) +// 获取赠送礼物的类型列表 +const getSendGiftsPermissions = async () => { + const response = await getSendGiftsPermissionList() console.log('response:', response) - return response.body + + const permissions = response.body + + const tabs = [] + const hasVip = permissions.some((p) => p.startsWith('NOBLE_VIP')) + + if (permissions.includes('AVATAR_FRAME')) { + tabs.push({ id: 1, name: 'frames' }) + } + if (permissions.includes('RIDE')) { + tabs.push({ id: 2, name: 'vehicles' }) + } + if (hasVip) { + tabs.push({ id: 3, name: 'vip' }) + } + + tabList.value = tabs + + if (tabs.length > 0) { + activeIndex.value = 0 + currentTab.value = tabs[0].name + } + + return tabs } +// 赠送礼物 const sendGoods = async () => { if (confirmClick.value) { confirmClick.value = false @@ -267,8 +280,6 @@ const getPropsType = () => { const typeMap = { frames: 'AVATAR_FRAME', vehicles: 'RIDE', - chat_box: 'CHAT_BUBBLE', - theme: 'THEME', vip: 'NOBLE_VIP', } return typeMap[currentTab.value] @@ -299,11 +310,6 @@ const validityPeriod = computed(() => { return currentTab.value == 'VIP' ? '3' : '7' }) -// 获取本地图片 -const getImageUrl = (imgUrl) => { - return new URL(imgUrl, import.meta.url).href -} - const dialogshow = ref(false) // 展示弹窗 const showSendDialog = (product) => { @@ -320,21 +326,17 @@ const closedPopup = () => { dialogshow.value = false } -onMounted(() => { +onMounted(async () => { console.log('onMounted') - - // 检查是否有赠送VIP的资格 - if (getHasSendVIPPermission('NOBLE_VIP')) { - tabList.value.push({ - id: 3, - name: 'vip', - }) - } + await getSendGiftsPermissions() if (tabItems.value.length > 0) { - underlineStyle.value // 触发计算属性更新 + underlineStyle.value + } + + if (tabList.value.length > 0) { + loadProps() } - loadProps() })