WebApp【公共组件库】@前端(For Git Submodule)
‘chensiAb’
2025-04-01 196aac76666571c60536973418bff3da63bef1d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/**
 * 百度地图微信小程序 SDK
 */
 
'use strict';
function _classCallCheck(t, a) {
    if (!(t instanceof a)) throw new TypeError('Cannot call a class as a function');
}
var _createClass = (function() {
        function t(t, a) {
            for (var e = 0; e < a.length; e++) {
                var i = a[e];
                (i.enumerable = i.enumerable || !1),
                    (i.configurable = !0),
                    'value' in i && (i.writable = !0),
                    Object.defineProperty(t, i.key, i);
            }
        }
        return function(a, e, i) {
            return e && t(a.prototype, e), i && t(a, i), a;
        };
    })(),
    BMapWX = (function() {
        function t(a) {
            _classCallCheck(this, t), (this.ak = a.ak);
        }
        return (
            _createClass(t, [
                {
                    key: 'getWXLocation',
                    value: function(t, a, e, i) {
                        (t = t || 'gcj02'),
                            (a = a || function() {}),
                            (e = e || function() {}),
                            (i = i || function() {}),
                            wx.getLocation({ type: t, success: a, fail: e, complete: i });
                    },
                },
                {
                    key: 'search',
                    value: function(t) {
                        var a = this;
                        t = t || {};
                        var e = {
                                query: t.query || '生活服务$美食&酒店',
                                scope: t.scope || 1,
                                filter: t.filter || '',
                                coord_type: t.coord_type || 2,
                                page_size: t.page_size || 10,
                                page_num: t.page_num || 0,
                                output: t.output || 'json',
                                ak: a.ak,
                                sn: t.sn || '',
                                timestamp: t.timestamp || '',
                                radius: t.radius || 2e3,
                                ret_coordtype: 'gcj02ll',
                            },
                            i = {
                                iconPath: t.iconPath,
                                iconTapPath: t.iconTapPath,
                                width: t.width,
                                height: t.height,
                                alpha: t.alpha || 1,
                                success: t.success || function() {},
                                fail: t.fail || function() {},
                            },
                            n = function(t) {
                                (e.location = t.latitude + ',' + t.longitude),
                                    wx.request({
                                        url: 'https://api.map.baidu.com/place/v2/search',
                                        data: e,
                                        header: { 'content-type': 'application/json' },
                                        method: 'GET',
                                        success: function(t) {
                                            var a = t.data;
                                            if (0 === a.status) {
                                                var e = a.results,
                                                    n = {};
                                                (n.originalData = a), (n.wxMarkerData = []);
                                                for (var s = 0; s < e.length; s++)
                                                    n.wxMarkerData[s] = {
                                                        id: s,
                                                        latitude: e[s].location.lat,
                                                        longitude: e[s].location.lng,
                                                        title: e[s].name,
                                                        iconPath: i.iconPath,
                                                        iconTapPath: i.iconTapPath,
                                                        address: e[s].address,
                                                        telephone: e[s].telephone,
                                                        alpha: i.alpha,
                                                        width: i.width,
                                                        height: i.height,
                                                    };
                                                i.success(n);
                                            } else
                                                i.fail({ errMsg: a.message, statusCode: a.status });
                                        },
                                        fail: function(t) {
                                            i.fail(t);
                                        },
                                    });
                            },
                            s = function(t) {
                                i.fail(t);
                            },
                            o = function(t) {};
                        if (t.location) {
                            var c = t.location.split(',')[1];
                            n({
                                errMsg: 'input location',
                                latitude: t.location.split(',')[0],
                                longitude: c,
                            });
                        } else a.getWXLocation('gcj02', n, s, o);
                    },
                },
                {
                    key: 'suggestion',
                    value: function(t) {
                        var a = this;
                        t = t || {};
                        var e = {
                                query: t.query || '',
                                region: t.region || '全国',
                                city_limit: t.city_limit || !1,
                                output: t.output || 'json',
                                ak: a.ak,
                                sn: t.sn || '',
                                timestamp: t.timestamp || '',
                                ret_coordtype: 'gcj02ll',
                            },
                            i = {
                                success: t.success || function() {},
                                fail: t.fail || function() {},
                            };
                        wx.request({
                            url: 'https://api.map.baidu.com/place/v2/suggestion',
                            data: e,
                            header: { 'content-type': 'application/json' },
                            method: 'GET',
                            success: function(t) {
                                var a = t.data;
                                0 === a.status
                                    ? i.success(a)
                                    : i.fail({ errMsg: a.message, statusCode: a.status });
                            },
                            fail: function(t) {
                                i.fail(t);
                            },
                        });
                    },
                },
                {
                    key: 'regeocoding',
                    value: function(t) {
                        var a = this;
                        t = t || {};
                        var e = {
                                coordtype: t.coordtype || 'gcj02ll',
                                ret_coordtype: 'gcj02ll',
                                radius: t.radius || 1e3,
                                ak: a.ak,
                                sn: t.sn || '',
                                output: t.output || 'json',
                                callback: t.callback || function() {},
                                extensions_poi: t.extensions_poi || 1,
                                extensions_road: t.extensions_road || !1,
                                extensions_town: t.extensions_town || !1,
                                language: t.language || 'zh-CN',
                                language_auto: t.language_auto || 0,
                            },
                            i = {
                                iconPath: t.iconPath,
                                iconTapPath: t.iconTapPath,
                                width: t.width,
                                height: t.height,
                                alpha: t.alpha || 1,
                                success: t.success || function() {},
                                fail: t.fail || function() {},
                            },
                            n = function(t) {
                                (e.location = t.latitude + ',' + t.longitude),
                                    wx.request({
                                        url: 'https://api.map.baidu.com/reverse_geocoding/v3',
                                        data: e,
                                        header: { 'content-type': 'application/json' },
                                        method: 'GET',
                                        success: function(a) {
                                            var e = a.data;
                                            if (0 === e.status) {
                                                var n = e.result,
                                                    s = {};
                                                (s.originalData = e),
                                                    (s.wxMarkerData = []),
                                                    (s.wxMarkerData[0] = {
                                                        id: 0,
                                                        latitude: t.latitude,
                                                        longitude: t.longitude,
                                                        address: n.formatted_address,
                                                        iconPath: i.iconPath,
                                                        iconTapPath: i.iconTapPath,
                                                        desc: n.sematic_description,
                                                        business: n.business,
                                                        alpha: i.alpha,
                                                        width: i.width,
                                                        height: i.height,
                                                    }),
                                                    i.success(s);
                                            } else
                                                i.fail({ errMsg: e.message, statusCode: e.status });
                                        },
                                        fail: function(t) {
                                            i.fail(t);
                                        },
                                    });
                            },
                            s = function(t) {
                                i.fail(t);
                            },
                            o = function(t) {};
                        if (t.location) {
                            var c = t.location.split(',')[1];
                            n({
                                errMsg: 'input location',
                                latitude: t.location.split(',')[0],
                                longitude: c,
                            });
                        } else a.getWXLocation('gcj02', n, s, o);
                    },
                },
                {
                    key: 'geocoding',
                    value: function(t) {
                        var a = this;
                        t = t || {};
                        var e = {
                                address: t.address || '',
                                city: t.city || '',
                                ret_coordtype: t.coordtype || 'gcj02ll',
                                ak: a.ak,
                                sn: t.sn || '',
                                output: t.output || 'json',
                                callback: t.callback || function() {},
                            },
                            i = {
                                iconPath: t.iconPath,
                                iconTapPath: t.iconTapPath,
                                width: t.width,
                                height: t.height,
                                alpha: t.alpha || 1,
                                success: t.success || function() {},
                                fail: t.fail || function() {},
                            };
                        if (t.address)
                            wx.request({
                                url: 'https://api.map.baidu.com/geocoding/v3',
                                data: e,
                                header: { 'content-type': 'application/json' },
                                method: 'GET',
                                success: function(t) {
                                    var a = t.data;
                                    if (0 === a.status) {
                                        var e = a.result,
                                            n = a;
                                        (n.originalData = a),
                                            (n.wxMarkerData = []),
                                            (n.wxMarkerData[0] = {
                                                id: 0,
                                                latitude: e.location.lat,
                                                longitude: e.location.lng,
                                                iconPath: i.iconPath,
                                                iconTapPath: i.iconTapPath,
                                                alpha: i.alpha,
                                                width: i.width,
                                                height: i.height,
                                            }),
                                            i.success(n);
                                    } else i.fail({ errMsg: a.message, statusCode: a.status });
                                },
                                fail: function(t) {
                                    i.fail(t);
                                },
                            });
                        else {
                            var n = { errMsg: 'input address!' };
                            i.fail(n);
                        }
                    },
                },
                {
                    key: 'weather',
                    value: function(t) {
                        var a = this;
                        t = t || {};
                        var e = {
                                coord_type: t.coord_type || 'gcj02',
                                output: t.output || 'json',
                                ak: a.ak,
                                sn: t.sn || '',
                                timestamp: t.timestamp || '',
                            },
                            i = {
                                success: t.success || function() {},
                                fail: t.fail || function() {},
                            },
                            n = function(t) {
                                (e.location = t.longitude + ',' + t.latitude),
                                    wx.request({
                                        url: 'https://api.map.baidu.com/telematics/v3/weather',
                                        data: e,
                                        header: { 'content-type': 'application/json' },
                                        method: 'GET',
                                        success: function(t) {
                                            var a = t.data;
                                            if (0 === a.error && 'success' === a.status) {
                                                var e = a.results,
                                                    n = {};
                                                (n.originalData = a),
                                                    (n.currentWeather = []),
                                                    (n.currentWeather[0] = {
                                                        currentCity: e[0].currentCity,
                                                        pm25: e[0].pm25,
                                                        date: e[0].weather_data[0].date,
                                                        temperature:
                                                            e[0].weather_data[0].temperature,
                                                        weatherDesc: e[0].weather_data[0].weather,
                                                        wind: e[0].weather_data[0].wind,
                                                    }),
                                                    i.success(n);
                                            } else
                                                i.fail({ errMsg: a.message, statusCode: a.status });
                                        },
                                        fail: function(t) {
                                            i.fail(t);
                                        },
                                    });
                            },
                            s = function(t) {
                                i.fail(t);
                            },
                            o = function(t) {};
                        if (t.location) {
                            var c = t.location.split(',')[0];
                            n({
                                errMsg: 'input location',
                                latitude: t.location.split(',')[1],
                                longitude: c,
                            });
                        } else a.getWXLocation('gcj02', n, s, o);
                    },
                },
            ]),
            t
        );
    })();
module.exports.BMapWX = BMapWX;