sunlupeng hai 1 ano
pai
achega
b7cd2977bb
Modificáronse 3 ficheiros con 60 adicións e 42 borrados
  1. 56 2
      App.vue
  2. 2 2
      config.js
  3. 2 38
      permission.js

+ 56 - 2
App.vue

@@ -1,7 +1,23 @@
 <script>
   import config from './config'
-  import store from '@/store'
   import { getAccessToken } from '@/utils/auth'
+  import { authLogin } from "@/api/login";
+  import { setToken, setTenantId } from '@/utils/auth'
+  import { openAuth } from "dingtalk-design-libs/biz/openAuth";
+  import * as dd from "dingtalk-jsapi";
+  function getQueryString() {
+     let url = window.location.href; //获取url中"?"符后的字串
+	 console.log(url)
+      if (url.indexOf("?") != -1) { 
+         let str = url.substr(1); 
+         let strs = str.split("=");
+		 let index = strs[1].indexOf("#")
+		 let corpId = strs[1].substring(0, index);
+		 console.log(corpId)
+         return corpId;          
+      }
+  };
+  
   export default {
     onLaunch: function() {
       this.initApp()
@@ -20,8 +36,46 @@
         this.globalData.config = config
       },
       checkLogin() {
+		  let that = this;
+		  debugger
+		let corpId = getQueryString();
+		console.log(corpId);
         if (!getAccessToken()) {
-          this.$tab.reLaunch('/pages/login')
+			if (dd.env.platform !== "notInDingTalk") {
+				debugger
+			  return new Promise((resolve, reject) => {
+			    dd.ready(function () {
+			      // 唤起授权--统一授权套件SDK
+			      openAuth({
+			        clientId: "suite7tssbigaaqsejgth", // 应用ID(唯一标识)
+			        corpId: corpId, // 当前组织的corpId
+			        rpcScope: "Contact.User.Read", //通讯录
+			        fieldScope: "Contact.User.mobile", //手机号
+			        type: 0, // 0 标识授权个人信息;1 标识授权组织信息
+			      }).then((res) => {
+			        // 处理返回数据
+			        console.log("统一授权套件SDK==res=", res);
+					console.log("corpId", corpId);
+			        authLogin({ code: res.result.authCode, corpId: corpId })
+			          .then((res) => {
+			            console.log("===登录授权=", res);
+			            setToken(res.data);
+			            setTenantId(res.msg)
+						// 设置用户信息
+						that.$store.dispatch('GetInfo').then(res => {
+							that.$tab.reLaunch('/pages/index')
+						})
+			            resolve();
+			          })
+			          .catch((err) => {
+			            reject();
+			          });
+			      });
+			    });
+			  });
+			}else{
+				this.$tab.reLaunch('/pages/login')
+			}
         }
       }
     }

+ 2 - 2
config.js

@@ -1,7 +1,7 @@
 // 应用全局配置
 module.exports = {
-  baseUrl: 'http://47.103.79.143:48081',
-  // baseUrl: 'https://isaas.dgtiscloud.com',
+  // baseUrl: 'http://47.103.79.143:48081',
+  baseUrl: 'https://app139020.eapps.dingtalkcloud.com',
   baseApi: '/admin-api',
   // 应用信息
   appInfo: {

+ 2 - 38
permission.js

@@ -1,8 +1,4 @@
 import { getAccessToken } from '@/utils/auth'
-import { authLogin } from "@/api/login";
-import { setToken, setTenantId } from '@/utils/auth'
-import { openAuth } from "dingtalk-design-libs/biz/openAuth";
-import * as dd from "dingtalk-jsapi";
 // 登录页面
 const loginPage = "/pages/login"
 
@@ -28,40 +24,8 @@ list.forEach(item => {
         }
         return true
       } else {
-        if (dd.env.platform !== "notInDingTalk") {
-          return new Promise((resolve, reject) => {
-            dd.ready(function () {
-              // 钉钉免登录认证-第三方企业
-              // let corpId = that.$store.state.app.corpId;
-              // console.log("corpId====", corpId);
-              // 唤起授权--统一授权套件SDK
-              openAuth({
-                clientId: "suite7tssbigaaqsejgth", // 应用ID(唯一标识)
-                corpId: corpId, // 当前组织的corpId
-                rpcScope: "Contact.User.Read", //通讯录
-                fieldScope: "Contact.User.mobile", //手机号
-                type: 0, // 0 标识授权个人信息;1 标识授权组织信息
-              }).then((res) => {
-                // 处理返回数据
-                console.log("统一授权套件SDK==res=", res);
-                authLogin({ code: res.result.authCode, corpId: corpId.corpId })
-                  .then((res) => {
-                    console.log("===登录授权=", res);
-                    setToken(res.data);
-                    setTenantId(res.msg)
-                    next({ path: '/' })
-                    resolve();
-                  })
-                  .catch((err) => {
-                    reject();
-                  });
-              });
-            });
-          });
-        } else {
-          if (checkWhite(to.url)) {
-            return true
-          }
+        if (checkWhite(to.url)) {
+          return true
         }
         uni.reLaunch({ url: loginPage })
         return false