优惠券显示

This commit is contained in:
邹方成 2026-02-18 22:34:13 +08:00
parent 29f272c22c
commit b97cd0f267
3 changed files with 135 additions and 8 deletions

View File

@ -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
@ -337,6 +379,25 @@ 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 {

View File

@ -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: '' } //
]

View File

@ -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() {