|
...
|
...
|
@@ -15,19 +15,11 @@ Component({ |
|
|
|
data: {
|
|
|
|
checkedNum:0,
|
|
|
|
display:false,
|
|
|
|
checkoutObj:null,
|
|
|
|
},
|
|
|
|
observers: {
|
|
|
|
'checkout': function(checkout) {
|
|
|
|
if(!checkout) return;
|
|
|
|
let num=0;
|
|
|
|
checkout.discount.forEach(q=>{
|
|
|
|
if(q.checked){
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
checkedNum:num,
|
|
|
|
})
|
|
|
|
this.discountFormat(checkout)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
...
|
...
|
@@ -44,27 +36,36 @@ Component({ |
|
|
|
display:false,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
discountFormat(checkout){
|
|
|
|
if(!checkout) return;
|
|
|
|
let num=0;
|
|
|
|
let disObj={}
|
|
|
|
let subsidy_price=0;
|
|
|
|
checkout.discount.forEach(q=>{
|
|
|
|
checkout.disabled=false
|
|
|
|
if(q.checked){
|
|
|
|
num++;
|
|
|
|
disObj[q.owner+'-'+q.receive_condition]=true
|
|
|
|
subsidy_price+=q.price/1
|
|
|
|
}
|
|
|
|
})
|
|
|
|
checkout.discount.forEach(q=>{
|
|
|
|
if(!q.checked && disObj[q.owner+'-'+q.receive_condition]){
|
|
|
|
checkout.disabled=true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
checkout.subsidy_price=subsidy_price
|
|
|
|
this.setData({
|
|
|
|
checkedNum:num,
|
|
|
|
checkoutObj:checkout
|
|
|
|
})
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
let checkout=this.data.checkout
|
|
|
|
checkout.discount[index].checked=!checkout.discount[index].checked
|
|
|
|
this.discountFormat(checkout)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}) |
...
|
...
|
|