Procházet zdrojové kódy

企业微信版本号

xiuli.gao %!s(int64=2) %!d(string=před) roky
rodič
revize
dd2c3d90d8

File diff suppressed because it is too large
+ 1 - 1
qwh5/dist/index.html


File diff suppressed because it is too large
+ 0 - 1
qwh5/dist/js/app.5655904b.js


File diff suppressed because it is too large
+ 1 - 0
qwh5/dist/js/app.ed60a127.js


File diff suppressed because it is too large
+ 1 - 1
qwh5/dist/js/userPortrait.e1369ada.js


+ 37 - 21
qwh5/src/utils/getWxConfig.ts

@@ -1,28 +1,44 @@
1 1
 import axios from './axios';
2 2
 import { getQueryString } from './common'
3
+import { setLocal, getLocal } from './storage'
3 4
 
4
-function getAuthInfo(cb?: any, redirect_url?: any) {//jsapi通用授权数据
5
-  axios.post('/api/h5/auth/commonAuthData', {
6
-    corpid: getQueryString('corpid'),
7
-    url: location.href.split('#')[0],
8
-  }).then((res: any) => {
9
-    // alert(`${res+'getAuthInfo'}`)
10
-    if (redirect_url) {//构造网页授权链接回调
11
-      redirect_url(res.rst)
12
-    }
13
-    if (cb) {
14
-      //在企业微信内部 并企业微信的版本号大约或等于3.0.24时,无须先调用wx.config,可直接wx.agentConfig.  
15
-      //文档说明于 https://developer.work.weixin.qq.com/document/path/94313
16
-      if (isWxwork() && isWxwork() != 'false' && compareVersion(isWxwork(), '3.0.24') != -1) {
17
-        alert('无须先调用wx.config,可直接wx.agentConfig')
18
-        initYYConfig(res.rst, cb);//
19
-      } else {
20
-        initQYConfig(res.rst, cb);
5
+/**
6
+ * jsapi通用授权数据
7
+ * @param cb 正常授权回跳
8
+ * @param redirect_url 构造网页授权链接回跳 目的是根据回跳拿到code
9
+ */
10
+function getAuthInfo(cb?: any, redirect_url?: any) {
11
+  //回跳回来后,拿到本地存储的信息去走授权
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)
21 24
       }
22
-    }
23
-  }).catch((err) => {
24
-    console.log(err, 'err')
25
-  })
25
+      if (cb) {
26
+        initEvent(res.rst, cb)
27
+      }
28
+    }).catch((err) => {
29
+      console.log(err, 'err')
30
+    })
31
+  }
32
+}
33
+
34
+function initEvent(authInfo: any, 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
+    initYYConfig(authInfo, cb);//
39
+  } else {
40
+    initQYConfig(authInfo, cb);
41
+  }
26 42
 }
27 43
 
28 44
 function initQYConfig(authInfo, cb) { // 企业