Commit 0bb3098e by daqian

优惠券列表

parent 659ee7b9
// component/selectCoupon/selectCoupon.js // component/selectCoupon/selectCoupon.js
const wxService = require('../../utils/wxService')
Component({ Component({
/** /**
* 组件的属性列表 * 组件的属性列表
...@@ -18,6 +20,7 @@ Component({ ...@@ -18,6 +20,7 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
checkedColor: 'rgb(203, 60, 60)',
isSelect:false isSelect:false
}, },
...@@ -28,8 +31,7 @@ Component({ ...@@ -28,8 +31,7 @@ Component({
_couponList(newV, oldV) { _couponList(newV, oldV) {
console.log('newV, oldV', newV) console.log('newV, oldV', newV)
if (newV !== oldV) { if (newV !== oldV) {
newV.map(item=> { newV.map(item => {
console.log(item.couponSettingDTO.notice)
item.couponSettingDTO.notice = JSON.parse(item.couponSettingDTO.notice) item.couponSettingDTO.notice = JSON.parse(item.couponSettingDTO.notice)
for (let i in item.couponSettingDTO.notice) { for (let i in item.couponSettingDTO.notice) {
if (item.couponSettingDTO.notice[i].type == 1) { if (item.couponSettingDTO.notice[i].type == 1) {
...@@ -48,21 +50,29 @@ Component({ ...@@ -48,21 +50,29 @@ Component({
this.setData(data) this.setData(data)
} }
}, },
selectCoupon() { selectCoupon(e) {
console.log('2222') // 1 抵用券 2 折扣券
// 当前优惠券价格 const { id,index,type } = e.currentTarget.dataset
this.setData({ const { couponList } = this.data
isSelect: !this.data.isSelect console.log('2222', id,index, type)
couponList.forEach(item=>{
item.checked = false
}) })
couponList[index].checked = true
wxService.nextTick(() => {
this.triggerEvent('updateCoupon', couponList[index].couponDiscount)
})
this.setData({
couponList
},()=>{
this.hidePopup()})
}, },
hidePopup: function () { // 隐藏弹出框 hidePopup: function () { // 隐藏弹出框
this.setData({ this.setData({
show: false show: false
}) })
}, },
}
},
}) })
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
</view> </view>
<view class="modal-info" wx:if="{{couponList.length}}"> <view class="modal-info" wx:if="{{couponList.length}}">
<block wx:for="{{couponList}}" wx:key="{{item}}"> <block wx:for="{{couponList}}" wx:key="{{index}}" wx:for-item="item">
<view class="coupon-list" bindtap="selectCoupon"> <view class="coupon-list" data-id="{{item.couponSettingDTO.couponSettingId}}" data-index="{{index}}" data-type="{{item.couponSettingDTO.type}}" bindtap="selectCoupon">
<image <image
wx:if="{{false}}" wx:if="{{false}}"
class="coupon-bg" class="coupon-bg"
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
<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="{{item.couponSettingDetailDTO.style.takeCouponBgimg}}" />
</view> </view>
<view class="right-info"> <view class="right-info">
<view class="coupon-title">{{item.couponSettingDTO.title}}</view> <view class="coupon-title">{{item.couponSettingDTO.title}}</view>
<view wx:for="{{item.couponSettingDTO.notice}}" wx:key="{{index}}"> <view wx:for="{{item.couponSettingDTO.notice}}" wx:key="{{index}}">
...@@ -35,7 +34,12 @@ ...@@ -35,7 +34,12 @@
</view> </view>
</view> </view>
<view class="select-radio"> <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"> <view class="{{isSelect ? 'theme-color' : ''}} coupon-radio">
<image <image
wx:if="{{isSelect}}" wx:if="{{isSelect}}"
...@@ -44,7 +48,7 @@ ...@@ -44,7 +48,7 @@
mode="widthFix" mode="widthFix"
/> />
</view> </view>
</view> </view>-->
</view> </view>
</view> </view>
......
...@@ -19,7 +19,8 @@ wxService.page({ ...@@ -19,7 +19,8 @@ wxService.page({
citys: null, citys: null,
cityView: '', cityView: '',
multiIndex: [0, 0, 0], multiIndex: [0, 0, 0],
selectCityName: ['', ''] selectCityName: ['', ''],
currentCoupon: '无可用优惠券'
}, },
/** /**
...@@ -62,7 +63,15 @@ wxService.page({ ...@@ -62,7 +63,15 @@ wxService.page({
// 地址列表 // 地址列表
this.getAddressList() this.getAddressList()
}, },
updateCoupon(e){
console.log('e', e.detail)
if(e.detail){
this.setData({
haveCoupon: true,
currentCoupon: e.detail
})
}
},
formSubmit(e) { formSubmit(e) {
const { goodsAddress } = this.data const { goodsAddress } = this.data
// 保存地址 && 支付 // 保存地址 && 支付
......
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<view> <view>
<text class="price-label">优惠券</text> <text class="price-label">优惠券</text>
<view class="select-coupon" bindtap="selectCoupon"> <view class="select-coupon" bindtap="selectCoupon">
<text class="{{haveCoupon ? 'coupon-price' : 'no-coupon'}}">{{haveCoupon ? '-¥100' : '无可用优惠券'}}</text> <text class="{{haveCoupon ? 'coupon-price' : 'no-coupon'}}">{{currentCoupon}}</text>
<image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" /> <image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" />
</view> </view>
</view> </view>
...@@ -160,5 +160,5 @@ ...@@ -160,5 +160,5 @@
</view> </view>
<!--goHome--> <!--goHome-->
<go-home/> <go-home/>
<select-coupon show="{{showSelectCoupon}}" coupon-list="{{currentOrderList.couponDiscountPreviews}}"/> <select-coupon show="{{showSelectCoupon}}" bind:updateCoupon="updateCoupon" coupon-list="{{currentOrderList.couponDiscountPreviews}}"/>
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