|
|
@@ -63,7 +63,6 @@ export default {
|
|
|
},
|
|
|
allPrice() {
|
|
|
let price = 0;
|
|
|
- console.log('this.selectList总价',this.selectList)
|
|
|
if (this.selectList) {
|
|
|
for (const item of this.selectList) {
|
|
|
const itemInfo = this.getSelectItemById(item.id, item.classId);
|
|
|
@@ -73,12 +72,11 @@ export default {
|
|
|
!this.$util.isEmpty(itemInfo.smallPrice)
|
|
|
) {
|
|
|
if(item.userPrice>0){
|
|
|
- price += item.userPrice;
|
|
|
+ price += Number(item.userPrice);
|
|
|
}else{
|
|
|
price += item.bigCount * Number(itemInfo.bigPrice);
|
|
|
price += item.smallCount * Number(itemInfo.smallPrice);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -171,22 +169,7 @@ export default {
|
|
|
}
|
|
|
this.filterProductInfo = classList
|
|
|
},
|
|
|
- /**
|
|
|
- * 通过id获取当前选中的该商品信息
|
|
|
- */
|
|
|
- // getSelectItemInfoById(id, classId) {
|
|
|
- // let info = null;
|
|
|
- // const item =
|
|
|
- // this.productInfo &&
|
|
|
- // this.productInfo.forEach(element => {
|
|
|
- // if (element.classId == classId && element.child) {
|
|
|
- // info = element.child.find(ele => {
|
|
|
- // return ele.id == id;
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
- // return info;
|
|
|
- // },
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前选中商品总价
|
|
|
*/
|
|
|
@@ -254,10 +237,10 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 添加商品
|
|
|
+ * 添加花材
|
|
|
*/
|
|
|
addEvent(item) {
|
|
|
- console.log(item,'****')
|
|
|
+ console.log('新增花材',item)
|
|
|
const list = this.selectList;
|
|
|
let has = false;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
@@ -270,7 +253,6 @@ export default {
|
|
|
}else{
|
|
|
list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
}
|
|
|
-
|
|
|
}else{
|
|
|
if (this.isLimit) {
|
|
|
if (element.bigCount < item.bigNum) {
|
|
|
@@ -283,16 +265,12 @@ export default {
|
|
|
this.$msg("库存不足");
|
|
|
return;
|
|
|
}
|
|
|
- // else if (element.smallCount < item.smallNum) {
|
|
|
- // list[index] = { ...element, smallCount: ++element.smallCount };
|
|
|
- // }
|
|
|
} else {
|
|
|
if(this.isSmallCount){
|
|
|
list[index] = { ...element, smallCount: ++element.smallCount };
|
|
|
}else{
|
|
|
list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
}
|
|
|
- // list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
}
|
|
|
if (this.isLimit) {
|
|
|
const { bigCount, smallCount } = list[index];
|
|
|
@@ -308,14 +286,11 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!has) {
|
|
|
let info = { classId: item.classId, id: item.id };
|
|
|
-
|
|
|
const classInfo =
|
|
|
this.productInfo &&
|
|
|
this.productInfo.find(element => {
|
|
|
@@ -326,7 +301,6 @@ export default {
|
|
|
return ele.id == item.id;
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
let params = {
|
|
|
...info,
|
|
|
bigCount: this.isSmallCount?0:1, //扎数
|
|
|
@@ -344,9 +318,19 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //点加号时增加花材补充userPrice字段 shish 20210728
|
|
|
+ list.forEach(function(product,index,array){
|
|
|
+ console.log(product.id,item.id,'id')
|
|
|
+ if(product.id == item.id){
|
|
|
+ let ratio = product.ratio <= 0 ? 1 : product.ratio
|
|
|
+ let smallUnitPrice = (product.price / ratio).toFixed(2)
|
|
|
+ array[index].userPrice = ((product.bigCount*ratio + product.smallCount)*smallUnitPrice).toFixed(2)
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('花材列表',list)
|
|
|
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- // this.$forceUpdate();
|
|
|
},
|
|
|
|
|
|
addCustomNumEvent(item,params1,type) {
|
|
|
@@ -374,12 +358,10 @@ export default {
|
|
|
userPrice: null, //调价价格
|
|
|
};
|
|
|
list.push(params);
|
|
|
- console.log(list,'-----------')
|
|
|
if(type!='noAdd'){
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
}
|
|
|
this.$nextTick(()=>{
|
|
|
- console.log(9999)
|
|
|
this.customNum(params1)
|
|
|
})
|
|
|
},
|
|
|
@@ -387,6 +369,7 @@ export default {
|
|
|
* 减去商品
|
|
|
*/
|
|
|
delEvent(item) {
|
|
|
+ console.log('减少花材',item)
|
|
|
const list = copyObject(this.selectList);
|
|
|
let has = false;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
@@ -399,13 +382,22 @@ export default {
|
|
|
if (element.smallCount > 0) {
|
|
|
if(this.isSmallCount){list[index] = { ...element, smallCount: --element.smallCount };}
|
|
|
}
|
|
|
- if (element.bigCount == 0 && element.smallCount == 0) {
|
|
|
- list.splice(index, 1);
|
|
|
- }
|
|
|
+ if (element.bigCount == 0 && element.smallCount == 0) {
|
|
|
+ list.splice(index, 1);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ //点减号时减少花材补充userPrice字段 shish 20210728
|
|
|
+ list.forEach(function(product,index,array){
|
|
|
+ console.log(product.id,item.id,'id')
|
|
|
+ if(product.id == item.id){
|
|
|
+ let ratio = product.ratio <= 0 ? 1 : product.ratio
|
|
|
+ let smallUnitPrice = (product.price / ratio).toFixed(2)
|
|
|
+ array[index].userPrice = ((product.bigCount*ratio + product.smallCount)*smallUnitPrice).toFixed(2)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log('花材列表',list)
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- // this.$forceUpdate();
|
|
|
},
|
|
|
//减去所有商品
|
|
|
delAllEvent(item) {
|
|
|
@@ -428,21 +420,6 @@ export default {
|
|
|
}
|
|
|
console.log('this.selectList','减少花材之后:',this.selectList)
|
|
|
},
|
|
|
- // /**
|
|
|
- // * 删除商品
|
|
|
- // */
|
|
|
- // removeEvent(item) {
|
|
|
- // const list = this.selectList;
|
|
|
- // for (let index = list.length - 1; index >= 0; index--) {
|
|
|
- // const element = list[index];
|
|
|
- // if (element.id == item.id && element.classId == item.classId) {
|
|
|
- // list.splice(index, 1);
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- // // this.$forceUpdate();
|
|
|
- // },
|
|
|
/**
|
|
|
* 更新商品
|
|
|
*/
|
|
|
@@ -485,7 +462,6 @@ export default {
|
|
|
if(this.isReserve){
|
|
|
uni.setStorageSync('selectList', this.selectList);
|
|
|
}
|
|
|
- // this.$forceUpdate();
|
|
|
},
|
|
|
/**
|
|
|
* 切换左侧商品类别
|
|
|
@@ -568,7 +544,6 @@ export default {
|
|
|
// this.scrollPushList();
|
|
|
break;
|
|
|
}
|
|
|
- // console.log(this.classIndex,'this.classIndex----')
|
|
|
}
|
|
|
},
|
|
|
scroll_bottom(){
|