Compare commits

..

No commits in common. '7bf94f778196fe51d17d1fa345b9744e4431214c' and 'e2e0552b5e96042ccfc734aa669f0ec1cc3e9ded' have entirely different histories.

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

@ -51,11 +51,6 @@ 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:true whetherCheck:false
} }
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="!isEdit&&item.loseEfficacy?false:item.whetherCheck" /> value="item.id" :checked="item.whetherCheck" />
</checkbox-group> </checkbox-group>
<view class="cart-detail"> <view class="cart-detail">
<view class="cart-img"> <view class="cart-img">
@ -116,8 +116,7 @@
import { import {
getShoppingCartList, getShoppingCartList,
goodsEditNum, goodsEditNum,
deleteShoppingCart, deleteShoppingCart
whetherCheckUpdate
} from '@/Utils/physicalObject.js' } from '@/Utils/physicalObject.js'
const app = getApp(); const app = getApp();
@ -173,9 +172,15 @@
// //
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&&!item.loseEfficacy) { if (item.whetherCheck) {
str =parseFloat((str + (item.num*item.price)).toFixed(2)) str =parseFloat((str + (item.num*item.price)).toFixed(2))
@ -224,13 +229,7 @@
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({
@ -243,95 +242,74 @@
}, },
editDelete() { editDelete() {
this.isEdit = !this.isEdit; this.isEdit = !this.isEdit;
// if (!this.isEdit) { //退 if (!this.isEdit) { //退
// this.allCheck.whetherCheck = false; this.cartList.map(item => {
// this.cartList.map(item => { if (item.whetherCheck && item.loseEfficacy) {
// if (item.whetherCheck && item.loseEfficacy) { item.whetherCheck = false;
// item.whetherCheck = false; }
// } })
// }) } else { //
// } else { // if (this.allCheck.whetherCheck) {
// this.allCheck.whetherCheck = false; this.cartList.map(item => {
// if (this.allCheck.whetherCheck) { item.whetherCheck = true;
// 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;
this.checkAllClickChildMethod() if (this.allCheck.whetherCheck) {
}, this.cartList.map(item => {
checkAllClickChildMethod(){ if (!this.isEdit) { //,loseEfficacyundefined
// if (this.allCheck.whetherCheck) { if (!item.loseEfficacy) {
// this.cartList.map(item => { item.whetherCheck = true
// if (!this.isEdit) { //,loseEfficacyundefined
// 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)
// }
} }
let id=select.join() } else { //
item.whetherCheck = true
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();//
}) })
} else {
this.cartList.map(item => {
item.whetherCheck = false
})
}
}, },
// //
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.allCheck.whetherCheck = false; // const goods = this.cartList.every(item => {
// } else if (this.isEdit) { // if(!this.isEdit){//
// this.allCheck.whetherCheck = false; // if(item.loseEfficacy){
// return true;
// } // }
// }
// return item.whetherCheck === true
// })
// if (goods) {
// this.allCheck.whetherCheck = true
// } else { // } else {
// this.allCheckInit() // this.allCheck.whetherCheck = false
// } // }
this.allCheckInit()
}
}, },
allCheckInit() { allCheckInit() {
@ -399,7 +377,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&&!item.loseEfficacy) == true) let selestArr = this.cartList.filter(item => item.whetherCheck == true)
selestArr = JSON.stringify(selestArr) selestArr = JSON.stringify(selestArr)
// console.log(selestArr,"") // console.log(selestArr,"")

Loading…
Cancel
Save