@tmsfe/tms-core 0.0.14 → 0.0.18
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/dist/index-proxy.js +10 -0
- package/dist/index.js +62 -18
- package/dist/request-f350158c.js +543 -0
- package/dist/request-fea3ef26.js +538 -0
- package/dist/request.js +1 -1
- package/package.json +1 -1
- package/src/config.js +10 -5
- package/src/fastreport.js +8 -4
- package/src/index-proxy.js +9 -0
- package/src/location/base.ts +11 -4
- package/src/location/index.ts +44 -0
- package/src/report.js +2 -2
- package/src/request.js +10 -1
package/dist/index-proxy.js
CHANGED
|
@@ -131,6 +131,16 @@ function getLocationManager() {
|
|
|
131
131
|
return setUserLocation;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
if (name === 'locForNoAuth') {
|
|
135
|
+
return {
|
|
136
|
+
province: '广东省',
|
|
137
|
+
cityCode: '440300',
|
|
138
|
+
cityName: '深圳市',
|
|
139
|
+
latitude: 22.54286,
|
|
140
|
+
longitude: 114.05956
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
return function (...args) {
|
|
135
145
|
return ps.then(() => invoke(manager, name, args));
|
|
136
146
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Request, g as getLogManager, a as getRealtimeLogManager } from './request-
|
|
1
|
+
import { R as Request, g as getLogManager, a as getRealtimeLogManager } from './request-f350158c.js';
|
|
2
2
|
import { g as getEnvInfo, a as getAuthInfo, s as setAuthInfo, i as isAppPageExist, b as getHomePage, c as setEnvInfo, d as setAppPagePaths } from './env-c7da70e1.js';
|
|
3
3
|
import { s as syncApi, f as formatPlate, a as subStr, h as hidePhoneCenter, i as isValidPhone, b as isValidPlate, c as isValidAuthCode, r as roundStr, d as formatTime, e as formatTimeStr, g as formatTimeWithDetails, j as dateToString, k as ipxInit, l as isIPX, m as getIpxClass, n as getIpxConfig, o as serialize, p as rpxToPx } from './ipxHelper-71ef86c1.js';
|
|
4
4
|
import { m as md5 } from './md5-34a9daf3.js';
|
|
@@ -37,6 +37,8 @@ const handleParamOfDifferentType = param => {
|
|
|
37
37
|
});
|
|
38
38
|
return data;
|
|
39
39
|
};
|
|
40
|
+
|
|
41
|
+
const defAssign = (value, defaultValue) => value || defaultValue;
|
|
40
42
|
/**
|
|
41
43
|
* @class FastReport
|
|
42
44
|
* @classdesc 快速上报模块,不依赖用户标识和位置
|
|
@@ -54,16 +56,20 @@ class FastReport {
|
|
|
54
56
|
* @param {Boolean} appVer 是否上报小程序版本
|
|
55
57
|
* @returns {Promsie} 返回上报结果
|
|
56
58
|
*/
|
|
57
|
-
static report(param, simulatedUserId = true, simulatedUserIdIndex = 40, reportShowScene = true, appVer = true) {
|
|
59
|
+
static report(param = {}, simulatedUserId = true, simulatedUserIdIndex = 40, reportShowScene = true, appVer = true) {
|
|
58
60
|
var _data$;
|
|
59
61
|
|
|
60
|
-
if (!
|
|
62
|
+
if (!param[27]) return Promise.reject('invalid report param');
|
|
61
63
|
const env = getEnvInfo();
|
|
62
64
|
const data = handleParamOfDifferentType(param);
|
|
63
65
|
data[9] = '2';
|
|
64
66
|
data[33] = encodeURIComponent(JSON.stringify(getSystemInfo$1()));
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
+
|
|
68
|
+
if (appVer) {
|
|
69
|
+
data[10] = defAssign(data[10], env.appVersion);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
data[26] = defAssign(data[26], (_data$ = data[27]) === null || _data$ === void 0 ? void 0 : _data$[0]);
|
|
67
73
|
data[28] = env.client;
|
|
68
74
|
|
|
69
75
|
if (reportShowScene && !data[29]) {
|
|
@@ -122,6 +128,17 @@ const parseAllCfgs = (configPaths, resData, defaultCfgs) => configPaths.map((pat
|
|
|
122
128
|
|
|
123
129
|
return {}; // 没找到配置,返回一个空对象
|
|
124
130
|
});
|
|
131
|
+
|
|
132
|
+
const formatConfigPaths = configPath => {
|
|
133
|
+
const configPaths = Array.isArray(configPath) ? configPath : [configPath];
|
|
134
|
+
const {
|
|
135
|
+
client
|
|
136
|
+
} = getEnvInfo();
|
|
137
|
+
configPaths.forEach((path, index) => {
|
|
138
|
+
configPaths[index] = path.replace(/\$\{client\}/, client);
|
|
139
|
+
});
|
|
140
|
+
return configPaths;
|
|
141
|
+
};
|
|
125
142
|
/**
|
|
126
143
|
* getConfig 批量拉取配置
|
|
127
144
|
* @description 拉取运营平台上的配置内容。关于运营平台的具体用法,参见{@link https://iwiki.woa.com/pages/viewpage.action?pageId=527948584}
|
|
@@ -159,14 +176,8 @@ function getConfig(configPath, extendAttr = {}, defaultCfg) {
|
|
|
159
176
|
}
|
|
160
177
|
}
|
|
161
178
|
|
|
162
|
-
const configPaths =
|
|
179
|
+
const configPaths = formatConfigPaths(configPath);
|
|
163
180
|
const defaultCfgs = defaultCfg && (Array.isArray(defaultCfg) ? defaultCfg : [defaultCfg]) || null;
|
|
164
|
-
const {
|
|
165
|
-
client
|
|
166
|
-
} = getEnvInfo();
|
|
167
|
-
configPaths.forEach((path, index) => {
|
|
168
|
-
configPaths[index] = path.replace(/\$\{client\}/, client);
|
|
169
|
-
});
|
|
170
181
|
const extendAttrs = typeof extendAttr === 'string' ? extendAttr : JSON.stringify(extendAttr);
|
|
171
182
|
const api = new Request();
|
|
172
183
|
return api.post('marketing/config', {
|
|
@@ -548,6 +559,8 @@ function getWxLocation(type = defaultLocationType) {
|
|
|
548
559
|
});
|
|
549
560
|
});
|
|
550
561
|
}
|
|
562
|
+
// 是否开启监听位置变更
|
|
563
|
+
let isListenerLocation = false;
|
|
551
564
|
/**
|
|
552
565
|
* @class Location
|
|
553
566
|
* @classdesc 基于微信api,封装location相关的接口。 包括监听位置变化, 获取用户位置信息
|
|
@@ -555,11 +568,14 @@ function getWxLocation(type = defaultLocationType) {
|
|
|
555
568
|
*/
|
|
556
569
|
class LocationBase {
|
|
557
570
|
/**
|
|
558
|
-
* @private
|
|
571
|
+
* @private 开启监听位置变更,要在授权之后才能开启
|
|
559
572
|
*/
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
573
|
+
listenerLocation() {
|
|
574
|
+
if (!isListenerLocation) {
|
|
575
|
+
isListenerLocation = true;
|
|
576
|
+
wx.onLocationChange(this.subscribeLocationChnage);
|
|
577
|
+
wx.startLocationUpdate({});
|
|
578
|
+
}
|
|
563
579
|
}
|
|
564
580
|
/**
|
|
565
581
|
* 获取用户当前位置(经纬度)
|
|
@@ -609,6 +625,7 @@ class LocationBase {
|
|
|
609
625
|
getWxLocationPromise(showModalWhenCloseAuth, type, content = '', showCancel = true) {
|
|
610
626
|
return new Promise((resolve, reject) => {
|
|
611
627
|
getWxLocation(type).then((res) => {
|
|
628
|
+
this.listenerLocation();
|
|
612
629
|
userLocationCache$1 = res;
|
|
613
630
|
// 更新用户状态 -- todo
|
|
614
631
|
updateLocStatus(true);
|
|
@@ -750,6 +767,7 @@ let cityTheUserAt = '';
|
|
|
750
767
|
// 用户城市变化事件名
|
|
751
768
|
const CityChangeEventName = 'loc_city_changed';
|
|
752
769
|
const LocationType = 'gcj02'; // 获取经纬度时的坐标名称
|
|
770
|
+
let ipLocationPromise = null; // ip定位请求的promise
|
|
753
771
|
/**
|
|
754
772
|
* @class Location
|
|
755
773
|
* @classdesc 基于LocationBase,封装业务侧位置的接口。 将用户经纬度转化为城市等展示信息
|
|
@@ -976,6 +994,32 @@ class Location extends LocationBase$1 {
|
|
|
976
994
|
}
|
|
977
995
|
return request.post('basic/lbs/direction', { from, to, mode });
|
|
978
996
|
}
|
|
997
|
+
/**
|
|
998
|
+
* ip定位
|
|
999
|
+
* 原理:通过调手图接口查询当前IP所在位置,市级的准确率是91%
|
|
1000
|
+
* 注意:由于服务端对该查询服务有次数限制,所以本函数会缓存成功的promise
|
|
1001
|
+
* @param force 是否清除上次的缓存重新请求
|
|
1002
|
+
*/
|
|
1003
|
+
getIpLocation(force = false) {
|
|
1004
|
+
if (ipLocationPromise === null || force) {
|
|
1005
|
+
ipLocationPromise = new Promise((resolve, reject) => {
|
|
1006
|
+
request.post('basic/lbs/decodeip')
|
|
1007
|
+
.then((res) => {
|
|
1008
|
+
if (res.errCode === 0) {
|
|
1009
|
+
resolve(res.resData);
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
reject({ erMsg: res.errMsg });
|
|
1013
|
+
ipLocationPromise = null;
|
|
1014
|
+
})
|
|
1015
|
+
.catch((e) => {
|
|
1016
|
+
reject(e);
|
|
1017
|
+
ipLocationPromise = null;
|
|
1018
|
+
});
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
return ipLocationPromise;
|
|
1022
|
+
}
|
|
979
1023
|
}
|
|
980
1024
|
// 因为在构造函数中会用到wx的api,所以使用到时才实例化
|
|
981
1025
|
let instance;
|
|
@@ -1119,11 +1163,11 @@ const getProvinceInfoByIp = () => {
|
|
|
1119
1163
|
if (!ProvinceInfoCacheByIp) {
|
|
1120
1164
|
ProvinceInfoCacheByIp = new Promise(async resolve => {
|
|
1121
1165
|
try {
|
|
1122
|
-
const loc = await
|
|
1166
|
+
const loc = await getLocInstance().getIpLocation();
|
|
1123
1167
|
const {
|
|
1124
1168
|
city,
|
|
1125
1169
|
province
|
|
1126
|
-
} = loc.
|
|
1170
|
+
} = loc.ad_info;
|
|
1127
1171
|
resolve({
|
|
1128
1172
|
cityName: city,
|
|
1129
1173
|
province
|