@tmsfe/tms-core 0.0.83 → 0.0.84

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.83",
3
+ "version": "0.0.84",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,27 +17,20 @@
17
17
  "esm"
18
18
  ]
19
19
  },
20
- "whiteDependencies": {
21
- "@babel/core": "ignore",
22
- "@babel/plugin-proposal-optional-chaining": "ignore",
23
- "@typescript-eslint/eslint-plugin": "ignore",
24
- "@typescript-eslint/parser": "ignore",
25
- "miniprogram-api-typings": "ignore"
26
- },
27
20
  "devDependencies": {
28
- "@babel/core": "^7.15.0",
21
+ "@babel/core": "^7.17.9",
29
22
  "@babel/plugin-proposal-class-properties": "^7.14.5",
30
23
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
31
- "@babel/plugin-proposal-optional-chaining": "^7.14.2",
24
+ "@babel/plugin-proposal-optional-chaining": "^7.14.5",
32
25
  "@rollup/plugin-babel": "^5.0.2",
33
26
  "@rollup/plugin-commonjs": "^19.0.0",
34
27
  "@rollup/plugin-dynamic-import-vars": "^1.1.1",
35
28
  "@rollup/plugin-json": "^4.0.3",
36
- "@typescript-eslint/eslint-plugin": "^4.29.3",
37
- "@typescript-eslint/parser": "^4.29.3",
29
+ "@typescript-eslint/eslint-plugin": "^5.2.0",
30
+ "@typescript-eslint/parser": "^5.2.0",
38
31
  "babel-core": "^6.26.3",
39
32
  "babel-preset-env": "^1.7.0",
40
- "miniprogram-api-typings": "^3.4.4",
33
+ "miniprogram-api-typings": "latest",
41
34
  "rimraf": "^3.0.2",
42
35
  "rollup": "^2.6.1",
43
36
  "rollup-plugin-node-resolve": "^5.2.0",
@@ -1,3 +1,11 @@
1
+ /**
2
+ * @desc: 位置工具方法语法糖
3
+ * @author: fenggangsun
4
+ * @date: 2022-06-27 11:46:25
5
+ * @lastEditors: fenggangsun
6
+ * @lastEditTime: 2022-06-29 17:34:24
7
+ * @copyright 2022-present, Tencent, Inc. All rights reserved.
8
+ */
1
9
  const defaultLoc = {
2
10
  province: '广东省',
3
11
  cityName: '深圳市',
@@ -29,6 +37,7 @@ const locTypeEnum = { // 位置类型
29
37
  * @param {String} option.authTip 获取实时定位,发起授权时的提示语
30
38
  * @param {Boolean} option.ipCache 是否使用缓存的 ip 位置,默认 true;ipCache = false 时会重新发起 ip 定位
31
39
  * @returns {Promise<Object>} { loc, locType }
40
+ * loc: { adCode, provinceCode, cityCode, province, cityName, longitude, latitude }
32
41
  */
33
42
  const getPrioritizedLocation = async (typeOrders, option) => {
34
43
  const { showAuth, authTip, ipCache = true } = option || {};
@@ -39,7 +48,15 @@ const getPrioritizedLocation = async (typeOrders, option) => {
39
48
  getLocProm = defaultLoc;
40
49
  break;
41
50
  case locTypeEnum.ip:
42
- getLocProm = getLocManager().getIpLocation(!ipCache);
51
+ getLocProm = getLocManager().getIpLocation(!ipCache)
52
+ .then((data) => {
53
+ const { ad_info: { adcode, cityCode, province, city }, location: { lng, lat } } = data;
54
+ return {
55
+ adCode: adcode, cityCode, provinceCode: `${cityCode.slice(0, 4)}00`,
56
+ province, cityName: city, longitude: lng, latitude: lat,
57
+ ...data,
58
+ };
59
+ });
43
60
  break;
44
61
  case locTypeEnum.real: // 实时位置
45
62
  getLocProm = getLocManager().getLocationDetail(showAuth, undefined, authTip);