Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

yangyuxuan 8 mēneši atpakaļ
vecāks
revīzija
6d99ffcee4
3 mainītis faili ar 29 papildinājumiem un 8 dzēšanām
  1. 16 4
      src/permission.ts
  2. 9 0
      src/utils/validate.ts
  3. 4 4
      src/views/index.vue

+ 16 - 4
src/permission.ts

@@ -10,7 +10,7 @@ import setPageTitle from "@/utils/set-page-title";
 import usePermissionStore from '@/store/modules/permission';
 
 NProgress.configure({ showSpinner: false });
-const whiteList = ['/login'];
+const whiteList = ['/login', '/yzy/callback'];
 
 router.beforeEach(async (to, from, next) => {
   NProgress.start();
@@ -62,9 +62,21 @@ router.beforeEach(async (to, from, next) => {
       // 在免登录白名单,直接进入
       next();
     } else {
-      const redirect = encodeURIComponent(to.fullPath || '/');
-      next(`/login?redirect=${redirect}`); // 否则全部重定向到登录页
-      NProgress.done();
+      if (/(wxworklocal)/i.test(navigator.userAgent)) {
+        let state_json = {
+          "redirect_url": to.fullPath || '/',
+          "rnd": Math.floor(Math.random() * 1000000)
+        };
+        const state = JSON.stringify(state_json);
+        let redirect_uri = encodeURIComponent(window.location.protocol + "//" + window.location.host + "/yjxp/#/yzy/callback")
+        let next_url = `https://open.weixin.qq.com/connect/Oauth2/authorize?appid=wld341060039&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&agentid=1004302&state=${state}#wechat_redirect`;
+        window.location.href = next_url; // 粤政易自动登录
+      }
+      else {
+        const redirect = encodeURIComponent(to.fullPath || '/');
+        next(`/login?redirect=${redirect}`); // 否则全部重定向到登录页
+        NProgress.done();
+      }
     }
   }
 });

+ 9 - 0
src/utils/validate.ts

@@ -15,3 +15,12 @@ export function validatePhone(phoneNumber: string) {
 export function validateFile(fieList: []) {
   return fieList && fieList.length > 0;
 }
+
+/**
+ * 判断url是否是http或https
+ * @returns {Boolean}
+ * @param url
+ */
+export const isHttp = (url: string): boolean => {
+  return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1;
+};

+ 4 - 4
src/views/index.vue

@@ -34,11 +34,11 @@ onMounted(() => {
   console.log('env:', env);
   // if(env === 'development') 
   {
-    setToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiZXhwIjoyMDM5Njk2ODMzfQ.Rhd38oo_S1odjg0xnT4n31cCWCAAPXGb8y_V2XcgqzQ')
+    // setToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiZXhwIjoyMDM5Njk2ODMzfQ.Rhd38oo_S1odjg0xnT4n31cCWCAAPXGb8y_V2XcgqzQ')
     nextTick(()=>{
       setTimeout(()=> {
         getUserInfo();
-      }, 1000);
+      }, 100);
     })
   }
 })
@@ -78,12 +78,12 @@ const getUserInfo = () => {
 
 <style lang="scss" scoped>
 .container {
-  padding: 39px 8px 20px;
+  padding: 10px 10px 20px;
   .item {
     background: url("@/assets/images/staffBox.png") no-repeat;
   }
   .item2 {
-    margin-top: 20px;
+    margin-top: 10px;
     background: url("@/assets/images/leaderBox.png") no-repeat;
   }
   .item,