|
@@ -157,7 +157,6 @@
|
|
|
reducedPrice:0,//满减
|
|
|
allPrice:0,//所有价格
|
|
|
allCount:0,//被选中的产品数量
|
|
|
- isNnder:true,
|
|
|
isModallayer:false,
|
|
|
skeletonShow:true,
|
|
|
isshowDelbtn:false,
|
|
@@ -171,6 +170,9 @@
|
|
|
pullFlag: true,
|
|
|
pageSize: 10,
|
|
|
pageNum: 1,
|
|
|
+ submitIds:[],
|
|
|
+ depositIds : [6060,6061,6062,6063,6064],//定金商品ID
|
|
|
+ rechargeIds : [6065,6066,6067,6068,6069],//充值余额商品ID
|
|
|
isIphoneX:this.$store.state.isIphoneX
|
|
|
}
|
|
|
},
|
|
@@ -232,7 +234,7 @@
|
|
|
this.goodsList = resultsData.results;
|
|
|
this.goodsList.forEach((item,index) => {
|
|
|
let productsListLength = item.productsList.length,invalidLength = 0;
|
|
|
- this.kindCount = productsListLength;
|
|
|
+ this.kindCount += productsListLength;
|
|
|
item.productsList.forEach(pros => {
|
|
|
pros.shopID = item.shopID;
|
|
|
pros.isStep = false
|
|
@@ -306,6 +308,16 @@
|
|
|
},
|
|
|
ischeck(item,pro){//为未选中的时候改变为true,反之为true
|
|
|
pro.productsChecked = !pro.productsChecked;
|
|
|
+ if(pro.productsChecked) {
|
|
|
+ if(!this.submitIds.includes(pro.productID*1)){
|
|
|
+ this.submitIds.push(pro.productID);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ var lent = this.submitIds.indexOf(pro.productID*1);
|
|
|
+ if(lent >=0 ){
|
|
|
+ this.submitIds.splice(lent, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
this.updateProductCheckedAllBtn(item);
|
|
|
this.updateCheckAllBtn();
|
|
|
},
|
|
@@ -345,14 +357,18 @@
|
|
|
this.updateCheckAllBtn();
|
|
|
},
|
|
|
setProductChecked(item) {
|
|
|
- let products = item.productsList;
|
|
|
- products.forEach(pros=>{
|
|
|
+ item.productsList.forEach(pros=>{
|
|
|
if(item.checked) {
|
|
|
- // 有效
|
|
|
- this.isNnder = false;
|
|
|
pros.productsChecked = true;
|
|
|
+ if(!this.submitIds.includes(pros.productID*1)){
|
|
|
+ this.submitIds.push(pros.productID);
|
|
|
+ }
|
|
|
} else {
|
|
|
pros.productsChecked = false;
|
|
|
+ var lent = this.submitIds.indexOf(pros.productID*1);
|
|
|
+ if(lent >=0 ){
|
|
|
+ this.submitIds.splice(lent, 1);
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -375,32 +391,30 @@
|
|
|
this.updateBothCheckBtn();
|
|
|
},
|
|
|
totalShopPeice(){//每次所属会所下的商品增减重新计算合计价格&减去含有下架的商品
|
|
|
- let prosPrice=0;
|
|
|
- let touchPrice = 0;
|
|
|
+ let touchPrice = 0;
|
|
|
let reducedPrice = 0;//商铺合计满减价
|
|
|
- let totalOriginalPrice = 0;//商铺合计原价
|
|
|
- let productsList=[];
|
|
|
this.goodsList.map((item,index)=>{
|
|
|
- productsList = item.productsList;
|
|
|
//计算店铺满减后店铺合计
|
|
|
if(item.promotions && item.promotions.mode == 2){
|
|
|
- productsList.forEach(pros=>{
|
|
|
+ let prosPrice=0;
|
|
|
+ let totalOriginalPrice = 0;//商铺合计原价
|
|
|
+ item.productsList.forEach(pros=>{
|
|
|
prosPrice += pros.retailPrice*pros.productCount
|
|
|
- totalOriginalPrice += pros.retailPrice*pros.productCount;
|
|
|
- if(prosPrice >= item.promotions.touchPrice){
|
|
|
- item.totalPrice = prosPrice - item.promotions.reducedPrice
|
|
|
- item.reducedPrice = item.promotions.reducedPrice
|
|
|
- item.totalOriginalPrice = totalOriginalPrice
|
|
|
- }else{
|
|
|
- item.reducedPrice = 0
|
|
|
- item.totalPrice = prosPrice
|
|
|
- }
|
|
|
+ totalOriginalPrice += pros.retailPrice*pros.productCount
|
|
|
})
|
|
|
+ if(prosPrice >= item.promotions.touchPrice){
|
|
|
+ item.totalPrice = prosPrice - item.promotions.reducedPrice
|
|
|
+ item.reducedPrice = item.promotions.reducedPrice
|
|
|
+ item.totalOriginalPrice = totalOriginalPrice
|
|
|
+ }else{
|
|
|
+ item.reducedPrice = 0 //统计合计价格
|
|
|
+ item.totalPrice = prosPrice
|
|
|
+ }
|
|
|
}else{//以下为计算除店铺满减以外的单品满减以及正常商品合计
|
|
|
let _totalPrice = 0;
|
|
|
let _reducedPrice = 0;
|
|
|
let _totalOriginalPrice =0;
|
|
|
- productsList.forEach(pros=>{
|
|
|
+ item.productsList.forEach(pros=>{
|
|
|
let _price = pros.retailPrice*pros.productCount
|
|
|
_totalOriginalPrice += pros.retailPrice*pros.productCount;
|
|
|
if(pros.promotions && pros.promotions.type != 2 && pros.promotions.mode == 2){
|
|
@@ -408,7 +422,7 @@
|
|
|
_price = _price - pros.promotions.reducedPrice
|
|
|
_reducedPrice += pros.promotions.reducedPrice
|
|
|
}
|
|
|
- _totalPrice += _price
|
|
|
+ _totalPrice += _price
|
|
|
}else{
|
|
|
_reducedPrice = 0;
|
|
|
_totalPrice += pros.retailPrice*pros.productCount;
|
|
@@ -421,89 +435,65 @@
|
|
|
})
|
|
|
},
|
|
|
totalPeice(){ //计算总价格,每次调用此方法,将初始值为0,遍历价格并累加
|
|
|
- this.allPrice = 0
|
|
|
- let productsList =[];
|
|
|
- //店铺满减
|
|
|
- let prosPrice=0;
|
|
|
let totalPrice = 0;
|
|
|
- let reducedPrice=0;//促销满减
|
|
|
- let totalOriginalPrice=0;//促销原价
|
|
|
- //凑单满减.单品满减
|
|
|
- let _totalPrice = 0;
|
|
|
- let _promsPrice = 0;
|
|
|
- let _reducedPrice = 0;
|
|
|
- let _reducedPromsPrice = 0;
|
|
|
- let _totalOriginalPrice =0;
|
|
|
- // 正常商品
|
|
|
- let _totalNonePrice = 0;
|
|
|
- let _isFlag = false;
|
|
|
- let _isShopFlag = false;
|
|
|
- /*
|
|
|
- *originalPrice:商品原价
|
|
|
- *price:商品现价
|
|
|
- *mode:促销商品满减计算 促销方式mode为 2 的单独做计算 当mode == 2时商品promotions字段为促销活动内容,
|
|
|
- *touchPrice 为需要满金额
|
|
|
- *reducedPrice 为满减金额
|
|
|
- **/
|
|
|
+ let reducedPrice = 0;
|
|
|
+ let originalPrice = 0;
|
|
|
this.goodsList.forEach((item,index)=>{
|
|
|
+ let supplierPrice = 0;
|
|
|
+ let supplierReducedPrice = 0;
|
|
|
+ item.totalprice = 0;
|
|
|
+ item.reducedprice = 0;
|
|
|
+ item.originalprice = 0;
|
|
|
item.productsList.forEach(pros=>{
|
|
|
- if(pros.productsChecked){
|
|
|
- if(item.promotions && item.promotions.mode == 2){
|
|
|
- this.promotionsList.forEach(proms =>{
|
|
|
- if (item.promotions.id == proms.id){
|
|
|
- _isShopFlag = true;
|
|
|
- prosPrice += pros.retailPrice*pros.productCount
|
|
|
- }
|
|
|
- })
|
|
|
- if(_isShopFlag){
|
|
|
- if(prosPrice >= item.promotions.touchPrice){//判断如果商品合计价格已满足满减活动,计算价格
|
|
|
- totalPrice = prosPrice - item.promotions.reducedPrice //统计合计价格
|
|
|
- totalOriginalPrice += pros.price1*pros.productCount //统计原商品价格
|
|
|
- reducedPrice = item.promotions.reducedPrice //统计总减金额
|
|
|
- }else{
|
|
|
- totalPrice += prosPrice //未达满减的统计合计价格
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(pros.promotions && pros.promotions.type == 1 && pros.promotions.mode == 2){//以下为计算除店铺满减以外的单品满减
|
|
|
- let _price = 0;
|
|
|
- _price = pros.retailPrice*pros.productCount
|
|
|
- _totalOriginalPrice += pros.price1*pros.productCount; //统计原商品价格
|
|
|
- if(_price >= pros.promotions.touchPrice){//判断如果商品合计价格已满足满减活动,计算价格
|
|
|
- _price = _price - pros.promotions.reducedPrice //商品满减后价格
|
|
|
- _reducedPrice += pros.promotions.reducedPrice //统计总减金额
|
|
|
- }else{
|
|
|
- _reducedPrice = 0 //将满减金额置为0
|
|
|
+ if(pros.productsChecked){
|
|
|
+ supplierPrice += pros.retailPrice*pros.productCount;
|
|
|
+ // 单品满减
|
|
|
+ if(pros.promotions && pros.promotions.type*1===1 && pros.promotions.mode*1===2){
|
|
|
+ // 单品满减-重新计算供应商总价/满减金额
|
|
|
+ if(pros.retailPrice*pros.productCount >= pros.promotions.touchPrice){
|
|
|
+ supplierPrice -= pros.promotions.reducedPrice;
|
|
|
+ supplierReducedPrice += pros.promotions.reducedPrice;
|
|
|
}
|
|
|
- _totalPrice += _price //统计合计价格
|
|
|
- }else if(pros.promotions && pros.promotions.type == 2 && pros.promotions.mode == 2){//凑单满减计算合计
|
|
|
- let _price = 0;
|
|
|
- this.promotionsList.forEach(proms =>{
|
|
|
- proms.products.forEach(el =>{
|
|
|
- if (pros.productID == el.productID){
|
|
|
- _isFlag = true;
|
|
|
- _price += pros.retailPrice*pros.productCount
|
|
|
- _totalOriginalPrice += pros.price1*pros.productCount; //统计原商品价格
|
|
|
- }
|
|
|
- })
|
|
|
- if(_price >= pros.promotions.touchPrice){//判断如果商品合计价格已满足满减活动,计算价格
|
|
|
- _reducedPromsPrice = pros.promotions.reducedPrice //统计总减金额
|
|
|
- }else{
|
|
|
- _reducedPromsPrice = 0 //将满减金额置为0
|
|
|
- }
|
|
|
- })
|
|
|
- _promsPrice += _price//统计合计价格
|
|
|
- }else{
|
|
|
- _totalNonePrice += pros.retailPrice*pros.productCount; //正常商品的价格总计
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+ // 店铺满减
|
|
|
+ if(item.promotions && item.promotions.mode*1===2){
|
|
|
+ // 店铺满减-计算供应商总价/满减金额
|
|
|
+ if(supplierPrice >= item.promotions.touchPrice){
|
|
|
+ supplierPrice -= item.promotions.reducedPrice;
|
|
|
+ supplierReducedPrice += item.promotions.reducedPrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.totalprice = supplierPrice;
|
|
|
+ item.reducedprice = supplierReducedPrice;
|
|
|
+ item.originalprice = (supplierPrice+supplierReducedPrice);
|
|
|
+ totalPrice += item.totalprice;
|
|
|
+ reducedPrice += item.reducedprice;
|
|
|
+ originalPrice += item.originalprice;
|
|
|
})
|
|
|
- if(_isFlag){
|
|
|
- _promsPrice = _promsPrice - _reducedPromsPrice
|
|
|
- }
|
|
|
- this.totalOriginalPrice = totalOriginalPrice + _totalOriginalPrice;
|
|
|
- this.reducedPrice = reducedPrice + _reducedPrice + _reducedPromsPrice;
|
|
|
- this.allPrice = totalPrice + _totalPrice + _promsPrice + _totalNonePrice;
|
|
|
+ //总促销计算
|
|
|
+ this.promotionsList.forEach(promotions =>{
|
|
|
+ // 凑单满减
|
|
|
+ if(promotions.mode*1===2 && promotions.type*1===2){
|
|
|
+ let total = 0;
|
|
|
+ promotions.products.forEach(pros=>{
|
|
|
+ if (this.submitIds.includes(pros.productID*1)){
|
|
|
+ total += pros.productCount * pros.retailPrice;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(total>=promotions.touchPrice){
|
|
|
+ totalPrice -= promotions.reducedPrice;
|
|
|
+ reducedPrice += promotions.reducedPrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //最后统计商品原价
|
|
|
+ this.totalOriginalPrice = originalPrice;
|
|
|
+ //最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
|
|
|
+ this.reducedPrice = reducedPrice;
|
|
|
+ //最终合计价格 = 店铺满减合计 + 单品满减 + 正常合计 + 凑单满减
|
|
|
+ this.allPrice = totalPrice ;
|
|
|
},
|
|
|
totalCount(){//计算总数量
|
|
|
this.allCount = 0
|
|
@@ -593,6 +583,8 @@
|
|
|
},
|
|
|
toConfirmation(){//跳转确认订单页面
|
|
|
let setGoodsList=[];
|
|
|
+ let productIdList = [];
|
|
|
+ let productID = '';
|
|
|
this.goodsList.forEach(res=>{
|
|
|
let products = res.productsList
|
|
|
products.forEach(pros=>{
|
|
@@ -609,14 +601,36 @@
|
|
|
* @获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
|
|
|
* @获取勾选的商品分类ID拼接字符串格式逗号隔开,最后一个逗号去掉
|
|
|
*/
|
|
|
- let productID = '';
|
|
|
this.goodsList.forEach(el=>{
|
|
|
el.productsList.forEach(pros=>{
|
|
|
if(pros.productsChecked){
|
|
|
- productID += pros.productID+','
|
|
|
+ productIdList.push(pros.productID)
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
+ console.log(productIdList)
|
|
|
+ const isHasDepositlds = productIdList.filter(item =>this.depositIds.includes(item))
|
|
|
+ const isHasRechargeIds = productIdList.filter(item =>this.rechargeIds.includes(item))
|
|
|
+ console.log(isHasDepositlds)
|
|
|
+ console.log(isHasRechargeIds)
|
|
|
+ if(isHasDepositlds.length == 1){
|
|
|
+ productIdList.forEach(item =>{
|
|
|
+ productID += item +','
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.$util.modal('提示','缴纳定金商品或余额充值商品请单独下单!','确定','',false,() =>{})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(isHasRechargeIds.length == 1){
|
|
|
+ productIdList.forEach(item =>{
|
|
|
+ productID += item +','
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.$util.modal('提示','缴纳定金商品或余额充值商品请单独下单!','确定','',false,() =>{})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
let cartPramsData={
|
|
|
clubId:this.clubId,
|
|
|
allPrice:this.allPrice,
|
|
@@ -629,7 +643,6 @@
|
|
|
},
|
|
|
showDelManager(){//显示删除商品管理
|
|
|
this.isshowDelbtn = true;
|
|
|
- this.isNnder = true;
|
|
|
if(this.isCheckAll) {
|
|
|
this.updateBothCheckBtn();
|
|
|
} else {
|