wl-design-mobile 0.7.9 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/util/jssdk-sczy.js +31 -10
package/package.json
CHANGED
package/util/jssdk-sczy.js
CHANGED
|
@@ -58,7 +58,7 @@ const isIos14AndMore = () => {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function getSczyJsConfig() {
|
|
61
|
+
async function getSczyJsConfig() {
|
|
62
62
|
let url = window.location.href.split('#')[0]
|
|
63
63
|
if (isIos14AndMore()) {
|
|
64
64
|
const storedUrl = sessionStorage.getItem('ios14ConfigUrl')
|
|
@@ -69,19 +69,20 @@ function getSczyJsConfig() {
|
|
|
69
69
|
|
|
70
70
|
const cached = getCachedSignature(url)
|
|
71
71
|
if (cached) {
|
|
72
|
-
return
|
|
72
|
+
return cached
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
const resp = await axios.get(config.platformServerContext + '/api/weixin/js/signature', {
|
|
76
76
|
params: { url }
|
|
77
|
-
}).then((resp) => {
|
|
78
|
-
const data = resp && resp.data ? resp.data : {}
|
|
79
|
-
if (!data || data.data.errcode !== 0 || !data.data) {
|
|
80
|
-
throw new Error((data && data.errmsg) ? data.errmsg : '获取签名失败')
|
|
81
|
-
}
|
|
82
|
-
setCachedSignature(url, data.data)
|
|
83
|
-
return data.data
|
|
84
77
|
})
|
|
78
|
+
const data = resp && resp.data ? resp.data : {}
|
|
79
|
+
const signatureData = data && data.data ? data.data : null
|
|
80
|
+
const errcode = data && data.errcode
|
|
81
|
+
if (errcode !== 0 || !signatureData) {
|
|
82
|
+
throw new Error((data && data.errmsg) ? data.errmsg : '获取签名失败')
|
|
83
|
+
}
|
|
84
|
+
setCachedSignature(url, signatureData)
|
|
85
|
+
return signatureData
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
function configWx() {
|
|
@@ -92,6 +93,7 @@ function configWx() {
|
|
|
92
93
|
configPromise = getSczyJsConfig().then((resp) => {
|
|
93
94
|
return new Promise((resolve, reject) => {
|
|
94
95
|
wx.config({
|
|
96
|
+
beta: true,
|
|
95
97
|
debug: false,
|
|
96
98
|
appId: resp.appId,
|
|
97
99
|
timestamp: resp.timestamp,
|
|
@@ -100,11 +102,18 @@ function configWx() {
|
|
|
100
102
|
jsApiList: ['scanQRCode']
|
|
101
103
|
})
|
|
102
104
|
|
|
105
|
+
const timeout = setTimeout(() => {
|
|
106
|
+
configPromise = null
|
|
107
|
+
reject('企业微信初始化js-sdk超时')
|
|
108
|
+
}, 15000)
|
|
109
|
+
|
|
103
110
|
wx.ready(() => {
|
|
111
|
+
clearTimeout(timeout)
|
|
104
112
|
resolve()
|
|
105
113
|
})
|
|
106
114
|
|
|
107
115
|
wx.error((res) => {
|
|
116
|
+
clearTimeout(timeout)
|
|
108
117
|
configPromise = null
|
|
109
118
|
reject('企业微信初始化js-sdk失败' + (res && res.errMsg ? res.errMsg : ''))
|
|
110
119
|
})
|
|
@@ -130,6 +139,11 @@ function extractScanText(res) {
|
|
|
130
139
|
function scanQRCode() {
|
|
131
140
|
return new Promise((resolve, reject) => {
|
|
132
141
|
configWx().then(() => {
|
|
142
|
+
if (!wx.scanQRCode) {
|
|
143
|
+
reject('当前客户端不支持扫码能力')
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
133
147
|
wx.scanQRCode({
|
|
134
148
|
desc: 'scanQRCode desc',
|
|
135
149
|
needResult: 1,
|
|
@@ -137,6 +151,13 @@ function scanQRCode() {
|
|
|
137
151
|
success: function (res) {
|
|
138
152
|
resolve(extractScanText(res))
|
|
139
153
|
},
|
|
154
|
+
fail: function (res) {
|
|
155
|
+
if (res && res.errMsg && res.errMsg.indexOf('function_not_exist') > -1) {
|
|
156
|
+
reject('版本过低请升级')
|
|
157
|
+
} else {
|
|
158
|
+
reject('企业微信扫码失败,请联系系统管理员!')
|
|
159
|
+
}
|
|
160
|
+
},
|
|
140
161
|
error: function (res) {
|
|
141
162
|
if (res && res.errMsg && res.errMsg.indexOf('function_not_exist') > -1) {
|
|
142
163
|
reject('版本过低请升级')
|