|
|
@ -15,7 +15,7 @@ |
|
|
|
<view class="cart-container2"> |
|
|
|
<view class="cart-container2"> |
|
|
|
<checkbox-group @change="checkClick(item)"> |
|
|
|
<checkbox-group @change="checkClick(item)"> |
|
|
|
<checkbox @click.stop class="mycheck checkContainer" :disabled="!isEdit&&item.loseEfficacy" color="#FFC71E" |
|
|
|
<checkbox @click.stop class="mycheck checkContainer" :disabled="!isEdit&&item.loseEfficacy" color="#FFC71E" |
|
|
|
value="item.id" :checked="item.whetherCheck" /> |
|
|
|
value="item.id" :checked="!isEdit&&item.loseEfficacy?false:item.whetherCheck" /> |
|
|
|
</checkbox-group> |
|
|
|
</checkbox-group> |
|
|
|
<view class="cart-detail"> |
|
|
|
<view class="cart-detail"> |
|
|
|
<view class="cart-img"> |
|
|
|
<view class="cart-img"> |
|
|
@ -116,7 +116,8 @@ |
|
|
|
import { |
|
|
|
import { |
|
|
|
getShoppingCartList, |
|
|
|
getShoppingCartList, |
|
|
|
goodsEditNum, |
|
|
|
goodsEditNum, |
|
|
|
deleteShoppingCart |
|
|
|
deleteShoppingCart, |
|
|
|
|
|
|
|
whetherCheckUpdate |
|
|
|
} from '@/Utils/physicalObject.js' |
|
|
|
} from '@/Utils/physicalObject.js' |
|
|
|
|
|
|
|
|
|
|
|
const app = getApp(); |
|
|
|
const app = getApp(); |
|
|
@ -172,15 +173,9 @@ |
|
|
|
//现价金额 |
|
|
|
//现价金额 |
|
|
|
priceAll() { |
|
|
|
priceAll() { |
|
|
|
let str = 0; |
|
|
|
let str = 0; |
|
|
|
// for (var i = 0; i < this.cartList.length; i++) { |
|
|
|
|
|
|
|
// if (this.cartList[i].whetherCheck) { |
|
|
|
|
|
|
|
// str += this.cartList[i].num * this.cartList[i].price; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.cartList.length > 0) { |
|
|
|
if (this.cartList.length > 0) { |
|
|
|
this.cartList.map(item => { |
|
|
|
this.cartList.map(item => { |
|
|
|
if (item.whetherCheck) { |
|
|
|
if (item.whetherCheck&&!item.loseEfficacy) { |
|
|
|
|
|
|
|
|
|
|
|
str =parseFloat((str + (item.num*item.price)).toFixed(2)) |
|
|
|
str =parseFloat((str + (item.num*item.price)).toFixed(2)) |
|
|
|
|
|
|
|
|
|
|
@ -229,7 +224,13 @@ |
|
|
|
if (res.return_code == '000000') { |
|
|
|
if (res.return_code == '000000') { |
|
|
|
this.allCheck.whetherCheck = false; |
|
|
|
this.allCheck.whetherCheck = false; |
|
|
|
this.cartList = res.return_data; |
|
|
|
this.cartList = res.return_data; |
|
|
|
// this.allCheckInit(); |
|
|
|
|
|
|
|
|
|
|
|
// 测试失效数据 |
|
|
|
|
|
|
|
this.cartList[0].loseEfficacy=true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.allCheckInit(); //全选是否勾中判断 |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
uni.showToast({ |
|
|
@ -242,74 +243,95 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
editDelete() { |
|
|
|
editDelete() { |
|
|
|
this.isEdit = !this.isEdit; |
|
|
|
this.isEdit = !this.isEdit; |
|
|
|
if (!this.isEdit) { //退出编辑 |
|
|
|
// if (!this.isEdit) { //退出编辑 |
|
|
|
this.cartList.map(item => { |
|
|
|
// this.allCheck.whetherCheck = false; |
|
|
|
if (item.whetherCheck && item.loseEfficacy) { |
|
|
|
// this.cartList.map(item => { |
|
|
|
item.whetherCheck = false; |
|
|
|
// if (item.whetherCheck && item.loseEfficacy) { |
|
|
|
} |
|
|
|
// item.whetherCheck = false; |
|
|
|
}) |
|
|
|
// } |
|
|
|
} else { //进入编辑 |
|
|
|
// }) |
|
|
|
if (this.allCheck.whetherCheck) { |
|
|
|
// } else { //进入编辑 |
|
|
|
this.cartList.map(item => { |
|
|
|
// this.allCheck.whetherCheck = false; |
|
|
|
item.whetherCheck = true; |
|
|
|
// if (this.allCheck.whetherCheck) { |
|
|
|
}) |
|
|
|
// this.cartList.map(item => { |
|
|
|
} |
|
|
|
// item.whetherCheck = true; |
|
|
|
} |
|
|
|
// }) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.allCheckInit(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.allCheck.whetherCheck = false; |
|
|
|
|
|
|
|
// this.checkAllClickChildMethod() |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 全选的点击事件 |
|
|
|
// 全选的点击事件 |
|
|
|
checkAllClick(e) { |
|
|
|
checkAllClick(e) { |
|
|
|
this.allCheck.whetherCheck = !this.allCheck.whetherCheck; |
|
|
|
this.allCheck.whetherCheck = !this.allCheck.whetherCheck; |
|
|
|
if (this.allCheck.whetherCheck) { |
|
|
|
this.checkAllClickChildMethod() |
|
|
|
this.cartList.map(item => { |
|
|
|
}, |
|
|
|
if (!this.isEdit) { //商品的全选事件,loseEfficacy商品的失效,默认undefined |
|
|
|
checkAllClickChildMethod(){ |
|
|
|
if (!item.loseEfficacy) { |
|
|
|
// if (this.allCheck.whetherCheck) { |
|
|
|
item.whetherCheck = true |
|
|
|
// this.cartList.map(item => { |
|
|
|
|
|
|
|
// if (!this.isEdit) { //商品的全选事件,loseEfficacy商品的失效,默认undefined |
|
|
|
|
|
|
|
// if (!item.loseEfficacy) { //无失效的商品 |
|
|
|
|
|
|
|
// item.whetherCheck = true |
|
|
|
|
|
|
|
// }else{ //有失效的商品 |
|
|
|
|
|
|
|
// item.whetherCheck = false |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } else { //编辑的全选事件 |
|
|
|
|
|
|
|
// item.whetherCheck = true |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// this.cartList.map(item => { |
|
|
|
|
|
|
|
// item.whetherCheck = false |
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var select = []; |
|
|
|
|
|
|
|
for (var i = 0; i < this.cartList.length; i++) { |
|
|
|
|
|
|
|
// if (this.cartList[i].whetherCheck) { |
|
|
|
|
|
|
|
select.push(this.cartList[i].id) |
|
|
|
|
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
} else { //编辑的全选事件 |
|
|
|
let id=select.join() |
|
|
|
item.whetherCheck = true |
|
|
|
|
|
|
|
|
|
|
|
this.whetherCheckUpdate(id,this.allCheck.whetherCheck) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
whetherCheckUpdate(id,whetherCheck){ |
|
|
|
|
|
|
|
let params = { |
|
|
|
|
|
|
|
ids:id, |
|
|
|
|
|
|
|
whetherCheck:whetherCheck |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
whetherCheckUpdate(params).then(res=>{ |
|
|
|
} else { |
|
|
|
if(res.return_code == "000000"){ |
|
|
|
this.cartList.map(item => { |
|
|
|
}else{ |
|
|
|
item.whetherCheck = false |
|
|
|
uni.showToast({title:res.return_msg,icon:'none'}); |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.initData();//刷新购物车 |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 单个商品的选择 |
|
|
|
// 单个商品的选择 |
|
|
|
checkClick(item) { |
|
|
|
checkClick(item) { |
|
|
|
item.whetherCheck = !item.whetherCheck; |
|
|
|
item.whetherCheck = !item.whetherCheck; |
|
|
|
|
|
|
|
|
|
|
|
if (!item.whetherCheck) { |
|
|
|
this.whetherCheckUpdate(String(item.id),item.whetherCheck) |
|
|
|
if (!this.isEdit && !item.loseEfficacy) { //商品 |
|
|
|
|
|
|
|
this.allCheck.whetherCheck = false; |
|
|
|
|
|
|
|
} else if (this.isEdit) { |
|
|
|
|
|
|
|
this.allCheck.whetherCheck = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// // 判断每一个商品是否是被选择的状态 |
|
|
|
|
|
|
|
// const goods = this.cartList.every(item => { |
|
|
|
|
|
|
|
// if(!this.isEdit){//商品 |
|
|
|
|
|
|
|
// if(item.loseEfficacy){ |
|
|
|
|
|
|
|
// return true; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!item.whetherCheck) { |
|
|
|
|
|
|
|
// if (!this.isEdit && !item.loseEfficacy) { //商品 |
|
|
|
|
|
|
|
// this.allCheck.whetherCheck = false; |
|
|
|
|
|
|
|
// } else if (this.isEdit) { |
|
|
|
|
|
|
|
// this.allCheck.whetherCheck = false; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// return item.whetherCheck === true |
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
// if (goods) { |
|
|
|
|
|
|
|
// this.allCheck.whetherCheck = true |
|
|
|
|
|
|
|
// } else { |
|
|
|
// } else { |
|
|
|
// this.allCheck.whetherCheck = false |
|
|
|
// this.allCheckInit() |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
this.allCheckInit() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
allCheckInit() { |
|
|
|
allCheckInit() { |
|
|
|
|
|
|
|
|
|
|
@ -377,7 +399,7 @@ |
|
|
|
if (!this.isHaveGoods()) return; |
|
|
|
if (!this.isHaveGoods()) return; |
|
|
|
|
|
|
|
|
|
|
|
if (this.priceAll > 0) { |
|
|
|
if (this.priceAll > 0) { |
|
|
|
let selestArr = this.cartList.filter(item => item.whetherCheck == true) |
|
|
|
let selestArr = this.cartList.filter(item => (item.whetherCheck&&!item.loseEfficacy) == true) |
|
|
|
selestArr = JSON.stringify(selestArr) |
|
|
|
selestArr = JSON.stringify(selestArr) |
|
|
|
|
|
|
|
|
|
|
|
// console.log(selestArr,"选择的商品") |
|
|
|
// console.log(selestArr,"选择的商品") |
|
|
|