Browse Source

微信会跳路径处理

shaogen1995 2 năm trước cách đây
mục cha
commit
7d2b6cb3c8
2 tập tin đã thay đổi với 39 bổ sung32 xóa
  1. 1 2
      yfyc/src/views/Interact/index.vue
  2. 38 30
      yfyc/src/views/Layout/index.vue

+ 1 - 2
yfyc/src/views/Interact/index.vue

@@ -166,8 +166,7 @@ export default {
           "YFYC_userInfo",
           JSON.stringify({ ...res.data.wxUser, time: Date.now() })
         );
-        window.location.href = '/web/index.html#/layout/interact/issue'
-        // this.$router.push("/layout/interact/issue");
+        this.$router.push("/layout/interact/issue");
       }
       // else {
       //   Toast.fail("登录失败,请联系管理人员");

+ 38 - 30
yfyc/src/views/Layout/index.vue

@@ -1,12 +1,22 @@
 <template>
-  <div class='Layout'>
-
+  <div class="Layout">
     <!-- 底部固定栏 -->
     <div class="bottom">
-      <div class="row" @click="$router.push(item.path).catch(() => { })" v-for="item in data" :key="item.id">
-        <img :src="require(`@/assets/img/layout/inco${item.id}${item.id === $route.meta.myInd ? 'Ac' : ''}.png`)" alt="">
+      <div
+        class="row"
+        @click="toUrl(item.path)"
+        v-for="item in data"
+        :key="item.id"
+      >
+        <img
+          :src="
+            require(`@/assets/img/layout/inco${item.id}${
+              item.id === $route.meta.myInd ? 'Ac' : ''
+            }.png`)
+          "
+          alt=""
+        />
         <p>{{ item.name }}</p>
-        
       </div>
     </div>
 
@@ -15,38 +25,37 @@
 </template>
 
 <script>
-
 export default {
   components: {},
   data() {
     return {
       data: [
-        { id: 1, path: '/layout/list', name: '建筑可阅读' },
-        { id: 2, path: '/layout/serve', name: '建筑可游玩' },
-        { id: 3, path: '/layout/interact', name: '建筑可对话' },
-        { id: 4, path: '/layout/my', name: '我的' },
-      ]
+        { id: 1, path: "/layout/list", name: "建筑可阅读" },
+        { id: 2, path: "/layout/serve", name: "建筑可游玩" },
+        { id: 3, path: "/layout/interact", name: "建筑可对话" },
+        { id: 4, path: "/layout/my", name: "我的" },
+      ],
     };
   },
   computed: {},
   watch: {},
   methods: {
-
-  },
-  created() {
-
+    toUrl(url) {
+      const href = window.location.href
+      if(href.includes('?code'))  window.location.href = `/web/index.html#${url}`;
+      else this.$router.push(url)
+    },
   },
-  mounted() {
-
-  },
-  beforeCreate() { }, //生命周期 - 创建之前
-  beforeMount() { }, //生命周期 - 挂载之前
-  beforeUpdate() { }, //生命周期 - 更新之前
-  updated() { }, //生命周期 - 更新之后
-  beforeDestroy() { }, //生命周期 - 销毁之前
-  destroyed() { }, //生命周期 - 销毁完成
-  activated() { }, //如果页面有keep-alive缓存功能,这个函数会触发
-}
+  created() {},
+  mounted() {},
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+};
 </script>
 <style lang='less' scoped>
 .Layout {
@@ -65,18 +74,17 @@ export default {
     background-color: #fff;
     display: flex;
     align-items: center;
-    .row{
+    .row {
       width: 25%;
       text-align: center;
-      &>img{
+      & > img {
         width: 30px;
       }
-      &>p{
+      & > p {
         margin-top: 5px;
         font-size: 12px;
       }
     }
-
   }
 }
 </style>