|
|
|
@ -39,7 +39,7 @@
|
|
|
|
|
class="tab-category-menu__right flex-1"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
v-for="item in categroyData"
|
|
|
|
|
v-for="item in list"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
@mouseenter="handleCategoryHover(item.id)"
|
|
|
|
|
class="category-menu-right__wrap"
|
|
|
|
@ -61,10 +61,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
|
|
|
|
ApiGetCategoryOneList,
|
|
|
|
|
ApiGetCategoryTwoAndGoods,
|
|
|
|
|
} from "@/plugins/api/goods";
|
|
|
|
|
import { mapState } from "vuex";
|
|
|
|
|
import { ApiGetCategoryTwoAndGoods } from "@/plugins/api/goods";
|
|
|
|
|
import { CATEGROY_LEVEL } from "@/constants";
|
|
|
|
|
const CATEGROY_HIDE_PAGES = [/\/account/]; // 隐藏热门分类tab的页面
|
|
|
|
|
|
|
|
|
@ -76,10 +74,11 @@ export default {
|
|
|
|
|
categroyTwoVisible: false, // 是否展示二级分类
|
|
|
|
|
categroyVisible: false, // 是否展示一级分类
|
|
|
|
|
currentCategroyId: 0, // 当前鼠标悬停的一级分类id
|
|
|
|
|
categroyData: [],
|
|
|
|
|
list: [],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
...mapState(["categroyData"]),
|
|
|
|
|
showCategroyTab() {
|
|
|
|
|
return !CATEGROY_HIDE_PAGES.some((reg) => {
|
|
|
|
|
return reg.test(this.$route.path);
|
|
|
|
@ -91,16 +90,21 @@ export default {
|
|
|
|
|
return this.$route.path === "/";
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
watch: {
|
|
|
|
|
categroyData: {
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler(val) {
|
|
|
|
|
if (val.length > 0) {
|
|
|
|
|
this.getCategroyData();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 获取热门分类信息
|
|
|
|
|
async getCategroyData() {
|
|
|
|
|
const { result } = await ApiGetCategoryOneList();
|
|
|
|
|
if (result && result.length > 0) {
|
|
|
|
|
this.categroyData = await Promise.all(
|
|
|
|
|
result.map(async (item) => {
|
|
|
|
|
this.list = await Promise.all(
|
|
|
|
|
this.categroyData.map(async (item) => {
|
|
|
|
|
const { result: resultGoods } = await ApiGetCategoryTwoAndGoods({
|
|
|
|
|
categoryId: item.id,
|
|
|
|
|
});
|
|
|
|
@ -112,7 +116,6 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 一级分类鼠标悬停
|
|
|
|
|
handleCategoryHover(id) {
|
|
|
|
|