feat: 增加游戏再来一局功能,并支持任务按订单金额统计进度。

This commit is contained in:
邹方成 2026-01-01 12:07:30 +08:00
parent e24f05f6ac
commit d4d298a275
2 changed files with 19 additions and 0 deletions

View File

@ -43,6 +43,16 @@ function onMessage(e) {
data.forEach(msg => {
if (msg.action === 'close') {
uni.navigateBack()
} else if (msg.action === 'playAgain') {
// : token
console.log('PlayAgain: 返回游戏入口页面')
uni.navigateBack({
delta: 1,
success: () => {
// :
uni.$emit('refreshGame')
}
})
} else if (msg.action === 'game_over') {
// Optional: Refresh user balance or state
}

View File

@ -139,6 +139,7 @@ const claiming = reactive({})
// ()
const userProgress = reactive({
orderCount: 0,
orderAmount: 0,
inviteCount: 0,
firstOrder: false,
claimedTiers: {} // { taskId: [tierId1, tierId2] }
@ -224,6 +225,7 @@ function getTierBadge(tier) {
const metric = tier.metric || ''
if (metric === 'first_order') return '首'
if (metric === 'order_count') return `${tier.threshold}`
if (metric === 'order_amount') return `¥${tier.threshold / 100}`
if (metric === 'invite_count') return `${tier.threshold}`
return tier.threshold || ''
}
@ -233,6 +235,7 @@ function getTierConditionText(tier) {
const metric = tier.metric || ''
if (metric === 'first_order') return '完成首笔订单'
if (metric === 'order_count') return `累计下单 ${tier.threshold}`
if (metric === 'order_amount') return `累计消费 ¥${tier.threshold / 100}`
if (metric === 'invite_count') return `邀请 ${tier.threshold} 位好友`
return `达成 ${tier.threshold}`
}
@ -285,6 +288,8 @@ function isTierClaimable(task, tier) {
return userProgress.firstOrder
} else if (metric === 'order_count') {
current = userProgress.orderCount || 0
} else if (metric === 'order_amount') {
current = userProgress.orderAmount || 0
} else if (metric === 'invite_count') {
current = userProgress.inviteCount || 0
}
@ -305,6 +310,9 @@ function getTierProgressText(task, tier) {
return userProgress.firstOrder ? '已完成' : '未完成'
} else if (metric === 'order_count') {
current = userProgress.orderCount || 0
} else if (metric === 'order_amount') {
current = userProgress.orderAmount || 0
return `¥${current / 100}${threshold / 100}`
} else if (metric === 'invite_count') {
current = userProgress.inviteCount || 0
}
@ -368,6 +376,7 @@ async function fetchData() {
try {
const progressRes = await getTaskProgress(list[0].id, userId)
userProgress.orderCount = progressRes.order_count || 0
userProgress.orderAmount = progressRes.order_amount || 0
userProgress.inviteCount = progressRes.invite_count || 0
userProgress.firstOrder = progressRes.first_order || false