Compare commits

...

3 Commits

  1. 5
      Utils/physicalObject.js
  2. 2
      components/cart-choose/cart-choose.vue
  3. 158
      physical-merchants/classify/cart/cart.vue

@ -51,6 +51,11 @@ export const deleteShoppingCart = params => {
return POST('GET', `${base}/shoppingCart/deleteShoppingCart`, params).then(res => res.data); return POST('GET', `${base}/shoppingCart/deleteShoppingCart`, params).then(res => res.data);
} }
// 修改购物车选中状态
export const whetherCheckUpdate = params => {
return POST('GET', `${base}/shoppingCart/whetherCheck`, params).then(res => res.data);
}
// 查询购物车列表 // 查询购物车列表
export const getShoppingCartList = params => { export const getShoppingCartList = params => {
return POST('GET', `${base}/shoppingCart/getShoppingCartList`, params).then(res => res.data); return POST('GET', `${base}/shoppingCart/getShoppingCartList`, params).then(res => res.data);

@ -214,7 +214,7 @@
goodsId:this.specificationList[this.chooseIndex].goodsId, goodsId:this.specificationList[this.chooseIndex].goodsId,
num:this.chooseNumber, num:this.chooseNumber,
sku:this.specificationList[this.chooseIndex].id, sku:this.specificationList[this.chooseIndex].id,
whetherCheck:false // whetherCheck:true
} }
insertShoppingCart(params).then(async res=>{ insertShoppingCart(params).then(async res=>{

@ -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) { //,loseEfficacyundefined checkAllClickChildMethod(){
if (!item.loseEfficacy) { // if (this.allCheck.whetherCheck) {
item.whetherCheck = true // this.cartList.map(item => {
} // if (!this.isEdit) { //,loseEfficacyundefined
} else { // // if (!item.loseEfficacy) { //
item.whetherCheck = true // item.whetherCheck = true
} // }else{ //
// item.whetherCheck = false
}) // }
} else { // } else { //
this.cartList.map(item => { // item.whetherCheck = true
item.whetherCheck = false // }
})
// })
// } 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)
// }
} }
let id=select.join()
this.whetherCheckUpdate(id,this.allCheck.whetherCheck)
},
whetherCheckUpdate(id,whetherCheck){
let params = {
ids:id,
whetherCheck:whetherCheck
}
whetherCheckUpdate(params).then(res=>{
if(res.return_code == "000000"){
}else{
uni.showToast({title:res.return_msg,icon:'none'});
}
this.initData();//
})
}, },
// //
checkClick(item) { checkClick(item) {
item.whetherCheck = !item.whetherCheck; item.whetherCheck = !item.whetherCheck;
this.whetherCheckUpdate(String(item.id),item.whetherCheck)
// if (!item.whetherCheck) {
// if (!this.isEdit && !item.loseEfficacy) { //
// this.allCheck.whetherCheck = false;
// } else if (this.isEdit) {
// this.allCheck.whetherCheck = false;
// }
if (!item.whetherCheck) { // } else {
if (!this.isEdit && !item.loseEfficacy) { // // this.allCheckInit()
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;
// }
// }
// return item.whetherCheck === true
// })
// if (goods) {
// this.allCheck.whetherCheck = true
// } else {
// this.allCheck.whetherCheck = false
// }
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,"")

Loading…
Cancel
Save