Commit 657118ac by 高淑倩

实付款

parent a566706a
...@@ -60,10 +60,24 @@ Component({ ...@@ -60,10 +60,24 @@ Component({
}) })
couponList[index].checked = true couponList[index].checked = true
let params = {
type,
faceAmount: ''
}
if(type == 1){
params.faceAmount = couponList[index].couponSettingDTO.faceAmount
} else if(type == 2){
params.faceAmount = couponList[index].couponSettingDTO.faceAmount
}
wxService.nextTick(() => { wxService.nextTick(() => {
this.triggerEvent('updateCoupon', couponList[index].couponDiscount) this.triggerEvent('updateCoupon', params)
}) })
// wxService.nextTick(() => {
// this.triggerEvent('updateCoupon', couponList[index].couponDiscount)
// })
this.setData({ this.setData({
couponList couponList
},()=>{ },()=>{
......
...@@ -20,7 +20,8 @@ wxService.page({ ...@@ -20,7 +20,8 @@ wxService.page({
cityView: '', cityView: '',
multiIndex: [0, 0, 0], multiIndex: [0, 0, 0],
selectCityName: ['', ''], selectCityName: ['', ''],
currentCoupon: '无可用优惠券' currentCoupon: '',
orderPrice: null, // 订单金额
}, },
/** /**
...@@ -63,14 +64,34 @@ wxService.page({ ...@@ -63,14 +64,34 @@ wxService.page({
// 地址列表 // 地址列表
this.getAddressList() this.getAddressList()
}, },
updateCoupon(e){ updateCoupon(e) {
console.log('e', e.detail) console.log('e', e.detail)
if(e.detail){ // faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
const { faceAmount, type } = e.detail
const { orderPrice } = this.data
if (type == 1) {
this.setData({ this.setData({
haveCoupon: true, haveCoupon: true,
currentCoupon: `- ${e.detail}` currentCoupon: `${faceAmount / 100}`
})
} else if (type == 2) {
let discounPrice = (faceAmount / 100) * (orderPrice)
let spread = Math.round(orderPrice - discounPrice)
this.setData({
haveCoupon: true,
currentCoupon: `${spread}`
}) })
} }
// 实付款
this.setPayPrice()
},
setPayPrice() {
const { currentCoupon, orderPrice } = this.data
let orderCoupon = parseFloat(currentCoupon)
this.setData({
orderPrice: Math.round(orderPrice - currentCoupon)
})
}, },
formSubmit(e) { formSubmit(e) {
const { goodsAddress } = this.data const { goodsAddress } = this.data
...@@ -230,7 +251,10 @@ wxService.page({ ...@@ -230,7 +251,10 @@ wxService.page({
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
wx.hideLoading() wx.hideLoading()
this.setData({ currentOrderList: data }) this.setData({
currentOrderList: data,
orderPrice: data.amount
})
} }
} }
}) })
......
<!--pages/confirmOrder/confirmOrder.wxml--> <!--pages/confirmOrder/confirmOrder.wxml-->
<wxs src="../..//wxs/utils.wxs" module="utils" />
<view class="page-confirm-order"> <view class="page-confirm-order">
<form bindsubmit="formSubmit"> <form bindsubmit="formSubmit">
<view class="address-wrap"> <view class="address-wrap">
...@@ -122,7 +124,7 @@ ...@@ -122,7 +124,7 @@
<view> <view>
<text class="price-label">优惠券</text> <text class="price-label">优惠券</text>
<view class="select-coupon" bindtap="selectCoupon"> <view class="select-coupon" bindtap="selectCoupon">
<text class="{{haveCoupon ? 'coupon-price' : 'no-coupon'}}">{{currentCoupon}}</text> <text class="{{haveCoupon ? 'coupon-price' : 'no-coupon'}}"> {{currentCoupon ? '-' : '无可用优惠券'}} {{currentCoupon}}</text>
<image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" /> <image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" />
</view> </view>
</view> </view>
...@@ -147,7 +149,7 @@ ...@@ -147,7 +149,7 @@
<view class="pro-footer"> <view class="pro-footer">
<view class="cost"> <view class="cost">
<text class="cost-label">实付款:</text> <text class="cost-label">实付款:</text>
<text class="cost-price">¥{{currentOrderList.amount}}</text> <text class="cost-price">¥{{utils.numberFormat(orderPrice)}}</text>
</view> </view>
<!-- <button form-type="submit" class="theme-color buy-btn">立即购买</button>--> <!-- <button form-type="submit" class="theme-color buy-btn">立即购买</button>-->
<!-- <view class="theme-color buy-btn" bindtap="handelGobuy">立即购买</view> --> <!-- <view class="theme-color buy-btn" bindtap="handelGobuy">立即购买</view> -->
......
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