wl-design-mobile 0.4.0 → 0.4.1
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 +3 -2
- package/util/jssdk.js +116 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wl-design-mobile",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "finch",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"moment": "^2.30.1",
|
|
22
22
|
"axios": "^1.7.2",
|
|
23
23
|
"dingtalk-jsapi": "^3.0.12",
|
|
24
|
-
"weixin-js-sdk": "^1.6.5"
|
|
24
|
+
"weixin-js-sdk": "^1.6.5",
|
|
25
|
+
"@wecom/jssdk": "^1.4.5"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"vue": "^2.6.14"
|
package/util/jssdk.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import wx from "weixin-js-sdk";
|
|
2
|
+
import * as ww from '@wecom/jssdk'
|
|
2
3
|
import * as dd from 'dingtalk-jsapi';
|
|
3
4
|
import config from '../config/config'
|
|
4
5
|
import {axios} from '../util/axios'
|
|
@@ -67,13 +68,13 @@ function configWx(){
|
|
|
67
68
|
});
|
|
68
69
|
|
|
69
70
|
wx.ready(() => {
|
|
70
|
-
console.log('
|
|
71
|
+
console.log('微信初始化js-sdk成功');
|
|
71
72
|
resolve()
|
|
72
73
|
});
|
|
73
74
|
wx.error(res => {
|
|
74
|
-
console.log('
|
|
75
|
+
console.log('微信初始化js-sdk失败' + res.errMsg);
|
|
75
76
|
console.log('友情提示:若想成功,则需通过params传参(而不是query)!!!');
|
|
76
|
-
reject('
|
|
77
|
+
reject('微信初始化js-sdk失败' + res.errMsg)
|
|
77
78
|
});
|
|
78
79
|
}).catch((error)=>{
|
|
79
80
|
reject('请求服务端jssdk签名失败:'+error)
|
|
@@ -81,6 +82,43 @@ function configWx(){
|
|
|
81
82
|
})
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
async function getConfigSignature(url) {
|
|
86
|
+
const resp = await axios.post(config.platformServerContext + '/api/weixin/getJsConfig', {
|
|
87
|
+
appType: getAppType(),
|
|
88
|
+
appId: appId,
|
|
89
|
+
agentId: agentId,
|
|
90
|
+
corpId: corpId,
|
|
91
|
+
appKey: appKey,
|
|
92
|
+
url: url
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
let timestamp = resp.data.timestamp
|
|
96
|
+
let nonceStr = resp.data.noncestr
|
|
97
|
+
let signature = resp.data.signature
|
|
98
|
+
|
|
99
|
+
return { timestamp, nonceStr, signature }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function configWw(){
|
|
103
|
+
return new Promise((resolve, reject) =>{
|
|
104
|
+
ww.register({
|
|
105
|
+
corpId: appId, // 必填,当前用户企业所属企业ID
|
|
106
|
+
jsApiList: ['chooseImage', 'uploadImage', 'downloadImage', 'getLocalImgData', 'openLocation', 'getLocation', 'scanQRCode', 'chooseWXPay', 'onHistoryBack','invoke','onLocationChange','previewFile'], // 必填,需要使用的JSAPI列表
|
|
107
|
+
getConfigSignature, // 必填,根据url生成企业签名的回调函数
|
|
108
|
+
onConfigSuccess:(res) => {
|
|
109
|
+
console.log('企业微信初始化js-sdk成功');
|
|
110
|
+
console.log(res.checkResult)
|
|
111
|
+
resolve()
|
|
112
|
+
},
|
|
113
|
+
onConfigFail:(res) =>{
|
|
114
|
+
console.log('企业微信初始化js-sdk失败' + res.errMsg);
|
|
115
|
+
console.log(res)
|
|
116
|
+
reject('企业微信初始化js-sdk失败' + res.errMsg)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
84
122
|
function configDd(){
|
|
85
123
|
return new Promise((resolve, reject)=>{
|
|
86
124
|
getJsConfig().then((resp)=>{
|
|
@@ -130,6 +168,22 @@ let JsSDK = (function () {
|
|
|
130
168
|
},
|
|
131
169
|
complete: () => {},
|
|
132
170
|
});
|
|
171
|
+
}else if(getAppType() === '20'){
|
|
172
|
+
configWw().then(()=>{
|
|
173
|
+
ww.scanQRCode({
|
|
174
|
+
needResult: true,
|
|
175
|
+
scanType: ['qrCode', 'barCode']
|
|
176
|
+
}). then(resp =>{
|
|
177
|
+
console.log("微信扫码结果:", resp)
|
|
178
|
+
if(resp.resultStr){
|
|
179
|
+
resolve(resp.resultStr)
|
|
180
|
+
}else{
|
|
181
|
+
reject("企业微信扫码失败!"+resp.errMsg)
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
}).catch((error)=>{
|
|
185
|
+
reject('企业微信扫码失败:'+error)
|
|
186
|
+
})
|
|
133
187
|
}else{
|
|
134
188
|
configWx().then(()=>{
|
|
135
189
|
wx.scanQRCode({
|
|
@@ -180,6 +234,22 @@ let JsSDK = (function () {
|
|
|
180
234
|
}).catch((error)=>{
|
|
181
235
|
reject('钉钉获取位置失败:'+error)
|
|
182
236
|
})
|
|
237
|
+
}else if(getAppType() === '20'){
|
|
238
|
+
configWw().then(()=>{
|
|
239
|
+
ww.getLocation({
|
|
240
|
+
type: 'gcj02'
|
|
241
|
+
}).then((resp) => {
|
|
242
|
+
console.log(resp);
|
|
243
|
+
if(resp.longitude){
|
|
244
|
+
resolve(resp)
|
|
245
|
+
}else{
|
|
246
|
+
reject("企业微信获取位置失败" + JSON.stringify(resp))
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
}).catch((error)=>{
|
|
250
|
+
reject('企业微信获取位置失败:'+error)
|
|
251
|
+
})
|
|
252
|
+
|
|
183
253
|
}else{
|
|
184
254
|
configWx().then(()=>{
|
|
185
255
|
wx.getLocation({
|
|
@@ -223,6 +293,21 @@ let JsSDK = (function () {
|
|
|
223
293
|
}).catch((error)=>{
|
|
224
294
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
225
295
|
})
|
|
296
|
+
}else if(getAppType() === '20'){
|
|
297
|
+
configWw().then(()=>{
|
|
298
|
+
ww.openLocation({
|
|
299
|
+
latitude: latitude,//目的地latitude
|
|
300
|
+
longitude: longitude,//目的地longitude
|
|
301
|
+
name: name,
|
|
302
|
+
address: address,
|
|
303
|
+
scale: scale//地图缩放大小,可根据情况具体调整
|
|
304
|
+
}).then((resp)=>{
|
|
305
|
+
console.log(resp)
|
|
306
|
+
resolve()
|
|
307
|
+
})
|
|
308
|
+
}).catch((error)=>{
|
|
309
|
+
reject('企业微信启动内置地图失败:'+error)
|
|
310
|
+
})
|
|
226
311
|
}else{
|
|
227
312
|
configWx().then(()=>{
|
|
228
313
|
wx.openLocation({
|
|
@@ -264,32 +349,27 @@ let JsSDK = (function () {
|
|
|
264
349
|
}).catch((error)=>{
|
|
265
350
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
266
351
|
})
|
|
267
|
-
}else{
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
function(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
);
|
|
285
|
-
}else {
|
|
286
|
-
//错误处理
|
|
287
|
-
reject()
|
|
288
|
-
}
|
|
289
|
-
});
|
|
352
|
+
}else if(getAppType() === '20'){
|
|
353
|
+
configWw().then(()=>{
|
|
354
|
+
ww.startAutoLBS({
|
|
355
|
+
type: 'gcj02',
|
|
356
|
+
success:()=>{
|
|
357
|
+
ww.onLocationChange(function(event) {
|
|
358
|
+
console.log(event)
|
|
359
|
+
resolve({longitude:event.longitude,latitude:event.latitude})
|
|
360
|
+
})
|
|
361
|
+
},
|
|
362
|
+
fail:()=>{
|
|
363
|
+
reject()
|
|
364
|
+
}
|
|
365
|
+
}).then(resp => {
|
|
366
|
+
console.log(resp)
|
|
367
|
+
})
|
|
290
368
|
}).catch((error)=>{
|
|
291
|
-
reject('
|
|
369
|
+
reject('企业微信开启连续定位失败:'+error)
|
|
292
370
|
})
|
|
371
|
+
}else{
|
|
372
|
+
reject('微信不支持连续定位')
|
|
293
373
|
}
|
|
294
374
|
})
|
|
295
375
|
}
|
|
@@ -314,21 +394,17 @@ let JsSDK = (function () {
|
|
|
314
394
|
}).catch((error)=>{
|
|
315
395
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
316
396
|
})
|
|
317
|
-
}else{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
resolve()
|
|
324
|
-
}else {
|
|
325
|
-
//错误处理
|
|
326
|
-
reject()
|
|
327
|
-
}
|
|
328
|
-
});
|
|
397
|
+
}else if(getAppType() === '20'){
|
|
398
|
+
configWw().then(()=>{
|
|
399
|
+
ww.stopAutoLBS().then(resp => {
|
|
400
|
+
console.log(resp)
|
|
401
|
+
resolve()
|
|
402
|
+
})
|
|
329
403
|
}).catch((error)=>{
|
|
330
|
-
reject('
|
|
404
|
+
reject('企业微信关闭连续定位失败:'+error)
|
|
331
405
|
})
|
|
406
|
+
}else{
|
|
407
|
+
reject('微信不支持连续定位')
|
|
332
408
|
}
|
|
333
409
|
})
|
|
334
410
|
}
|