diff --git a/src/components/HomePage/homePage.vue b/src/components/HomePage/homePage.vue
index c3e37d4d..4317f4e3 100644
--- a/src/components/HomePage/homePage.vue
+++ b/src/components/HomePage/homePage.vue
@@ -104,7 +104,7 @@
}
},
mounted() {
- this.pageId = this.$route.query.id;
+ this.pageId = this.$xpage.getHomeId(this.$route);
this.sex = this.userInfo.sex;
// 判断路由是进入的学员默认页面就重置setCurIdentity
if(this.$route.path == '/uc/study/task' || this.$route.path == '/study/index'){
diff --git a/src/components/Portal/authorImg.vue b/src/components/Portal/authorImg.vue
index 4d36235b..c3b145e8 100644
--- a/src/components/Portal/authorImg.vue
+++ b/src/components/Portal/authorImg.vue
@@ -60,7 +60,7 @@
methods:{
toHome() {
// ,query:{id:item.objId || item.id}
- this.$router.push({path:'/home/index?id='+this.aid})
+ this.$router.push({path:this.$xpage.getHomePath(this.aid)})
}
},
watch:{
diff --git a/src/components/Portal/authorInfo.vue b/src/components/Portal/authorInfo.vue
index 376742f0..7ddcabc2 100644
--- a/src/components/Portal/authorInfo.vue
+++ b/src/components/Portal/authorInfo.vue
@@ -74,7 +74,7 @@
toHome() {
// ,query:{id:item.objId || item.id}
if(this.aid){
- this.$router.push({path:'/home/index?id='+this.aid})
+ this.$router.push({path:this.$xpage.getHomePath(this.aid)})
}else{
this.$message.error("参数错误");
}
diff --git a/src/components/PortalHeader.vue b/src/components/PortalHeader.vue
index f03a6c27..8065c542 100644
--- a/src/components/PortalHeader.vue
+++ b/src/components/PortalHeader.vue
@@ -108,7 +108,7 @@
个人中心
- 个人主页
+ 个人主页
diff --git a/src/layout/components/TopNav/Index.vue b/src/layout/components/TopNav/Index.vue
index d930edc3..a39b3ed4 100644
--- a/src/layout/components/TopNav/Index.vue
+++ b/src/layout/components/TopNav/Index.vue
@@ -67,7 +67,7 @@
个人中心
- 个人主页
+ 个人主页
@@ -83,7 +83,7 @@
-->
- 登出
+ 登出
diff --git a/src/main.js b/src/main.js
index afcb8c1a..d64cabda 100644
--- a/src/main.js
+++ b/src/main.js
@@ -5,7 +5,7 @@ import store from './store'
//import './mock/index'
-import constants from '@/utils/constants'
+import xpage from '@/utils/xpage'
import VueCookies from 'vue-cookies'
Vue.use(VueCookies)
import Element from 'element-ui'
@@ -29,7 +29,7 @@ Vue.prototype.$watermark = watermark
Vue.config.productionTip = false
-Vue.prototype.$Constants = constants;
+Vue.prototype.$xpage = xpage;
Vue.prototype.msgSuccess = function(msg) {
diff --git a/src/router/index.js b/src/router/index.js
index f7dfcdca..8bbc5bb2 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -154,17 +154,17 @@ export const constantRoutes = [{
hidden: true,
component: (resolve) => require(['@/views/homepage/Index'], resolve),
name: 'homePage',
- redirect: '/home/index',
+ redirect: '/home/:id',
meta: { title: '个人主页', icon: 'dashboard', noCache: true, affix: false },
children: [{
- path: 'index',
+ path: ':id',
hidden: true,
component: (resolve) => require(['@/views/homepage/page'], resolve),
name: 'page',
meta: { title: '个人主页', icon: 'dashboard', noCache: true, affix: true }
},
{
- path: 'leaving',
+ path: ':id/leaving',
hidden: true,
component: (resolve) => require(['@/views/homepage/leavingMessage'], resolve),
name: 'leavingMessage',
diff --git a/src/security.js b/src/security.js
index 6d70133c..78ff4c80 100644
--- a/src/security.js
+++ b/src/security.js
@@ -6,7 +6,7 @@ import 'nprogress/nprogress.css'
import { getToken } from '@/utils/token'
import { routers } from "@/data/pages"
import watermark from './utils/warterMark.js'
-import constants from '@/utils/constants'
+import xpage from '@/utils/xpage'
NProgress.configure({ showSpinner: false })
@@ -17,9 +17,9 @@ router.beforeEach((to, from, next) => {
//动态计算文件的路径
let configPath=process.env.VUE_APP_FILE_RELATIVE_PATH;
if(configPath.startsWith('http')){
- constants.fileBaseUrl=configPath;
+ xpage.fileBaseUrl=configPath;
}else{
- constants.fileBaseUrl = window.location.protocol+'//'+window.location.host+configPath;
+ xpage.fileBaseUrl = window.location.protocol+'//'+window.location.host+configPath;
}
diff --git a/src/utils/constants.js b/src/utils/constants.js
deleted file mode 100644
index 80e5d4b7..00000000
--- a/src/utils/constants.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/**页面设置的一些常量*/
-const constants={
- fileBaseUrl:'http://192.168.0.10/pc/cdn/upload',
- newLoginKey:'boe_new_login'
-}
-
-export default constants
diff --git a/src/utils/xpage.js b/src/utils/xpage.js
new file mode 100644
index 00000000..c4543bc9
--- /dev/null
+++ b/src/utils/xpage.js
@@ -0,0 +1,20 @@
+/**页面设置的一些常量,方便,用于一个处理只写一处,不要多处写*/
+const constants={
+ fileBaseUrl:'http://192.168.0.10/pc/cdn/upload',
+ newLoginKey:'boe_new_login'
+}
+
+/**返回个人主页的id参数*/
+const getHomeId=function(r){
+ return r.params.id;
+}
+
+const getHomePath=function(id){
+ return '/home/'+id;
+}
+
+export default {
+ getHomeId,
+ getHomePath,
+ constants
+}
diff --git a/src/views/homepage/Index.vue b/src/views/homepage/Index.vue
index a9841f6f..db14e891 100644
--- a/src/views/homepage/Index.vue
+++ b/src/views/homepage/Index.vue
@@ -73,8 +73,8 @@
}
},
created() {
- this.pageId = this.$route.query.id;
- if(!this.$route.query.id){
+ this.pageId = this.$xpage.getHomeId(this.$route);
+ if(!this.pageId){
this.$router.push({path:'/404'})
}else{
this.init();
diff --git a/src/views/homepage/leavingMessage.vue b/src/views/homepage/leavingMessage.vue
index 35879ed1..0b2d5b16 100644
--- a/src/views/homepage/leavingMessage.vue
+++ b/src/views/homepage/leavingMessage.vue
@@ -95,13 +95,14 @@
}
}
},
- watch:{
-
-
- },
- mounted() {
- this.pageId = this.$route.query.id;
- this.getList();
+ created() {
+ this.pageId =this.$xpage.getHomeId(this.$route);
+ if(this.pageId){
+ this.getList();
+ }else{
+ this.$router.push({path:'/404'})
+ }
+
},
methods: {
delReplySon(item,index) { //子级的删除手动删掉,调用保存接口
diff --git a/src/views/homepage/page.vue b/src/views/homepage/page.vue
index 31a69580..ba9eac63 100644
--- a/src/views/homepage/page.vue
+++ b/src/views/homepage/page.vue
@@ -118,16 +118,9 @@
Profess:[]
}
},
- // watch:{
- // '$route' (to, from) { //监听路由是否变化
- // if(to.query.id != from.query.id && from.path == "/home/index"){
- // this.id = to.query.id;
- // this.init();//重新加载数据
- // }
- // }
- // },
created(){
- if(this.$route.query.id && this.$route.query.id!=''){
+ this.pageId = this.$xpage.getHomeId(this.$route);
+ if(this.pageId && this.pageId!=''){
this.init();
}else{
//this.$message.error("参数错误");
@@ -135,12 +128,22 @@
this.$router.push({path:'/404'})
}
},
+ watch:{
+ '$route' (to, from) { //监听路由是否变化
+ console.log(from,'from')
+ if(to.params.id != from.params.id){
+ this.pageId = to.params.id;
+ console.log(this.pageId,'重新加载页面');
+ this.init();//重新加载数据
+ }
+ }
+ },
mounted() {
},
methods:{
init(){
- this.pageId = this.$route.query.id;
+
this.getList();
if(this.pageId == this.userInfo.aid) {
this.personal = true;