|
@@ -53,6 +53,19 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
|
|
+ <!-- 积分兑换优惠券 -->
|
|
|
|
|
+ <view class="coupon-exchange-section" v-if="productCoupons.length > 0">
|
|
|
|
|
+ <text class="section-title">积分兑换优惠券</text>
|
|
|
|
|
+ <view class="coupon-item" v-for="(item, index) in productCoupons" :key="getCouponKey(item, index)">
|
|
|
|
|
+ <view class="coupon-info">
|
|
|
|
|
+ <text class="coupon-name">{{ item.name }}</text>
|
|
|
|
|
+ <text class="coupon-desc">{{ getCouponDesc(item) }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="coupon-price">{{ item.pointsPrice }}积分</view>
|
|
|
|
|
+ <button class="coupon-exchange-btn" @click="doExchangeCoupon(item)">兑换</button>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
<view class="intro-section" v-if="product.intro">
|
|
<view class="intro-section" v-if="product.intro">
|
|
|
<text class="section-title">商品介绍</text>
|
|
<text class="section-title">商品介绍</text>
|
|
|
<mp-html :content="product.intro" />
|
|
<mp-html :content="product.intro" />
|
|
@@ -90,7 +103,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import config from '@/config.js'
|
|
import config from '@/config.js'
|
|
|
-import { productDetail, productOrderCreate, productOrderPay, cartAdd, getShareQrCode, productSpecMap, getMyMembership } from '@/utils/api.js'
|
|
|
|
|
|
|
+import { productDetail, productOrderCreate, productOrderPay, cartAdd, getShareQrCode, productSpecMap, getMyMembership, getProductCoupons, exchangeCoupon } from '@/utils/api.js'
|
|
|
import MpHtml from '@/components/mp-html/mp-html.vue'
|
|
import MpHtml from '@/components/mp-html/mp-html.vue'
|
|
|
import ContentSharePoster from '@/components/ContentSharePoster.vue'
|
|
import ContentSharePoster from '@/components/ContentSharePoster.vue'
|
|
|
import shareMixin from '../../../components/share-mixin.js'
|
|
import shareMixin from '../../../components/share-mixin.js'
|
|
@@ -110,7 +123,8 @@ export default {
|
|
|
specGroups: [],
|
|
specGroups: [],
|
|
|
selectedSpecs: {},
|
|
selectedSpecs: {},
|
|
|
selectedSku: null,
|
|
selectedSku: null,
|
|
|
- isMember: false
|
|
|
|
|
|
|
+ isMember: false,
|
|
|
|
|
+ productCoupons: []
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -250,6 +264,7 @@ export default {
|
|
|
'/pages/discover-detail/product-detail/product-detail?id=' + that.product.id
|
|
'/pages/discover-detail/product-detail/product-detail?id=' + that.product.id
|
|
|
)
|
|
)
|
|
|
that.loadSkuData(id)
|
|
that.loadSkuData(id)
|
|
|
|
|
+ that.loadProductCoupons(parseInt(id))
|
|
|
}
|
|
}
|
|
|
}).catch(function() {
|
|
}).catch(function() {
|
|
|
that.loading = false
|
|
that.loading = false
|
|
@@ -270,6 +285,50 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ loadProductCoupons: function(productId) {
|
|
|
|
|
+ if (!productId) return
|
|
|
|
|
+ var that = this
|
|
|
|
|
+ getProductCoupons({ productId: productId }).then(function(res) {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ that.productCoupons = res.data || []
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(function() {
|
|
|
|
|
+ // 兑换券加载失败不阻塞页面
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ getCouponKey: function(item, index) {
|
|
|
|
|
+ return item.id + '-' + index
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ getCouponDesc: function(item) {
|
|
|
|
|
+ if (item.type === 'DISCOUNT') {
|
|
|
|
|
+ return '折扣券 ' + (item.discountRate / 100).toFixed(1) + '折'
|
|
|
|
|
+ }
|
|
|
|
|
+ return '立减 ' + (item.value / 100).toFixed(2) + '元'
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ doExchangeCoupon: function(item) {
|
|
|
|
|
+ var that = this
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '确认兑换',
|
|
|
|
|
+ content: '消耗 ' + item.pointsPrice + ' 积分兑换「' + item.name + '」?',
|
|
|
|
|
+ success: function(r) {
|
|
|
|
|
+ if (!r.confirm) return
|
|
|
|
|
+ exchangeCoupon({ couponId: item.id }).then(function(res) {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ uni.showToast({ title: '兑换成功', icon: 'success' })
|
|
|
|
|
+ that.loadProductCoupons(that.product.id)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({ title: res.message || '兑换失败', icon: 'none' })
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(function(e) {
|
|
|
|
|
+ uni.showToast({ title: e.message || '兑换失败', icon: 'none' })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
checkMemberStatus: function() {
|
|
checkMemberStatus: function() {
|
|
|
var that = this
|
|
var that = this
|
|
|
getMyMembership().then(function(res) {
|
|
getMyMembership().then(function(res) {
|
|
@@ -642,6 +701,57 @@ export default {
|
|
|
font-size: 24rpx;
|
|
font-size: 24rpx;
|
|
|
color: #F97316;
|
|
color: #F97316;
|
|
|
}
|
|
}
|
|
|
|
|
+/* 积分兑换优惠券 */
|
|
|
|
|
+.coupon-exchange-section {
|
|
|
|
|
+ background: #fff;
|
|
|
|
|
+ padding: 30rpx;
|
|
|
|
|
+ margin-bottom: 20rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-item {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding: 20rpx 0;
|
|
|
|
|
+ border-bottom: 1rpx solid #f5f5f5;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-item:last-child {
|
|
|
|
|
+ border-bottom: none;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-info {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ min-width: 0;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-name {
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ display: block;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-desc {
|
|
|
|
|
+ font-size: 24rpx;
|
|
|
|
|
+ color: #F97316;
|
|
|
|
|
+ margin-top: 6rpx;
|
|
|
|
|
+ display: block;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-price {
|
|
|
|
|
+ font-size: 26rpx;
|
|
|
|
|
+ color: #F97316;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ margin-right: 24rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-exchange-btn {
|
|
|
|
|
+ background: linear-gradient(135deg, #F97316, #FB923C);
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ font-size: 26rpx;
|
|
|
|
|
+ padding: 0 32rpx;
|
|
|
|
|
+ height: 64rpx;
|
|
|
|
|
+ line-height: 64rpx;
|
|
|
|
|
+ border-radius: 32rpx;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+}
|
|
|
|
|
+.coupon-exchange-btn::after {
|
|
|
|
|
+ border: none;
|
|
|
|
|
+}
|
|
|
.member-price-row {
|
|
.member-price-row {
|
|
|
margin-top: 6rpx;
|
|
margin-top: 6rpx;
|
|
|
}
|
|
}
|