任务中心的代码问题

This commit is contained in:
邹方成 2026-01-09 00:11:44 +08:00
parent e05403b673
commit 6da73a1955
2 changed files with 32 additions and 15 deletions

View File

@ -387,9 +387,9 @@ async function onPaymentConfirm(paymentData) {
channel: 'miniapp',
count: selectedChoices.value.length,
slot_index: selectedChoices.value.map(c => Number(c.id || c.number)),
coupon_id: paymentData.coupon_id || 0,
item_card_id: paymentData.item_card_id || 0,
use_game_pass: paymentData.use_game_pass || false
coupon_id: paymentData.coupon?.id ? Number(paymentData.coupon.id) : 0,
item_card_id: paymentData.card?.id ? Number(paymentData.card.id) : 0,
use_game_pass: paymentData.useGamePass || false
}
console.log('[Yifanshang] Calling join with:', joinData)

View File

@ -136,7 +136,7 @@ const isRefreshing = ref(false)
const expandedTasks = reactive({})
const claiming = reactive({})
// ()
// ( - )
const userProgress = reactive({
orderCount: 0,
orderAmount: 0,
@ -145,6 +145,9 @@ const userProgress = reactive({
claimedTiers: {} // { taskId: [tierId1, tierId2] }
})
// BUG
const taskProgress = reactive({}) // { taskId: { orderCount, orderAmount, inviteCount, firstOrder } }
// ID
function getUserId() {
return uni.getStorageSync('user_id')
@ -294,21 +297,24 @@ function isTierClaimed(taskId, tierId) {
return claimed.includes(tierId)
}
//
// - BUG使
function isTierClaimable(task, tier) {
const metric = tier.metric || ''
const threshold = tier.threshold || 0
const operator = tier.operator || '>='
//
const progress = taskProgress[task.id] || {}
let current = 0
if (metric === 'first_order') {
return userProgress.firstOrder
return progress.firstOrder || false
} else if (metric === 'order_count') {
current = userProgress.orderCount || 0
current = progress.orderCount || 0
} else if (metric === 'order_amount') {
current = userProgress.orderAmount || 0
current = progress.orderAmount || 0
} else if (metric === 'invite_count') {
current = userProgress.inviteCount || 0
current = progress.inviteCount || 0
}
if (operator === '>=') return current >= threshold
@ -317,21 +323,24 @@ function isTierClaimable(task, tier) {
return current >= threshold
}
//
// - BUG使
function getTierProgressText(task, tier) {
const metric = tier.metric || ''
const threshold = tier.threshold || 0
//
const progress = taskProgress[task.id] || {}
let current = 0
if (metric === 'first_order') {
return userProgress.firstOrder ? '已完成' : '未完成'
return progress.firstOrder ? '已完成' : '未完成'
} else if (metric === 'order_count') {
current = userProgress.orderCount || 0
current = progress.orderCount || 0
} else if (metric === 'order_amount') {
current = userProgress.orderAmount || 0
current = progress.orderAmount || 0
return `¥${current / 100}${threshold / 100}`
} else if (metric === 'invite_count') {
current = userProgress.inviteCount || 0
current = progress.inviteCount || 0
}
return `${current}/${threshold}`
@ -412,7 +421,15 @@ async function fetchData() {
const p = result.value
const taskId = list[index].id
// ()
// BUG
taskProgress[taskId] = {
orderCount: p.order_count || 0,
orderAmount: p.order_amount || 0,
inviteCount: p.invite_count || 0,
firstOrder: p.first_order || false
}
// ( - )
userProgress.orderCount = Math.max(userProgress.orderCount, p.order_count || 0)
userProgress.orderAmount = Math.max(userProgress.orderAmount, p.order_amount || 0)
userProgress.inviteCount = Math.max(userProgress.inviteCount, p.invite_count || 0)