Commit 6dc3a2d5 by 高淑倩

coupon

parent 657118ac
...@@ -54,7 +54,7 @@ Component({ ...@@ -54,7 +54,7 @@ Component({
// 1 抵用券 2 折扣券 // 1 抵用券 2 折扣券
const { id,index,type } = e.currentTarget.dataset const { id,index,type } = e.currentTarget.dataset
const { couponList } = this.data const { couponList } = this.data
console.log('type---1 抵用券 2 折扣券 ', id,index, type)
couponList.forEach(item=>{ couponList.forEach(item=>{
item.checked = false item.checked = false
}) })
...@@ -62,6 +62,7 @@ Component({ ...@@ -62,6 +62,7 @@ Component({
let params = { let params = {
type, type,
id,
faceAmount: '' faceAmount: ''
} }
if(type == 1){ if(type == 1){
......
...@@ -65,22 +65,23 @@ wxService.page({ ...@@ -65,22 +65,23 @@ wxService.page({
this.getAddressList() this.getAddressList()
}, },
updateCoupon(e) { updateCoupon(e) {
console.log('e', e.detail)
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券 // faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
const { faceAmount, type } = e.detail const { faceAmount, type, id } = e.detail
const { orderPrice } = this.data const { orderPrice } = this.data
console.log('id', id)
if (type == 1) { if (type == 1) {
this.setData({ this.setData({
couponId: id,
haveCoupon: true, haveCoupon: true,
currentCoupon: `${faceAmount / 100}` currentCoupon: `${faceAmount / 100}`
}) })
} else if (type == 2) { } else if (type == 2) {
let discounPrice = (faceAmount / 100) * (orderPrice) let discounPrice = (faceAmount / 100) * (orderPrice)
let spread = Math.round(orderPrice - discounPrice) let spread = Math.round(orderPrice - discounPrice)
this.setData({ this.setData({
couponId: id,
haveCoupon: true, haveCoupon: true,
currentCoupon: `${spread}` currentCoupon: `${spread}`
}) })
} }
// 实付款 // 实付款
...@@ -89,8 +90,9 @@ wxService.page({ ...@@ -89,8 +90,9 @@ wxService.page({
setPayPrice() { setPayPrice() {
const { currentCoupon, orderPrice } = this.data const { currentCoupon, orderPrice } = this.data
let orderCoupon = parseFloat(currentCoupon) let orderCoupon = parseFloat(currentCoupon)
console.log('orderPrice - orderCoupon', orderPrice - orderCoupon)
this.setData({ this.setData({
orderPrice: Math.round(orderPrice - currentCoupon) orderPrice: Math.round(orderPrice - orderCoupon)
}) })
}, },
formSubmit(e) { formSubmit(e) {
......
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