Commit 5af38f54 authored by youjie's avatar youjie

叠加使用优惠券

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