Fix(商品/订单):[#1021]商品详情页购买时选择优惠券,点击“立即购买”后已显示扣除优惠金额,但点开提交订单页面的优惠券时,优惠券未勾选
This commit is contained in:
+28
-9
@@ -1,18 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="components-coupons">
|
<view class="components-coupons">
|
||||||
<image class="coupons__cover" :src="data.image" mode="widthFix"/>
|
<image
|
||||||
|
:src="data.image"
|
||||||
|
class="coupons__cover"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
<view class="coupons__section flex jc-between ai-center">
|
<view class="coupons__section flex jc-between ai-center">
|
||||||
<view>有效期至:
|
<view>有效期至:
|
||||||
<text>{{ data.endTime }}</text>
|
<text>{{ data.endTime }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="coupons__tag coupons__tag-expire" v-if="data.status===2">已到期</view>
|
<view
|
||||||
<view class="coupons__tag" @click="goGoods()" v-if="data.status===0 && !radioModel">去使用</view>
|
v-if="data.status===2"
|
||||||
|
class="coupons__tag coupons__tag-expire"
|
||||||
|
>已到期</view>
|
||||||
|
<view
|
||||||
|
v-if="data.status === 0 && !radioModel"
|
||||||
|
class="coupons__tag"
|
||||||
|
@click="goGoods()"
|
||||||
|
>去使用</view>
|
||||||
<view @click="selectCoupon">
|
<view @click="selectCoupon">
|
||||||
<radio :value="data.id" :checked="data.checked" color="#FF564A" v-if="radioModel && data.status===0"/>
|
<radio
|
||||||
|
v-if="radioModel && data.status === 0"
|
||||||
|
:value="data.id"
|
||||||
|
:checked="data.checked"
|
||||||
|
color="#FF564A"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="coupons__rules">
|
<view class="coupons__rules">
|
||||||
<view class="coupons__rules-title" @click="changeRules()">使用规则
|
<view class="coupons__rules-title" @click="changeRules()">使用规则
|
||||||
<image :class="{'open':isOpen}" :src="webUrl+'/20231125220409665027.png'" mode="scaleToFill"/>
|
<image :class="{'open':isOpen}" :src="webUrl+'/20231125220409665027.png'" mode="scaleToFill"/>
|
||||||
@@ -31,7 +45,13 @@
|
|||||||
export default {
|
export default {
|
||||||
name: "Coupons",
|
name: "Coupons",
|
||||||
props: {
|
props: {
|
||||||
data: Object,
|
data: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 是否显示选择框
|
||||||
radioModel: {
|
radioModel: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@@ -52,8 +72,7 @@ export default {
|
|||||||
this.isOpen = !this.isOpen
|
this.isOpen = !this.isOpen
|
||||||
},
|
},
|
||||||
goGoods() {
|
goGoods() {
|
||||||
uni.switchTab({url: '/pages/home/landMark'})
|
uni.switchTab({ url: '/pages/home/landMark' })
|
||||||
// this.$global.navToGoods(this.data.productId)
|
|
||||||
},
|
},
|
||||||
selectCoupon() {
|
selectCoupon() {
|
||||||
if (!this.radioModel) return
|
if (!this.radioModel) return
|
||||||
|
|||||||
+46
-39
@@ -2,20 +2,41 @@
|
|||||||
<view class="popup-coupons">
|
<view class="popup-coupons">
|
||||||
<view class="popup-box">
|
<view class="popup-box">
|
||||||
<view class="popup-title bold tc">选择优惠券</view>
|
<view class="popup-title bold tc">选择优惠券</view>
|
||||||
<SubSection :current="current" :can-use="canUse" :not-use="notUse" radioModel @change="changeNav"/>
|
<SubSection
|
||||||
|
:current="current"
|
||||||
|
:can-use="canUse"
|
||||||
|
:not-use="notUse"
|
||||||
|
radio-model
|
||||||
|
@change="changeNav"
|
||||||
|
/>
|
||||||
<view class="list-box">
|
<view class="list-box">
|
||||||
<view style="margin-bottom: 20rpx" v-for="(item,index) in list" :key="index">
|
<view
|
||||||
<Coupons :data="item" radioModel @change="selectCoupon"/>
|
v-for="(item, index) in list"
|
||||||
|
:key="index"
|
||||||
|
style="margin-bottom: 20rpx"
|
||||||
|
>
|
||||||
|
<Coupons
|
||||||
|
:data="item"
|
||||||
|
radio-model
|
||||||
|
@change="selectCoupon"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
<view
|
||||||
<view class="tc" v-if="list.length===0">
|
v-if="list.length === 0"
|
||||||
|
class="tc"
|
||||||
|
>
|
||||||
<image class="zero-coupons" :src="webUrl+'/20231201201733142658.png'" mode="scaleToFill"/>
|
<image class="zero-coupons" :src="webUrl+'/20231201201733142658.png'" mode="scaleToFill"/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button disabled></button>
|
<button disabled></button>
|
||||||
<view class="btn-done bold flex jc-center ai-center" :class="{'btn-disabled':current===1}" @click="setCoupon" v-if="current===0">确定
|
<view
|
||||||
|
v-if="current === 0"
|
||||||
|
:class="{ 'btn-disabled': current === 1 }"
|
||||||
|
class="btn-done bold flex jc-center ai-center"
|
||||||
|
@click="setCoupon"
|
||||||
|
>
|
||||||
|
确定
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -26,16 +47,26 @@ import Coupons from '@/components/Coupons.vue'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CouponsPopup',
|
name: 'CouponsPopup',
|
||||||
components: {SubSection, Coupons},
|
components: { SubSection, Coupons },
|
||||||
props: {
|
props: {
|
||||||
twoList: {
|
twoList: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {}
|
default: {
|
||||||
|
usable: [],
|
||||||
|
unusable: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||||
|
current: 0,
|
||||||
|
couponId: uni.getStorageSync('couponId') || 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
list() {
|
list() {
|
||||||
let temp = this.current === 0 ? this.twoList['usable'] : this.twoList['unusable']
|
const temp = this.current === 0 ? this.twoList['usable'] : this.twoList['unusable']
|
||||||
return this.$global.deepClone(temp)
|
return this.$global.deepClone(temp)
|
||||||
},
|
},
|
||||||
canUse() {
|
canUse() {
|
||||||
@@ -45,44 +76,20 @@ export default {
|
|||||||
return this.twoList['unusable'].length
|
return this.twoList['unusable'].length
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
current() {
|
|
||||||
this.selectCoupon(this.couponId)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
|
||||||
current: 0,
|
|
||||||
couponId: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.couponId = uni.getStorageSync('couponId') || 0
|
|
||||||
this.selectCoupon(this.couponId)
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
changeNav(index) {
|
changeNav(index) {
|
||||||
this.current = index
|
this.current = index
|
||||||
},
|
},
|
||||||
selectCoupon(id) {
|
selectCoupon(id) {
|
||||||
const isCancel = this.couponId === id
|
this.couponId = id
|
||||||
this.couponId = isCancel ? 0 : id
|
this.list.map(item => {
|
||||||
|
item.checked = id === item.id
|
||||||
this.list?.forEach(item => {
|
|
||||||
if (!isCancel) {
|
|
||||||
item.checked = id === item.id
|
|
||||||
} else {
|
|
||||||
item.checked = false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setCoupon() {
|
setCoupon() {
|
||||||
if (this.current === 1) return
|
if (this.current === 1) return
|
||||||
// if (this.couponId !== 0) {
|
uni.setStorageSync('couponId', this.couponId)
|
||||||
uni.setStorageSync('couponId', this.couponId)
|
this.$emit('change')
|
||||||
// }
|
|
||||||
this.$emit('close')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,8 +185,18 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- v9 优惠券开始 -->
|
<!-- v9 优惠券开始 -->
|
||||||
<u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons">
|
<u-popup
|
||||||
<CouponsPopup :two-list="couponList" @close="changeCoupons" v-if="couponList.usable"/>
|
:show="show"
|
||||||
|
:round="10"
|
||||||
|
mode="bottom"
|
||||||
|
close-on-click-overlay
|
||||||
|
@close="changeCoupons"
|
||||||
|
>
|
||||||
|
<CouponsPopup
|
||||||
|
v-if="couponList.usable.length > 0"
|
||||||
|
:two-list="couponList"
|
||||||
|
@change="changeCoupons"
|
||||||
|
/>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
<!-- v9 优惠券结束 -->
|
<!-- v9 优惠券结束 -->
|
||||||
|
|
||||||
@@ -272,8 +282,11 @@ export default {
|
|||||||
lotteryRecordId:'',
|
lotteryRecordId:'',
|
||||||
payPassword: null,
|
payPassword: null,
|
||||||
// v9-2
|
// v9-2
|
||||||
couponList: {},
|
couponList: {
|
||||||
couponId: 0,
|
unusable: [],
|
||||||
|
usable: []
|
||||||
|
},
|
||||||
|
couponId: uni.getStorageSync('couponId') || 0,
|
||||||
couponIndex: -1,
|
couponIndex: -1,
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
@@ -354,35 +367,42 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCartInfo() {
|
getCartInfo() {
|
||||||
var that = this;
|
const _this = this
|
||||||
// const cartIds = this.$yroute.query.id;
|
if (!_this.cartid && !_this.lotteryRecordId) {
|
||||||
if (!that.cartid && !that.lotteryRecordId) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "参数有误",
|
title: "参数有误",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
})
|
||||||
return this.$yrouter.back();
|
return this.$yrouter.back()
|
||||||
}
|
}
|
||||||
postOrderConfirm(that.cartid,that.lotteryRecordId)
|
postOrderConfirm(_this.cartid,_this.lotteryRecordId).then(res => {
|
||||||
.then(res => {
|
const { data } = res
|
||||||
that.offlinePayStatus = res.data.offline_pay_status;
|
_this.offlinePayStatus = data.offline_pay_status
|
||||||
that.orderGroupInfo = res.data;
|
_this.orderGroupInfo = data
|
||||||
that.deduction = res.data.deduction;
|
_this.deduction = data.deduction
|
||||||
that.couponList = res.data.couponList
|
_this.couponList = data.couponList
|
||||||
that.addressInfo = res.data.addressInfo || {};
|
if (_this.couponId > 0) {
|
||||||
that.systemStore = res.data.systemStore || {};
|
_this.couponList['usable'].map((item, index) => {
|
||||||
that.storeSelfMention = res.data.storeSelfMention;
|
if (item.id === _this.couponId) {
|
||||||
that.couponId = uni.getStorageSync('couponId') || 0
|
item.checked = true
|
||||||
that.computedPrice()
|
_this.couponIndex = index
|
||||||
|
} else {
|
||||||
|
item.checked = false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
}
|
||||||
uni.showToast({
|
_this.addressInfo = data.addressInfo || {}
|
||||||
title: err.msg,
|
_this.systemStore = data.systemStore || {}
|
||||||
icon: "none",
|
_this.storeSelfMention = data.storeSelfMention
|
||||||
duration: 2000
|
_this.computedPrice()
|
||||||
});
|
}).catch(err => {
|
||||||
});
|
uni.showToast({
|
||||||
|
title: err.msg,
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
addressTap: function () {
|
addressTap: function () {
|
||||||
//改用跳转页面方式
|
//改用跳转页面方式
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
|
|
||||||
<!-- v9 优惠券开始 -->
|
<!-- v9 优惠券开始 -->
|
||||||
<u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons()">
|
<u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons()">
|
||||||
<CouponsPopup :two-list="couponList" @close="changeCoupons"/>
|
<CouponsPopup :two-list="couponList" @change="changeCoupons"/>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
<!-- v9 优惠券结束 -->
|
<!-- v9 优惠券结束 -->
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user