@tmsfe/tms-core 0.0.110 → 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 -41
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,13 +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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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));
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
/**
|
|
@@ -216,13 +216,13 @@ class Location extends LocationBase {
|
|
|
216
216
|
*/
|
|
217
217
|
getLocationDetailSilent(getPoi = 0, type = 'gcj02') {
|
|
218
218
|
return this.getLocationSilent(type)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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));
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/**
|
|
@@ -239,7 +239,7 @@ class Location extends LocationBase {
|
|
|
239
239
|
* longitude: 116.2545454,
|
|
240
240
|
* adCode: 1212144,
|
|
241
241
|
* }
|
|
242
|
-
|
|
242
|
+
*/
|
|
243
243
|
getUserLocation(): PostionType | undefined {
|
|
244
244
|
return userLocation;
|
|
245
245
|
}
|
|
@@ -337,18 +337,18 @@ class Location extends LocationBase {
|
|
|
337
337
|
if (ipLocationPromise === null || force) {
|
|
338
338
|
ipLocationPromise = new Promise((resolve, reject) => {
|
|
339
339
|
request.post('basic/lbs/decodeip')
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
+
});
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
return ipLocationPromise;
|