优惠券显示
This commit is contained in:
parent
29f272c22c
commit
b97cd0f267
@ -69,6 +69,21 @@
|
||||
<view class="task-meta">
|
||||
<text class="task-name">{{ task.name }}</text>
|
||||
<text class="task-desc">{{ task.description }}</text>
|
||||
|
||||
<!-- 新增:独立进度展示 (当存在 sub_progress 时显示) -->
|
||||
<view class="sub-progress-list" v-if="taskProgress[task.id]?.subProgress?.length > 0">
|
||||
<view
|
||||
v-for="sub in taskProgress[task.id].subProgress"
|
||||
:key="sub.activity_id"
|
||||
class="sub-progress-item"
|
||||
>
|
||||
<text class="sub-label">活动 {{ sub.activity_id }}</text>
|
||||
<view class="sub-bar-bg">
|
||||
<view class="sub-bar-fill" :style="{ width: getSubProgressWidth(sub, task) }"></view>
|
||||
</view>
|
||||
<text class="sub-value">¥{{ sub.order_amount / 100 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="task-status-wrap">
|
||||
@ -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}%`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -678,6 +759,51 @@ onLoad(() => {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
/* 独立进度条样式 */
|
||||
.sub-progress-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.sub-progress-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 20rpx;
|
||||
color: $text-tertiary;
|
||||
}
|
||||
|
||||
.sub-label {
|
||||
margin-right: 8rpx;
|
||||
min-width: 80rpx;
|
||||
}
|
||||
|
||||
.sub-bar-bg {
|
||||
flex: 1;
|
||||
height: 8rpx;
|
||||
background: #f0f0f0;
|
||||
border-radius: 4rpx;
|
||||
margin-right: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sub-bar-fill {
|
||||
height: 100%;
|
||||
background: $brand-primary;
|
||||
border-radius: 4rpx;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.sub-value {
|
||||
font-family: 'DIN Alternate';
|
||||
font-weight: 700;
|
||||
color: $text-sub;
|
||||
min-width: 60rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.task-status-wrap {
|
||||
|
||||
@ -126,8 +126,8 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 优惠券视图 - 已隐藏优惠券兑换功能 -->
|
||||
<!-- <view v-else-if="currentTab === 'coupon'" class="coupons-compact-list">
|
||||
<!-- 优惠券视图 -->
|
||||
<view v-else-if="currentTab === 'coupon'" class="coupons-compact-list">
|
||||
<view class="coupon-compact-card" v-for="c in items" :key="c.id">
|
||||
<view class="c-val-box">
|
||||
<text class="c-val">¥{{ (c.discount_value || 0) / 100 }}</text>
|
||||
@ -138,7 +138,7 @@
|
||||
</view>
|
||||
<view class="c-btn" @tap="onRedeemTap(c)">兑换</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 道具卡视图 (后期开放) -->
|
||||
<view v-else-if="currentTab === 'item_card'" class="item-cards-list">
|
||||
@ -254,8 +254,9 @@ const priceRanges = [
|
||||
const activePriceRange = ref('all')
|
||||
|
||||
const tabs = [
|
||||
{ id: 'product', name: '商品' }
|
||||
// { id: 'coupon', name: '优惠券' } // 隐藏优惠券兑换功能
|
||||
{ id: 'product', name: '商品' },
|
||||
{ id: 'coupon', name: '优惠券' }
|
||||
// { id: 'item_card', name: '道具卡' } // 暂不开放
|
||||
// { id: 'item_card', name: '道具卡' } // 暂不开放
|
||||
]
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const BASE_URL = 'http://127.0.0.1:9991'
|
||||
// const BASE_URL = 'https://kdy.1024tool.vip'
|
||||
// const BASE_URL = 'http://127.0.0.1:9991'
|
||||
const BASE_URL = 'https://kdy.1024tool.vip'
|
||||
let authModalShown = false
|
||||
|
||||
function handleAuthExpired() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user