Commit 3b3bed9f by 谢中龙

提交订单切换优惠券 重新调用一下preview接口

parent 1b94b36b
......@@ -51,6 +51,7 @@ wxService.page({
storeCode: ''
},
orderStoreInfo: null,
couponDiscountPreviews : [],
},
/**
......@@ -223,13 +224,14 @@ wxService.page({
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券 3 定额券
if (!e.detail) {
this.setData({
defalutCoupon: 0,
couponId: '',
couponSettingId: '',
defalutCouponId: '',
currentCoupon: 0,
defalutCoupon: 0,
couponId: '',
couponSettingId: '',
defalutCouponId: '',
currentCoupon: 0,
}, () => {
this.setPayPrice();
this.setPayPrice();
this.reCallPreview();
});
return
}
......@@ -247,6 +249,8 @@ wxService.page({
// couponId: id,
haveCoupon: true,
currentCoupon: `${parseFloat(faceAmount/10/10).toFixed(2)} 元`
},() => {
this.reCallPreview();
})
} else if (type == 2) {
// let discounPrice = (faceAmount / 100) * (orderPrice)
......@@ -258,6 +262,8 @@ wxService.page({
// couponId: id,
haveCoupon: true,
currentCoupon: `${couponDiscount} 元`
},() => {
this.reCallPreview();
});
}
else if(type == 3){ //定额券
......@@ -268,8 +274,11 @@ wxService.page({
[finCouponName]: finCouponId,
haveCoupon: true,
currentCoupon: `${couponDiscount} 元`
},() => {
this.reCallPreview();
})
}
// 实付款
this.setPayPrice();
},
......@@ -505,24 +514,7 @@ wxService.page({
couponSettingId: '',
defalutCouponId: ''
}, () => {
const { trolleySku2Buy, checkByPremium, addressId, addressInfo } = this.data
let params = {
checkByPremium,
trolleySku2Buy,
}
// 增加门店自提和快递配送判断
if (this.data.currentType == 'delivery') {
params.addressId = addressId ? addressId : addressInfo.id // 微信地址 or 地址id
params.orderType = 1;
}
else {
params.orderType = 4;
params.storeId = this.data.storeInfo.storeId;
}
this.calPreferentialPrice(params) // 重新计算优惠价
this.reCallPreview();
// 获取默认付费会员设置
this.getPremiumDefault()
})
......@@ -553,6 +545,29 @@ wxService.page({
selectAddress() {
wxService.router('/pages/myAddress/myAddress?isFrom=order')
},
//拼接字段重新调用preview
reCallPreview() {
const { trolleySku2Buy, checkByPremium, addressId, addressInfo } = this.data
let params = {
checkByPremium,
trolleySku2Buy,
}
// 增加门店自提和快递配送判断
if (this.data.currentType == 'delivery') {
params.addressId = addressId ? addressId : addressInfo.id // 微信地址 or 地址id
params.orderType = 1;
}
else {
params.orderType = 4;
params.storeId = this.data.storeInfo.storeId;
}
this.calPreferentialPrice(params) // 重新计算优惠价
// 获取默认付费会员设置
this.getPremiumDefault()
},
// 计算优惠价
calPreferentialPrice(params) {
wx.showLoading({
......@@ -564,8 +579,7 @@ wxService.page({
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
let skuList = data.tradePreviewSkus
let skuList = data.tradePreviewSkus;
let sum = 0
skuList.forEach((item, index) => {
// item.price
......@@ -578,44 +592,58 @@ wxService.page({
if (isSelect) {
this.setData({
selectPrice: sum
selectPrice: sum
})
} else {
this.setData({
noSelectPrice: sum
noSelectPrice: sum
})
}
//获取优惠券信息
let defalutCoupon = data && data.couponDiscountPreviews.length &&
//如果没有couponId则认为是第一次进来没有自己选择优惠券
if (!this.data.couponId) {
//获取优惠券信息
let defalutCoupon = data && data.couponDiscountPreviews.length &&
data.couponDiscountPreviews[0].couponSettingDTO.type == 1 ?
data && data.couponDiscountPreviews.length &&
data.couponDiscountPreviews[0].couponSettingDTO.faceAmount / 100 : data &&
data.couponDiscountPreviews.length && data.couponDiscountPreviews[0] &&
data.couponDiscountPreviews[0].couponDiscount;
defalutCoupon = defalutCoupon ? parseFloat(defalutCoupon).toFixed(2) : 0;
let defalutCouponId = data && data.couponDiscountPreviews.length &&
let defalutCouponId = data && data.couponDiscountPreviews.length &&
data.couponDiscountPreviews[0] && data.couponDiscountPreviews[0].couponDTOS[0] &&
data.couponDiscountPreviews[0].couponDTOS[0].id || '';
let couponSettingId = data && data.couponDiscountPreviews.length &&
let couponSettingId = data && data.couponDiscountPreviews.length &&
data.couponDiscountPreviews[0] && data.couponDiscountPreviews[0].couponDTOS[0] &&
data.couponDiscountPreviews[0].couponDTOS[0].couponSettingId || '';
data.couponDiscountPreviews = data.couponDiscountPreviews ? data.couponDiscountPreviews : [];
// id / couponSettingId
this.setData({
data.couponDiscountPreviews = data.couponDiscountPreviews ? data.couponDiscountPreviews : [];
this.data.couponDiscountPreviews = data.couponDiscountPreviews;
// id / couponSettingId
this.setData({
currentOrderList: data,
couponDiscountPreviews: this.data.couponDiscountPreviews,
defalutCoupon: defalutCoupon,
defalutCouponId: defalutCouponId,
couponSettingId: couponSettingId,
orderInitPrice: data.amount,
totalGoodsPrice: this.data.totalGoodsPrice,
currentCoupon : 0,
}, () => {
totalGoodsPrice: this.data.totalGoodsPrice
}, () => {
// 实付款
this.setPayPrice()
})
})
}
else{
//重新调用之后 不刷新优惠券列表
this.setData({
currentOrderList: data,
defalutCoupon: this.data.defalutCoupon,
defalutCouponId: this.data.defalutCouponId,
couponSettingId: this.data.couponSettingId,
orderInitPrice: data.amount,
totalGoodsPrice: this.data.totalGoodsPrice
}, () => {
// 实付款
this.setPayPrice()
})
}
}
}
})
......
......@@ -263,5 +263,8 @@
<!--goHome-->
<go-home/>
<floatNav bind:getAuth="_getUserInfo" bind:updatePage="updatePage"/>
<select-coupon show="{{showSelectCoupon}}" bind:updateCoupon="updateCoupon" coupon-list="{{currentOrderList.couponDiscountPreviews}}"/>
<select-coupon
show="{{showSelectCoupon}}"
bind:updateCoupon="updateCoupon"
coupon-list="{{couponDiscountPreviews}}"/>
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