diff --git a/src/main.js b/src/main.js index f802403..c300f9f 100644 --- a/src/main.js +++ b/src/main.js @@ -28,3 +28,10 @@ new Vue({ }).$mount('#app') +//重复点击同一个报错解决 +import Router from 'vue-router' +const routerPush = Router.prototype.push +Router.prototype.push = function push(location) { + return routerPush.call(this, location).catch(error=> error) +} + diff --git a/src/pages/CustomerView.vue b/src/pages/CustomerView.vue index 54f7647..4e1bc3f 100644 --- a/src/pages/CustomerView.vue +++ b/src/pages/CustomerView.vue @@ -143,6 +143,7 @@ import customerView from "../services/datacenter/customerView"; export default { + inject:['setMenuName'], data() { return { userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId, @@ -362,6 +363,7 @@ }, //零推广更多跳转 zeroExtendMore: function () { + this.setMenuName("首页","推广为0店铺数"); let that = this; this.$router.push({ path: '/zero/extend/detail', diff --git a/src/pages/Home.vue b/src/pages/Home.vue index 5aee3dc..2d5df56 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -31,7 +31,7 @@ - {{selectedMenu}} + {{selectedMenu}} {{selectedSubMenu}} @@ -51,10 +51,12 @@ provide() { return { checkParamBlank: this.checkParamBlank, + setMenuName: this.setMenuName, }; }, data() { return { + mainUrl: "/customer/view", isCollapsed: false, mHeight: 600, selectedItemName: null, @@ -71,6 +73,8 @@ twoPermissionList: [], //3级权限 threePermissionList: [], + //面包屑点击跳转路径 + breadcrumbUrl: "", } }, mounted() { @@ -127,6 +131,7 @@ if (cItem.id === val) { this.selectedMenu = item.name; this.selectedSubMenu = cItem.name; + this.breadcrumbUrl = cItem.resource; } } } @@ -239,12 +244,14 @@ } }) }, - //导航栏点击 + //导航栏初始化 menuInit: function () { let that = this; //默认首页 that.selectedItemName = 0; - this.$router.push({path: "/customer/view"}); + this.$router.push({path: that.mainUrl}); + this.selectedMenu = "首页"; + this.breadcrumbUrl = this.mainUrl; // that.selectedItemName = that.onePermissionList[0].subMenuList[0].id; // that.openName = [that.onePermissionList[0].id]; // this.$nextTick(() => { @@ -273,6 +280,18 @@ this.$nextTick(() => { that.$refs.menu.updateActiveName(); }) + }, + //手动设置面包屑 + setMenuName: function (menu1, menu2) { + this.selectedMenu = menu1; + this.selectedSubMenu = menu2; + }, + //面包屑点击跳转 + breadcrumbClick: function () { + if(this.selectedMenu === "首页"){ + this.selectedSubMenu = ""; + } + this.$router.push(this.breadcrumbUrl); } },