Commit 68f22e39 authored by youjie's avatar youjie

修复 叠加优惠券

parent 96a4d94f
......@@ -60,35 +60,36 @@
<script>
export default {
props: ["list", "current","currentPrice","order","multiple"],
props: ["list", "current","currentPrice","order"],
data() {
return {
mc: "",
show: true,
currentChosen: "",
currentChosen: [],
value:'',
ts: [],
stacking: 0,
multipleChosen: [],
};
},
mounted() {
this.mc = this.$uiConfig.mainColor;
if(this.current) {
this.currentChosen = this.current;
this.value = this.current;
}
if(this.multiple) this.multipleChosen = this.multiple
// this.value = this.current[0]
this.ts = this.list
this.ts.forEach(x => {
x.start_time = x.effectDate.split(' ')[0].replace(/-/g, '.')
x.end_time = x.expirationDate.split(' ')[0].replace(/-/g, '.')
if(this.multipleChosen&&this.multipleChosen.length>0){
this.multipleChosen.forEach(y => {
if(this.currentChosen&&this.currentChosen.length>0){
this.currentChosen.forEach(y => {
if (x.id == y) {
console.log(y,'====')
x.checkId = y
x.check = true
if(!x.overlapUse){
this.value = y
}else{
this.value = 0
this.stacking = 1
}
}
})
}
......@@ -119,50 +120,57 @@
},
popupClose() {
if(this.stacking==0){
if (this.currentChosen != this.current) {
if (this.currentChosen.length>0
&& this.currentChosen[0] != this.current[0]) {
this.$emit('close', this.currentChosen)
} else {
this.$emit('close', -1)
}
}else{
if(this.multipleChosen.length>0){
this.$emit('close', this.multipleChosen)
if(this.currentChosen.length>0){
this.$emit('close', this.currentChosen)
}else{
this.$emit('close', -1)
}
}
},
// 不可叠加使用优惠券
radioChange(e){
if(this.stacking) {
this.currentChosen = []
this.stacking = 0
this.multipleChosen = []
}
this.ts.forEach(x => {
x.checkId = 0
x.check = false
})
if(this.currentChosen != e){
this.currentChosen = e
if(this.currentChosen.length==0||(this.currentChosen.length==1&&this.currentChosen[0] != e)){
this.currentChosen = [e]
}else{
this.currentChosen = 0;
this.value = 0
}
// console.log('---单选',this.currentChosen)
},
// 叠加使用优惠券
multipleChoice(e,i){
this.stacking = 1
this.value = 0
if(!this.ts[i].check) this.ts[i].check = true
else this.ts[i].check = false
if(!this.stacking) {
this.currentChosen = []
this.stacking = 1
this.value = 0
}
if(!this.ts[i].check) {
this.ts[i].checkId = 0
this.multipleChosen = this.multipleChosen.filter(x=>{return x!=e})
this.currentChosen = this.currentChosen.filter(x=>{return x!=e})
}else {
this.ts[i].checkId = e
let list = this.multipleChosen.findIndex(x=>x==this.ts[i].id)
if(list==-1) this.multipleChosen.push(e)
let list = this.currentChosen.findIndex(x=>x==this.ts[i].id)
if(list==-1) this.currentChosen.push(e)
}
console.log(e,'---',this.multipleChosen)
// console.log(e,'---多选',this.currentChosen)
}
},
};
......
......@@ -314,7 +314,7 @@
<view style="font-size: 12px;width:1px;flex:1">请选择优惠券</view>
<view style="display: flex;align-items: center;">
<text style="color:#F20707;font-size: 12px;" @click="showCouponHandler">
<text style="flex: 1;" v-if="useCouponId == 0 &&couponList.length>0">{{couponList.length}}张可用优惠券</text>
<text style="flex: 1;" v-if="useCouponIds.length == 0 &&couponList.length>0">{{couponList.length}}张可用优惠券</text>
<text class="content" style="color:grey" v-else-if="couponList.length==0">暂无优惠券</text>
<text class="content" v-else :style="{ color: mainColor }">已优惠 {{currentCoupon.discountMoney}}</text>
<!-- <u-icon name="ellipsis" size="36" v-if="couponList.length > 0"></u-icon> -->
......@@ -402,7 +402,7 @@
<view style="text-align: right">{{ orderMsg.ManNum + orderMsg.ChirdNum, }}人 × ¥{{currentPriceInfo.visaPrice}}</view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :style="{'color':mainColor+' !important'}" v-if="useCouponId>0">
<view class="flex f12 grey" style="margin-bottom: 40rpx" :style="{'color':mainColor+' !important'}" v-if="useCouponIds.length>0">
<view style="flex: 1">
<text style="margin-right: 30rpx">优惠券</text>
</view>
......@@ -424,8 +424,7 @@
<view class="empty-block"></view>
<coupon v-if="couponList.length > 0 && showCoupon"
:list="couponList"
:current="useCouponId"
:multiple="multipleChosenIds"
:current="useCouponIds"
@close="closeCouponHandler"
:current-price="realCurrentPriceInfo" :order="orderMsg"></coupon>
<view style="padding: 50rpx 40rpx" v-if="tips != ''">
......@@ -525,7 +524,7 @@
GuestList: [],
couponList: [],
showCoupon: false,
useCouponId: 0,
useCouponIds: [],
currentCoupon: {
discountMoney: 0
},
......@@ -535,7 +534,6 @@
CreateBy: 0,
showPz:false,
pzCoupon:null,
multipleChosenIds: [],
};
},
created() {
......@@ -578,12 +576,12 @@
},
closeCouponHandler(e) {
if (e != -1) {
if(e instanceof Array){//叠加使用优惠券
this.multipleChosenIds = e
this.useCouponIds = e;
console.log(this.useCouponIds,'==========')
//叠加使用优惠券
let TotalDiscountAmount = 0
this.useCouponId = 1
this.couponList.forEach(x=>{
let findIndex = this.multipleChosenIds.findIndex(y=>x.id==y)
let findIndex = this.useCouponIds.findIndex(y=>x.id==y)
if(findIndex!=-1){
let discountMoney = 0
if(x.couponsType==1){
......@@ -597,24 +595,22 @@
})
if(TotalDiscountAmount)this.currentCoupon.discountMoney = TotalDiscountAmount
else this.currentCoupon.discountMoney = 0
// if(this.useCouponIds.length==0){
// this.currentCoupon = this.couponList.find(x => x.id == this.useCouponIds)
// if (this.currentCoupon.couponsType == 1) {
// this.currentCoupon.discountMoney = this.currentCoupon.denomination
// } else {
// this.currentCoupon.discountMoney = (parseFloat(this.price) * (1 - parseFloat(this.currentCoupon.denomination / 10)))
// .toFixed(2)
// }
// }else{
// this.currentCoupon.discountMoney = 0
// }
}else{
this.useCouponId = e;
if(this.useCouponId){
this.currentCoupon = this.couponList.find(x => x.id == this.useCouponId)
if (this.currentCoupon.couponsType == 1) {
this.currentCoupon.discountMoney = this.currentCoupon.denomination
} else {
this.currentCoupon.discountMoney = (parseFloat(this.price) * (1 - parseFloat(this.currentCoupon.denomination / 10)))
.toFixed(2)
}
}else{
this.currentCoupon.discountMoney = 0
}
}
}else{
this.multipleChosenIds = []
this.currentCoupon.discountMoney = 0
this.useCouponId = 0
this.useCouponIds = []
}
this.showCoupon = false;
},
......@@ -885,10 +881,8 @@
price = this.currentPriceInfo.b2CPrice;
}
let CouponAllotIds = ''
if(this.multipleChosenIds.length>0){
CouponAllotIds = this.multipleChosenIds.join(',')
}else{
CouponAllotIds = this.useCouponId > 0 ? this.currentCoupon.id.toString() : ''
if(this.useCouponIds.length>0){
CouponAllotIds = this.useCouponIds.join(',')
}
let msg = {
OrderId: 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment