@tmsfe/tms-core 0.0.109 → 0.0.111
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 +1 -1
- package/src/location/index.ts +41 -31
package/package.json
CHANGED
package/src/location/index.ts
CHANGED
|
@@ -55,19 +55,19 @@ let ipLocationPromise: null | Promise<IpLocationType> = null; // ip定位请求
|
|
|
55
55
|
*/
|
|
56
56
|
class Location extends LocationBase {
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
* @desc 默认位置信息
|
|
59
|
+
* @property {object} locForNoAuth 默认的位置信息
|
|
60
|
+
* @property {string} locForNoAuth.privince 省份信息
|
|
61
|
+
* @property {string} locForNoAuth.cityCode 城市编码
|
|
62
|
+
* @property {string} locForNoAuth.cityName 城市名称
|
|
63
|
+
* @property {string} locForNoAuth.district 地区名称
|
|
64
|
+
* @property {string} locForNoAuth.latitude 维度
|
|
65
|
+
* @property {string} locForNoAuth.longitude 经度
|
|
66
|
+
* @example
|
|
67
|
+
* const app = getApp({ allowDefault: true });
|
|
68
|
+
* const locationManager = app.tms.getLocationManager(); // 获取位置管理器
|
|
69
|
+
* console.log(locationManager.locForNoAuth) // 获取默认位置
|
|
70
|
+
*/
|
|
71
71
|
public locForNoAuth = {
|
|
72
72
|
province: '广东省',
|
|
73
73
|
cityCode: '440300',
|
|
@@ -133,7 +133,7 @@ class Location extends LocationBase {
|
|
|
133
133
|
|
|
134
134
|
return Promise.reject(res);
|
|
135
135
|
})
|
|
136
|
-
|
|
136
|
+
.catch(err => Promise.reject(err));
|
|
137
137
|
|
|
138
138
|
return userLocationCache[cacheName];
|
|
139
139
|
}
|
|
@@ -175,8 +175,13 @@ class Location extends LocationBase {
|
|
|
175
175
|
*/
|
|
176
176
|
getLocationDetail(showModalWhenCloseAuth = false, type = LocationType, content = '', getPoi = 0) {
|
|
177
177
|
return this.getLocation(showModalWhenCloseAuth, type, content)
|
|
178
|
-
|
|
179
|
-
.
|
|
178
|
+
.then(async (res: WxPostionType) => {
|
|
179
|
+
const res2 = await this.getPoiInfo(res.latitude, res.longitude, getPoi);
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
res2.accuracy = res.accuracy;
|
|
182
|
+
return res2;
|
|
183
|
+
})
|
|
184
|
+
.catch(err => Promise.reject(err));
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
/**
|
|
@@ -211,8 +216,13 @@ class Location extends LocationBase {
|
|
|
211
216
|
*/
|
|
212
217
|
getLocationDetailSilent(getPoi = 0, type = 'gcj02') {
|
|
213
218
|
return this.getLocationSilent(type)
|
|
214
|
-
|
|
215
|
-
.
|
|
219
|
+
.then(async (res: WxPostionType) => {
|
|
220
|
+
const res2 = await this.getPoiInfo(res.latitude, res.longitude, getPoi);
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
res2.accuracy = res.accuracy;
|
|
223
|
+
return res2;
|
|
224
|
+
})
|
|
225
|
+
.catch(err => Promise.reject(err));
|
|
216
226
|
}
|
|
217
227
|
|
|
218
228
|
/**
|
|
@@ -229,7 +239,7 @@ class Location extends LocationBase {
|
|
|
229
239
|
* longitude: 116.2545454,
|
|
230
240
|
* adCode: 1212144,
|
|
231
241
|
* }
|
|
232
|
-
|
|
242
|
+
*/
|
|
233
243
|
getUserLocation(): PostionType | undefined {
|
|
234
244
|
return userLocation;
|
|
235
245
|
}
|
|
@@ -327,18 +337,18 @@ class Location extends LocationBase {
|
|
|
327
337
|
if (ipLocationPromise === null || force) {
|
|
328
338
|
ipLocationPromise = new Promise((resolve, reject) => {
|
|
329
339
|
request.post('basic/lbs/decodeip')
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
.then((res) => {
|
|
341
|
+
if (res.errCode === 0) {
|
|
342
|
+
resolve(res.resData as IpLocationType);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
reject({ erMsg: res.errMsg });
|
|
346
|
+
ipLocationPromise = null;
|
|
347
|
+
})
|
|
348
|
+
.catch((e) => {
|
|
349
|
+
reject(e);
|
|
350
|
+
ipLocationPromise = null;
|
|
351
|
+
});
|
|
342
352
|
});
|
|
343
353
|
}
|
|
344
354
|
return ipLocationPromise;
|