...
|
...
|
@@ -8,6 +8,7 @@ Page({ |
|
|
success: false,
|
|
|
fail: false,
|
|
|
name: '',
|
|
|
choudanNum:0,
|
|
|
addressId: 0,
|
|
|
tel: '',
|
|
|
area: '',
|
...
|
...
|
@@ -35,35 +36,71 @@ Page({ |
|
|
let index = e.currentTarget.dataset.index
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let check = e.currentTarget.dataset.check
|
|
|
let coudan = this.data.coudan
|
|
|
let coudan_arr = this.data.coudan_arr
|
|
|
let coudan = this.data.coudan||[]
|
|
|
let coudan_arr = this.data.coudan_arr||[]
|
|
|
let price = e.currentTarget.dataset.price;
|
|
|
let price2 = e.currentTarget.dataset.price2;
|
|
|
|
|
|
if (type == 1) {
|
|
|
if(this.data.info.choudan*100<(price*100)){
|
|
|
wx.showToast({
|
|
|
title: '当前剩余积分不足,请重新挑选',
|
|
|
icon:'none'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
num++
|
|
|
} else {
|
|
|
num--
|
|
|
if (num < 0) {
|
|
|
num = 0;
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
that.setData({
|
|
|
[`info.coudanProduct[${index}].num`]: num
|
|
|
})
|
|
|
if (check) {
|
|
|
|
|
|
if (num<1) {
|
|
|
coudan.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
item.num = num
|
|
|
coudan_arr[index].num = num
|
|
|
coudan.splice(index, 1)
|
|
|
coudan_arr.splice(index, 1)
|
|
|
}
|
|
|
})
|
|
|
this.get_choudan()
|
|
|
} else {
|
|
|
if(type==1&&num==1){
|
|
|
//选中
|
|
|
coudan.push({
|
|
|
id: id,
|
|
|
num: num
|
|
|
})
|
|
|
coudan_arr.push({
|
|
|
id: id,
|
|
|
num: num,
|
|
|
price: Number(price),
|
|
|
price2:Number(price2)
|
|
|
})
|
|
|
}else{
|
|
|
coudan.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
item.num = num
|
|
|
coudan_arr[index].num = num
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
that.setData({
|
|
|
coudan: coudan,
|
|
|
coudan_arr: coudan_arr,
|
|
|
[`info.coudanProduct[${index}].num`]: num
|
|
|
// [`info.coudanProduct[${index}].check`]: check
|
|
|
})
|
|
|
this.get_choudan()
|
|
|
},
|
|
|
// 计算凑单费用
|
|
|
get_choudan() {
|
|
|
let coudan_arr = this.data.coudan_arr
|
|
|
let choudan_money = 0;
|
|
|
|
|
|
|
|
|
let num = 0
|
|
|
for (let obj of coudan_arr) {
|
|
|
console.log(obj)
|
|
|
console.log(obj.price2)
|
...
|
...
|
@@ -74,14 +111,13 @@ Page({ |
|
|
console.log(222)
|
|
|
choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
|
|
|
}
|
|
|
num = num+obj.num
|
|
|
}
|
|
|
|
|
|
console.log(typeof (choudan_money))
|
|
|
console.log(choudan_money)
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
choudan_money: choudan_money*100
|
|
|
choudan_money: choudan_money*100,
|
|
|
choudanNum:num,
|
|
|
'info.choudan': this.data.info.syjf - choudan_money
|
|
|
// choudan_money: Math.floor(choudan_money* 100) / 100
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -167,9 +203,11 @@ Page({ |
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
console.log('99999', res, Number(res.msg.total))
|
|
|
|
|
|
res.msg.syjf = res.msg.choudan - res.msg.yunfei
|
|
|
res.msg.choudan = res.msg.choudan - res.msg.yunfei
|
|
|
res.msg.total = Number(res.msg.total * 100)
|
|
|
res.msg.yunfei = Number(res.msg.yunfei * 100)
|
|
|
|
|
|
let total = (res.msg.total + res.msg.yunfei).toFixed("1");
|
|
|
console.log(total)
|
|
|
|
...
|
...
|
|