|
@@ -9,48 +9,38 @@ import { setLocal, getLocal } from './storage'
|
9
|
9
|
*/
|
10
|
10
|
function getAuthInfo(cb?: any, redirect_url?: any) {
|
11
|
11
|
//回跳回来后,拿到本地存储的信息去走授权
|
12
|
|
- if (getLocal('authInfo') && getQueryString('againJump')) {
|
13
|
|
- const local_auth_info: string = getLocal('authInfo') || null;
|
14
|
|
- const data_auth_info = JSON.parse(local_auth_info)
|
15
|
|
- // initEvent(JSON.parse(local_auth_info), cb)
|
16
|
|
- //在企业微信内部 并企业微信的版本号大约或等于3.0.24时,无须先调用wx.config,可直接wx.agentConfig.
|
17
|
|
- //文档说明于 https://developer.work.weixin.qq.com/document/path/94313
|
18
|
|
- if (isWxwork() && isWxwork() != 'false' && compareVersion(isWxwork(), '3.0.24') != -1) {
|
19
|
|
- alert('不' + JSON.stringify(data_auth_info))
|
20
|
|
- initYYConfig(data_auth_info, cb);
|
21
|
|
- } else {
|
22
|
|
- alert('是')
|
23
|
|
- initQYConfig(data_auth_info, cb);
|
|
12
|
+ // if (getLocal('authInfo') && getQueryString('againJump')) {
|
|
13
|
+ // const local_auth_info: string = getLocal('authInfo') || null;
|
|
14
|
+ // initEvent(JSON.parse(local_auth_info), cb)
|
|
15
|
+ // } else {
|
|
16
|
+ axios.post('/api/h5/auth/commonAuthData', {
|
|
17
|
+ corpid: getQueryString('corpid'),
|
|
18
|
+ url: location.href.split('#')[0],
|
|
19
|
+ }).then((res: any) => {
|
|
20
|
+ //构造网页授权链接回调 保存返回信息
|
|
21
|
+ if (redirect_url) {
|
|
22
|
+ setLocal('authInfo', JSON.stringify(res.rst))
|
|
23
|
+ redirect_url(res.rst)
|
24
|
24
|
}
|
25
|
|
- } else {
|
26
|
|
- axios.post('/api/h5/auth/commonAuthData', {
|
27
|
|
- corpid: getQueryString('corpid'),
|
28
|
|
- url: location.href.split('#')[0],
|
29
|
|
- }).then((res: any) => {
|
30
|
|
- //构造网页授权链接回调 保存返回信息
|
31
|
|
- if (redirect_url) {
|
32
|
|
- setLocal('authInfo', JSON.stringify(res.rst))
|
33
|
|
- redirect_url(res.rst)
|
34
|
|
- }
|
35
|
|
- if (cb) {
|
36
|
|
- //在企业微信内部 并企业微信的版本号大约或等于3.0.24时,无须先调用wx.config,可直接wx.agentConfig.
|
37
|
|
- //文档说明于 https://developer.work.weixin.qq.com/document/path/94313
|
38
|
|
- if (isWxwork() && isWxwork() != 'false' && compareVersion(isWxwork(), '3.0.24') != -1) {
|
39
|
|
- alert('不' + JSON.stringify(res.rst))
|
40
|
|
- initYYConfig(res.rst, cb);
|
41
|
|
- } else {
|
42
|
|
- alert('是')
|
43
|
|
- initQYConfig(res.rst, cb);
|
44
|
|
- }
|
45
|
|
- }
|
46
|
|
- }).catch((err) => {
|
47
|
|
- console.log(err, 'err')
|
48
|
|
- })
|
49
|
|
- }
|
|
25
|
+ if (cb) {
|
|
26
|
+ initEvent(res.rst, cb)
|
|
27
|
+ }
|
|
28
|
+ }).catch((err) => {
|
|
29
|
+ console.log(err, 'err')
|
|
30
|
+ })
|
|
31
|
+ // }
|
50
|
32
|
}
|
51
|
33
|
|
52
|
34
|
function initEvent(data, cb) {
|
53
|
|
-
|
|
35
|
+ //在企业微信内部 并企业微信的版本号大约或等于3.0.24时,无须先调用wx.config,可直接wx.agentConfig.
|
|
36
|
+ //文档说明于 https://developer.work.weixin.qq.com/document/path/94313
|
|
37
|
+ if (isWxwork() && isWxwork() != 'false' && compareVersion(isWxwork(), '3.0.24') != -1) {
|
|
38
|
+ alert('不' + JSON.stringify(data))
|
|
39
|
+ initYYConfig(data, cb);
|
|
40
|
+ } else {
|
|
41
|
+ alert('是')
|
|
42
|
+ initQYConfig(data, cb);
|
|
43
|
+ }
|
54
|
44
|
}
|
55
|
45
|
|
56
|
46
|
function initQYConfig(authInfo, cb) { // 企业
|