Commit a40e3013 by 高淑倩

优惠券checked

parent 8238a249
......@@ -37,10 +37,9 @@ Component({
const { couponList } = this.data
if (couponList.length) {
couponList.map(coupon => {
console.log('22222', coupon)
coupon.couponDTOS.forEach((item,index) => {
coupon.couponDTOS.forEach(item => {
item.checked = false
coupon.couponDTOS[0].checked = true
couponList[0].couponDTOS[0] ? couponList[0].couponDTOS[0].checked = true : item[0].checked = true
item.couponDiscount = coupon.couponDiscount
item.title = coupon.couponSettingDTO.title
item.type = coupon.couponSettingDTO.type
......@@ -70,19 +69,29 @@ Component({
},
selectCoupon(e) {
// 1 抵用券 2 折扣券
const { id, index, sid, type, amount, couponDiscount} = e.currentTarget.dataset
const { id, index, sid, checked, type, amount, couponDiscount} = 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 )
item.couponDTOS.forEach(coupon => {
if(coupon.checked) {
coupon.checked = coupon.checked ? false : true
} else {
coupon.checked = coupon.id == id ? true : false
}
} )
})
let params = {
let params = null
if(!checked) {
params = {
type,
id,
faceAmount: amount,
couponDiscount: couponDiscount
}
}
wxService.nextTick(() => {
this.triggerEvent('updateCoupon', params)
......@@ -91,7 +100,7 @@ Component({
this.setData({
newConponOrderList
}, () => {
this.hidePopup()
// this.hidePopup()
})
},
hidePopup: function () { // 隐藏弹出框
......
<view class="modal-container{{show ? ' active' : ''}}" bindtap="hidePopup" />
<view class="modal-content{{show ? ' active' : ''}}">
<view class="modal-header">
<image src="/assets/imgs/7_1_0/arrow-right.png" class="modal-to-back" mode="widthFix" />
<image src="/assets/imgs/7_1_0/arrow-right.png" class="modal-to-back" mode="widthFix" bindtap="hidePopup"/>
<text class="modal-title">选择优惠券</text>
<image
class="modal-close"
......@@ -20,9 +20,10 @@
data-sid="{{coupon.couponSettingId}}"
data-index="{{index}}"
data-type="{{coupon.type}}"
data-checked="{{coupon.checked}}"
data-coupon-discount="{{coupon.couponDiscount}}"
data-amount="{{coupon.faceAmount}}"
bindtap="selectCoupon"
catchtap="selectCoupon"
>
<image
wx:if="{{false}}"
......@@ -43,7 +44,7 @@
</view>
</view>
<view class="select-radio">
<view class="select-radio" data-index="{{index}}" data-checked="{{coupon.checked}}" >
<icon size="16" type="{{coupon.checked ? 'success' : 'circle'}}" color="{{checkedColor}}" />
</view>
</view>
......
......@@ -254,7 +254,7 @@ Component({
id: clickData.id,
name: clickData.name
}
console.log(event)
// curSpec.push({
// id: clickData.id,
// name: clickData.name
......@@ -265,7 +265,7 @@ Component({
} else {
return false
}
console.log('........', clickData)
// 有库存
let btnText = '确定'
let isOutStock = false
......@@ -305,7 +305,6 @@ Component({
var curSpec = this.data.curSpec
for (var i = 0; i < this.data.skuInfos.length; i++){
var skuNameArray = this.data.skuInfos[i].specValue.split('###')
// console.log(skuNameArray)
var flag = true
for (var j = 0; j < skuNameArray.length; j++){
if (curSpec[j] && i !== j && curSpec[j] !== skuNameArray[j]) {
......@@ -321,8 +320,6 @@ Component({
})
}
}
console.log('00000',this.data.skuStock)
// 根据当前选中的规格,设置头部的规格信息
var skuText = []
if (curSpec.join('') === '') {
......@@ -356,7 +353,6 @@ Component({
salePrice = item.salePrice
picUrl = item.picUrl
}
console.log(flag)
return flag
})
......@@ -385,7 +381,6 @@ Component({
// updateData.price = price// 拼团规格没有价格信息
// }
this.setData(updateData)
console.log('666', updateData.skuStock)
},
_getUserInfo(res = {}) {
this.triggerEvent('getAuth', res);
......
......@@ -93,16 +93,25 @@ wxService.page({
updateCoupon(e) {
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
console.log('detail', e.detail)
if(!e.detail) {
this.setData({
defalutCoupon: 0,
couponId: '',
couponSettingId: '',
defalutCouponId: ''
})
return
}
const { faceAmount, type, id, couponDiscount,sid } = e.detail
const { orderPrice } = this.data
console.log('detail2222222', e.detail)
console.log('orderPrice', this.data)
console.log('faceAmount', faceAmount)
// couponId couponSettingId
let finCouponId = id ? id : sid
let finCouponName = id ? 'couponId' : 'couponSettingId'
if (type == 1) {
this.setData({
defalutCoupon: true,
[finCouponName] : finCouponId,
// couponId: id,
haveCoupon: true,
......@@ -111,8 +120,8 @@ wxService.page({
} else if (type == 2) {
// let discounPrice = (faceAmount / 100) * (orderPrice)
// let spread = Math.round(orderPrice - discounPrice)
this.setData({
defalutCoupon: true,
[finCouponName] : finCouponId,
// couponId: id,
haveCoupon: true,
......
......@@ -164,7 +164,6 @@ wxService.page({
this.setData({
productInfo: data
})
console.log('111111111111', this.data.productInfo)
}
}).finally(() => {
wx.hideLoading()
......
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