Browse Source

经销商拜访

zhujindu 9 tháng trước cách đây
mục cha
commit
3beb7105e4
1 tập tin đã thay đổi với 10 bổ sung3 xóa
  1. 10 3
      src/permission.js

+ 10 - 3
src/permission.js

@@ -1,9 +1,15 @@
+import Vue from 'vue';
 import router from './router';
 import store from './store';
+// 微信JSSDK实例
+const wx = Vue.prototype.wx;
 
 const whiteList = ['/login', '/auth-redirect', '/bind', '/register'];
 
 router.beforeEach((to, from, next) => {
+  // 历史遗留问题 loginName和token参数都是唯一标识
+  if (to.query.token || to.query.loginName)
+    localStorage.setItem('loginName', to.query.token || to.query.loginName);
   const username = localStorage.getItem('loginName');
   if (username) {
     /* has token*/
@@ -22,10 +28,11 @@ router.beforeEach((to, from, next) => {
     }
   } else {
     // 测试使用 账户密码登录页面,正式环境禁用
-    if (to.path == '/logincs' && process.env.NODE_ENV == 'production') {
-      next('/');
-    } else {
+    if (to.path == '/login') {
       next();
+    } else {
+      alert('当前用户没有权限');
+      wx.closeWindow();
     }
     // // 没有token
     // if (whiteList.indexOf(to.path) !== -1) {