Commit 1846eac6 by 高淑倩

优惠券优惠

parent 1c2fc8a7
......@@ -41,6 +41,7 @@ Component({
item.checked = false
item.title = coupon.couponSettingDTO.title
item.type = coupon.couponSettingDTO.type
item.faceAmount = coupon.couponSettingDTO.faceAmount
item.takeCouponBgimg = coupon.couponSettingDetailDTO.style.takeCouponBgimg
// notice 格式
item.newNotice = JSON.parse(item.notice)
......@@ -51,7 +52,7 @@ Component({
}
})
})
console.log('couponDTOS', couponList)
wxService.nextTick(() => {
this.setData({
newConponOrderList: couponList
......@@ -66,24 +67,17 @@ Component({
},
selectCoupon(e) {
// 1 抵用券 2 折扣券
const { id, index, type } = e.currentTarget.dataset
const { id, index, type, amount } = e.currentTarget.dataset
const { newConponOrderList } = this.data
newConponOrderList.forEach(item => {
item.couponDTOS.forEach(coupon =>
coupon.checked = coupon.id == id ? true : false
)
item.couponDTOS.forEach(coupon => coupon.checked = coupon.id == id ? true : false )
})
let params = {
type,
id,
faceAmount: ''
}
if (type == 1) {
params.faceAmount = newConponOrderList[index].couponSettingDTO.faceAmount
} else if (type == 2) {
params.faceAmount = newConponOrderList[index].couponSettingDTO.faceAmount
faceAmount: amount
}
wxService.nextTick(() => {
......
......@@ -19,8 +19,9 @@
data-id="{{coupon.id}}"
data-index="{{index}}"
data-type="{{coupon.type}}"
data-amount="{{coupon.faceAmount}}"
bindtap="selectCoupon"
>
>{{coupon.type}} -- {{coupon.faceAmount}}
<image
wx:if="{{false}}"
class="coupon-bg"
......
......@@ -72,7 +72,7 @@ wxService.page({
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
const { faceAmount, type, id } = e.detail
const { orderPrice } = this.data
console.log('id', id)
if (type == 1) {
this.setData({
couponId: id,
......@@ -82,10 +82,11 @@ wxService.page({
} else if (type == 2) {
let discounPrice = (faceAmount / 100) * (orderPrice)
let spread = Math.round(orderPrice - discounPrice)
this.setData({
couponId: id,
haveCoupon: true,
currentCoupon: `${spread} `
currentCoupon: `${spread} `
})
}
// 实付款
......@@ -94,7 +95,7 @@ wxService.page({
setPayPrice() {
const { currentCoupon, orderPrice } = this.data
let orderCoupon = parseFloat(currentCoupon)
console.log('orderPrice - orderCoupon', orderPrice - orderCoupon)
this.setData({
orderPrice: Math.round(orderPrice - orderCoupon)
})
......
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