Commit cdbd0de1cc900ea9fbe8a08ccd570722b1ad62d5

Authored by vking
1 parent 938f16dd

商家红包活动

// pack-checkout/components/discount.js
import util from '../../utils/util'
import App from '../../utils/uri'
Component({
/**
* 组件的属性列表
... ... @@ -42,6 +44,27 @@ Component({
display:false,
})
},
discountChecked(e){
console.log('discountChecked',e)
let index=util.attr(e,'index')
let discount=this.data.checkout.discount
let checked=discount[index].checked
discount[index].checked=!discount[index].checked
if(checked) {
let subsidy_price=(this.data.checkout.subsidy_price/1 - discount[index].price/1).toFixed(2)
this.setData({
[`checkout.subsidy_price`]: subsidy_price,
[`checkout.discount`]: discount,
checkedNum:this.data.checkedNum-1,
})
}else{
let subsidy_price=(this.data.checkout.subsidy_price/1 + discount[index].price/1).toFixed(2)
this.setData({
[`checkout.subsidy_price`]: subsidy_price,
[`checkout.discount`]: discount,
checkedNum:this.data.checkedNum+1,
})
}
},
}
})
... ...
... ... @@ -9,12 +9,12 @@
<view class="tips">红包均为一次使用,不找零、不兑现,每次买单抵扣不超过消费总额</view>
<view class="content">
<view class="msg flex-ll">
你选中了<text class="light">{{checkedNum}}</text>个红包,共可抵扣<text class="light">{{checkout.subsidy_price}}</text>
你选中了<text class="light">{{checkedNum}}</text>个红包,共可抵扣<text class="light">¥{{checkout.subsidy_price}}</text>
</view>
<view class="list">
<view class="quan" wx:for="{{checkout.discount}}" wx:key="discount">
<quan quan="{{item}}">
<radio value="r1" checked="{{item.checked}}" color="#F05522"/>
<radio data-index="{{index}}" checked="{{item.checked}}" color="#F05522" bindtap="discountChecked"/>
</quan>
</view>
... ...