|
|
@@ -31,6 +31,7 @@ export default {
|
|
|
globalCustomId:0,
|
|
|
globalClassData:[],
|
|
|
globalClassId:0,
|
|
|
+ globalClassDataIndex:[],
|
|
|
globalFinishGetItem:0,
|
|
|
globalPage:1,
|
|
|
globalPy:'',
|
|
|
@@ -142,6 +143,7 @@ export default {
|
|
|
getMenu().then(res=>{
|
|
|
if(res.code == 1){
|
|
|
that.globalClassData = res.data.class ? res.data.class : []
|
|
|
+ that.globalClassDataIndex = res.data.classIndex ? res.data.classIndex : []
|
|
|
if(that.globalClassData[0]){
|
|
|
that.globalClassId = that.globalClassData[0].id
|
|
|
//保存到仓库
|
|
|
@@ -178,6 +180,13 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ sorts_fun(arr) {
|
|
|
+ return function(a, b) {
|
|
|
+ var v1 = a[arr];
|
|
|
+ var v2 = b[arr];
|
|
|
+ return v1 - v2;
|
|
|
+ }
|
|
|
+ },
|
|
|
globalRememberRefresh(){
|
|
|
let that = this
|
|
|
if(that.$util.isEmpty(that.globalItemData)){
|
|
|
@@ -191,9 +200,13 @@ export default {
|
|
|
}
|
|
|
//修改数据需要复制一份,否则不会生效
|
|
|
that.globalItemData = copyObject(that.globalItemData);
|
|
|
+
|
|
|
+ that.globalItemData = that.globalItemData.sort(this.sorts_fun('classId'))
|
|
|
+ let hasExists = []
|
|
|
for (let i=0;i<that.globalItemData.length;i++){
|
|
|
let currentProduct = that.globalItemData[i]
|
|
|
let currentPId = currentProduct.id
|
|
|
+ let currentClassId = currentProduct.classId||0
|
|
|
let selectProduct = selectListData[currentPId] || []
|
|
|
if(!that.$util.isEmpty(selectProduct)){
|
|
|
that.globalItemData[i].bigCount = selectProduct.bigCount || 0
|
|
|
@@ -204,6 +217,15 @@ export default {
|
|
|
that.globalItemData[i].userPrice = 0
|
|
|
that.globalItemData[i].smallCount = 0
|
|
|
}
|
|
|
+ let cName = ''
|
|
|
+ if(hasExists[currentClassId]){
|
|
|
+ //无操作
|
|
|
+ }else{
|
|
|
+ let currentClass = this.globalClassDataIndex[currentClassId] ? this.globalClassDataIndex[currentClassId] : null
|
|
|
+ cName = currentClass.name ? currentClass.name : ''
|
|
|
+ hasExists[currentClassId] = 1
|
|
|
+ }
|
|
|
+ that.globalItemData[i].className = cName
|
|
|
}
|
|
|
},
|
|
|
globalSwitchClass(cur,item) {
|