|
|
@@ -200,28 +200,75 @@ export default {
|
|
|
return has;
|
|
|
}
|
|
|
},
|
|
|
+ onShow(){
|
|
|
+ if(this.pageType == 'cg' && !this.$util.isEmpty(this.option.id)){
|
|
|
+ //在initGhsData()获取记忆的花材,保证价格有变时取到最新价格
|
|
|
+ }else{
|
|
|
+ if(uni.getStorageSync('selectList'+this.pageType)){
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: uni.getStorageSync('selectList'+this.pageType) })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
...mapActions(["setSelectInfoByType", "resetSelectInfoByType"]),
|
|
|
- /**
|
|
|
- * 请求商品数据
|
|
|
- */
|
|
|
+ //记忆已选的花材
|
|
|
+ rememberProduct(){
|
|
|
+ if(this.pageType == 'cg' && !this.$util.isEmpty(this.option.id)){
|
|
|
+ uni.setStorageSync('selectList'+this.pageType+'_ghs_'+this.option.id, this.selectList)
|
|
|
+ }else{
|
|
|
+ uni.setStorageSync('selectList'+this.pageType, this.selectList)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //清除已记忆花材
|
|
|
+ removeMemory(ghsId){
|
|
|
+ if(ghsId){
|
|
|
+ uni.removeStorageSync('selectList'+this.pageType+'_ghs_'+ghsId);
|
|
|
+ }else{
|
|
|
+ uni.removeStorageSync('selectList'+this.pageType);
|
|
|
+ }
|
|
|
+ this.resetSelectInfoByType(this.pageType);
|
|
|
+ },
|
|
|
+ //采购时请求供应商花材
|
|
|
async initGhsData(id,shopId) {
|
|
|
- //extendInfo调用时的扩展参数 如 shopId
|
|
|
+ //extendInfo调用时的扩展参数,如shopId
|
|
|
try {
|
|
|
let params = {
|
|
|
py: this.py,
|
|
|
id:id,
|
|
|
shopId:shopId
|
|
|
};
|
|
|
+ let directList = [];
|
|
|
const { data } = await getGhsProductList(params);
|
|
|
data.forEach(element => {
|
|
|
element.child &&
|
|
|
element.child.forEach(child => {
|
|
|
+
|
|
|
+ //价格如果有改动,记忆的花材价格需要改掉 shish 20210811
|
|
|
+ directList[child.id] = child
|
|
|
+
|
|
|
child.classId = element.classId;
|
|
|
child.className = element.className;
|
|
|
});
|
|
|
});
|
|
|
this.productInfo = data;
|
|
|
+
|
|
|
+ if(this.pageType == 'cg' && !this.$util.isEmpty(this.option.id)){
|
|
|
+ if(uni.getStorageSync('selectList'+this.pageType+'_ghs_'+this.option.id)){
|
|
|
+ let currentInfo = uni.getStorageSync('selectList'+this.pageType+'_ghs_'+this.option.id)
|
|
|
+ if(!this.$util.isEmpty(currentInfo)){
|
|
|
+ currentInfo.forEach((currentItem,currentIndex,currentArray)=>{
|
|
|
+ let currentId = currentItem.id
|
|
|
+ if(directList[currentId]){
|
|
|
+ //价格如果有改动,记忆花材的价格需要更新 shish 20210811
|
|
|
+ currentArray[currentIndex].bigPrice = directList[currentId].bigPrice
|
|
|
+ currentArray[currentIndex].smallPrice = directList[currentId].smallPrice
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: currentInfo })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.classIndex = 0;
|
|
|
this.scroll_into_view = 'class_0';
|
|
|
this.scrollPushList();
|
|
|
@@ -507,10 +554,7 @@ export default {
|
|
|
}
|
|
|
return info;
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加商品
|
|
|
- */
|
|
|
+ //添加商品
|
|
|
addEvent(item) {
|
|
|
const list = this.selectList;
|
|
|
let has = false;
|
|
|
@@ -581,7 +625,16 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ console.log('花材列表',list)
|
|
|
+
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
+
|
|
|
+ console.log('this.selectList',this.selectList)
|
|
|
+
|
|
|
+ //记忆已经选择的花材
|
|
|
+ this.rememberProduct()
|
|
|
+
|
|
|
},
|
|
|
|
|
|
addCustomNumEvent(item,params1,type) {
|
|
|
@@ -610,10 +663,12 @@ export default {
|
|
|
this.$nextTick(()=>{
|
|
|
this.customNum(params1)
|
|
|
})
|
|
|
+
|
|
|
+ //记忆已经选择的花材
|
|
|
+ this.rememberProduct()
|
|
|
+
|
|
|
},
|
|
|
- /**
|
|
|
- * 减去商品
|
|
|
- */
|
|
|
+ //减去商品
|
|
|
delEvent(item) {
|
|
|
|
|
|
const list = copyObject(this.selectList);
|
|
|
@@ -638,6 +693,9 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.setSelectInfoByType({type: this.pageType, info: list});
|
|
|
+ console.log('this.selectList','减少花材之后:',this.selectList)
|
|
|
+ //记忆已经选择的花材
|
|
|
+ this.rememberProduct()
|
|
|
},
|
|
|
delAllEvent(item) {
|
|
|
const list = this.selectList;
|
|
|
@@ -649,6 +707,10 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
+
|
|
|
+ console.log('this.selectList','减少花材之后:',this.selectList)
|
|
|
+ //记忆已经选择的花材
|
|
|
+ this.rememberProduct()
|
|
|
},
|
|
|
/**
|
|
|
* 通过id获取当前选中的商品类别信息 左边菜单角标 当前选中该类别商品多少件
|
|
|
@@ -813,7 +875,10 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- // this.$forceUpdate();
|
|
|
+
|
|
|
+ //记忆已经选择的花材
|
|
|
+ this.rememberProduct()
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 切换左侧商品类别
|