feat: 为商品详情和列表页增加售罄状态显示与兑换限制,并更新 API BASE_URL。

This commit is contained in:
邹方成 2026-01-04 15:30:23 +08:00
parent 29e3ecbdd4
commit 413f7557f1
3 changed files with 48 additions and 4 deletions

View File

@ -24,7 +24,13 @@
<!-- Action Bar Moved Outside info-card --> <!-- Action Bar Moved Outside info-card -->
<view class="action-bar-placeholder" v-if="detail.id"></view> <view class="action-bar-placeholder" v-if="detail.id"></view>
<view class="action-bar" v-if="detail.id"> <view class="action-bar" v-if="detail.id">
<view class="action-btn redeem" @tap="onRedeem">立即兑换</view> <view
class="action-btn redeem"
:class="{ disabled: detail.stock === 0 }"
@tap="onRedeem"
>
{{ detail.stock === 0 ? '已售罄' : '立即兑换' }}
</view>
</view> </view>
</view> </view>
</template> </template>
@ -62,6 +68,16 @@ function onBuy() {
async function onRedeem() { async function onRedeem() {
const p = detail.value const p = detail.value
if (!p || !p.id) return if (!p || !p.id) return
//
if (p.stock === 0) {
uni.showModal({
title: '商品已售罄',
content: '该商品库存不足,请联系客服处理',
showCancel: false
})
return
}
const token = uni.getStorageSync('token') const token = uni.getStorageSync('token')
if (!token) { if (!token) {
@ -305,7 +321,16 @@ onLoad((opts) => {
&:active { transform: scale(0.96); } &:active { transform: scale(0.96); }
} }
.action-btn.redeem { background: linear-gradient(135deg, #FFB74D, #FF9800); box-shadow: 0 8rpx 20rpx rgba(255, 152, 0, 0.3); } .action-btn.redeem {
background: linear-gradient(135deg, #FFB74D, #FF9800);
box-shadow: 0 8rpx 20rpx rgba(255, 152, 0, 0.3);
&.disabled {
background: #ccc;
box-shadow: none;
color: #999;
}
}
.action-btn.buy { background: linear-gradient(135deg, #FF6B6B, #FF3B30); box-shadow: 0 8rpx 20rpx rgba(255, 59, 48, 0.3); } .action-btn.buy { background: linear-gradient(135deg, #FF6B6B, #FF3B30); box-shadow: 0 8rpx 20rpx rgba(255, 59, 48, 0.3); }
@keyframes fadeInUp { @keyframes fadeInUp {

View File

@ -93,7 +93,13 @@
<text class="points-val">{{ p.points || 0 }}</text> <text class="points-val">{{ p.points || 0 }}</text>
<text class="points-unit">积分</text> <text class="points-unit">积分</text>
</view> </view>
<view class="redeem-btn" @tap.stop="onRedeemTap(p)">兑换</view> <view
class="redeem-btn"
:class="{ disabled: p.stock === 0 }"
@tap.stop="onRedeemTap(p)"
>
{{ p.stock === 0 ? '已售罄' : '兑换' }}
</view>
</view> </view>
</view> </view>
</view> </view>
@ -366,6 +372,15 @@ function onProductTap(p) {
} }
async function onRedeemTap(item) { async function onRedeemTap(item) {
//
if (item.kind === 'product' && item.stock === 0) {
uni.showModal({
title: '商品已售罄',
content: '该商品库存不足,请联系客服处理',
showCancel: false
})
return
}
const token = uni.getStorageSync('token') const token = uni.getStorageSync('token')
if (!token) { if (!token) {
uni.showModal({ uni.showModal({
@ -615,6 +630,10 @@ onUnmounted(() => {
.redeem-btn { .redeem-btn {
background: $gradient-brand; color: #fff; font-size: 22rpx; background: $gradient-brand; color: #fff; font-size: 22rpx;
padding: 6rpx 18rpx; border-radius: 24rpx; font-weight: 600; padding: 6rpx 18rpx; border-radius: 24rpx; font-weight: 600;
&.disabled {
background: #ccc;
color: #999;
}
} }
/* 优惠券 (Ticket Style) */ /* 优惠券 (Ticket Style) */

View File

@ -1,4 +1,4 @@
const BASE_URL = 'http://127.0.0.1:9991' const BASE_URL = 'https://mini-chat.1024tool.vip'
let authModalShown = false let authModalShown = false