feat: 增加游戏再来一局功能,并支持任务按订单金额统计进度。
This commit is contained in:
parent
e24f05f6ac
commit
d4d298a275
@ -43,6 +43,16 @@ function onMessage(e) {
|
|||||||
data.forEach(msg => {
|
data.forEach(msg => {
|
||||||
if (msg.action === 'close') {
|
if (msg.action === 'close') {
|
||||||
uni.navigateBack()
|
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') {
|
} else if (msg.action === 'game_over') {
|
||||||
// Optional: Refresh user balance or state
|
// Optional: Refresh user balance or state
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,6 +139,7 @@ const claiming = reactive({})
|
|||||||
// 用户进度 (汇总)
|
// 用户进度 (汇总)
|
||||||
const userProgress = reactive({
|
const userProgress = reactive({
|
||||||
orderCount: 0,
|
orderCount: 0,
|
||||||
|
orderAmount: 0,
|
||||||
inviteCount: 0,
|
inviteCount: 0,
|
||||||
firstOrder: false,
|
firstOrder: false,
|
||||||
claimedTiers: {} // { taskId: [tierId1, tierId2] }
|
claimedTiers: {} // { taskId: [tierId1, tierId2] }
|
||||||
@ -224,6 +225,7 @@ function getTierBadge(tier) {
|
|||||||
const metric = tier.metric || ''
|
const metric = tier.metric || ''
|
||||||
if (metric === 'first_order') return '首'
|
if (metric === 'first_order') return '首'
|
||||||
if (metric === 'order_count') return `${tier.threshold}单`
|
if (metric === 'order_count') return `${tier.threshold}单`
|
||||||
|
if (metric === 'order_amount') return `¥${tier.threshold / 100}`
|
||||||
if (metric === 'invite_count') return `${tier.threshold}人`
|
if (metric === 'invite_count') return `${tier.threshold}人`
|
||||||
return tier.threshold || ''
|
return tier.threshold || ''
|
||||||
}
|
}
|
||||||
@ -233,6 +235,7 @@ function getTierConditionText(tier) {
|
|||||||
const metric = tier.metric || ''
|
const metric = tier.metric || ''
|
||||||
if (metric === 'first_order') return '完成首笔订单'
|
if (metric === 'first_order') return '完成首笔订单'
|
||||||
if (metric === 'order_count') return `累计下单 ${tier.threshold} 笔`
|
if (metric === 'order_count') return `累计下单 ${tier.threshold} 笔`
|
||||||
|
if (metric === 'order_amount') return `累计消费 ¥${tier.threshold / 100}`
|
||||||
if (metric === 'invite_count') return `邀请 ${tier.threshold} 位好友`
|
if (metric === 'invite_count') return `邀请 ${tier.threshold} 位好友`
|
||||||
return `达成 ${tier.threshold}`
|
return `达成 ${tier.threshold}`
|
||||||
}
|
}
|
||||||
@ -285,6 +288,8 @@ function isTierClaimable(task, tier) {
|
|||||||
return userProgress.firstOrder
|
return userProgress.firstOrder
|
||||||
} else if (metric === 'order_count') {
|
} else if (metric === 'order_count') {
|
||||||
current = userProgress.orderCount || 0
|
current = userProgress.orderCount || 0
|
||||||
|
} else if (metric === 'order_amount') {
|
||||||
|
current = userProgress.orderAmount || 0
|
||||||
} else if (metric === 'invite_count') {
|
} else if (metric === 'invite_count') {
|
||||||
current = userProgress.inviteCount || 0
|
current = userProgress.inviteCount || 0
|
||||||
}
|
}
|
||||||
@ -305,6 +310,9 @@ function getTierProgressText(task, tier) {
|
|||||||
return userProgress.firstOrder ? '已完成' : '未完成'
|
return userProgress.firstOrder ? '已完成' : '未完成'
|
||||||
} else if (metric === 'order_count') {
|
} else if (metric === 'order_count') {
|
||||||
current = userProgress.orderCount || 0
|
current = userProgress.orderCount || 0
|
||||||
|
} else if (metric === 'order_amount') {
|
||||||
|
current = userProgress.orderAmount || 0
|
||||||
|
return `¥${current / 100}/¥${threshold / 100}`
|
||||||
} else if (metric === 'invite_count') {
|
} else if (metric === 'invite_count') {
|
||||||
current = userProgress.inviteCount || 0
|
current = userProgress.inviteCount || 0
|
||||||
}
|
}
|
||||||
@ -368,6 +376,7 @@ async function fetchData() {
|
|||||||
try {
|
try {
|
||||||
const progressRes = await getTaskProgress(list[0].id, userId)
|
const progressRes = await getTaskProgress(list[0].id, userId)
|
||||||
userProgress.orderCount = progressRes.order_count || 0
|
userProgress.orderCount = progressRes.order_count || 0
|
||||||
|
userProgress.orderAmount = progressRes.order_amount || 0
|
||||||
userProgress.inviteCount = progressRes.invite_count || 0
|
userProgress.inviteCount = progressRes.invite_count || 0
|
||||||
userProgress.firstOrder = progressRes.first_order || false
|
userProgress.firstOrder = progressRes.first_order || false
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user