@10yun/cv-mobile-ui 0.5.38 → 0.5.40

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.
@@ -0,0 +1,485 @@
1
+ function AMapWX(a) {
2
+ this.key = a.key;
3
+ this.requestConfig = {
4
+ key: a.key,
5
+ s: 'rsx',
6
+ platform: 'WXJS',
7
+ appname: a.key,
8
+ sdkversion: '1.2.0',
9
+ logversion: '2.0'
10
+ };
11
+ this.MeRequestConfig = {
12
+ key: a.key,
13
+ serviceName: 'https://restapi.amap.com/rest/me'
14
+ };
15
+ }
16
+ AMapWX.prototype.getWxLocation = function (a, b) {
17
+ wx.getLocation({
18
+ type: 'gcj02',
19
+ success: function (c) {
20
+ c = c.longitude + ',' + c.latitude;
21
+ wx.setStorage({
22
+ key: 'userLocation',
23
+ data: c
24
+ });
25
+ b(c);
26
+ },
27
+ fail: function (c) {
28
+ wx.getStorage({
29
+ key: 'userLocation',
30
+ success: function (d) {
31
+ d.data && b(d.data);
32
+ }
33
+ });
34
+ a.fail({ errCode: '0', errMsg: c.errMsg || '' });
35
+ }
36
+ });
37
+ };
38
+ AMapWX.prototype.getMEKeywordsSearch = function (a) {
39
+ if (!a.options) return a.fail({ errCode: '0', errMsg: '\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570' });
40
+ var b = a.options,
41
+ c = this.MeRequestConfig,
42
+ d = { key: c.key, s: 'rsx', platform: 'WXJS', appname: a.key, sdkversion: '1.2.0', logversion: '2.0' };
43
+ b.layerId && (d.layerId = b.layerId);
44
+ b.keywords && (d.keywords = b.keywords);
45
+ b.city && (d.city = b.city);
46
+ b.filter && (d.filter = b.filter);
47
+ b.sortrule && (d.sortrule = b.sortrule);
48
+ b.pageNum && (d.pageNum = b.pageNum);
49
+ b.pageSize && (d.pageSize = b.pageSize);
50
+ b.sig && (d.sig = b.sig);
51
+ wx.request({
52
+ url: c.serviceName + '/cpoint/datasearch/local',
53
+ data: d,
54
+ method: 'GET',
55
+ header: { 'content-type': 'application/json' },
56
+ success: function (e) {
57
+ (e = e.data) && e.status && '1' === e.status && 0 === e.code ? a.success(e.data) : a.fail({ errCode: '0', errMsg: e });
58
+ },
59
+ fail: function (e) {
60
+ a.fail({ errCode: '0', errMsg: e.errMsg || '' });
61
+ }
62
+ });
63
+ };
64
+ AMapWX.prototype.getMEIdSearch = function (a) {
65
+ if (!a.options) return a.fail({ errCode: '0', errMsg: '\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570' });
66
+ var b = a.options,
67
+ c = this.MeRequestConfig,
68
+ d = { key: c.key, s: 'rsx', platform: 'WXJS', appname: a.key, sdkversion: '1.2.0', logversion: '2.0' };
69
+ b.layerId && (d.layerId = b.layerId);
70
+ b.id && (d.id = b.id);
71
+ b.sig && (d.sig = b.sig);
72
+ wx.request({
73
+ url: c.serviceName + '/cpoint/datasearch/id',
74
+ data: d,
75
+ method: 'GET',
76
+ header: { 'content-type': 'application/json' },
77
+ success: function (e) {
78
+ (e = e.data) && e.status && '1' === e.status && 0 === e.code ? a.success(e.data) : a.fail({ errCode: '0', errMsg: e });
79
+ },
80
+ fail: function (e) {
81
+ a.fail({ errCode: '0', errMsg: e.errMsg || '' });
82
+ }
83
+ });
84
+ };
85
+ AMapWX.prototype.getMEPolygonSearch = function (a) {
86
+ if (!a.options) return a.fail({ errCode: '0', errMsg: '\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570' });
87
+ var b = a.options,
88
+ c = this.MeRequestConfig,
89
+ d = { key: c.key, s: 'rsx', platform: 'WXJS', appname: a.key, sdkversion: '1.2.0', logversion: '2.0' };
90
+ b.layerId && (d.layerId = b.layerId);
91
+ b.keywords && (d.keywords = b.keywords);
92
+ b.polygon && (d.polygon = b.polygon);
93
+ b.filter && (d.filter = b.filter);
94
+ b.sortrule && (d.sortrule = b.sortrule);
95
+ b.pageNum && (d.pageNum = b.pageNum);
96
+ b.pageSize && (d.pageSize = b.pageSize);
97
+ b.sig && (d.sig = b.sig);
98
+ wx.request({
99
+ url: c.serviceName + '/cpoint/datasearch/polygon',
100
+ data: d,
101
+ method: 'GET',
102
+ header: { 'content-type': 'application/json' },
103
+ success: function (e) {
104
+ (e = e.data) && e.status && '1' === e.status && 0 === e.code ? a.success(e.data) : a.fail({ errCode: '0', errMsg: e });
105
+ },
106
+ fail: function (e) {
107
+ a.fail({ errCode: '0', errMsg: e.errMsg || '' });
108
+ }
109
+ });
110
+ };
111
+ AMapWX.prototype.getMEaroundSearch = function (a) {
112
+ if (!a.options) return a.fail({ errCode: '0', errMsg: '\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570' });
113
+ var b = a.options,
114
+ c = this.MeRequestConfig,
115
+ d = { key: c.key, s: 'rsx', platform: 'WXJS', appname: a.key, sdkversion: '1.2.0', logversion: '2.0' };
116
+ b.layerId && (d.layerId = b.layerId);
117
+ b.keywords && (d.keywords = b.keywords);
118
+ b.center && (d.center = b.center);
119
+ b.radius && (d.radius = b.radius);
120
+ b.filter && (d.filter = b.filter);
121
+ b.sortrule && (d.sortrule = b.sortrule);
122
+ b.pageNum && (d.pageNum = b.pageNum);
123
+ b.pageSize && (d.pageSize = b.pageSize);
124
+ b.sig && (d.sig = b.sig);
125
+ wx.request({
126
+ url: c.serviceName + '/cpoint/datasearch/around',
127
+ data: d,
128
+ method: 'GET',
129
+ header: { 'content-type': 'application/json' },
130
+ success: function (e) {
131
+ (e = e.data) && e.status && '1' === e.status && 0 === e.code ? a.success(e.data) : a.fail({ errCode: '0', errMsg: e });
132
+ },
133
+ fail: function (e) {
134
+ a.fail({ errCode: '0', errMsg: e.errMsg || '' });
135
+ }
136
+ });
137
+ };
138
+ AMapWX.prototype.getGeo = function (a) {
139
+ var b = this.requestConfig,
140
+ c = a.options;
141
+ b = {
142
+ key: this.key,
143
+ extensions: 'all',
144
+ s: b.s,
145
+ platform: b.platform,
146
+ appname: this.key,
147
+ sdkversion: b.sdkversion,
148
+ logversion: b.logversion
149
+ };
150
+ c.address && (b.address = c.address);
151
+ c.city && (b.city = c.city);
152
+ c.batch && (b.batch = c.batch);
153
+ c.sig && (b.sig = c.sig);
154
+ wx.request({
155
+ url: 'https://restapi.amap.com/v3/geocode/geo',
156
+ data: b,
157
+ method: 'GET',
158
+ header: { 'content-type': 'application/json' },
159
+ success: function (d) {
160
+ (d = d.data) && d.status && '1' === d.status ? a.success(d) : a.fail({ errCode: '0', errMsg: d });
161
+ },
162
+ fail: function (d) {
163
+ a.fail({ errCode: '0', errMsg: d.errMsg || '' });
164
+ }
165
+ });
166
+ };
167
+ AMapWX.prototype.getRegeo = function (a) {
168
+ function b(d) {
169
+ var e = c.requestConfig;
170
+ wx.request({
171
+ url: 'https://restapi.amap.com/v3/geocode/regeo',
172
+ data: {
173
+ key: c.key,
174
+ location: d,
175
+ extensions: 'all',
176
+ s: e.s,
177
+ platform: e.platform,
178
+ appname: c.key,
179
+ sdkversion: e.sdkversion,
180
+ logversion: e.logversion
181
+ },
182
+ method: 'GET',
183
+ header: { 'content-type': 'application/json' },
184
+ success: function (g) {
185
+ if (g.data.status && '1' == g.data.status) {
186
+ g = g.data.regeocode;
187
+ var h = g.addressComponent,
188
+ f = [],
189
+ k = g.roads[0].name + '\u9644\u8fd1',
190
+ m = d.split(',')[0],
191
+ n = d.split(',')[1];
192
+ if (g.pois && g.pois[0]) {
193
+ k = g.pois[0].name + '\u9644\u8fd1';
194
+ var l = g.pois[0].location;
195
+ l && ((m = parseFloat(l.split(',')[0])), (n = parseFloat(l.split(',')[1])));
196
+ }
197
+ h.provice && f.push(h.provice);
198
+ h.city && f.push(h.city);
199
+ h.district && f.push(h.district);
200
+ h.streetNumber && h.streetNumber.street && h.streetNumber.number
201
+ ? (f.push(h.streetNumber.street), f.push(h.streetNumber.number))
202
+ : f.push(g.roads[0].name);
203
+ f = f.join('');
204
+ a.success([
205
+ {
206
+ iconPath: a.iconPath,
207
+ width: a.iconWidth,
208
+ height: a.iconHeight,
209
+ name: f,
210
+ desc: k,
211
+ longitude: m,
212
+ latitude: n,
213
+ id: 0,
214
+ regeocodeData: g
215
+ }
216
+ ]);
217
+ } else a.fail({ errCode: g.data.infocode, errMsg: g.data.info });
218
+ },
219
+ fail: function (g) {
220
+ a.fail({ errCode: '0', errMsg: g.errMsg || '' });
221
+ }
222
+ });
223
+ }
224
+ var c = this;
225
+ a.location
226
+ ? b(a.location)
227
+ : c.getWxLocation(a, function (d) {
228
+ b(d);
229
+ });
230
+ };
231
+ AMapWX.prototype.getWeather = function (a) {
232
+ function b(g) {
233
+ var h = 'base';
234
+ a.type && 'forecast' == a.type && (h = 'all');
235
+ wx.request({
236
+ url: 'https://restapi.amap.com/v3/weather/weatherInfo',
237
+ data: {
238
+ key: d.key,
239
+ city: g,
240
+ extensions: h,
241
+ s: e.s,
242
+ platform: e.platform,
243
+ appname: d.key,
244
+ sdkversion: e.sdkversion,
245
+ logversion: e.logversion
246
+ },
247
+ method: 'GET',
248
+ header: { 'content-type': 'application/json' },
249
+ success: function (f) {
250
+ if (f.data.status && '1' == f.data.status)
251
+ if (f.data.lives) {
252
+ if ((f = f.data.lives) && 0 < f.length) {
253
+ f = f[0];
254
+ var k = {
255
+ city: { text: '\u57ce\u5e02', data: f.city },
256
+ weather: { text: '\u5929\u6c14', data: f.weather },
257
+ temperature: { text: '\u6e29\u5ea6', data: f.temperature },
258
+ winddirection: { text: '\u98ce\u5411', data: f.winddirection + '\u98ce' },
259
+ windpower: { text: '\u98ce\u529b', data: f.windpower + '\u7ea7' },
260
+ humidity: { text: '\u6e7f\u5ea6', data: f.humidity + '%' }
261
+ };
262
+ k.liveData = f;
263
+ a.success(k);
264
+ }
265
+ } else f.data.forecasts && f.data.forecasts[0] && a.success({ forecast: f.data.forecasts[0] });
266
+ else a.fail({ errCode: f.data.infocode, errMsg: f.data.info });
267
+ },
268
+ fail: function (f) {
269
+ a.fail({ errCode: '0', errMsg: f.errMsg || '' });
270
+ }
271
+ });
272
+ }
273
+ function c(g) {
274
+ wx.request({
275
+ url: 'https://restapi.amap.com/v3/geocode/regeo',
276
+ data: {
277
+ key: d.key,
278
+ location: g,
279
+ extensions: 'all',
280
+ s: e.s,
281
+ platform: e.platform,
282
+ appname: d.key,
283
+ sdkversion: e.sdkversion,
284
+ logversion: e.logversion
285
+ },
286
+ method: 'GET',
287
+ header: { 'content-type': 'application/json' },
288
+ success: function (h) {
289
+ if (h.data.status && '1' == h.data.status) {
290
+ h = h.data.regeocode;
291
+ if (h.addressComponent) var f = h.addressComponent.adcode;
292
+ else h.aois && 0 < h.aois.length && (f = h.aois[0].adcode);
293
+ b(f);
294
+ } else a.fail({ errCode: h.data.infocode, errMsg: h.data.info });
295
+ },
296
+ fail: function (h) {
297
+ a.fail({ errCode: '0', errMsg: h.errMsg || '' });
298
+ }
299
+ });
300
+ }
301
+ var d = this,
302
+ e = d.requestConfig;
303
+ a.city
304
+ ? b(a.city)
305
+ : d.getWxLocation(a, function (g) {
306
+ c(g);
307
+ });
308
+ };
309
+ AMapWX.prototype.getPoiAround = function (a) {
310
+ function b(e) {
311
+ e = {
312
+ key: c.key,
313
+ location: e,
314
+ s: d.s,
315
+ platform: d.platform,
316
+ appname: c.key,
317
+ sdkversion: d.sdkversion,
318
+ logversion: d.logversion
319
+ };
320
+ a.querytypes && (e.types = a.querytypes);
321
+ a.querykeywords && (e.keywords = a.querykeywords);
322
+ wx.request({
323
+ url: 'https://restapi.amap.com/v3/place/around',
324
+ data: e,
325
+ method: 'GET',
326
+ header: { 'content-type': 'application/json' },
327
+ success: function (g) {
328
+ if (g.data.status && '1' == g.data.status) {
329
+ if ((g = g.data) && g.pois) {
330
+ for (var h = [], f = 0; f < g.pois.length; f++) {
331
+ var k = 0 == f ? a.iconPathSelected : a.iconPath;
332
+ h.push({
333
+ latitude: parseFloat(g.pois[f].location.split(',')[1]),
334
+ longitude: parseFloat(g.pois[f].location.split(',')[0]),
335
+ iconPath: k,
336
+ width: 22,
337
+ height: 32,
338
+ id: f,
339
+ name: g.pois[f].name,
340
+ address: g.pois[f].address
341
+ });
342
+ }
343
+ a.success({ markers: h, poisData: g.pois });
344
+ }
345
+ } else a.fail({ errCode: g.data.infocode, errMsg: g.data.info });
346
+ },
347
+ fail: function (g) {
348
+ a.fail({ errCode: '0', errMsg: g.errMsg || '' });
349
+ }
350
+ });
351
+ }
352
+ var c = this,
353
+ d = c.requestConfig;
354
+ a.location
355
+ ? b(a.location)
356
+ : c.getWxLocation(a, function (e) {
357
+ b(e);
358
+ });
359
+ };
360
+ AMapWX.prototype.getStaticmap = function (a) {
361
+ function b(e) {
362
+ c.push('location=' + e);
363
+ a.zoom && c.push('zoom=' + a.zoom);
364
+ a.size && c.push('size=' + a.size);
365
+ a.scale && c.push('scale=' + a.scale);
366
+ a.markers && c.push('markers=' + a.markers);
367
+ a.labels && c.push('labels=' + a.labels);
368
+ a.paths && c.push('paths=' + a.paths);
369
+ a.traffic && c.push('traffic=' + a.traffic);
370
+ e = 'https://restapi.amap.com/v3/staticmap?' + c.join('&');
371
+ a.success({ url: e });
372
+ }
373
+ var c = [];
374
+ c.push('key=' + this.key);
375
+ var d = this.requestConfig;
376
+ c.push('s=' + d.s);
377
+ c.push('platform=' + d.platform);
378
+ c.push('appname=' + d.appname);
379
+ c.push('sdkversion=' + d.sdkversion);
380
+ c.push('logversion=' + d.logversion);
381
+ a.location
382
+ ? b(a.location)
383
+ : this.getWxLocation(a, function (e) {
384
+ b(e);
385
+ });
386
+ };
387
+ AMapWX.prototype.getInputtips = function (a) {
388
+ var b = Object.assign({}, this.requestConfig);
389
+ a.location && (b.location = a.location);
390
+ a.keywords && (b.keywords = a.keywords);
391
+ a.type && (b.type = a.type);
392
+ a.city && (b.city = a.city);
393
+ a.citylimit && (b.citylimit = a.citylimit);
394
+ wx.request({
395
+ url: 'https://restapi.amap.com/v3/assistant/inputtips',
396
+ data: b,
397
+ method: 'GET',
398
+ header: { 'content-type': 'application/json' },
399
+ success: function (c) {
400
+ c && c.data && c.data.tips && a.success({ tips: c.data.tips });
401
+ },
402
+ fail: function (c) {
403
+ a.fail({ errCode: '0', errMsg: c.errMsg || '' });
404
+ }
405
+ });
406
+ };
407
+ AMapWX.prototype.getDrivingRoute = function (a) {
408
+ var b = Object.assign({}, this.requestConfig);
409
+ a.origin && (b.origin = a.origin);
410
+ a.destination && (b.destination = a.destination);
411
+ a.strategy && (b.strategy = a.strategy);
412
+ a.waypoints && (b.waypoints = a.waypoints);
413
+ a.avoidpolygons && (b.avoidpolygons = a.avoidpolygons);
414
+ a.avoidroad && (b.avoidroad = a.avoidroad);
415
+ wx.request({
416
+ url: 'https://restapi.amap.com/v3/direction/driving',
417
+ data: b,
418
+ method: 'GET',
419
+ header: { 'content-type': 'application/json' },
420
+ success: function (c) {
421
+ c && c.data && c.data.route && a.success({ paths: c.data.route.paths, taxi_cost: c.data.route.taxi_cost || '' });
422
+ },
423
+ fail: function (c) {
424
+ a.fail({ errCode: '0', errMsg: c.errMsg || '' });
425
+ }
426
+ });
427
+ };
428
+ AMapWX.prototype.getWalkingRoute = function (a) {
429
+ var b = Object.assign({}, this.requestConfig);
430
+ a.origin && (b.origin = a.origin);
431
+ a.destination && (b.destination = a.destination);
432
+ wx.request({
433
+ url: 'https://restapi.amap.com/v3/direction/walking',
434
+ data: b,
435
+ method: 'GET',
436
+ header: { 'content-type': 'application/json' },
437
+ success: function (c) {
438
+ c && c.data && c.data.route && a.success({ paths: c.data.route.paths });
439
+ },
440
+ fail: function (c) {
441
+ a.fail({ errCode: '0', errMsg: c.errMsg || '' });
442
+ }
443
+ });
444
+ };
445
+ AMapWX.prototype.getTransitRoute = function (a) {
446
+ var b = Object.assign({}, this.requestConfig);
447
+ a.origin && (b.origin = a.origin);
448
+ a.destination && (b.destination = a.destination);
449
+ a.strategy && (b.strategy = a.strategy);
450
+ a.city && (b.city = a.city);
451
+ a.cityd && (b.cityd = a.cityd);
452
+ wx.request({
453
+ url: 'https://restapi.amap.com/v3/direction/transit/integrated',
454
+ data: b,
455
+ method: 'GET',
456
+ header: { 'content-type': 'application/json' },
457
+ success: function (c) {
458
+ c &&
459
+ c.data &&
460
+ c.data.route &&
461
+ ((c = c.data.route), a.success({ distance: c.distance || '', taxi_cost: c.taxi_cost || '', transits: c.transits }));
462
+ },
463
+ fail: function (c) {
464
+ a.fail({ errCode: '0', errMsg: c.errMsg || '' });
465
+ }
466
+ });
467
+ };
468
+ AMapWX.prototype.getRidingRoute = function (a) {
469
+ var b = Object.assign({}, this.requestConfig);
470
+ a.origin && (b.origin = a.origin);
471
+ a.destination && (b.destination = a.destination);
472
+ wx.request({
473
+ url: 'https://restapi.amap.com/v3/direction/riding',
474
+ data: b,
475
+ method: 'GET',
476
+ header: { 'content-type': 'application/json' },
477
+ success: function (c) {
478
+ c && c.data && c.data.route && a.success({ paths: c.data.route.paths });
479
+ },
480
+ fail: function (c) {
481
+ a.fail({ errCode: '0', errMsg: c.errMsg || '' });
482
+ }
483
+ });
484
+ };
485
+ module.exports.AMapWX = AMapWX;