Commit 3b3bed9f by 谢中龙

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

parent 1b94b36b
...@@ -51,6 +51,7 @@ wxService.page({ ...@@ -51,6 +51,7 @@ wxService.page({
storeCode: '' storeCode: ''
}, },
orderStoreInfo: null, orderStoreInfo: null,
couponDiscountPreviews : [],
}, },
/** /**
...@@ -230,6 +231,7 @@ wxService.page({ ...@@ -230,6 +231,7 @@ wxService.page({
currentCoupon: 0, currentCoupon: 0,
}, () => { }, () => {
this.setPayPrice(); this.setPayPrice();
this.reCallPreview();
}); });
return return
} }
...@@ -247,6 +249,8 @@ wxService.page({ ...@@ -247,6 +249,8 @@ wxService.page({
// couponId: id, // couponId: id,
haveCoupon: true, haveCoupon: true,
currentCoupon: `${parseFloat(faceAmount/10/10).toFixed(2)} 元` currentCoupon: `${parseFloat(faceAmount/10/10).toFixed(2)} 元`
},() => {
this.reCallPreview();
}) })
} else if (type == 2) { } else if (type == 2) {
// let discounPrice = (faceAmount / 100) * (orderPrice) // let discounPrice = (faceAmount / 100) * (orderPrice)
...@@ -258,6 +262,8 @@ wxService.page({ ...@@ -258,6 +262,8 @@ wxService.page({
// couponId: id, // couponId: id,
haveCoupon: true, haveCoupon: true,
currentCoupon: `${couponDiscount} 元` currentCoupon: `${couponDiscount} 元`
},() => {
this.reCallPreview();
}); });
} }
else if(type == 3){ //定额券 else if(type == 3){ //定额券
...@@ -268,8 +274,11 @@ wxService.page({ ...@@ -268,8 +274,11 @@ wxService.page({
[finCouponName]: finCouponId, [finCouponName]: finCouponId,
haveCoupon: true, haveCoupon: true,
currentCoupon: `${couponDiscount} 元` currentCoupon: `${couponDiscount} 元`
},() => {
this.reCallPreview();
}) })
} }
// 实付款 // 实付款
this.setPayPrice(); this.setPayPrice();
}, },
...@@ -505,24 +514,7 @@ wxService.page({ ...@@ -505,24 +514,7 @@ wxService.page({
couponSettingId: '', couponSettingId: '',
defalutCouponId: '' defalutCouponId: ''
}, () => { }, () => {
const { trolleySku2Buy, checkByPremium, addressId, addressInfo } = this.data this.reCallPreview();
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() this.getPremiumDefault()
}) })
...@@ -553,6 +545,29 @@ wxService.page({ ...@@ -553,6 +545,29 @@ wxService.page({
selectAddress() { selectAddress() {
wxService.router('/pages/myAddress/myAddress?isFrom=order') 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) { calPreferentialPrice(params) {
wx.showLoading({ wx.showLoading({
...@@ -564,8 +579,7 @@ wxService.page({ ...@@ -564,8 +579,7 @@ wxService.page({
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
wx.hideLoading() wx.hideLoading()
let skuList = data.tradePreviewSkus let skuList = data.tradePreviewSkus;
let sum = 0 let sum = 0
skuList.forEach((item, index) => { skuList.forEach((item, index) => {
// item.price // item.price
...@@ -585,7 +599,8 @@ wxService.page({ ...@@ -585,7 +599,8 @@ wxService.page({
noSelectPrice: sum noSelectPrice: sum
}) })
} }
//如果没有couponId则认为是第一次进来没有自己选择优惠券
if (!this.data.couponId) {
//获取优惠券信息 //获取优惠券信息
let defalutCoupon = data && data.couponDiscountPreviews.length && let defalutCoupon = data && data.couponDiscountPreviews.length &&
data.couponDiscountPreviews[0].couponSettingDTO.type == 1 ? data.couponDiscountPreviews[0].couponSettingDTO.type == 1 ?
...@@ -593,9 +608,6 @@ wxService.page({ ...@@ -593,9 +608,6 @@ wxService.page({
data.couponDiscountPreviews[0].couponSettingDTO.faceAmount / 100 : data && data.couponDiscountPreviews[0].couponSettingDTO.faceAmount / 100 : data &&
data.couponDiscountPreviews.length && data.couponDiscountPreviews[0] && data.couponDiscountPreviews.length && data.couponDiscountPreviews[0] &&
data.couponDiscountPreviews[0].couponDiscount; 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] && data.couponDiscountPreviews[0].couponDTOS[0] &&
data.couponDiscountPreviews[0].couponDTOS[0].id || ''; data.couponDiscountPreviews[0].couponDTOS[0].id || '';
...@@ -603,20 +615,36 @@ wxService.page({ ...@@ -603,20 +615,36 @@ wxService.page({
data.couponDiscountPreviews[0] && data.couponDiscountPreviews[0].couponDTOS[0] && data.couponDiscountPreviews[0] && data.couponDiscountPreviews[0].couponDTOS[0] &&
data.couponDiscountPreviews[0].couponDTOS[0].couponSettingId || ''; data.couponDiscountPreviews[0].couponDTOS[0].couponSettingId || '';
data.couponDiscountPreviews = data.couponDiscountPreviews ? data.couponDiscountPreviews : []; data.couponDiscountPreviews = data.couponDiscountPreviews ? data.couponDiscountPreviews : [];
this.data.couponDiscountPreviews = data.couponDiscountPreviews;
// id / couponSettingId // id / couponSettingId
this.setData({ this.setData({
currentOrderList: data, currentOrderList: data,
couponDiscountPreviews: this.data.couponDiscountPreviews,
defalutCoupon: defalutCoupon, defalutCoupon: defalutCoupon,
defalutCouponId: defalutCouponId, defalutCouponId: defalutCouponId,
couponSettingId: couponSettingId, couponSettingId: couponSettingId,
orderInitPrice: data.amount, orderInitPrice: data.amount,
totalGoodsPrice: this.data.totalGoodsPrice, totalGoodsPrice: this.data.totalGoodsPrice
currentCoupon : 0,
}, () => { }, () => {
// 实付款 // 实付款
this.setPayPrice() 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 @@ ...@@ -263,5 +263,8 @@
<!--goHome--> <!--goHome-->
<go-home/> <go-home/>
<floatNav bind:getAuth="_getUserInfo" bind:updatePage="updatePage"/> <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