|
@@ -11,7 +11,17 @@ function getAuthInfo(cb?: any, redirect_url?: any) {
|
11
|
11
|
//回跳回来后,拿到本地存储的信息去走授权
|
12
|
12
|
if (getLocal('authInfo') && getQueryString('againJump')) {
|
13
|
13
|
const local_auth_info: string = getLocal('authInfo') || null;
|
14
|
|
- initEvent(JSON.parse(local_auth_info), cb)
|
|
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);
|
|
24
|
+ }
|
15
|
25
|
} else {
|
16
|
26
|
axios.post('/api/h5/auth/commonAuthData', {
|
17
|
27
|
corpid: getQueryString('corpid'),
|
|
@@ -23,7 +33,15 @@ function getAuthInfo(cb?: any, redirect_url?: any) {
|
23
|
33
|
redirect_url(res.rst)
|
24
|
34
|
}
|
25
|
35
|
if (cb) {
|
26
|
|
- initEvent(res.rst, 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
|
+ }
|
27
|
45
|
}
|
28
|
46
|
}).catch((err) => {
|
29
|
47
|
console.log(err, 'err')
|
|
@@ -32,15 +50,7 @@ function getAuthInfo(cb?: any, redirect_url?: any) {
|
32
|
50
|
}
|
33
|
51
|
|
34
|
52
|
function initEvent(data, cb) {
|
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
|
|
- }
|
|
53
|
+
|
44
|
54
|
}
|
45
|
55
|
|
46
|
56
|
function initQYConfig(authInfo, cb) { // 企业
|
|
@@ -64,6 +74,7 @@ function initQYConfig(authInfo, cb) { // 企业
|
64
|
74
|
}
|
65
|
75
|
|
66
|
76
|
function initYYConfig(authInfo, cb) { // 应用
|
|
77
|
+ alert('到了')
|
67
|
78
|
wx.agentConfig({
|
68
|
79
|
debug: true,
|
69
|
80
|
corpid: authInfo.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
|
@@ -73,10 +84,12 @@ function initYYConfig(authInfo, cb) { // 应用
|
73
|
84
|
signature: authInfo.app_signature, // 必填,签名,见附录-JS-SDK使用权限签名算法 应用签名
|
74
|
85
|
jsApiList: ['getCurExternalContact', 'sendChatMessage'], // 必填,传入需要使用的接口名称
|
75
|
86
|
success: function (res) {
|
|
87
|
+ alert(JSON.stringify(res) + 'success')
|
76
|
88
|
console.log(res, 'YYready')
|
77
|
89
|
cb ? cb(authInfo) : ''
|
78
|
90
|
},
|
79
|
91
|
fail: function (res) {
|
|
92
|
+ alert(JSON.stringify(res))
|
80
|
93
|
if (res.errMsg.indexOf('function not exist') > -1) {
|
81
|
94
|
alert('版本过低请升级')
|
82
|
95
|
}
|