sunlupeng hai 1 ano
pai
achega
f24161d010
Modificáronse 5 ficheiros con 53 adicións e 6 borrados
  1. 0 1
      App.vue
  2. 8 1
      api/login.js
  3. 2 0
      main.js
  4. 4 1
      package.json
  5. 39 3
      permission.js

+ 0 - 1
App.vue

@@ -2,7 +2,6 @@
   import config from './config'
   import store from '@/store'
   import { getAccessToken } from '@/utils/auth'
-
   export default {
     onLaunch: function() {
       this.initApp()

+ 8 - 1
api/login.js

@@ -1,5 +1,12 @@
 import request from '@/utils/request'
-
+// DD第三方-授权登录
+export function authLogin(data) {
+	return request({
+	  url: '/system/auth/ding/authLogin',
+	  method: 'post',
+	  data: data
+	})
+  }
 // 登录方法
 export function login(username, password, captchaVerification) {
 	const data = {

+ 2 - 0
main.js

@@ -4,6 +4,8 @@ import store from './store' // store
 import plugins from './plugins' // plugins
 import './permission' // permission
 import { parseTime,handleTree,getFileType } from "@/utils/ruoyi";
+import VConsole from "vconsole";
+const vConsole = new VConsole();
 Vue.use(plugins)
 
 Vue.config.productionTip = false

+ 4 - 1
package.json

@@ -1,5 +1,8 @@
 {
   "dependencies": {
-    "crypto-js": "^4.0.0"
+    "crypto-js": "^4.0.0",
+    "dingtalk-design-libs": "^0.2.0",
+    "vconsole": "^3.15.1",
+    "dingtalk-jsapi": "^3.0.29"
   }
 }

+ 39 - 3
permission.js

@@ -1,5 +1,8 @@
 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"
 
@@ -25,11 +28,44 @@ list.forEach(item => {
         }
         return true
       } else {
-        if (checkWhite(to.url)) {
-          return true
+        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
+          }
         }
         uni.reLaunch({ url: loginPage })
         return false
+        
       }
     },
     fail(err) {