Commit 1846eac6 by 高淑倩

优惠券优惠

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