diff --git a/pages-user/tasks/index.vue b/pages-user/tasks/index.vue
index b41d8a6..28c407c 100644
--- a/pages-user/tasks/index.vue
+++ b/pages-user/tasks/index.vue
@@ -69,6 +69,21 @@
{{ task.name }}
{{ task.description }}
+
+
+
+
+ 活动 {{ sub.activity_id }}
+
+
+
+ ¥{{ sub.order_amount / 100 }}
+
+
@@ -312,6 +327,33 @@ function isTierClaimable(task, tier) {
// 获取该任务独立的进度数据
const progress = taskProgress[task.id] || {}
+ // FIX: 如果档位关联了特定活动,优先使用活动独立进度 (sub_progress)
+ if (tier.activity_id > 0) {
+ if (progress.subProgress) {
+ const sub = progress.subProgress.find(s => s.activity_id === tier.activity_id)
+ if (sub) {
+ if (metric === 'order_amount') {
+ const current = sub.order_amount || 0
+ if (operator === '>=') return current >= threshold
+ if (operator === '==') return current === threshold
+ if (operator === '>') return current > threshold
+ return current >= threshold
+ } else if (metric === 'order_count') {
+ const current = sub.order_count || 0
+ if (operator === '>=') return current >= threshold
+ if (operator === '==') return current === threshold
+ if (operator === '>') return current > threshold
+ return current >= threshold
+ }
+ // 其他指标暂时没有拆分,回退到总进度校验
+ } else {
+ // 没找到该活动的进度记录 -> 视为 0 ->不可领取
+ return false
+ }
+ }
+ }
+
+ // 回退:使用任务总进度
let current = 0
if (metric === 'first_order') {
return progress.firstOrder || false
@@ -336,7 +378,26 @@ function getTierProgressText(task, tier) {
// 获取该任务独立的进度数据
const progress = taskProgress[task.id] || {}
+
+ // FIX: 如果档位关联了特定活动,优先显示活动独立进度
+ if (tier.activity_id > 0 && progress.subProgress) {
+ const sub = progress.subProgress.find(s => s.activity_id === tier.activity_id)
+ if (sub) {
+ if (metric === 'order_amount') {
+ const current = sub.order_amount || 0
+ return `¥${current / 100}/¥${threshold / 100}`
+ } else if (metric === 'order_count') {
+ const current = sub.order_count || 0
+ return `${current}/${threshold}`
+ }
+ } else {
+ // 没找到记录 -> 0
+ if (metric === 'order_amount') return `¥0/¥${threshold / 100}`
+ return `0/${threshold}`
+ }
+ }
+ // 回退:使用任务总进度
let current = 0
if (metric === 'first_order') {
return progress.firstOrder ? '已完成' : '未完成'
@@ -432,7 +493,8 @@ async function fetchData() {
orderCount: p.order_count || 0,
orderAmount: p.order_amount || 0,
inviteCount: p.invite_count || 0,
- firstOrder: p.first_order || false
+ firstOrder: p.first_order || false,
+ subProgress: p.sub_progress || [] // 新增:独立进度列表
}
// 聚合进度指标 (取各任务返回的最大值 - 仅用于顶部统计卡片显示)
@@ -457,6 +519,25 @@ async function fetchData() {
onLoad(() => {
fetchData()
})
+
+// 计算子进度条宽度
+function getSubProgressWidth(sub, task) {
+ // 尝试找该任务的最大金额门槛作为分母
+ let maxThreshold = 0
+ if (task.tiers && task.tiers.length > 0) {
+ // 过滤出与金额相关的档位
+ const amountTiers = task.tiers.filter(t => t.metric === 'order_amount')
+ if (amountTiers.length > 0) {
+ maxThreshold = Math.max(...amountTiers.map(t => t.threshold || 0))
+ }
+ }
+
+ // 如果没有找到阈值,默认100% (或者可以设一个默认值如 200元)
+ if (maxThreshold === 0) maxThreshold = 20000 // 默认200元
+
+ const percent = Math.min((sub.order_amount || 0) / maxThreshold * 100, 100)
+ return `${percent}%`
+}