Fix:4127 【商城小程序】订单结算页面的优惠详情弹窗—勾选其他优惠券后点击【×】关闭按钮,再次打开弹窗会显示勾选新选择的优惠券

This commit is contained in:
linxi
2025-08-05 16:47:21 +08:00
parent a2250ccc9a
commit a9a7a46807
3 changed files with 32 additions and 13 deletions
+20 -6
View File
@@ -142,6 +142,10 @@ export default {
id: { id: {
type: Number, type: Number,
default: 0 default: 0
},
couponId1: {
type: Number,
default: 0
} }
}, },
data() { data() {
@@ -155,10 +159,11 @@ export default {
} }
}, },
watch: { watch: {
id: { couponId1: {
immediate: true, immediate: true,
handler(value) { handler(value) {
console.log('couponId', value); console.log(value);
if(value) { if(value) {
this.selectCoupon(value) this.selectCoupon(value)
} }
@@ -169,7 +174,7 @@ export default {
list() { list() {
const temp = this.current === 0 ? this.twoList['usable'] : this.twoList['unusable'] const temp = this.current === 0 ? this.twoList['usable'] : this.twoList['unusable']
if (this.current === 0) { if (this.current === 0) {
const localCouponId = uni.getStorageSync('couponId') || 0 const localCouponId = this.couponId1 || 0
temp.map(item => { temp.map(item => {
item.checked = localCouponId === item.id item.checked = localCouponId === item.id
}) })
@@ -193,8 +198,8 @@ export default {
}, },
largOne() { largOne() {
if(this.list[this.maxIndex]) { if(this.list[this.maxIndex]) {
this.selectCoupon(this.list[this.maxIndex].id) // this.selectCoupon(this.list[this.maxIndex].id)
uni.setStorageSync('couponId', this.list[this.maxIndex].id) // uni.setStorageSync('couponId', this.list[this.maxIndex].id)
} }
// this.$emit('max', this.list[this.maxIndex] || {}) // this.$emit('max', this.list[this.maxIndex] || {})
return this.list[this.maxIndex] || {} return this.list[this.maxIndex] || {}
@@ -206,7 +211,17 @@ export default {
}, },
methods: { methods: {
close() { close() {
this.couponId = this.couponId1
this.selectItem = this.list.find(e => e.id === this.couponId1) || {}
// this.$emit('select', this.selectItem)
this.list.map(item => {
item.checked = this.couponId1 === item.id
})
this.$emit('close') this.$emit('close')
// uni.setStorageSync('couponId', this.couponId)
// this.$emit('change', this.selectItem || {})
// this.$emit('ok', this.couponId)
}, },
force2Decimal(value) { force2Decimal(value) {
return this.$force2Decimal(value); return this.$force2Decimal(value);
@@ -224,7 +239,6 @@ export default {
}, },
setCoupon() { setCoupon() {
if (this.current === 1) return if (this.current === 1) return
console.log(this.current, '====1=======');
uni.setStorageSync('couponId', this.couponId) uni.setStorageSync('couponId', this.couponId)
this.$emit('change', this.selectItem || {}) this.$emit('change', this.selectItem || {})
this.$emit('ok', this.couponId) this.$emit('ok', this.couponId)
+9 -5
View File
@@ -130,7 +130,7 @@
<text class="v12-dark-text v12-font-24" >{{ couponList.usable.length === 0 ? '无' : '去选择' }}</text> <text class="v12-dark-text v12-font-24" >{{ couponList.usable.length === 0 ? '无' : '去选择' }}</text>
<text class="iconfont icon-jiantou v12-font-24 v12-dark-text"></text> <text class="iconfont icon-jiantou v12-font-24 v12-dark-text"></text>
</view> --> </view> -->
<view class="v12-secondary-dark-text v12-align-center" @click="changeCoupons"> <view class="v12-secondary-dark-text v12-align-center" @click="showCouponsPopup">
<text class="v12-font-22 ">-</text> <text class="v12-font-22 ">-</text>
<text class="v12-font-28">{{ force2Decimal(orderPrice.couponPrice) }}</text> <text class="v12-font-28">{{ force2Decimal(orderPrice.couponPrice) }}</text>
<text class="iconfont icon-jiantou v12-font-24 v12-dark-text"></text> <text class="iconfont icon-jiantou v12-font-24 v12-dark-text"></text>
@@ -255,20 +255,21 @@
</view> </view>
<!-- v9 优惠券开始 --> <!-- v9 优惠券开始 -->
<u-popup <u-popup
v-if="show"
:show="show" :show="show"
:round="10" :round="10"
mode="bottom" mode="bottom"
close-on-click-overlay close-on-click-overlay
@close="changeCoupons" @close="close"
> >
<CouponsPopup <CouponsPopup
v-if="couponList.usable.length > 0" v-if="couponList.usable.length > 0 && show"
:two-list="couponList" :two-list="couponList"
@change="changeCoupons" @change="changeCoupons"
@close="close" @close="close"
:currentPrice="force2Decimal(orderPrice.totalPrice)" :currentPrice="force2Decimal(orderPrice.totalPrice)"
:id="couponId" :id="couponId"
@max="couponMax" :couponId1="couponId"
:show-tab="false" :show-tab="false"
/> />
</u-popup> </u-popup>
@@ -473,7 +474,7 @@ export default {
postOrderComputed(this.orderGroupInfo.orderKey, { postOrderComputed(this.orderGroupInfo.orderKey, {
addressId: this.addressInfo.id, addressId: this.addressInfo.id,
useIntegral: this.useIntegral ? 1 : 0, useIntegral: this.useIntegral ? 1 : 0,
couponId: this.couponList.usable.length === 0 ? 0 : this.couponId || 0, couponId: this.couponList.usable.length === 0 ? 0 : this.couponId,
usePoints: this.usePointsCheck ? 1 : 0, usePoints: this.usePointsCheck ? 1 : 0,
shipping_type: parseInt(this.shipping_type) + 1 shipping_type: parseInt(this.shipping_type) + 1
}).then(res => { }).then(res => {
@@ -800,6 +801,9 @@ export default {
close() { close() {
this.show = !this.show this.show = !this.show
}, },
showCouponsPopup() {
this.show = !this.show
},
// v9-2 // v9-2
changeCoupons(item) { changeCoupons(item) {
if(!item) return if(!item) return
+3 -2
View File
@@ -192,15 +192,16 @@
:round="10" :round="10"
mode="bottom" mode="bottom"
close-on-click-overlay close-on-click-overlay
@close="changeCoupons" @close="close"
> >
<CouponsPopup <CouponsPopup
v-if="couponList.usable && couponList.usable.length > 0" v-if="couponList.usable && couponList.usable.length > 0 && showPopup"
:two-list="couponList" :two-list="couponList"
@change="changeCoupons" @change="changeCoupons"
:currentPrice="computedResult.canUseCouponPrice" :currentPrice="computedResult.canUseCouponPrice"
@close="close" @close="close"
:id="couponId" :id="couponId"
:couponId1="couponId"
:show-tab="false" :show-tab="false"
/> />
</u-popup> </u-popup>