@tmsfe/tms-core 0.0.88 → 0.0.89
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/utils/location/index.js +16 -4
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @author: fenggangsun
|
|
4
4
|
* @date: 2022-06-27 11:46:25
|
|
5
5
|
* @lastEditors: fenggangsun
|
|
6
|
-
* @lastEditTime: 2022-
|
|
6
|
+
* @lastEditTime: 2022-07-27 02:35:10
|
|
7
7
|
* @copyright 2022-present, Tencent, Inc. All rights reserved.
|
|
8
8
|
*/
|
|
9
9
|
const defaultLoc = {
|
|
@@ -52,8 +52,7 @@ const getPrioritizedLocation = async (typeOrders, option) => {
|
|
|
52
52
|
.then((data) => {
|
|
53
53
|
const { ad_info: { adcode, cityCode, province, city }, location: { lng, lat } } = data;
|
|
54
54
|
return {
|
|
55
|
-
adCode: adcode, cityCode,
|
|
56
|
-
province, cityName: city, longitude: lng, latitude: lat,
|
|
55
|
+
adCode: adcode, province, cityCode, cityName: city, longitude: lng, latitude: lat,
|
|
57
56
|
...data,
|
|
58
57
|
};
|
|
59
58
|
});
|
|
@@ -70,11 +69,24 @@ const getPrioritizedLocation = async (typeOrders, option) => {
|
|
|
70
69
|
default: break;
|
|
71
70
|
}
|
|
72
71
|
const loc = await Promise.resolve(getLocProm).catch(() => null);
|
|
73
|
-
if (loc) return {
|
|
72
|
+
if (loc) return {
|
|
73
|
+
locType,
|
|
74
|
+
loc: {
|
|
75
|
+
...loc,
|
|
76
|
+
provinceCode: parseProvinceCode(loc),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
74
79
|
}
|
|
75
80
|
return Promise.reject('按照参数指定的类型未能获取到位置');
|
|
76
81
|
};
|
|
77
82
|
|
|
83
|
+
const parseProvinceCode = (loc) => {
|
|
84
|
+
if (!loc) return '';
|
|
85
|
+
const { provinceCode, cityCode } = loc;
|
|
86
|
+
if (provinceCode) return provinceCode;
|
|
87
|
+
return cityCode ? cityCode.slice(0, 2).padEnd(6, 0) : '';
|
|
88
|
+
};
|
|
89
|
+
|
|
78
90
|
/**
|
|
79
91
|
* 按优先级获取用户位置
|
|
80
92
|
* @param {Boolean} visitedIndex 是否打开过首页
|