| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 | | import * as dd from "dingtalk-jsapi" |  | import { ddLogin, getUserInfo, getDingdingCorpId } from '@/api/system/common' |  | import store from '@/store' |  | export function getCode(c, callBack) { |  |   console.log('dd登录'); |  |   // alert(c); |  |   dd.ready(() => { |  |     // alert('companyId2:', c); |  |     //使用SDK 获取免登授权码 |  |     getDingdingCorpId(c) |  |       .then(corpid => { |  |         // alert('CorpId:'+ JSON.parse(JSON.stringify(corpid))); |  |         dd.runtime.permission.requestAuthCode({ |  |           corpId: corpid, |  |           onSuccess: (info) => { |  |             // 根据钉钉提供的api 获得code后,再次调用这个callback方法 process.env.VUE_APP_CORPID |  |             // 由于是钉钉获取code是异步操作,不知道什么时候执行完毕 |  |             // callback 函数会等他执行完毕后在自己调用自己 |  |             ddLogin(info.code, store.state.companyId) |  |               .then(res => { |  |                 console.log('dd结果', res) |  |                 getUserInfo() |  |                   .then(userInfo => { |  |                     callBack(userInfo) |  |                   }) |  |               }) |  |               .catch(() => {}) |  |             callBack(info.code) |  |           }, |  |           onFail: (err) => { |  |             alert('fail'); |  |             alert(JSON.stringify(err)); |  |           } |  |         }) |  |       }) |  |   }) |  | } | 
 |