|
|
@@ -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) {
|