wl-design-mobile 0.3.9 → 0.4.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 +2 -3
- package/util/jssdk.js +40 -116
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wl-design-mobile",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "finch",
|
|
@@ -21,8 +21,7 @@
|
|
|
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"
|
|
25
|
-
"@wecom/jssdk": "^2.1.0"
|
|
24
|
+
"weixin-js-sdk": "^1.6.5"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"vue": "^2.6.14"
|
package/util/jssdk.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import wx from "weixin-js-sdk";
|
|
2
|
-
import * as ww from '@wecom/jssdk'
|
|
3
2
|
import * as dd from 'dingtalk-jsapi';
|
|
4
3
|
import config from '../config/config'
|
|
5
4
|
import {axios} from '../util/axios'
|
|
@@ -68,13 +67,13 @@ function configWx(){
|
|
|
68
67
|
});
|
|
69
68
|
|
|
70
69
|
wx.ready(() => {
|
|
71
|
-
console.log('
|
|
70
|
+
console.log('初始化js-sdk成功');
|
|
72
71
|
resolve()
|
|
73
72
|
});
|
|
74
73
|
wx.error(res => {
|
|
75
|
-
console.log('
|
|
74
|
+
console.log('初始化js-sdk失败' + res.errMsg);
|
|
76
75
|
console.log('友情提示:若想成功,则需通过params传参(而不是query)!!!');
|
|
77
|
-
reject('
|
|
76
|
+
reject('初始化js-sdk失败' + res.errMsg)
|
|
78
77
|
});
|
|
79
78
|
}).catch((error)=>{
|
|
80
79
|
reject('请求服务端jssdk签名失败:'+error)
|
|
@@ -82,43 +81,6 @@ function configWx(){
|
|
|
82
81
|
})
|
|
83
82
|
}
|
|
84
83
|
|
|
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
|
-
|
|
122
84
|
function configDd(){
|
|
123
85
|
return new Promise((resolve, reject)=>{
|
|
124
86
|
getJsConfig().then((resp)=>{
|
|
@@ -168,22 +130,6 @@ let JsSDK = (function () {
|
|
|
168
130
|
},
|
|
169
131
|
complete: () => {},
|
|
170
132
|
});
|
|
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
|
-
})
|
|
187
133
|
}else{
|
|
188
134
|
configWx().then(()=>{
|
|
189
135
|
wx.scanQRCode({
|
|
@@ -234,22 +180,6 @@ let JsSDK = (function () {
|
|
|
234
180
|
}).catch((error)=>{
|
|
235
181
|
reject('钉钉获取位置失败:'+error)
|
|
236
182
|
})
|
|
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
|
-
|
|
253
183
|
}else{
|
|
254
184
|
configWx().then(()=>{
|
|
255
185
|
wx.getLocation({
|
|
@@ -293,21 +223,6 @@ let JsSDK = (function () {
|
|
|
293
223
|
}).catch((error)=>{
|
|
294
224
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
295
225
|
})
|
|
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
|
-
})
|
|
311
226
|
}else{
|
|
312
227
|
configWx().then(()=>{
|
|
313
228
|
wx.openLocation({
|
|
@@ -349,27 +264,32 @@ let JsSDK = (function () {
|
|
|
349
264
|
}).catch((error)=>{
|
|
350
265
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
351
266
|
})
|
|
352
|
-
}else
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
267
|
+
}else{
|
|
268
|
+
configWx().then(()=>{
|
|
269
|
+
wx.invoke('startAutoLBS',{
|
|
270
|
+
type: 'gcj02', // wgs84是gps坐标,gcj02是火星坐标
|
|
271
|
+
},
|
|
272
|
+
function(res) {
|
|
273
|
+
if(res.err_msg === "startAutoLBS:ok"){
|
|
274
|
+
//调用成功
|
|
275
|
+
wx.onLocationChange(
|
|
276
|
+
function(res) {
|
|
277
|
+
if(res.errMsg === "auto:location:report:ok"){
|
|
278
|
+
resolve({longitude:res.longitude,latitude:res.latitude})
|
|
279
|
+
}else {
|
|
280
|
+
//错误处理
|
|
281
|
+
reject()
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}else {
|
|
286
|
+
//错误处理
|
|
287
|
+
reject()
|
|
288
|
+
}
|
|
289
|
+
});
|
|
368
290
|
}).catch((error)=>{
|
|
369
|
-
reject('
|
|
291
|
+
reject('微信开启连续定位失败:'+error)
|
|
370
292
|
})
|
|
371
|
-
}else{
|
|
372
|
-
reject('微信不支持连续定位')
|
|
373
293
|
}
|
|
374
294
|
})
|
|
375
295
|
}
|
|
@@ -394,17 +314,21 @@ let JsSDK = (function () {
|
|
|
394
314
|
}).catch((error)=>{
|
|
395
315
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
396
316
|
})
|
|
397
|
-
}else
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
317
|
+
}else{
|
|
318
|
+
configWx().then(()=>{
|
|
319
|
+
wx.invoke('stopAutoLBS',{},
|
|
320
|
+
function(res) {
|
|
321
|
+
if(res.err_msg === "stopAutoLBS:ok"){
|
|
322
|
+
//调用成功
|
|
323
|
+
resolve()
|
|
324
|
+
}else {
|
|
325
|
+
//错误处理
|
|
326
|
+
reject()
|
|
327
|
+
}
|
|
328
|
+
});
|
|
403
329
|
}).catch((error)=>{
|
|
404
|
-
reject('
|
|
330
|
+
reject('微信停止连续定位失败:'+error)
|
|
405
331
|
})
|
|
406
|
-
}else{
|
|
407
|
-
reject('微信不支持连续定位')
|
|
408
332
|
}
|
|
409
333
|
})
|
|
410
334
|
}
|