Commit e775c8bd by 林家欣

修改搜索页显示逻辑

parent 9bca8256
...@@ -74,6 +74,7 @@ import HeaderDropdown from "./HeaderDropdown.vue"; ...@@ -74,6 +74,7 @@ import HeaderDropdown from "./HeaderDropdown.vue";
import { nav } from "./mock"; import { nav } from "./mock";
import Qs from "qs"; import Qs from "qs";
import { cleanObject } from "@/axios/parameter"; import { cleanObject } from "@/axios/parameter";
import { deepFindBreadcrumb } from "@/utils/utils";
export default { export default {
components: { HeaderBtn, HeaderDropdown }, components: { HeaderBtn, HeaderDropdown },
...@@ -103,11 +104,11 @@ export default { ...@@ -103,11 +104,11 @@ export default {
} else { } else {
// TODO 去dropdown里面精确查找当前的路径 // TODO 去dropdown里面精确查找当前的路径
let result; 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) { if (!result && Object.keys(this.$route.query).length > 0) {
const queryString = Qs.stringify(cleanObject(this.$route.query)); const queryString = Qs.stringify(cleanObject(this.$route.query));
let path = `${this.$route.path}?${queryString}`; let path = `${this.$route.path}?${queryString}`;
result = this.comparePath(nav_.children, path); result = deepFindBreadcrumb(nav_.children, path);
} }
result && result &&
result.breadcrumb && result.breadcrumb &&
...@@ -123,28 +124,6 @@ export default { ...@@ -123,28 +124,6 @@ export default {
window.removeEventListener("click", this.handleWindowClick); window.removeEventListener("click", this.handleWindowClick);
}, },
methods: { 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() { handleWindowClick() {
// console.log('handleWindowClick', this.fromNav, this.preActive); // console.log('handleWindowClick', this.fromNav, this.preActive);
if (this.preActive && !this.fromNav) { if (this.preActive && !this.fromNav) {
......
...@@ -16,7 +16,12 @@ ...@@ -16,7 +16,12 @@
<div class="top-banner-item tb-hover">咨询电话:400-7000-690</div> <div class="top-banner-item tb-hover">咨询电话:400-7000-690</div>
<div class="top-banner-item"> <div class="top-banner-item">
<img src="../../assets/image/head/wx.png" alt="" /> <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>
<div class="top-banner-item"> <div class="top-banner-item">
<img src="../../assets/image/head/xlwb.png" alt="" /> <img src="../../assets/image/head/xlwb.png" alt="" />
...@@ -24,7 +29,7 @@ ...@@ -24,7 +29,7 @@
>官方微博</a >官方微博</a
> >
</div> </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="" /> <img src="../../assets/image/head/search.png" alt="" />
</div> </div>
</div> </div>
...@@ -34,6 +39,13 @@ ...@@ -34,6 +39,13 @@
<script> <script>
export default { export default {
name: "topBanner", name: "topBanner",
methods: {
handelSearch() {
this.$router.push({
path: "/Home/sousuo",
});
},
},
}; };
</script> </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