瀏覽代碼

数据丢失跳回登录页3323

zhouna 5 年之前
父節點
當前提交
64bc95388b
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/components/MainPage.vue

+ 9 - 0
src/components/MainPage.vue

@@ -111,6 +111,7 @@ export default {
   name:'MainPage',
   data(){
     return {
+      noAllowed:false,    //未登录
       num:-1,//题目计数
       pickDVal:'1天',    //时间控件默认值
       allMoudles:[],
@@ -153,6 +154,13 @@ export default {
   created() {
     //const userInfo= JSON.parse(localStorage.getItem("userInfo"))
     const userInfo = this.$store.state.pathInfo;
+    if(!userInfo.hospitalCode){    //用户数据丢失,刷新或本页面分享时,跳回登录页
+      this.noAllowed=true;
+      this.$router.push({
+        path:'/'
+      });
+      return;
+    }
     this.userInfo = userInfo;
     let tmpModule = moduleConfig(this.config,this.tmpAllMoudles);
     this.allMoudles = tmpModule.data;
@@ -160,6 +168,7 @@ export default {
     this.updata()
   },
   mounted(){
+    if(this.noAllowed)return;
     this.$nextTick(()=>{
       let bs = new BScroll('.wrapper', {
         probeType: 3,