瀏覽代碼

no message

DESKTOP-70VPDLK\Administrator 5 月之前
父節點
當前提交
6194b5e6fb
共有 2 個文件被更改,包括 30 次插入12 次删除
  1. 18 12
      src/utils/routerEach.js
  2. 12 0
      src/utils/tools.js

+ 18 - 12
src/utils/routerEach.js

@@ -1,24 +1,30 @@
 import router from '../router/index.js'
 import store from '@/store'
+import {hasMobile} from "@/utils/tools";
 
 
 const routeList = ['/Home','/Tourism','/Team','/Recharge','/Draw','/Me']
 router.beforeEach((to, from, next) => {
-  let userToken = window.localStorage.getItem('userToken')
-  let active = routeList.findIndex((item) => item === to.path)
+  if(hasMobile()){
+    document.location.href = 'http://wap.gmcyy.com'
+  }else {
+    let userToken = window.localStorage.getItem('userToken')
+    let active = routeList.findIndex((item) => item === to.path)
 
-  if (active > -1) {
-    active++
-  }
-  if (userToken) {
-    store.commit('user/setNavActive', active)
-    next()
-  } else {
-    store.commit('user/setNavActive', active)
-    if (to.path == '/Home'||to.path == '/Tourism'||to.path == '/Team'||to.path == '/login'||to.path == '/register'||to.path == '/forget-password') {
+    if (active > -1) {
+      active++
+    }
+    if (userToken) {
+      store.commit('user/setNavActive', active)
       next()
     } else {
-      next('/login')
+      store.commit('user/setNavActive', active)
+      if (to.path == '/Home'||to.path == '/Tourism'||to.path == '/Team'||to.path == '/login'||to.path == '/register'||to.path == '/forget-password') {
+        next()
+      } else {
+        next('/login')
+      }
     }
   }
+
 })

+ 12 - 0
src/utils/tools.js

@@ -19,3 +19,15 @@ tools.success=function(msg){
 }
 
 export default tools
+
+
+export function hasMobile() {
+  let isMobile = false;
+  if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
+    isMobile = true;
+  }
+  if (document.body.clientWidth < 800) {
+    isMobile = true;
+  }
+  return isMobile
+}