|
@@ -6,7 +6,11 @@ var app = getApp();
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
+ cartGoods00: [],//保税仓数据
|
|
|
+ cartGoods02: [],//保税展示数据
|
|
|
+ cartGoods11: [],//现场速递数据
|
|
|
cartGoods: [],
|
|
|
+ goodsBizType: '',//货品业务类型
|
|
|
footprintList: [],
|
|
|
cartTotal: {
|
|
|
"goodsCount": 0,
|
|
@@ -15,6 +19,9 @@ Page({
|
|
|
"checkedGoodsAmount": 0.00
|
|
|
},
|
|
|
checkedAllStatus: true,
|
|
|
+ checkedTypeStatus00: true,
|
|
|
+ checkedTypeStatus02: true,
|
|
|
+ checkedTypeStatus11: true,
|
|
|
couponInfoList: [],
|
|
|
openAttr: false,
|
|
|
specificationList: {},
|
|
@@ -41,24 +48,32 @@ Page({
|
|
|
// 页面关闭
|
|
|
|
|
|
},
|
|
|
- getCartList: function () {
|
|
|
+ getCartList: function () {//获取购物车数据
|
|
|
let that = this;
|
|
|
util.request(api.CartList).then(function (res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
cartGoods: res.data.cartList,
|
|
|
+ cartGoods00: res.data.cart00List,
|
|
|
+ cartGoods02: res.data.cart02List,
|
|
|
+ cartGoods11: res.data.cart11List,
|
|
|
cartTotal: res.data.cartTotal,
|
|
|
couponInfoList: res.data.couponInfoList
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+ //数据渲染选中
|
|
|
that.setData({
|
|
|
checkedAllStatus: that.isCheckedAll()
|
|
|
});
|
|
|
+ that.setData({
|
|
|
+ checkedTypeStatus00: that.isCheckedTypeStatus00(),
|
|
|
+ checkedTypeStatus02: that.isCheckedTypeStatus02(),
|
|
|
+ checkedTypeStatus11: that.isCheckedTypeStatus11()
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
isCheckedAll: function () {
|
|
|
- //判断购物车商品已全选
|
|
|
+ //判断购物车所有商品是否已全选
|
|
|
return this.data.cartGoods.every(function (element, index, array) {
|
|
|
if (element.checked == true) {
|
|
|
return true;
|
|
@@ -67,6 +82,36 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ isCheckedTypeStatus00: function () {
|
|
|
+ //判断该业务类型的购物车商品是否已全选
|
|
|
+ return this.data.cartGoods00.every(function (element, index, array) {
|
|
|
+ if (element.checked == true) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ isCheckedTypeStatus02: function () {
|
|
|
+ //判断该业务类型的购物车商品是否已全选
|
|
|
+ return this.data.cartGoods02.every(function (element, index, array) {
|
|
|
+ if (element.checked == true) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ isCheckedTypeStatus11: function () {
|
|
|
+ //判断该业务类型的购物车商品是否已全选
|
|
|
+ return this.data.cartGoods11.every(function (element, index, array) {
|
|
|
+ if (element.checked == true) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
toIndexPage: function () {
|
|
|
wx.switchTab({
|
|
|
url: "/pages/index/index"
|
|
@@ -84,12 +129,18 @@ Page({
|
|
|
console.log(res.data);
|
|
|
that.setData({
|
|
|
cartGoods: res.data.cartList,
|
|
|
+ cartGoods00: res.data.cart00List,
|
|
|
+ cartGoods02: res.data.cart02List,
|
|
|
+ cartGoods11: res.data.cart11List,
|
|
|
cartTotal: res.data.cartTotal,
|
|
|
couponInfoList: res.data.couponInfoList
|
|
|
});
|
|
|
}
|
|
|
that.setData({
|
|
|
- checkedAllStatus: that.isCheckedAll()
|
|
|
+ checkedAllStatus: that.isCheckedAll(),
|
|
|
+ checkedTypeStatus00: that.isCheckedTypeStatus00(),
|
|
|
+ checkedTypeStatus02: that.isCheckedTypeStatus02(),
|
|
|
+ checkedTypeStatus11: that.isCheckedTypeStatus11()
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -117,6 +168,9 @@ Page({
|
|
|
console.log(res.data);
|
|
|
that.setData({
|
|
|
cartGoods: res.data.cartList,
|
|
|
+ cartGoods00: res.data.cart00List,
|
|
|
+ cartGoods02: res.data.cart02List,
|
|
|
+ cartGoods11: res.data.cart11List,
|
|
|
cartTotal: res.data.cartTotal,
|
|
|
couponInfoList: res.data.couponInfoList
|
|
|
});
|
|
@@ -125,6 +179,61 @@ Page({
|
|
|
that.setData({
|
|
|
checkedAllStatus: that.isCheckedAll()
|
|
|
});
|
|
|
+ that.setData({
|
|
|
+ checkedTypeStatus00: that.isCheckedAll(),
|
|
|
+ checkedTypeStatus02: that.isCheckedAll(),
|
|
|
+ checkedTypeStatus11: that.isCheckedAll()
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ checkedAllGoodType: function (e) {
|
|
|
+ let that = this;
|
|
|
+ let goodsBizType = e.target.dataset.goodsBizType;
|
|
|
+ let isCheckedTypeStatu;
|
|
|
+ if (goodsBizType == '00') {
|
|
|
+ isCheckedTypeStatu = that.isCheckedTypeStatus00();
|
|
|
+ }
|
|
|
+ if (goodsBizType == '02') {
|
|
|
+ isCheckedTypeStatu = that.isCheckedTypeStatus02();
|
|
|
+ }
|
|
|
+ if (goodsBizType == '11') {
|
|
|
+ isCheckedTypeStatu = that.isCheckedTypeStatus11();
|
|
|
+ }
|
|
|
+ util.request(api.CartChecked, {
|
|
|
+ isChecked: isCheckedTypeStatu ? 0 : 1,
|
|
|
+ goodsBizType: goodsBizType
|
|
|
+ }, 'POST').then(function (res) {
|
|
|
+ if (res.errno === 0) {
|
|
|
+ console.log(res.data);
|
|
|
+ //渲染数据
|
|
|
+ that.setData({
|
|
|
+ cartGoods: res.data.cartList,
|
|
|
+ cartGoods00: res.data.cart00List,
|
|
|
+ cartGoods02: res.data.cart02List,
|
|
|
+ cartGoods11: res.data.cart11List,
|
|
|
+ cartTotal: res.data.cartTotal,
|
|
|
+ couponInfoList: res.data.couponInfoList,
|
|
|
+ goodsBizType: goodsBizType
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (goodsBizType == '00') {
|
|
|
+ that.setData({
|
|
|
+ checkedTypeStatus00: that.isCheckedTypeStatus00()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (goodsBizType == '02') {
|
|
|
+ that.setData({
|
|
|
+ checkedTypeStatus02: that.isCheckedTypeStatus02()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (goodsBizType == '11') {
|
|
|
+ that.setData({
|
|
|
+ checkedTypeStatus11: that.isCheckedTypeStatus11()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ checkedAllStatus: that.isCheckedAll()
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
updateCart: function (productId, goodsId, number, beforeNumber, id, itemIndex) {
|
|
@@ -138,7 +247,7 @@ Page({
|
|
|
}, 'POST').then(function (res) {
|
|
|
if (res.errno === 0) {
|
|
|
console.log(res.data);
|
|
|
- if (res.errmsg){
|
|
|
+ if (res.errmsg) {
|
|
|
wx.showModal({
|
|
|
title: '修改失败',
|
|
|
showCancel: false,
|
|
@@ -148,16 +257,19 @@ Page({
|
|
|
|
|
|
that.setData({
|
|
|
cartGoods: res.data.cartList,
|
|
|
+ cartGoods00: res.data.cart00List,
|
|
|
+ cartGoods02: res.data.cart02List,
|
|
|
+ cartGoods11: res.data.cart11List,
|
|
|
cartTotal: res.data.cartTotal,
|
|
|
couponInfoList: res.data.couponInfoList
|
|
|
});
|
|
|
} else {
|
|
|
// util.showErrorToast(res.errmsg);
|
|
|
- wx.showModal({
|
|
|
- title: '提示信息',
|
|
|
- content: res.errmsg,
|
|
|
- showCancel: false
|
|
|
- });
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示信息',
|
|
|
+ content: res.errmsg,
|
|
|
+ showCancel: false
|
|
|
+ });
|
|
|
let cartItem = that.data.cartGoods[itemIndex];
|
|
|
cartItem.number = beforeNumber;
|
|
|
that.setData({
|
|
@@ -166,7 +278,10 @@ Page({
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
- checkedAllStatus: that.isCheckedAll()
|
|
|
+ checkedAllStatus: that.isCheckedAll(),
|
|
|
+ checkedTypeStatus00: that.isCheckedTypeStatus00(),
|
|
|
+ checkedTypeStatus02: that.isCheckedTypeStatus02(),
|
|
|
+ checkedTypeStatus11: that.isCheckedTypeStatus11()
|
|
|
});
|
|
|
});
|
|
|
},
|
|
@@ -231,13 +346,19 @@ Page({
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
cartGoods: res.data.cartList,
|
|
|
+ cartGoods00: res.data.cart00List,
|
|
|
+ cartGoods02: res.data.cart02List,
|
|
|
+ cartGoods11: res.data.cart11List,
|
|
|
cartTotal: res.data.cartTotal,
|
|
|
couponInfoList: res.data.couponInfoList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
- checkedAllStatus: that.isCheckedAll()
|
|
|
+ checkedAllStatus: that.isCheckedAll(),
|
|
|
+ checkedTypeStatus00: that.isCheckedTypeStatus00(),
|
|
|
+ checkedTypeStatus02: that.isCheckedTypeStatus02(),
|
|
|
+ checkedTypeStatus11: that.isCheckedTypeStatus11()
|
|
|
});
|
|
|
});
|
|
|
console.log('用户点击确定')
|