Commit 5af38f54 authored by youjie's avatar youjie

叠加使用优惠券

parent b814f151
......@@ -24,14 +24,21 @@
<view class="err" v-if="x.err">
{{x.err}}
</view>
<view style="color: #dfbe6e;font-size: 22rpx;padding-top: 30rpx;">
{{x.overlapUse==1?'可叠加使用':'不可叠加使用'}}
</view>
<!-- <view class="rule" v-if="x.lineTeamName!='' || x.lineName!=''">{{x.lineName}} {{x.lineTeamName}} 可用</view> -->
</view>
<view class="chosen" v-if="!x.err">
<u-radio-group v-model="value" @change="radioChange" >
<u-radio-group v-if="!x.overlapUse" v-model="value" @change="radioChange" >
<u-radio shape="circle" :name="x.id" :icon-size="36" :active-color="mc"></u-radio>
</u-radio-group>
<u-radio-group v-else v-model="x.checkId" @change="(e)=>{multipleChoice(e,i)}" >
<u-radio shape="circle" :name="x.id" :icon-size="36" :active-color="mc"></u-radio>
</u-radio-group>
</view>
</view>
</view>
</view>
</scroll-view>
......@@ -52,24 +59,39 @@
<script>
export default {
props: ["list", "current","currentPrice","order"],
props: ["list", "current","currentPrice","order","multiple"],
data() {
return {
mc: "",
show: true,
currentChosen: "",
value:'',
ts: []
ts: [],
stacking: 0,
multipleChosen: [],
};
},
mounted() {
this.mc = this.$uiConfig.mainColor;
this.currentChosen = this.current;
this.value = this.current;
if(this.current) {
this.currentChosen = this.current;
this.value = this.current;
}
if(this.multiple) this.multipleChosen = this.multiple
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 (x.id == y) {
console.log(y,'====')
x.checkId = y
x.check = true
}
})
}
})
this.checkOrderCoupon()
},
......@@ -95,19 +117,51 @@
}
},
popupClose() {
if (this.currentChosen != this.current) {
this.$emit('close', this.currentChosen)
} else {
this.$emit('close', -1)
if(this.stacking==0){
if (this.currentChosen != this.current) {
this.$emit('close', this.currentChosen)
} else {
this.$emit('close', -1)
}
}else{
if(this.multipleChosen.length>0){
this.$emit('close', this.multipleChosen)
}else{
this.$emit('close', -1)
}
}
},
radioChange(e){
this.stacking = 0
this.multipleChosen = []
this.ts.forEach(x => {
x.checkId = 0
x.check = false
})
if(this.currentChosen != e){
this.currentChosen = e
}else{
this.currentChosen = 0;
this.value = 0
}
},
// 叠加使用优惠券
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.ts[i].check) {
this.ts[i].checkId = 0
this.multipleChosen = this.multipleChosen.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)
}
console.log(e,'---',this.multipleChosen)
}
},
};
......
......@@ -422,7 +422,12 @@
</view>
</view>
<view class="empty-block"></view>
<coupon v-if="couponList.length > 0 && showCoupon" :list="couponList" :current="useCouponId" @close="closeCouponHandler" :current-price="realCurrentPriceInfo" :order="orderMsg"></coupon>
<coupon v-if="couponList.length > 0 && showCoupon"
:list="couponList"
:current="useCouponId"
:multiple="multipleChosenIds"
@close="closeCouponHandler"
:current-price="realCurrentPriceInfo" :order="orderMsg"></coupon>
<view style="padding: 50rpx 40rpx" v-if="tips != ''">
<view class="big-title">
<text>重要提示</text>
......@@ -529,7 +534,8 @@
customer: {},
CreateBy: 0,
showPz:false,
pzCoupon:null
pzCoupon:null,
multipleChosenIds: [],
};
},
created() {
......@@ -572,18 +578,41 @@
},
closeCouponHandler(e) {
if (e != -1) {
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)
}
if(e instanceof Array){//叠加使用优惠券
this.multipleChosenIds = e
let TotalDiscountAmount = 0
this.couponList.forEach(x=>{
let findIndex = this.multipleChosenIds.findIndex(y=>x.id==y)
if(findIndex!=-1){
let discountMoney = 0
if(x.couponsType==1){
discountMoney = x.denomination
}else{
discountMoney = (parseFloat(this.price) * (1 - parseFloat(x.denomination / 10)))
.toFixed(2)
}
TotalDiscountAmount += discountMoney
}
})
if(TotalDiscountAmount)this.currentCoupon.discountMoney = TotalDiscountAmount
else this.currentCoupon.discountMoney = 0
}else{
this.currentCoupon.discountMoney = 0
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.showCoupon = false;
},
......@@ -619,6 +648,13 @@
(res) => {
console.log("coupon_post_GetUserCanUseCouponList", res);
if (res.resultCode == 1) {
let arrList = function(list){
list.forEach(x=>{
x.checkId=0
x.check=false
})
}
arrList(res.data)
this.couponList = res.data
this.calcPzCouponHandler()
}
......@@ -846,7 +882,12 @@
} else {
price = this.currentPriceInfo.b2CPrice;
}
let CouponAllotIds = ''
if(this.multipleChosenIds.length>0){
CouponAllotIds = this.multipleChosenIds.join(',')
}else{
CouponAllotIds = this.useCouponId > 0 ? this.currentCoupon.id.toString() : ''
}
let msg = {
OrderId: 0,
TCID: this.currentPriceInfo.tcid,
......@@ -859,7 +900,7 @@
IsIntermodal: 2,
Unit_Price: price,
TC_Price: price,
CouponAllotIds: this.useCouponId > 0 ? this.currentCoupon.id.toString() : '',
CouponAllotIds: CouponAllotIds,
ManNum: this.orderMsg.ManNum,
ChirdNum: this.orderMsg.ChirdNum,
ChirdNeedBedNum: this.orderMsg.ChirdNeedBedNum,
......
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