Commit 4ad19c2b by 高淑倩

优惠券id

parent 09da528c
......@@ -12,8 +12,7 @@ Component({
},
couponList: {
type: Array,
value: [],
observer: '_couponList'
value: []
}
},
/**
......@@ -21,27 +20,42 @@ Component({
*/
data: {
checkedColor: 'rgb(203, 60, 60)',
isSelect:false
isSelect: false,
newConponOrderList: []
},
observers: {
couponList: function (rate) {
this.changeList()
},
},
/**
* 组件的方法列表
*/
methods: {
_couponList(newV, oldV) {
console.log('newV, oldV', newV)
if (newV !== oldV) {
newV.map(item => {
item.couponSettingDTO.notice = JSON.parse(item.couponSettingDTO.notice)
for (let i in item.couponSettingDTO.notice) {
if (item.couponSettingDTO.notice[i].type == 1) {
item.couponSettingDTO.notice[i].value = item.couponSettingDTO.startTime.substring(0, 10) + ' 至 ' + item.couponSettingDTO.endTime.substring(0, 10)
changeList() {
const { couponList } = this.data
if (couponList.length) {
couponList.map(coupon => {
coupon.couponDTOS.forEach(item => {
item.checked = false
item.title = coupon.couponSettingDTO.title
item.type = coupon.couponSettingDTO.type
item.takeCouponBgimg = coupon.couponSettingDetailDTO.style.takeCouponBgimg
// notice 格式
item.newNotice = JSON.parse(item.notice)
for (let i in item.newNotice) {
if (item.newNotice[i].type == 1) {
item.newNotice[i].value = item.startTime.substring(0, 10) + ' 至 ' + item.endTime.substring(0, 10)
}
}
}
})
})
this._updateData({
couponList: newV
console.log('couponDTOS', couponList)
wxService.nextTick(() => {
this.setData({
newConponOrderList: couponList
})
})
}
},
......@@ -52,37 +66,35 @@ Component({
},
selectCoupon(e) {
// 1 抵用券 2 折扣券
const { id,index,type } = e.currentTarget.dataset
const { couponList } = this.data
couponList.forEach(item=>{
item.checked = false
const { id, index, type } = e.currentTarget.dataset
const { newConponOrderList } = this.data
newConponOrderList.forEach(item => {
item.couponDTOS.forEach(coupon =>
coupon.checked = coupon.id == id ? true : false
)
})
couponList[index].checked = true
let params = {
type,
id,
faceAmount: ''
}
if(type == 1){
params.faceAmount = couponList[index].couponSettingDTO.faceAmount
} else if(type == 2){
params.faceAmount = couponList[index].couponSettingDTO.faceAmount
if (type == 1) {
params.faceAmount = newConponOrderList[index].couponSettingDTO.faceAmount
} else if (type == 2) {
params.faceAmount = newConponOrderList[index].couponSettingDTO.faceAmount
}
wxService.nextTick(() => {
this.triggerEvent('updateCoupon', params)
})
// wxService.nextTick(() => {
// this.triggerEvent('updateCoupon', couponList[index].couponDiscount)
// })
this.setData({
couponList
},()=>{
this.hidePopup()})
newConponOrderList
}, () => {
this.hidePopup()
})
},
hidePopup: function () { // 隐藏弹出框
this.setData({
......
<view class="modal-container{{show ? ' active' : ''}}" bindtap="hidePopup" />
<view class="modal-content{{show ? ' active' : ''}}">
<!--{{couponList}}-->
<view class="modal-header">
<image src="/assets/imgs/7_1_0/arrow-right.png" class="modal-to-back" mode="widthFix" />
<text class="modal-title">选择优惠券</text>
......@@ -12,46 +11,41 @@
/>
</view>
<view class="modal-info" wx:if="{{couponList.length}}">
<block wx:for="{{couponList}}" wx:key="{{index}}" wx:for-item="item">
<view class="coupon-list" data-id="{{item.couponSettingDTO.couponSettingId}}" data-index="{{index}}" data-type="{{item.couponSettingDTO.type}}" bindtap="selectCoupon">
<image
wx:if="{{false}}"
class="coupon-bg"
src="/assets/imgs/7_1_0/coupon-bg.png"
mode="widthFix"
/>
<image class="coupon-bg" src="/assets/imgs/7_1_0/disabled-coupon.png" mode="widthFix" />
<view class="coupon-info">
<view class="left-price">
<image class="left-price-coupon-bg" src="{{item.couponSettingDetailDTO.style.takeCouponBgimg}}" />
</view>
<view class="right-info">
<view class="coupon-title">{{item.couponSettingDTO.title}}</view>
<view wx:for="{{item.couponSettingDTO.notice}}" wx:key="{{index}}">
<text class='coupon-time'>{{item.label}}</text>
<text class='coupon-desc wpl'>{{item.value}}</text>
<view class="modal-info" wx:if="{{newConponOrderList.length}}">
<block wx:for="{{newConponOrderList}}" wx:key="{{index}}" wx:for-item="item">
<block wx:for="{{item.couponDTOS}}" wx:key="{{index}}" wx:for-item="coupon">
<view
class="coupon-list"
data-id="{{coupon.id}}"
data-index="{{index}}"
data-type="{{coupon.type}}"
bindtap="selectCoupon"
>
<image
wx:if="{{false}}"
class="coupon-bg"
src="/assets/imgs/7_1_0/coupon-bg.png"
mode="widthFix"
/>
<image class="coupon-bg" src="/assets/imgs/7_1_0/disabled-coupon.png" mode="widthFix" />
<view class="coupon-info">
<view class="left-price">
<image class="left-price-coupon-bg" src="{{coupon.takeCouponBgimg}}" />
</view>
</view>
<view class="select-radio">
<icon size="16" type="{{item.checked ? 'success' : 'circle'}}" color="{{checkedColor}}"></icon>
</view>
<!-- <view class="select-radio">
<view class="{{isSelect ? 'theme-color' : ''}} coupon-radio">
<image
wx:if="{{isSelect}}"
class="tick-success"
src="/assets/imgs/7_1_0/tick-success.png"
mode="widthFix"
/>
<view class="right-info">
<view class="coupon-title">{{coupon.title}}</view>
<view wx:for="{{coupon.newNotice}}" wx:key="{{index}}" wx:for-item="notice">
<text class='coupon-time'>{{notice.label}}</text>
<text class='coupon-desc wpl'>{{notice.value}}</text>
</view>
</view>
</view>-->
<view class="select-radio">
<icon size="16" type="{{coupon.checked ? 'success' : 'circle'}}" color="{{checkedColor}}" />
</view>
</view>
</view>
</view>
</block>
</block>
</view>
......
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