Commit cdbd0de1cc900ea9fbe8a08ccd570722b1ad62d5

Authored by vking
1 parent 938f16dd

商家红包活动

1 // pack-checkout/components/discount.js 1 // pack-checkout/components/discount.js
  2 +import util from '../../utils/util'
  3 +import App from '../../utils/uri'
2 Component({ 4 Component({
3 /** 5 /**
4 * 组件的属性列表 6 * 组件的属性列表
@@ -42,6 +44,27 @@ Component({ @@ -42,6 +44,27 @@ Component({
42 display:false, 44 display:false,
43 }) 45 })
44 }, 46 },
45 - 47 + discountChecked(e){
  48 + console.log('discountChecked',e)
  49 + let index=util.attr(e,'index')
  50 + let discount=this.data.checkout.discount
  51 + let checked=discount[index].checked
  52 + discount[index].checked=!discount[index].checked
  53 + if(checked) {
  54 + let subsidy_price=(this.data.checkout.subsidy_price/1 - discount[index].price/1).toFixed(2)
  55 + this.setData({
  56 + [`checkout.subsidy_price`]: subsidy_price,
  57 + [`checkout.discount`]: discount,
  58 + checkedNum:this.data.checkedNum-1,
  59 + })
  60 + }else{
  61 + let subsidy_price=(this.data.checkout.subsidy_price/1 + discount[index].price/1).toFixed(2)
  62 + this.setData({
  63 + [`checkout.subsidy_price`]: subsidy_price,
  64 + [`checkout.discount`]: discount,
  65 + checkedNum:this.data.checkedNum+1,
  66 + })
  67 + }
  68 + },
46 } 69 }
47 }) 70 })
@@ -9,12 +9,12 @@ @@ -9,12 +9,12 @@
9 <view class="tips">红包均为一次使用,不找零、不兑现,每次买单抵扣不超过消费总额</view> 9 <view class="tips">红包均为一次使用,不找零、不兑现,每次买单抵扣不超过消费总额</view>
10 <view class="content"> 10 <view class="content">
11 <view class="msg flex-ll"> 11 <view class="msg flex-ll">
12 - 你选中了<text class="light">{{checkedNum}}</text>个红包,共可抵扣<text class="light">{{checkout.subsidy_price}}</text> 12 + 你选中了<text class="light">{{checkedNum}}</text>个红包,共可抵扣<text class="light">¥{{checkout.subsidy_price}}</text>
13 </view> 13 </view>
14 <view class="list"> 14 <view class="list">
15 <view class="quan" wx:for="{{checkout.discount}}" wx:key="discount"> 15 <view class="quan" wx:for="{{checkout.discount}}" wx:key="discount">
16 <quan quan="{{item}}"> 16 <quan quan="{{item}}">
17 - <radio value="r1" checked="{{item.checked}}" color="#F05522"/> 17 + <radio data-index="{{index}}" checked="{{item.checked}}" color="#F05522" bindtap="discountChecked"/>
18 </quan> 18 </quan>
19 </view> 19 </view>
20 20