|
|
@ -1,5 +1,6 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div class="layout-header">
|
|
|
|
<div class="layout-header">
|
|
|
|
|
|
|
|
<!-- 滚动吸顶头部 -->
|
|
|
|
<template v-if="isSticky">
|
|
|
|
<template v-if="isSticky">
|
|
|
|
<div class="sticky-bar-header">
|
|
|
|
<div class="sticky-bar-header">
|
|
|
|
<div class="sticky-bar-header__wrap flex flex-middle flex-between">
|
|
|
|
<div class="sticky-bar-header__wrap flex flex-middle flex-between">
|
|
|
@ -75,6 +76,7 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 热门分类 -->
|
|
|
|
<div class="bar-header-box__tab flex flex-middle">
|
|
|
|
<div class="bar-header-box__tab flex flex-middle">
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
v-show="showCategroyTab"
|
|
|
|
v-show="showCategroyTab"
|
|
|
@ -88,17 +90,21 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
v-show="isCategroyOpen || categroyVisible"
|
|
|
|
v-show="isCategroyOpen || categroyVisible"
|
|
|
|
class="tab-category__menu flex flex-left"
|
|
|
|
class="tab-category__menu flex"
|
|
|
|
@mouseenter="handleCategoryTwoChange(true)"
|
|
|
|
@mouseenter="handleCategoryTwoChange(true)"
|
|
|
|
@mouseleave="handleCategoryTwoChange(false)"
|
|
|
|
@mouseleave="handleCategoryTwoChange(false)"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<!-- 左侧一级分类 -->
|
|
|
|
<!-- 左侧一级分类 -->
|
|
|
|
<div class="tab-category-menu__left">
|
|
|
|
<div class="tab-category-menu__left">
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
v-for="item in categrayData"
|
|
|
|
v-for="item in categroyData"
|
|
|
|
:key="item.id"
|
|
|
|
:key="item.id"
|
|
|
|
@mouseenter="handleCategorySelect(item.id)"
|
|
|
|
@mouseenter="handleCategoryHover(item.id)"
|
|
|
|
|
|
|
|
@click="onCategoryClick(item.id, CATEGROY_LEVEL.ONE)"
|
|
|
|
class="menu-left__item flex flex-middle"
|
|
|
|
class="menu-left__item flex flex-middle"
|
|
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
|
|
'menu-left__item--light': item.id === currentCategroyId,
|
|
|
|
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<img />
|
|
|
|
<img />
|
|
|
|
<span>{{ item.name }}</span>
|
|
|
|
<span>{{ item.name }}</span>
|
|
|
@ -107,15 +113,25 @@
|
|
|
|
<!-- 右侧二级分类 -->
|
|
|
|
<!-- 右侧二级分类 -->
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
v-show="categroyTwoVisible"
|
|
|
|
v-show="categroyTwoVisible"
|
|
|
|
class="tab-category-menu__right"
|
|
|
|
class="tab-category-menu__right flex-1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
v-for="item in currentCategrayList"
|
|
|
|
v-for="item in categroyData"
|
|
|
|
:key="item.id"
|
|
|
|
:key="item.id"
|
|
|
|
class="menu-right__item"
|
|
|
|
@mouseenter="handleCategoryHover(item.id)"
|
|
|
|
@click="onCateogryTwoClick(item)"
|
|
|
|
class="category-menu-right__wrap"
|
|
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
|
|
'category-menu-right__wrap--light':
|
|
|
|
|
|
|
|
item.id === currentCategroyId,
|
|
|
|
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{{ item.name }}
|
|
|
|
<span
|
|
|
|
|
|
|
|
v-for="itemList in item.list"
|
|
|
|
|
|
|
|
:key="itemList.id"
|
|
|
|
|
|
|
|
class="menu-right-wrap__item"
|
|
|
|
|
|
|
|
@click="onCategoryClick(itemList.id, CATEGROY_LEVEL.TWO)"
|
|
|
|
|
|
|
|
>{{ itemList.name }}</span
|
|
|
|
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -141,11 +157,12 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import { mapState } from "vuex";
|
|
|
|
import { mapState } from "vuex";
|
|
|
|
import HeaderInfoBar from "./HeaderInfoBar.vue";
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
ApiGetCategoryOneList,
|
|
|
|
ApiGetCategoryOneList,
|
|
|
|
ApiGetCategoryTwoAndGoods,
|
|
|
|
ApiGetCategoryTwoAndGoods,
|
|
|
|
} from "@/plugins/api/goods";
|
|
|
|
} from "@/plugins/api/goods";
|
|
|
|
|
|
|
|
import { CATEGROY_LEVEL } from "@/constants";
|
|
|
|
|
|
|
|
import HeaderInfoBar from "./HeaderInfoBar.vue";
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: "DefaultHeader",
|
|
|
|
name: "DefaultHeader",
|
|
|
@ -177,28 +194,29 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
CATEGROY_LEVEL,
|
|
|
|
searchContent: "",
|
|
|
|
searchContent: "",
|
|
|
|
tabPath: "/",
|
|
|
|
tabPath: "/",
|
|
|
|
tabList: [
|
|
|
|
tabList: [
|
|
|
|
{ label: "首页", value: "/" },
|
|
|
|
{ label: "首页", value: "/" },
|
|
|
|
{ label: "爆款推荐", value: "/goods/list?id=1" },
|
|
|
|
{
|
|
|
|
{ label: "开发书籍", value: "/goods/list?id=2" },
|
|
|
|
label: "爆款推荐",
|
|
|
|
|
|
|
|
value: `/goods/list?id=recommend`,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: "开发书籍",
|
|
|
|
|
|
|
|
value: `/goods/list?id=6&levelType=${CATEGROY_LEVEL.ONE}`,
|
|
|
|
|
|
|
|
},
|
|
|
|
{ label: "限时秒杀", value: "/sckill" },
|
|
|
|
{ label: "限时秒杀", value: "/sckill" },
|
|
|
|
],
|
|
|
|
],
|
|
|
|
categroyTwoVisible: false, // 是否展示二级分类
|
|
|
|
categroyTwoVisible: false, // 是否展示二级分类
|
|
|
|
categroyVisible: false, // 是否展示一级分类
|
|
|
|
categroyVisible: false, // 是否展示一级分类
|
|
|
|
currentCategrayId: 0, // 当前鼠标悬停的一级分类id
|
|
|
|
currentCategroyId: 0, // 当前鼠标悬停的一级分类id
|
|
|
|
categrayData: [],
|
|
|
|
categroyData: [],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
|
...mapState(["userInfo", "token"]),
|
|
|
|
...mapState(["userInfo", "token"]),
|
|
|
|
currentCategrayList() {
|
|
|
|
|
|
|
|
const data = this.categrayData.find(({ id }) => {
|
|
|
|
|
|
|
|
return this.currentCategrayId === id;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return (data && data.list) || [];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.getCategroyData();
|
|
|
|
this.getCategroyData();
|
|
|
@ -207,24 +225,35 @@ export default {
|
|
|
|
onLoginClick() {
|
|
|
|
onLoginClick() {
|
|
|
|
this.$isLoginValidate();
|
|
|
|
this.$isLoginValidate();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 一级分类选中
|
|
|
|
// 一级分类鼠标悬停
|
|
|
|
handleCategorySelect(id) {
|
|
|
|
handleCategoryHover(id) {
|
|
|
|
this.currentCategrayId = id;
|
|
|
|
this.currentCategroyId = id;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 二级分类点击
|
|
|
|
// 分类点击
|
|
|
|
onCateogryTwoClick() {
|
|
|
|
onCategoryClick(id, levelType) {
|
|
|
|
this.$router.push("/goods/list");
|
|
|
|
this.categroyVisible = false;
|
|
|
|
|
|
|
|
this.categroyTwoVisible = false;
|
|
|
|
|
|
|
|
this.$router.push({
|
|
|
|
|
|
|
|
path: "/goods/list",
|
|
|
|
|
|
|
|
query: {
|
|
|
|
|
|
|
|
id,
|
|
|
|
|
|
|
|
levelType,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 一级分类是否可见
|
|
|
|
// 一级分类是否可见
|
|
|
|
handleCategoryChange(val) {
|
|
|
|
handleCategoryChange(val) {
|
|
|
|
this.categroyVisible = val;
|
|
|
|
this.categroyVisible = val;
|
|
|
|
|
|
|
|
if (!val) {
|
|
|
|
|
|
|
|
this.currentCategroyId = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 二级分类是否可见
|
|
|
|
// 二级分类是否可见
|
|
|
|
handleCategoryTwoChange(val) {
|
|
|
|
handleCategoryTwoChange(val) {
|
|
|
|
this.categroyTwoVisible = val;
|
|
|
|
this.categroyTwoVisible = val;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handleTabSelect(path) {
|
|
|
|
handleTabSelect(value) {
|
|
|
|
this.$router.push({ path });
|
|
|
|
this.$router.push({ path: value });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onTabSelect({ value }) {
|
|
|
|
onTabSelect({ value }) {
|
|
|
|
this.tabPath = value;
|
|
|
|
this.tabPath = value;
|
|
|
@ -240,7 +269,7 @@ export default {
|
|
|
|
async getCategroyData() {
|
|
|
|
async getCategroyData() {
|
|
|
|
const { result } = await ApiGetCategoryOneList();
|
|
|
|
const { result } = await ApiGetCategoryOneList();
|
|
|
|
if (result && result.length > 0) {
|
|
|
|
if (result && result.length > 0) {
|
|
|
|
this.categrayData = await Promise.all(
|
|
|
|
this.categroyData = await Promise.all(
|
|
|
|
result.map(async (item) => {
|
|
|
|
result.map(async (item) => {
|
|
|
|
const { result: resultGoods } = await ApiGetCategoryTwoAndGoods({
|
|
|
|
const { result: resultGoods } = await ApiGetCategoryTwoAndGoods({
|
|
|
|
categoryId: item.id,
|
|
|
|
categoryId: item.id,
|
|
|
@ -436,13 +465,14 @@ export default {
|
|
|
|
width: 190px;
|
|
|
|
width: 190px;
|
|
|
|
padding: 15px 0;
|
|
|
|
padding: 15px 0;
|
|
|
|
background: #ffffff;
|
|
|
|
background: #ffffff;
|
|
|
|
.menu-left__item:hover {
|
|
|
|
|
|
|
|
color: #ff875b;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-left__item {
|
|
|
|
.menu-left__item {
|
|
|
|
height: 50px;
|
|
|
|
height: 50px;
|
|
|
|
cursor: pointer;
|
|
|
|
cursor: pointer;
|
|
|
|
padding: 0 24px 0 41px;
|
|
|
|
padding: 0 24px 0 41px;
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
|
|
|
|
&--light {
|
|
|
|
|
|
|
|
color: #ff875b;
|
|
|
|
|
|
|
|
}
|
|
|
|
img {
|
|
|
|
img {
|
|
|
|
width: 20px;
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
height: 20px;
|
|
|
@ -451,20 +481,29 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.tab-category-menu__right {
|
|
|
|
.tab-category-menu__right {
|
|
|
|
width: 510px;
|
|
|
|
padding: 15px 26px;
|
|
|
|
padding: 30px 26px;
|
|
|
|
|
|
|
|
box-shadow: 7px 0px 10px 1px rgba(0, 0, 0, 0.1);
|
|
|
|
box-shadow: 7px 0px 10px 1px rgba(0, 0, 0, 0.1);
|
|
|
|
border: 1px solid #eeeeee;
|
|
|
|
border: 1px solid #eeeeee;
|
|
|
|
background: #ffffff;
|
|
|
|
background: #ffffff;
|
|
|
|
.menu-right__item:hover {
|
|
|
|
.category-menu-right__wrap {
|
|
|
|
color: #ff875b;
|
|
|
|
height: 50px;
|
|
|
|
}
|
|
|
|
line-height: 50px;
|
|
|
|
.menu-right__item {
|
|
|
|
padding: 0 16px;
|
|
|
|
display: inline-block;
|
|
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
font-size: 12px;
|
|
|
|
color: #999999;
|
|
|
|
color: #999999;
|
|
|
|
margin-right: 20px;
|
|
|
|
white-space: nowrap;
|
|
|
|
cursor: pointer;
|
|
|
|
&:hover,
|
|
|
|
|
|
|
|
&--light {
|
|
|
|
|
|
|
|
background: #f8f8f8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-right-wrap__item {
|
|
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
|
|
margin-right: 20px;
|
|
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
|
|
color: #ff875b;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|