wl-design-mobile 0.4.0 → 0.4.2
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 +74 -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.2",
|
|
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,48 @@ function configWx(){
|
|
|
81
82
|
})
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
function getConfigSignature(url) {
|
|
86
|
+
return new Promise((resolve,reject)=>{
|
|
87
|
+
axios.post(config.platformServerContext + '/api/weixin/getJsConfig', {
|
|
88
|
+
appType: getAppType(),
|
|
89
|
+
appId: appId,
|
|
90
|
+
agentId: agentId,
|
|
91
|
+
corpId: corpId,
|
|
92
|
+
appKey: appKey,
|
|
93
|
+
url: url.split('#')[0]
|
|
94
|
+
}).then(resp=>{
|
|
95
|
+
console.log('getConfigSignature',resp)
|
|
96
|
+
let timestamp = resp.data.timestamp
|
|
97
|
+
let nonceStr = resp.data.noncestr
|
|
98
|
+
let signature = resp.data.signature
|
|
99
|
+
resolve({ timestamp, nonceStr, signature })
|
|
100
|
+
}).catch((error)=>{
|
|
101
|
+
console.log(error)
|
|
102
|
+
reject(error)
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function configWw(){
|
|
108
|
+
return new Promise((resolve, reject) =>{
|
|
109
|
+
ww.register({
|
|
110
|
+
corpId: appId, // 必填,当前用户企业所属企业ID
|
|
111
|
+
jsApiList: ['chooseImage', 'uploadImage', 'downloadImage', 'getLocalImgData', 'openLocation', 'getLocation', 'scanQRCode', 'chooseWXPay', 'onHistoryBack','invoke','onLocationChange','previewFile'], // 必填,需要使用的JSAPI列表
|
|
112
|
+
getConfigSignature, // 必填,根据url生成企业签名的回调函数
|
|
113
|
+
onConfigSuccess:(res) => {
|
|
114
|
+
console.log('企业微信初始化js-sdk成功');
|
|
115
|
+
console.log(res)
|
|
116
|
+
resolve()
|
|
117
|
+
},
|
|
118
|
+
onConfigFail:(res) =>{
|
|
119
|
+
console.log('企业微信初始化js-sdk失败' + res.errMsg);
|
|
120
|
+
console.log(res)
|
|
121
|
+
reject('企业微信初始化js-sdk失败' + res.errMsg)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
84
127
|
function configDd(){
|
|
85
128
|
return new Promise((resolve, reject)=>{
|
|
86
129
|
getJsConfig().then((resp)=>{
|
|
@@ -264,32 +307,27 @@ let JsSDK = (function () {
|
|
|
264
307
|
}).catch((error)=>{
|
|
265
308
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
266
309
|
})
|
|
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
|
-
});
|
|
310
|
+
}else if(getAppType() === '20'){
|
|
311
|
+
configWw().then(()=>{
|
|
312
|
+
ww.startAutoLBS({
|
|
313
|
+
type: 'gcj02',
|
|
314
|
+
success:()=>{
|
|
315
|
+
ww.onLocationChange(function(event) {
|
|
316
|
+
console.log('onLocationChange',event)
|
|
317
|
+
resolve({longitude:event.longitude,latitude:event.latitude})
|
|
318
|
+
})
|
|
319
|
+
},
|
|
320
|
+
fail:()=>{
|
|
321
|
+
reject()
|
|
322
|
+
}
|
|
323
|
+
}).then(resp => {
|
|
324
|
+
console.log('企业微信开启连续定位',resp)
|
|
325
|
+
})
|
|
290
326
|
}).catch((error)=>{
|
|
291
|
-
reject('
|
|
327
|
+
reject('企业微信开启连续定位失败:'+error)
|
|
292
328
|
})
|
|
329
|
+
}else{
|
|
330
|
+
reject('微信不支持连续定位')
|
|
293
331
|
}
|
|
294
332
|
})
|
|
295
333
|
}
|
|
@@ -314,21 +352,17 @@ let JsSDK = (function () {
|
|
|
314
352
|
}).catch((error)=>{
|
|
315
353
|
reject('钉钉启动内置地图位置失败:'+error)
|
|
316
354
|
})
|
|
317
|
-
}else{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
resolve()
|
|
324
|
-
}else {
|
|
325
|
-
//错误处理
|
|
326
|
-
reject()
|
|
327
|
-
}
|
|
328
|
-
});
|
|
355
|
+
}else if(getAppType() === '20'){
|
|
356
|
+
configWw().then(()=>{
|
|
357
|
+
ww.stopAutoLBS().then(resp => {
|
|
358
|
+
console.log(resp)
|
|
359
|
+
resolve()
|
|
360
|
+
})
|
|
329
361
|
}).catch((error)=>{
|
|
330
|
-
reject('
|
|
362
|
+
reject('企业微信关闭连续定位失败:'+error)
|
|
331
363
|
})
|
|
364
|
+
}else{
|
|
365
|
+
reject('微信不支持连续定位')
|
|
332
366
|
}
|
|
333
367
|
})
|
|
334
368
|
}
|