Merge branch 'youmengting-dev' of http://gitea.dctpay.com/yangjie/high-mini into new-dev

master
杨杰 2 years ago
commit 7bf94f7781
  1. 5
      Utils/physicalObject.js
  2. 2
      components/cart-choose/cart-choose.vue
  3. 138
      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);
}
// 修改购物车选中状态
export const whetherCheckUpdate = params => {
return POST('GET', `${base}/shoppingCart/whetherCheck`, params).then(res => res.data);
}
// 查询购物车列表
export const getShoppingCartList = params => {
return POST('GET', `${base}/shoppingCart/getShoppingCartList`, params).then(res => res.data);

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

@ -15,7 +15,7 @@
<view class="cart-container2">
<checkbox-group @change="checkClick(item)">
<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>
<view class="cart-detail">
<view class="cart-img">
@ -116,7 +116,8 @@
import {
getShoppingCartList,
goodsEditNum,
deleteShoppingCart
deleteShoppingCart,
whetherCheckUpdate
} from '@/Utils/physicalObject.js'
const app = getApp();
@ -172,15 +173,9 @@
//
priceAll() {
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) {
this.cartList.map(item => {
if (item.whetherCheck) {
if (item.whetherCheck&&!item.loseEfficacy) {
str =parseFloat((str + (item.num*item.price)).toFixed(2))
@ -229,7 +224,13 @@
if (res.return_code == '000000') {
this.allCheck.whetherCheck = false;
this.cartList = res.return_data;
// this.allCheckInit();
//
this.cartList[0].loseEfficacy=true;
this.allCheckInit(); //
} else {
uni.showToast({
@ -242,74 +243,95 @@
},
editDelete() {
this.isEdit = !this.isEdit;
if (!this.isEdit) { //退
this.cartList.map(item => {
if (item.whetherCheck && item.loseEfficacy) {
item.whetherCheck = false;
}
})
} else { //
if (this.allCheck.whetherCheck) {
this.cartList.map(item => {
item.whetherCheck = true;
})
}
}
// if (!this.isEdit) { //退
// this.allCheck.whetherCheck = false;
// this.cartList.map(item => {
// if (item.whetherCheck && item.loseEfficacy) {
// item.whetherCheck = false;
// }
// })
// } else { //
// this.allCheck.whetherCheck = false;
// if (this.allCheck.whetherCheck) {
// this.cartList.map(item => {
// item.whetherCheck = true;
// })
// }
// }
this.allCheckInit();
// this.allCheck.whetherCheck = false;
// this.checkAllClickChildMethod()
},
//
checkAllClick(e) {
this.allCheck.whetherCheck = !this.allCheck.whetherCheck;
if (this.allCheck.whetherCheck) {
this.cartList.map(item => {
if (!this.isEdit) { //,loseEfficacyundefined
if (!item.loseEfficacy) {
item.whetherCheck = true
this.checkAllClickChildMethod()
},
checkAllClickChildMethod(){
// if (this.allCheck.whetherCheck) {
// this.cartList.map(item => {
// 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)
// }
}
} else { //
item.whetherCheck = true
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{
this.cartList.map(item => {
item.whetherCheck = false
})
uni.showToast({title:res.return_msg,icon:'none'});
}
this.initData();//
})
},
//
checkClick(item) {
item.whetherCheck = !item.whetherCheck;
if (!item.whetherCheck) {
if (!this.isEdit && !item.loseEfficacy) { //
this.allCheck.whetherCheck = false;
} else if (this.isEdit) {
this.allCheck.whetherCheck = false;
}
this.whetherCheckUpdate(String(item.id),item.whetherCheck)
} 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 {
// this.allCheck.whetherCheck = false
// this.allCheckInit()
// }
this.allCheckInit()
}
},
allCheckInit() {
@ -377,7 +399,7 @@
if (!this.isHaveGoods()) return;
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)
// console.log(selestArr,"")

Loading…
Cancel
Save