Commit a40e3013 by 高淑倩

优惠券checked

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