|
|
@@ -28,20 +28,47 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 赠送人信息(正常态展示) -->
|
|
|
- <view v-if="!isInvalid && detail && detail.giverNickname" class="giver-row">
|
|
|
+ <!-- 赠送人信息 -->
|
|
|
+ <view v-if="detail && detail.giverNickname" class="giver-row">
|
|
|
<image v-if="detail.giverAvatar" class="giver-avatar" :src="detail.giverAvatar" mode="aspectFill"></image>
|
|
|
<view v-else class="giver-avatar giver-avatar-default">{{ giverInitial }}</view>
|
|
|
<text class="giver-name">赠送人:{{ detail.giverNickname }}</text>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 正常态:确认领取 -->
|
|
|
- <view v-if="!isInvalid" class="action-area">
|
|
|
- <button class="claim-btn" :disabled="claiming" @click="onConfirmClaim">{{ claiming ? '领取中...' : '确认领取' }}</button>
|
|
|
- <text class="claim-tip">领取后可用于购买会员</text>
|
|
|
+ <!-- 券介绍 -->
|
|
|
+ <view v-if="detail" class="intro-card">
|
|
|
+ <text class="intro-title">券介绍</text>
|
|
|
+ <view class="intro-row">
|
|
|
+ <text class="intro-label">使用范围</text>
|
|
|
+ <text class="intro-value">会员专享,可用于购买会员</text>
|
|
|
+ </view>
|
|
|
+ <view class="intro-row">
|
|
|
+ <text class="intro-label">使用门槛</text>
|
|
|
+ <text class="intro-value">{{ conditionText(detail.minSpend) }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="intro-row">
|
|
|
+ <text class="intro-label">有效期至</text>
|
|
|
+ <text class="intro-value">{{ formatDate(detail.validUntil) }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="intro-row">
|
|
|
+ <text class="intro-label">领取后</text>
|
|
|
+ <text class="intro-value">自动存入你的券包</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 已领取:按钮保留但置灰 -->
|
|
|
+ <view v-if="isClaimed" class="action-area">
|
|
|
+ <button class="claim-btn" disabled>优惠券已经领取</button>
|
|
|
+ <text class="claim-tip">这张券已经被领走啦</text>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 正常态:领取 -->
|
|
|
+ <view v-else-if="!isInvalid" class="action-area">
|
|
|
+ <button class="claim-btn" :disabled="claiming" @click="onConfirmClaim">{{ claiming ? '领取中...' : '立即领取' }}</button>
|
|
|
+ <text class="claim-tip">领取后自动存入券包,可用于购买会员</text>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 失效态:提示 + 知道了 -->
|
|
|
+ <!-- 其他失效态:提示 + 知道了 -->
|
|
|
<view v-else class="action-area">
|
|
|
<text class="invalid-tip">⚠ {{ invalidText }}</text>
|
|
|
<button class="know-btn" @click="onKnow">知道了</button>
|
|
|
@@ -68,6 +95,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ isClaimed: function() {
|
|
|
+ if (this.detail && this.detail.status === 'CLAIMED') return true
|
|
|
+ // 并发抢领失败时接口返回「该分享已被领取」,同样按已领取态展示
|
|
|
+ if (this.claimError && this.claimError.indexOf('已被领取') >= 0) return true
|
|
|
+ return false
|
|
|
+ },
|
|
|
isInvalid: function() {
|
|
|
if (this.loading) return false
|
|
|
if (this.loadError || this.claimError) return true
|
|
|
@@ -81,7 +114,7 @@ export default {
|
|
|
if (this.claimError) return this.claimError
|
|
|
if (!this.detail) return '分享不存在或已失效'
|
|
|
var status = this.detail.status || ''
|
|
|
- if (status === 'CLAIMED') return '该分享已被领取'
|
|
|
+ if (status === 'CLAIMED') return '优惠券已经领取'
|
|
|
if (status === 'REVOKED') return '该分享已撤回'
|
|
|
if (status === 'EXPIRED') return '该分享已过期'
|
|
|
if (this.detail.claimable !== true) return '优惠券已失效'
|
|
|
@@ -136,6 +169,10 @@ export default {
|
|
|
this.claiming = true
|
|
|
claimCouponShare(this.shareToken).then(function(res) {
|
|
|
if (res && res.code === 200) {
|
|
|
+ // 先切到本地已领取态,避免跳转前按钮可重复点击
|
|
|
+ if (self.detail) {
|
|
|
+ self.detail.status = 'CLAIMED'
|
|
|
+ }
|
|
|
uni.showToast({ title: '领取成功', icon: 'success' })
|
|
|
setTimeout(function() {
|
|
|
uni.redirectTo({ url: '/pages/profile-extra/coupons' })
|
|
|
@@ -323,6 +360,37 @@ export default {
|
|
|
color: $facade-text-strong;
|
|
|
}
|
|
|
|
|
|
+/* ===== 券介绍 ===== */
|
|
|
+.intro-card {
|
|
|
+ background: $app-surface;
|
|
|
+ border-radius: 16rpx;
|
|
|
+ padding: 28rpx 24rpx;
|
|
|
+ margin-bottom: 24rpx;
|
|
|
+}
|
|
|
+.intro-title {
|
|
|
+ display: block;
|
|
|
+ font-size: calc(30rpx * var(--font-scale, 1));
|
|
|
+ font-weight: 600;
|
|
|
+ color: $facade-text-strong;
|
|
|
+ margin-bottom: 16rpx;
|
|
|
+}
|
|
|
+.intro-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-start;
|
|
|
+ margin-bottom: 12rpx;
|
|
|
+}
|
|
|
+.intro-label {
|
|
|
+ width: 140rpx;
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: calc(24rpx * var(--font-scale, 1));
|
|
|
+ color: $facade-text-muted;
|
|
|
+}
|
|
|
+.intro-value {
|
|
|
+ flex: 1;
|
|
|
+ font-size: calc(24rpx * var(--font-scale, 1));
|
|
|
+ color: $facade-text-strong;
|
|
|
+}
|
|
|
+
|
|
|
/* ===== 操作区 ===== */
|
|
|
.action-area {
|
|
|
display: flex;
|
|
|
@@ -345,7 +413,7 @@ export default {
|
|
|
border: none;
|
|
|
}
|
|
|
.claim-btn[disabled] {
|
|
|
- opacity: 0.7;
|
|
|
+ opacity: 0.55;
|
|
|
}
|
|
|
.claim-tip {
|
|
|
font-size: calc(22rpx * var(--font-scale, 1));
|