!74 进入分类页的时候自动勾选左侧一级分类(比如从首页进入)

Merge pull request !74 from 卢越/master
pull/75/MERGE
芋道源码 2024-08-10 02:23:32 +00:00 committed by Gitee
commit 92b9820f20
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 7 additions and 1 deletions

View File

@ -131,8 +131,14 @@
getGoodsList();
}
onLoad(async () => {
onLoad(async (params) => {
await getList();
// 首页点击分类的处理:查找满足条件的分类
const foundCategory = state.categoryList.find(category => category.id == params.id);
// 如果找到则调用 onMenu 自动勾选相应分类,否则调用 onMenu(0) 勾选第一个分类
onMenu(foundCategory ? state.categoryList.indexOf(foundCategory) : 0);
// 如果是 first 风格,需要加载商品分页
if (state.style === 'first_one' || state.style === 'first_two') {
onMenu(0);