...
|
...
|
@@ -30,6 +30,7 @@ Page({ |
|
|
storeId: 0,
|
|
|
skup: '',
|
|
|
coupons: [],
|
|
|
selectCouponData: {},
|
|
|
selectCouponCode: '',
|
|
|
selectCouponAmount: 0,
|
|
|
selectingCoupon: false,
|
...
|
...
|
@@ -101,22 +102,35 @@ Page({ |
|
|
selectPromotionAmount: amount,
|
|
|
isManualSelectPro: true,
|
|
|
});
|
|
|
if(code) {
|
|
|
|
|
|
let typeArr = Object.keys(this.data.selectCouponData);
|
|
|
let selectCouponCode = '';
|
|
|
let selectCouponAmount = 0;
|
|
|
let selectCouponData = {};
|
|
|
if(code) { //选择促销时 只保留运费券
|
|
|
if (typeArr.length > 0 && typeArr.includes('110')) {
|
|
|
selectCouponCode = this.data.selectCouponData[110].code;
|
|
|
selectCouponAmount = this.data.selectCouponData[110].amount;
|
|
|
selectCouponData[110] = this.data.selectCouponData[110]
|
|
|
}
|
|
|
this.setData({
|
|
|
// 重置优惠券
|
|
|
selectCouponAmount: 0,
|
|
|
selectCouponCode: '',
|
|
|
selectCouponData,
|
|
|
selectCouponAmount,
|
|
|
selectCouponCode,
|
|
|
isManualSelect: false
|
|
|
});
|
|
|
|
|
|
}
|
|
|
this.orderCompute({
|
|
|
promotion_id: code
|
|
|
promotion_id: code,
|
|
|
code: this.data.selectCouponCode
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
confirmSelectCoupon({detail}) {
|
|
|
let code = detail.code;
|
|
|
let amount = detail.amount || 0;
|
|
|
let typeVal = detail.typeVal;
|
|
|
let couponsList = this.data.couponList;
|
|
|
if (couponsList){
|
|
|
couponsList.forEach((item, index) => {
|
...
|
...
|
@@ -129,21 +143,28 @@ Page({ |
|
|
}
|
|
|
this.setData({
|
|
|
couponsList,
|
|
|
selectCouponData: typeVal,
|
|
|
selectCouponAmount: amount,
|
|
|
selectCouponCode: code,
|
|
|
selectingCoupon: false,
|
|
|
isManualSelect: true
|
|
|
});
|
|
|
if(code) {
|
|
|
let typeArr = Object.keys(typeVal);
|
|
|
if (typeArr.length > 0 && typeArr.includes('100')) { // 选择优惠券时才重置
|
|
|
this.setData({
|
|
|
// 重置促销
|
|
|
selectPromotionCode: 0,
|
|
|
selectPromotionAmount: 0,
|
|
|
isManualSelectPro: false
|
|
|
});
|
|
|
this.orderCompute({code})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
this.orderCompute({
|
|
|
code,
|
|
|
promotion_id: this.data.selectPromotionCode || ''
|
|
|
})
|
|
|
},
|
|
|
async orderCompute({
|
|
|
code = '',
|
...
|
...
|
@@ -244,12 +265,18 @@ Page({ |
|
|
if (data && data.couponList && data.couponList.length > 0){
|
|
|
let coupons = [];
|
|
|
let couponsAmount = 0;
|
|
|
let selectedCoupons = {};
|
|
|
data.couponList.forEach((item, index) => {
|
|
|
let selected = item.selected;
|
|
|
if (selected === 'Y'){
|
|
|
item.isChosen = true;
|
|
|
couponsAmount += parseFloat(item.coupon_value_str);
|
|
|
coupons.push(item.coupon_code);
|
|
|
let itemVal = {
|
|
|
code: item.coupon_code,
|
|
|
amount: parseFloat(item.coupon_value_str)
|
|
|
}
|
|
|
selectedCoupons[item.coupon_type] = itemVal
|
|
|
}else {
|
|
|
item.isChosen = false;
|
|
|
}
|
...
|
...
|
@@ -257,6 +284,7 @@ Page({ |
|
|
|
|
|
data.selectCouponAmount = couponsAmount;
|
|
|
data.selectCouponCode = coupons.join(',');
|
|
|
data.selectCouponData = selectedCoupons;
|
|
|
}
|
|
|
if (data && data.promotionList && data.promotionList.length > 0) {
|
|
|
let promotions = 0;
|
...
|
...
|
|