wl-design-mobile 0.4.1 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/util/jssdk.js +22 -64
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wl-design-mobile",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",
package/util/jssdk.js CHANGED
@@ -82,21 +82,26 @@ function configWx(){
82
82
  })
83
83
  }
84
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
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
+ })
93
104
  })
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
105
  }
101
106
 
102
107
  function configWw(){
@@ -107,7 +112,7 @@ function configWw(){
107
112
  getConfigSignature, // 必填,根据url生成企业签名的回调函数
108
113
  onConfigSuccess:(res) => {
109
114
  console.log('企业微信初始化js-sdk成功');
110
- console.log(res.checkResult)
115
+ console.log(res)
111
116
  resolve()
112
117
  },
113
118
  onConfigFail:(res) =>{
@@ -168,22 +173,6 @@ let JsSDK = (function () {
168
173
  },
169
174
  complete: () => {},
170
175
  });
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
176
  }else{
188
177
  configWx().then(()=>{
189
178
  wx.scanQRCode({
@@ -234,22 +223,6 @@ let JsSDK = (function () {
234
223
  }).catch((error)=>{
235
224
  reject('钉钉获取位置失败:'+error)
236
225
  })
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
226
  }else{
254
227
  configWx().then(()=>{
255
228
  wx.getLocation({
@@ -293,21 +266,6 @@ let JsSDK = (function () {
293
266
  }).catch((error)=>{
294
267
  reject('钉钉启动内置地图位置失败:'+error)
295
268
  })
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
269
  }else{
312
270
  configWx().then(()=>{
313
271
  wx.openLocation({
@@ -355,7 +313,7 @@ let JsSDK = (function () {
355
313
  type: 'gcj02',
356
314
  success:()=>{
357
315
  ww.onLocationChange(function(event) {
358
- console.log(event)
316
+ console.log('onLocationChange',event)
359
317
  resolve({longitude:event.longitude,latitude:event.latitude})
360
318
  })
361
319
  },
@@ -363,7 +321,7 @@ let JsSDK = (function () {
363
321
  reject()
364
322
  }
365
323
  }).then(resp => {
366
- console.log(resp)
324
+ console.log('企业微信开启连续定位',resp)
367
325
  })
368
326
  }).catch((error)=>{
369
327
  reject('企业微信开启连续定位失败:'+error)