|
|
@@ -21,6 +21,11 @@
|
|
|
<text v-else class="coupon-row-placeholder">选择优惠券</text>
|
|
|
<text class="coupon-row-arrow">›</text>
|
|
|
</view>
|
|
|
+ <view v-if="!isMember && hasMembershipCoupons" class="member-hint-row" @click="goToMembership">
|
|
|
+ <text class="member-hint-icon">👑</text>
|
|
|
+ <text class="member-hint-text">开通会员可使用会员专属优惠券</text>
|
|
|
+ <text class="coupon-row-arrow">›</text>
|
|
|
+ </view>
|
|
|
<view class="divider"></view>
|
|
|
<view class="total-row">
|
|
|
<text class="total-label">实付</text>
|
|
|
@@ -67,7 +72,7 @@
|
|
|
</view>
|
|
|
<view class="picker-item-right">
|
|
|
<text class="picker-item-name">{{ coupon.name }}</text>
|
|
|
- <text class="picker-item-condition">{{ getCouponCondition(coupon.minSpend) }}</text>
|
|
|
+ <text class="picker-item-condition">{{ getCouponCondition(coupon) }}</text>
|
|
|
</view>
|
|
|
<view class="picker-item-check" v-if="selectedCoupon && selectedCoupon.id === coupon.id">
|
|
|
<text>✓</text>
|
|
|
@@ -105,7 +110,8 @@ export default {
|
|
|
currentPeriod: 1,
|
|
|
splitAmount: 0,
|
|
|
orderNo: null,
|
|
|
- paying: false
|
|
|
+ paying: false,
|
|
|
+ isMember: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -144,8 +150,16 @@ export default {
|
|
|
return this.coupons.filter(function(c) {
|
|
|
if (c.status && c.status !== 'AVAILABLE') return false
|
|
|
if (c.applicableTo && c.applicableTo !== 'ALL' && c.applicableTo !== 'MEMBERSHIP') return false
|
|
|
+ // 会员专属券:非会员不显示在可选列表中
|
|
|
+ if (c.applicableTo === 'MEMBERSHIP' && !self.isMember) return false
|
|
|
return true
|
|
|
})
|
|
|
+ },
|
|
|
+ hasMembershipCoupons: function() {
|
|
|
+ var self = this
|
|
|
+ return this.coupons.some(function(c) {
|
|
|
+ return c.applicableTo === 'MEMBERSHIP' && (!c.status || c.status === 'AVAILABLE')
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
onLoad: function(options) {
|
|
|
@@ -154,6 +168,7 @@ export default {
|
|
|
this.periodLabel = this.getPeriodLabel(this.period)
|
|
|
this.loadPlans()
|
|
|
this.loadCoupons()
|
|
|
+ this.checkMemberStatus()
|
|
|
},
|
|
|
methods: {
|
|
|
getPeriodLabel: function(period) {
|
|
|
@@ -206,9 +221,27 @@ export default {
|
|
|
this.selectedCoupon = null
|
|
|
this.showCouponPicker = false
|
|
|
},
|
|
|
- getCouponCondition: function(minSpend) {
|
|
|
- if (!minSpend || minSpend <= 0) return '无门槛'
|
|
|
- return '满' + (minSpend / 100).toFixed(2) + '元可用'
|
|
|
+ checkMemberStatus: function() {
|
|
|
+ var self = this
|
|
|
+ uni.request({
|
|
|
+ url: getApp().$config.baseUrl + '/api/membership/my',
|
|
|
+ method: 'POST',
|
|
|
+ header: { 'Authorization': 'Bearer ' + uni.getStorageSync('token') },
|
|
|
+ success: function(res) {
|
|
|
+ if (res.data && res.data.code === 200 && res.data.data) {
|
|
|
+ var membership = res.data.data.membership
|
|
|
+ self.isMember = membership && membership.isActive
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getCouponCondition: function(coupon) {
|
|
|
+ if (!coupon) return '无门槛'
|
|
|
+ if (coupon.applicableTo === 'MEMBERSHIP' && !this.isMember) {
|
|
|
+ return '开通会员后可用'
|
|
|
+ }
|
|
|
+ if (!coupon.minSpend || coupon.minSpend <= 0) return '无门槛'
|
|
|
+ return '满' + (coupon.minSpend / 100).toFixed(2) + '元可用'
|
|
|
},
|
|
|
formatPrice: function(value) {
|
|
|
if (value == null) return '0.00'
|
|
|
@@ -331,6 +364,9 @@ export default {
|
|
|
self.paying = false
|
|
|
uni.redirectTo({ url: '/pages/membership/result?orderNo=' + (self.orderNo || '') + '&status=success' })
|
|
|
}, 800)
|
|
|
+ },
|
|
|
+ goToMembership: function() {
|
|
|
+ uni.navigateTo({ url: '/pages/membership/index' })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -422,6 +458,27 @@ export default {
|
|
|
color: #ccc;
|
|
|
margin-left: 8rpx;
|
|
|
}
|
|
|
+.member-hint-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 20rpx 0;
|
|
|
+ margin-top: 8rpx;
|
|
|
+ background: #FFF7ED;
|
|
|
+ border-radius: 12rpx;
|
|
|
+}
|
|
|
+.member-hint-row:active {
|
|
|
+ opacity: 0.7;
|
|
|
+}
|
|
|
+.member-hint-icon {
|
|
|
+ font-size: 28rpx;
|
|
|
+ margin-right: 12rpx;
|
|
|
+}
|
|
|
+.member-hint-text {
|
|
|
+ flex: 1;
|
|
|
+ font-size: 26rpx;
|
|
|
+ color: #F97316;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
.divider {
|
|
|
height: 1rpx;
|
|
|
background: #F1F5F9;
|