|
@@ -17,7 +17,7 @@ var shoppingCart = new Vue({
|
|
|
reducedPrice: 0,
|
|
|
originalPrice: 0,
|
|
|
allChecked: true,
|
|
|
- submitIds: [],//去结算商品Ids
|
|
|
+ submitIds: [],//去结算商品SkuIds
|
|
|
checkenProsList:[],// 勾选中的商品
|
|
|
isShowPopup:false,
|
|
|
currentTab:1,
|
|
@@ -86,21 +86,19 @@ var shoppingCart = new Vue({
|
|
|
// 默认全选
|
|
|
_self.listData = data.list.map(function(supplier){
|
|
|
if(supplier.cartList.length>0){
|
|
|
- supplier.cartList.map(function(cart){
|
|
|
+ supplier.cartList.forEach(function(cart){
|
|
|
if(cart.stock === 0 || cart.number > cart.stock ){
|
|
|
cart.isChecked = false;
|
|
|
supplier.isDisable = true
|
|
|
cart.isDisable = true
|
|
|
}else{
|
|
|
- supplier.isDisable = false
|
|
|
cart.isDisable = false
|
|
|
cart.isChecked = true;
|
|
|
+ _self.submitIds.push(cart.skuId);
|
|
|
+ _self.checkenProsList.push(cart);
|
|
|
}
|
|
|
cart.isSkuPopup = false;
|
|
|
- // _self.submitIds.push(cart.productId);
|
|
|
- _self.checkenProsList.push(cart);
|
|
|
_self.isCheckedProductStatus = true;
|
|
|
- return cart;
|
|
|
})
|
|
|
}
|
|
|
_self.updateProductCheckedAllBtn(supplier);
|
|
@@ -109,6 +107,7 @@ var shoppingCart = new Vue({
|
|
|
_self.updateCheckAllBtn();
|
|
|
_self.computedPrice();
|
|
|
_self.listLoading = false;
|
|
|
+ console.log('listData',_self.listData)
|
|
|
}else{
|
|
|
CAIMEI.Alert(response.msg,'确定',true, function(){});
|
|
|
}
|
|
@@ -135,16 +134,16 @@ var shoppingCart = new Vue({
|
|
|
if(pro.isDisable){ return }
|
|
|
pro.isChecked = !pro.isChecked;
|
|
|
if (pro.isChecked) {
|
|
|
- this.checkenProsList.push(pro);
|
|
|
- this.isCheckedProductStatus = true;
|
|
|
- // if (!_self.submitIds.includes(pro.productId * 1)) {
|
|
|
- // _self.submitIds.push(pro.productId);
|
|
|
- // }
|
|
|
+ if (!_self.submitIds.includes(pro.skuId * 1)) {
|
|
|
+ _self.submitIds.push(pro.skuId);
|
|
|
+ _self.checkenProsList.push(pro);
|
|
|
+ }
|
|
|
+ _self.isCheckedProductStatus = true;
|
|
|
} else {
|
|
|
- var lent = _self.submitIds.indexOf(pro.productId * 1)
|
|
|
+ var lent = _self.submitIds.indexOf(pro.skuId * 1)
|
|
|
if (lent >= 0) {
|
|
|
_self.submitIds.splice(lent, 1);
|
|
|
- this.checkenProsList.splice(lent, 1);
|
|
|
+ _self.checkenProsList.splice(lent, 1);
|
|
|
}
|
|
|
}
|
|
|
_self.updateProductCheckedAllBtn(supplier)
|
|
@@ -178,40 +177,40 @@ var shoppingCart = new Vue({
|
|
|
goodsCheckedLength++;
|
|
|
}
|
|
|
})
|
|
|
- _self.allChecked = goodsCheckedLength === goodsList.length;
|
|
|
+ this.allChecked = goodsCheckedLength === goodsList.length;
|
|
|
},
|
|
|
updateBothCheckBtn: function(){// 更新商铺勾选状态
|
|
|
var _self = this;
|
|
|
- _self.listData.forEach(supplier => {
|
|
|
+ this.listData = this.listData.map(supplier => {
|
|
|
supplier.isChecked = _self.allChecked;
|
|
|
_self.setProductChecked(supplier);
|
|
|
+ return supplier
|
|
|
})
|
|
|
},
|
|
|
setProductChecked: function(supplier) {//
|
|
|
var _self = this;
|
|
|
- supplier.cartList.forEach(pros => {
|
|
|
- if (supplier.isChecked) {
|
|
|
- pros.isChecked = true;
|
|
|
- if (!_self.submitIds.includes(pros.productId * 1)) {
|
|
|
- _self.submitIds.push(pros.productId);
|
|
|
- _self.checkenProsList.push(pros);
|
|
|
+ supplier.cartList.forEach(cart => {
|
|
|
+ if (supplier.isChecked && (cart.stock !== 0 || cart.number < cart.stock)) {
|
|
|
+ cart.isChecked = true;
|
|
|
+ if (!_self.submitIds.includes(cart.skuId * 1)) {
|
|
|
+ _self.submitIds.push(cart.skuId);
|
|
|
+ _self.checkenProsList.push(cart);
|
|
|
}
|
|
|
_self.isCheckedProductStatus = true;
|
|
|
} else {
|
|
|
- pros.isChecked = false;
|
|
|
- var lent = this.submitIds.indexOf(pros.productId * 1);
|
|
|
+ cart.isChecked = false;
|
|
|
+ var lent = this.submitIds.indexOf(cart.skuId * 1);
|
|
|
if (lent >= 0) {
|
|
|
_self.submitIds.splice(lent, 1);
|
|
|
_self.checkenProsList.splice(lent, 1);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- _self.computedPrice();
|
|
|
+ this.computedPrice();
|
|
|
},
|
|
|
ckeckAll: function(){
|
|
|
- var _self = this;
|
|
|
- _self.allChecked = !_self.allChecked;
|
|
|
- _self.updateBothCheckBtn()
|
|
|
+ this.allChecked = !this.allChecked;
|
|
|
+ this.updateBothCheckBtn()
|
|
|
},
|
|
|
setPromotions:function(){
|
|
|
var _self = this;
|
|
@@ -229,6 +228,7 @@ var shoppingCart = new Vue({
|
|
|
},
|
|
|
computedPrice: function() {
|
|
|
var _self = this;
|
|
|
+ console.log('submitIds',this.submitIds)
|
|
|
this.$nextTick(function () {
|
|
|
var totalPrice = 0;
|
|
|
var reducedPrice = 0;
|
|
@@ -241,7 +241,7 @@ var shoppingCart = new Vue({
|
|
|
var svipSupplierPrice = 0;
|
|
|
if (supplier.cartList.length > 0) {
|
|
|
supplier.cartList.forEach(function (cart) {
|
|
|
- if (cart.isChecked) {
|
|
|
+ if (_self.submitIds.includes(cart.skuId * 1)) {
|
|
|
supplierPrice += cart.price * cart.number;
|
|
|
kindCount += 1;
|
|
|
totalCount += cart.number;
|
|
@@ -366,7 +366,7 @@ var shoppingCart = new Vue({
|
|
|
var eligibleCoupons = [];
|
|
|
_self.listData.forEach(function(shop,index){
|
|
|
shop.cartList.forEach(function(pros){
|
|
|
- if(_self.submitIds.includes(pros.productId*1)){
|
|
|
+ if(_self.submitIds.includes(pros.skuId*1)){
|
|
|
_self.totalCouponList.forEach(function (coupon,index){//循环优惠券
|
|
|
switch(coupon.couponType){
|
|
|
case 0:// 活动券
|
|
@@ -500,23 +500,15 @@ var shoppingCart = new Vue({
|
|
|
},
|
|
|
deleteSelected: function(){
|
|
|
var _self = this;
|
|
|
- var productIds = _self.submitIds.join(",");
|
|
|
- if(productIds == ''){
|
|
|
+ var skuIds = _self.submitIds.join(",");
|
|
|
+ if(skuIds == ''){
|
|
|
CAIMEI.dialog('请选择要删除的商品~');
|
|
|
return false;
|
|
|
}
|
|
|
CAIMEI.Modal('确定删除选中的商品吗?','取消','确定',function(){
|
|
|
- _self.deleteCart(productIds);
|
|
|
+ _self.deleteCart(skuIds);
|
|
|
});
|
|
|
},
|
|
|
- submitCart: function(){ // type:(1购物车提交[对应表cm_cart],2直接购买提交, 3协销下单)
|
|
|
- var _self = this;
|
|
|
- if (_self.submitIds.length>0){
|
|
|
- var productIds = _self.submitIds.join(",");
|
|
|
- window.localStorage.setItem("shoppingProductIds", productIds);
|
|
|
- window.location.href = '/shopping/confirm.html?type=1';
|
|
|
- }
|
|
|
- },
|
|
|
queryPopupCoupons:function(){// 获取弹窗优惠券列表
|
|
|
var _self = this;
|
|
|
ShoppingApi.ShoppingCartGetCoupon(_self.couponParam, function (response) {
|