Browse Source

2023-3-15

master
guoxing 2 years ago
parent
commit
127580e43f
  1. 2
      mallplusui-uniapp-app/common/api.js
  2. 105
      mallplusui-uniapp-app/pages/category/category.vue

2
mallplusui-uniapp-app/common/api.js

@ -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/',

105
mallplusui-uniapp-app/pages/category/category.vue

@ -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); //pidid, pidpid=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); //pidid, pidpid=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;

Loading…
Cancel
Save