|
|
|
@ -15,7 +15,7 @@
|
|
|
|
|
<el-menu
|
|
|
|
|
:default-active="tabPath"
|
|
|
|
|
mode="horizontal"
|
|
|
|
|
@select="handleTabSelect"
|
|
|
|
|
@select="onTabSelect"
|
|
|
|
|
>
|
|
|
|
|
<el-menu-item
|
|
|
|
|
v-for="item in tabList"
|
|
|
|
@ -32,7 +32,7 @@
|
|
|
|
|
/>
|
|
|
|
|
<div class="header-wrap-icons__shop" @click="$router.push('/cart')">
|
|
|
|
|
<img src="~/assets/img/layout/icon-shop-sticky.png" />
|
|
|
|
|
<span class="">3</span>
|
|
|
|
|
<span v-if="cartCount > 0" class="">{{ cartCount }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
v-if="token"
|
|
|
|
@ -66,6 +66,7 @@
|
|
|
|
|
<div class="search-input">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="searchContent"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请输入商品名称"
|
|
|
|
|
></el-input>
|
|
|
|
|
</div>
|
|
|
|
@ -82,7 +83,9 @@
|
|
|
|
|
>
|
|
|
|
|
<img src="~/assets/img/layout/icon-shop.png" />
|
|
|
|
|
<span>购物车</span>
|
|
|
|
|
<div class="wrap-right-cart__tip">3</div>
|
|
|
|
|
<div v-if="cartCount > 0" class="wrap-right-cart__tip">
|
|
|
|
|
{{ cartCount }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -154,7 +157,7 @@
|
|
|
|
|
'header-box-tab__common--light':
|
|
|
|
|
item.value === $nuxt.$route.fullPath,
|
|
|
|
|
}"
|
|
|
|
|
@click="onTabSelect(item)"
|
|
|
|
|
@click="onTabSelect(item.value)"
|
|
|
|
|
>
|
|
|
|
|
{{ item.label }}
|
|
|
|
|
</div>
|
|
|
|
@ -171,6 +174,7 @@ import {
|
|
|
|
|
ApiGetCategoryOneList,
|
|
|
|
|
ApiGetCategoryTwoAndGoods,
|
|
|
|
|
} from "@/plugins/api/goods";
|
|
|
|
|
import { ApiGetCartList } from "@/plugins/api/cart";
|
|
|
|
|
import { CATEGROY_LEVEL } from "@/constants";
|
|
|
|
|
import HeaderInfoBar from "./HeaderInfoBar.vue";
|
|
|
|
|
|
|
|
|
@ -213,25 +217,39 @@ export default {
|
|
|
|
|
CATEGROY_LEVEL,
|
|
|
|
|
searchContent: "",
|
|
|
|
|
tabPath: "/",
|
|
|
|
|
tabList: [
|
|
|
|
|
{ label: "首页", value: "/" },
|
|
|
|
|
{
|
|
|
|
|
label: "开发书籍",
|
|
|
|
|
value: `/goods/list?id=6&levelType=${CATEGROY_LEVEL.ONE}`,
|
|
|
|
|
},
|
|
|
|
|
{ label: "限时秒杀", value: "/seckill" },
|
|
|
|
|
],
|
|
|
|
|
categroyTwoVisible: false, // 是否展示二级分类
|
|
|
|
|
categroyVisible: false, // 是否展示一级分类
|
|
|
|
|
currentCategroyId: 0, // 当前鼠标悬停的一级分类id
|
|
|
|
|
categroyData: [],
|
|
|
|
|
cartCount: 0, // 购物车商品数
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
...mapState(["userInfo", "token"]),
|
|
|
|
|
...mapState(["userInfo", "token", "seckillTabVisible"]),
|
|
|
|
|
tabList() {
|
|
|
|
|
const defaultList = [
|
|
|
|
|
{ label: "首页", value: "/" },
|
|
|
|
|
{
|
|
|
|
|
label: "开发书籍",
|
|
|
|
|
value: `/goods/list?id=6&levelType=${CATEGROY_LEVEL.ONE}`,
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
];
|
|
|
|
|
if (this.seckillTabVisible) {
|
|
|
|
|
return [...defaultList, { label: "限时秒杀", value: "/seckill" }];
|
|
|
|
|
}
|
|
|
|
|
return defaultList;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
"$route.path"(val) {
|
|
|
|
|
if (val !== "/goods/list") {
|
|
|
|
|
this.searchContent = "";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getCategroyData();
|
|
|
|
|
this.getCartInfo();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
onLoginClick() {
|
|
|
|
@ -264,11 +282,9 @@ export default {
|
|
|
|
|
handleCategoryTwoChange(val) {
|
|
|
|
|
this.categroyTwoVisible = val;
|
|
|
|
|
},
|
|
|
|
|
handleTabSelect(value) {
|
|
|
|
|
this.$router.push({ path: value });
|
|
|
|
|
},
|
|
|
|
|
onTabSelect({ value }) {
|
|
|
|
|
onTabSelect(value) {
|
|
|
|
|
this.tabPath = value;
|
|
|
|
|
this.searchContent = "";
|
|
|
|
|
this.$router.push({ path: value });
|
|
|
|
|
},
|
|
|
|
|
onJumpCart() {
|
|
|
|
@ -277,6 +293,14 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
this.$router.push("/cart");
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取购物车信息
|
|
|
|
|
async getCartInfo() {
|
|
|
|
|
const { result } = await ApiGetCartList();
|
|
|
|
|
if (result) {
|
|
|
|
|
this.cartCount = result.number;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 获取热门分类信息
|
|
|
|
|
async getCategroyData() {
|
|
|
|
|
const { result } = await ApiGetCategoryOneList();
|
|
|
|
|