This commit is contained in:
2026-04-22 17:49:33 +08:00
parent 562a9b5172
commit eced5c75d7
23 changed files with 790 additions and 244 deletions

View File

@@ -642,6 +642,13 @@ const buttonClass = computed(() => {
// VIP价格配置
const vipConfig = reactive({})
function toFiniteNumber(value, fallback = 0) {
if (value === null || value === undefined || value === '')
return fallback
const n = typeof value === 'number' ? value : Number(value)
return Number.isFinite(n) ? n : fallback
}
// 计算得出的收益数据
const revenueData = computed(() => {
const baseOrders = 300 // 基础订单数
@@ -741,20 +748,17 @@ onMounted(async () => {
const selectedType = ref('vip') // 默认选择VIP
const showPayment = ref(false)
const payData = ref({
product_name: `${selectedType.value.toUpperCase()}代理`,
sell_price: vipConfig.price,
})
const payID = ref('')
const payData = computed(() => ({
product_name: `${selectedType.value === 'vip' ? 'VIP' : 'SVIP'}代理`,
sell_price: selectedType.value === 'vip'
? toFiniteNumber(vipConfig.price)
: toFiniteNumber(vipConfig.svipPrice),
}))
// 选择代理类型
function selectType(type) {
selectedType.value = type
// 更新payData中的价格和产品名称
payData.value = {
product_name: `${type === 'vip' ? 'VIP' : 'SVIP'}代理`,
sell_price: type === 'vip' ? vipConfig.price : vipConfig.svipPrice,
}
}
// 申请VIP或SVIP
@@ -771,6 +775,11 @@ async function applyVip() {
return
}
if (toFiniteNumber(payData.value.sell_price) <= 0) {
showToast('会员价格加载中,请稍后重试')
return
}
const { data, error } = await useApiFetch('/agent/membership/activate')
.post({
type: selectedType.value.toUpperCase(),