Commit 4ad19c2b by 高淑倩

优惠券id

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