2023-3-15
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import store from '../store/index';
|
import store from '../store/index';
|
||||||
export default {
|
export default {
|
||||||
// qq 237524947 wx15d4269d3210863d
|
// qq 237524947 wx15d4269d3210863d
|
||||||
BASEURI: 'http://192.168.3.9:8111/api/',
|
BASEURI: 'http://192.168.3.9:8083/api/',
|
||||||
// BASEURI: 'http://mall.yyundong.com/portalapi/api/',
|
// BASEURI: 'http://mall.yyundong.com/portalapi/api/',
|
||||||
// BASEURI: 'http://192.168.31.52:8083/api/',
|
// BASEURI: 'http://192.168.31.52:8083/api/',
|
||||||
ADMINURI: 'http://mall.yyundong.com/adminapi/',
|
ADMINURI: 'http://mall.yyundong.com/adminapi/',
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
sizeCalcState: false,
|
sizeCalcState: false,
|
||||||
tabScrollTop: 0,
|
tabScrollTop: 0,
|
||||||
currentId: 1,
|
currentId: 1,
|
||||||
|
list: [],
|
||||||
flist: [],
|
flist: [],
|
||||||
slist: [],
|
slist: [],
|
||||||
tlist: [],
|
tlist: [],
|
||||||
@@ -75,27 +76,67 @@
|
|||||||
async loadData() {
|
async loadData() {
|
||||||
|
|
||||||
// let list = this.$db.get('categoryList')
|
// let list = this.$db.get('categoryList')
|
||||||
let list=[]
|
this.flist = []
|
||||||
this.flist =[]
|
this.slist = []
|
||||||
this.tlist = []
|
this.tlist = []
|
||||||
// if (!list) {
|
// if (!list) {
|
||||||
let params = {};
|
let params = {};
|
||||||
list = await Api.apiCall('get', Api.goods.typeGoodsList, params);
|
this.list = await Api.apiCall('get', Api.goods.typeGoodsList, params);
|
||||||
console.log("list>>>>>", list);
|
console.log("list>>>>>", this.list);
|
||||||
this.$db.set('categoryList', list)
|
this.$db.set('categoryList', this.list)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (list) {
|
if (this.list) {
|
||||||
list.forEach(item => {
|
|
||||||
|
|
||||||
if (item.level == 0) {
|
// 一级分类
|
||||||
this.flist.push(item); //pid为父级id, 没有pid或者pid=0是一级分类
|
this.flist = this.list.filter((item) => item.level == 0)
|
||||||
} else if (item.level == 1) {
|
console.log("flist", this.flist.length)
|
||||||
this.slist.push(item); //没有价格的是2级分类
|
console.log("flist", this.flist)
|
||||||
} else {
|
const pid = this.flist[0].id
|
||||||
this.tlist.push(item); //3级分类
|
this.currentId = pid
|
||||||
|
|
||||||
|
// 二级分类
|
||||||
|
let list2 = this.list.filter((item) => item.level == 1)
|
||||||
|
|
||||||
|
for (var j = 0; j < list2.length; j++) {
|
||||||
|
const pid2 = list2[j].pid
|
||||||
|
if (pid2 == pid) {
|
||||||
|
this.slist.push(list2[j])
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
console.log("this.slist", this.slist)
|
||||||
|
|
||||||
|
// 三级分类
|
||||||
|
let list3 = this.list.filter((item) => item.level == 2)
|
||||||
|
|
||||||
|
for (var i = 0; i < this.slist.length; i++) {
|
||||||
|
const pid2 = this.slist[i].id
|
||||||
|
for (var j = 0; j < list3.length; j++) {
|
||||||
|
const pid3 = list3[j].pid
|
||||||
|
if (pid3 == pid2) {
|
||||||
|
this.tlist.push(list3[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log("this.tlist", this.tlist)
|
||||||
|
|
||||||
|
// // 三级分类
|
||||||
|
// this.tlist = slist.filter((item) => item.level == 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// list.forEach(item => {
|
||||||
|
|
||||||
|
// if (item.level == 0) {
|
||||||
|
// this.flist.push(item); //pid为父级id, 没有pid或者pid=0是一级分类
|
||||||
|
// } else if (item.level == 1) {
|
||||||
|
// this.slist.push(item); //没有价格的是2级分类
|
||||||
|
// } else {
|
||||||
|
// this.tlist.push(item); //3级分类
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -106,7 +147,37 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.currentId = item.id;
|
this.currentId = item.id;
|
||||||
console.log(item.id);
|
this.slist = []
|
||||||
|
this.tlist = []
|
||||||
|
|
||||||
|
// 二级分类
|
||||||
|
let list2 = this.list.filter((item) => item.level == 1)
|
||||||
|
|
||||||
|
for (var j = 0; j < list2.length; j++) {
|
||||||
|
const pid2 = list2[j].pid
|
||||||
|
if (pid2 == this.currentId) {
|
||||||
|
this.slist.push(list2[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("this.slist", this.slist)
|
||||||
|
|
||||||
|
// 三级分类
|
||||||
|
let list3 = this.list.filter((item) => item.level == 2)
|
||||||
|
|
||||||
|
for (var i = 0; i < this.slist.length; i++) {
|
||||||
|
const pid2 = this.slist[i].id
|
||||||
|
for (var j = 0; j < list3.length; j++) {
|
||||||
|
const pid3 = list3[j].pid
|
||||||
|
if (pid3 == pid2) {
|
||||||
|
this.tlist.push(list3[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log("this.tlist", this.tlist)
|
||||||
|
|
||||||
|
|
||||||
let index = this.slist.findIndex(sitem => sitem.pid === item.id);
|
let index = this.slist.findIndex(sitem => sitem.pid === item.id);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
this.tabScrollTop = this.slist[index].top;
|
this.tabScrollTop = this.slist[index].top;
|
||||||
|
|||||||
Reference in New Issue
Block a user