Commit e775c8bd by 林家欣

修改搜索页显示逻辑

parent 9bca8256
......@@ -74,6 +74,7 @@ import HeaderDropdown from "./HeaderDropdown.vue";
import { nav } from "./mock";
import Qs from "qs";
import { cleanObject } from "@/axios/parameter";
import { deepFindBreadcrumb } from "@/utils/utils";
export default {
components: { HeaderBtn, HeaderDropdown },
......@@ -103,11 +104,11 @@ export default {
} else {
// TODO 去dropdown里面精确查找当前的路径
let result;
result = this.comparePath(nav_.children, this.$route.path);
result = deepFindBreadcrumb(nav_.children, this.$route.path);
if (!result && Object.keys(this.$route.query).length > 0) {
const queryString = Qs.stringify(cleanObject(this.$route.query));
let path = `${this.$route.path}?${queryString}`;
result = this.comparePath(nav_.children, path);
result = deepFindBreadcrumb(nav_.children, path);
}
result &&
result.breadcrumb &&
......@@ -123,28 +124,6 @@ export default {
window.removeEventListener("click", this.handleWindowClick);
},
methods: {
comparePath(arr, activePath) {
let current = [];
const deep = (arr, activePath) => {
for (let i = 0; i < arr.length; i += 1) {
if (
arr[i].link !== activePath &&
arr[i].children &&
arr[i].children.length > 0
) {
deep(arr[i].children, activePath);
} else if (arr[i].link === activePath) {
current = arr[i];
break;
}
if (current.length > 0) {
break;
}
}
};
deep(arr, activePath);
return current;
},
handleWindowClick() {
// console.log('handleWindowClick', this.fromNav, this.preActive);
if (this.preActive && !this.fromNav) {
......
......@@ -16,7 +16,12 @@
<div class="top-banner-item tb-hover">咨询电话:400-7000-690</div>
<div class="top-banner-item">
<img src="../../assets/image/head/wx.png" alt="" />
<a class="tb-hover" target="_blank" href="http://www.ancc.org.cn/gs1cnweixin.aspx">官方微信</a>
<a
class="tb-hover"
target="_blank"
href="http://www.ancc.org.cn/gs1cnweixin.aspx"
>官方微信</a
>
</div>
<div class="top-banner-item">
<img src="../../assets/image/head/xlwb.png" alt="" />
......@@ -24,7 +29,7 @@
>官方微博</a
>
</div>
<div class="top-banner-item tb-hover">
<div class="top-banner-item tb-hover" @click="handelSearch">
<img src="../../assets/image/head/search.png" alt="" />
</div>
</div>
......@@ -34,6 +39,13 @@
<script>
export default {
name: "topBanner",
methods: {
handelSearch() {
this.$router.push({
path: "/Home/sousuo",
});
},
},
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment