|
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
|
}) |