进入分类页的时候自动勾选左侧一级分类
parent
fd83bcf02a
commit
cc9f31f8c3
|
@ -133,14 +133,12 @@
|
||||||
|
|
||||||
onLoad(async (params) => {
|
onLoad(async (params) => {
|
||||||
await getList();
|
await getList();
|
||||||
// 从主页点进来的时候自动选中左侧一级菜单
|
|
||||||
const cateList = state.categoryList
|
// 首页点击分类的处理:查找满足条件的分类
|
||||||
for (let index = 0; index < cateList.length; index++) {
|
const foundCategory = state.categoryList.find(category => category.id == params.id);
|
||||||
if (cateList[index].id == params.id) {
|
// 如果找到则调用 onMenu 自动勾选相应分类,否则调用 onMenu(0) 勾选第一个分类
|
||||||
onMenu(index);
|
onMenu(foundCategory ? state.categoryList.indexOf(foundCategory) : 0);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 如果是 first 风格,需要加载商品分页
|
// 如果是 first 风格,需要加载商品分页
|
||||||
if (state.style === 'first_one' || state.style === 'first_two') {
|
if (state.style === 'first_one' || state.style === 'first_two') {
|
||||||
onMenu(0);
|
onMenu(0);
|
||||||
|
|
Loading…
Reference in New Issue