Fix:3982 【商城小程序】送礼页面优惠券改为选填模式

This commit is contained in:
linxi
2025-07-30 14:06:25 +08:00
parent 6df8cda11c
commit 615f7d9064
5 changed files with 130 additions and 33 deletions
+22 -5
View File
@@ -380,7 +380,7 @@ export default {
unusable: [],
usable: []
},
couponId: uni.getStorageSync('couponId') || 0,
couponId: null,
couponIndex: -1,
show: false,
// 是否使用积分开关
@@ -449,8 +449,8 @@ export default {
methods: {
isNullOrEmpty,
couponMax(e) {
this.couponTitle = e.couponTitle
this.couponId = this.$yroute.query.couponId || uni.getStorageSync('couponId') || 0
// this.couponTitle = e.couponTitle
// this.couponId = this.$yroute.query.couponId || uni.getStorageSync('couponId') || 0
},
showStoreList() {
this.$store.commit("get_to", "orders")
@@ -464,7 +464,11 @@ export default {
usePointsCheckChange(e) {
this.computedPrice()
},
// 计算订单金额
/**
* 计算订单金额
* @param {*} f 有值时 couponId不取默认值
*/
computedPrice(f) {
postOrderComputed(this.orderGroupInfo.orderKey, {
addressId: this.addressInfo.id,
@@ -473,6 +477,10 @@ export default {
usePoints: this.usePointsCheck ? 1 : 0,
shipping_type: parseInt(this.shipping_type) + 1
}).then(res => {
this.couponList = res.data.result.couponList
if(!f) {
this.couponId = res.data.result.defaultCouponId
}
const data = res.data;
if (data.status === "EXTEND_ORDER") {
this.$yrouter.replace({
@@ -797,8 +805,17 @@ export default {
if(!item) return
if (this.couponList.usable.length === 0) return
this.show = !this.show
this.couponId = uni.getStorageSync('couponId') || 0
if(!item.id) {
this.couponId = 0
this.couponTitle = ''
this.computedPrice(1)
return
}
this.couponId = item.id
this.couponTitle = item.couponTitle
this.computedPrice(1)
// this.couponId = uni.getStorageSync('couponId') || 0
// this.couponTitle = item.couponTitle
}
}
};
+4 -3
View File
@@ -207,7 +207,8 @@
@ok="setCoupon"
@change="changeCoupons"
@close="changeCoupons()"
:showTab="false"
:showTab="false"
:showRadio="false"
:currentPrice="storeInfo.price" />
</u-popup>
<!-- v9 优惠券结束 -->
@@ -1458,7 +1459,6 @@ export default {
path: "/pages/order/OrderSubmission/index",
query: {
id: res.data.cartId,
couponId: that.couponId, // 优惠券ID
discount: that.storeInfo.discount,
}
})
@@ -1467,7 +1467,8 @@ export default {
if(news === 2) {
const coupId = that.couponId ? that.couponId : (that.couponList.usable[0] && that.couponList.usable[0].id || '')
uni.navigateTo({
url: '/pkg_user/views/gift/gift?cartId=' + res.data.cartId + '&couponId=' + coupId + (that.storeInfo.discount ? '&discount=' + that.storeInfo.discount : '')
// + '&couponId=' + coupId
url: '/pkg_user/views/gift/gift?cartId=' + res.data.cartId + (that.storeInfo.discount ? '&discount=' + that.storeInfo.discount : '')
})
}
if(news === 0) {