@haluo/util 2.0.15 → 2.0.17

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/README.md CHANGED
@@ -175,6 +175,12 @@ number.random(1, 100) // 4
175
175
  number.formatMoney(123456) // 123,456
176
176
  ```
177
177
 
178
+ - formatPhoneNumber 格式化手机号码
179
+
180
+ ```js
181
+ number.formatPhoneNumber(13111111111) // 131 1111 1111
182
+ ```
183
+
178
184
 
179
185
 
180
186
  ### tools
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import filter from './modules/filter';
5
5
  import format from './modules/format';
6
6
  import match from './modules/match';
7
7
  import number from './modules/number';
8
+ import openApp from './modules/open-app';
8
9
  import tools from './modules/tools';
9
10
  import monitor from './modules/monitor';
10
11
  export * from './modules/monitor';
@@ -16,6 +17,7 @@ interface Modules {
16
17
  format: typeof format;
17
18
  match: typeof match;
18
19
  number: typeof number;
20
+ openApp: typeof openApp;
19
21
  tools: typeof tools;
20
22
  monitor: typeof monitor;
21
23
  }
@@ -32,4 +34,4 @@ interface Utils extends Modules {
32
34
  }
33
35
  declare const _default: Utils;
34
36
  export default _default;
35
- export { cookie, date, dom, filter, format, match, number, tools, monitor };
37
+ export { cookie, date, dom, filter, format, match, number, openApp, tools, monitor };
package/dist/index.js CHANGED
@@ -1,19 +1,23 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
8
12
  }));
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
18
  };
15
19
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.monitor = exports.tools = exports.number = exports.match = exports.format = exports.filter = exports.dom = exports.date = exports.cookie = void 0;
20
+ exports.monitor = exports.tools = exports.openApp = exports.number = exports.match = exports.format = exports.filter = exports.dom = exports.date = exports.cookie = void 0;
17
21
  var cookie_1 = __importDefault(require("./modules/cookie"));
18
22
  exports.cookie = cookie_1.default;
19
23
  var date_1 = __importDefault(require("./modules/date"));
@@ -28,6 +32,8 @@ var match_1 = __importDefault(require("./modules/match"));
28
32
  exports.match = match_1.default;
29
33
  var number_1 = __importDefault(require("./modules/number"));
30
34
  exports.number = number_1.default;
35
+ var open_app_1 = __importDefault(require("./modules/open-app"));
36
+ exports.openApp = open_app_1.default;
31
37
  var tools_1 = __importDefault(require("./modules/tools"));
32
38
  exports.tools = tools_1.default;
33
39
  var monitor_1 = __importDefault(require("./modules/monitor"));
@@ -41,6 +47,7 @@ var modules = {
41
47
  format: format_1.default,
42
48
  match: match_1.default,
43
49
  number: number_1.default,
50
+ openApp: open_app_1.default,
44
51
  tools: tools_1.default,
45
52
  monitor: monitor_1.default
46
53
  };
@@ -33,8 +33,8 @@ var CookieClass = /** @class */ (function () {
33
33
  var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
34
34
  var d = new Date();
35
35
  d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
36
- var expires = "expires=" + d.toUTCString();
37
- document.cookie = name + "=" + value + ";" + expires + ";path=" + path + ";domain=" + domain + ";";
36
+ var expires = "expires=".concat(d.toUTCString());
37
+ document.cookie = "".concat(name, "=").concat(value, ";").concat(expires, ";path=").concat(path, ";domain=").concat(domain, ";");
38
38
  };
39
39
  /**
40
40
  * 清除Cookie
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  function replacementDate(data, fmt) {
15
15
  for (var k in data) {
16
16
  if (new RegExp('(' + k + ')').test(fmt)) {
17
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00" + data[k]).substr(('' + data[k]).length)));
17
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00".concat(data[k])).substr(('' + data[k]).length)));
18
18
  }
19
19
  }
20
20
  return fmt;
@@ -70,7 +70,7 @@ var DateClass = /** @class */ (function () {
70
70
  };
71
71
  fmt = replacementYear(timeData, fmt);
72
72
  if (/(E+)/.test(fmt)) {
73
- fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[timeData.getDay() + " "]);
73
+ fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week["".concat(timeData.getDay(), " ")]);
74
74
  }
75
75
  return replacementDate(o, fmt);
76
76
  };
@@ -105,10 +105,10 @@ var DateClass = /** @class */ (function () {
105
105
  if (ts <= 0)
106
106
  return false;
107
107
  return {
108
- dd: (dd < 10 ? "0" + dd : dd),
109
- hh: (hh < 10 ? "0" + hh : hh),
110
- mm: (mm < 10 ? "0" + mm : mm),
111
- ss: (ss < 10 ? "0" + ss : ss)
108
+ dd: (dd < 10 ? "0".concat(dd) : dd),
109
+ hh: (hh < 10 ? "0".concat(hh) : hh),
110
+ mm: (mm < 10 ? "0".concat(mm) : mm),
111
+ ss: (ss < 10 ? "0".concat(ss) : ss)
112
112
  };
113
113
  };
114
114
  /**
@@ -121,19 +121,19 @@ var DateClass = /** @class */ (function () {
121
121
  var time = currentTime - startTime;
122
122
  var year = Math.floor(time / (1000 * 60 * 60 * 24) / 30 / 12);
123
123
  if (year)
124
- return year + "\u5E74\u524D";
124
+ return "".concat(year, "\u5E74\u524D");
125
125
  var month = Math.floor(time / (1000 * 60 * 60 * 24) / 30);
126
126
  if (month)
127
- return month + "\u4E2A\u6708\u524D";
127
+ return "".concat(month, "\u4E2A\u6708\u524D");
128
128
  var day = Math.floor(time / (1000 * 60 * 60 * 24));
129
129
  if (day)
130
- return day + "\u5929\u524D";
130
+ return "".concat(day, "\u5929\u524D");
131
131
  var hour = Math.floor(time / (1000 * 60 * 60));
132
132
  if (hour)
133
- return hour + "\u5C0F\u65F6\u524D";
133
+ return "".concat(hour, "\u5C0F\u65F6\u524D");
134
134
  var min = Math.floor(time / (1000 * 60));
135
135
  if (min)
136
- return min + "\u5206\u949F\u524D";
136
+ return "".concat(min, "\u5206\u949F\u524D");
137
137
  else
138
138
  return '刚刚';
139
139
  };
@@ -48,7 +48,7 @@ var DomClass = /** @class */ (function () {
48
48
  var value = object[key];
49
49
  if (Array.isArray(value)) {
50
50
  value.forEach(function (subValue, i) {
51
- return formData.append(key + ("[" + i + "]"), subValue);
51
+ return formData.append(key + "[".concat(i, "]"), subValue);
52
52
  });
53
53
  }
54
54
  else {
@@ -10,8 +10,8 @@ var tracker_1 = __importDefault(require("./utils/tracker"));
10
10
  exports.Tracker = tracker_1.default;
11
11
  // import timing from './lib/timing'
12
12
  function setup(data) {
13
- jsError_1.injectJsError(data);
14
- xhr_1.default(data);
13
+ (0, jsError_1.injectJsError)(data);
14
+ (0, xhr_1.default)(data);
15
15
  }
16
16
  exports.default = setup;
17
17
  // timing()
@@ -25,7 +25,7 @@ function injectJsError(data) {
25
25
  ));
26
26
  return;
27
27
  }
28
- tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'jsError', message: e.message, filename: e.filename, position: e.lineno + ":" + e.colno, reason: e.error.stack }, data
28
+ tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'jsError', message: e.message, filename: e.filename, position: "".concat(e.lineno, ":").concat(e.colno), reason: e.error.stack }, data
29
29
  // selector: lastEvent ? get
30
30
  ));
31
31
  }, true);
@@ -45,8 +45,7 @@ function injectJsError(data) {
45
45
  message = reason.message;
46
46
  stack = reason.stack;
47
47
  }
48
- tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'promiseError', message: message,
49
- filename: filename, position: line + ":" + column, reason: stack }, data
48
+ tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'promiseError', message: message, filename: filename, position: "".concat(line, ":").concat(column), reason: stack }, data
50
49
  // selector: lastEvent ? get
51
50
  ));
52
51
  });
@@ -35,7 +35,7 @@ function timing() {
35
35
  }
36
36
  observer.disconnect(); // 不再观察
37
37
  }).observe({ type: 'first-input', buffered: true }); // 观察页面中最大的元素
38
- onload_1.default(function () {
38
+ (0, onload_1.default)(function () {
39
39
  setTimeout(function () {
40
40
  console.dir(window.performance);
41
41
  var _a = performance.getEntriesByType('navigation')[0], fetchStart = _a.fetchStart, connectStart = _a.connectStart, connectEnd = _a.connectEnd, requestStart = _a.requestStart, responseStart = _a.responseStart, responseEnd = _a.responseEnd, domInteractive = _a.domInteractive, domContentLoadedEventStart = _a.domContentLoadedEventStart, domContentLoadedEventEnd = _a.domContentLoadedEventEnd, loadEventStart = _a.loadEventStart;
@@ -36,7 +36,7 @@ function injectXHR(data) {
36
36
  var duration = Date.now() - startTime_1;
37
37
  var status = _this.status;
38
38
  var statusText = _this.statusText;
39
- tracker_1.default.send(__assign({ kind: 'stability', type: 'xhr', eventType: event.type, pathname: _this.logData.url, status: status + '-' + statusText, duration: duration, response: _this.response ? JSON.stringify(_this.response) : '', params: body || '', title: 'xhr', reason: status + '-' + statusText + (" " + _this.logData.url + " " + (_this.response ? JSON.stringify(_this.response) : '')) }, data));
39
+ tracker_1.default.send(__assign({ kind: 'stability', type: 'xhr', eventType: event.type, pathname: _this.logData.url, status: status + '-' + statusText, duration: duration, response: _this.response ? JSON.stringify(_this.response) : '', params: body || '', title: 'xhr', reason: status + '-' + statusText + " ".concat(_this.logData.url, " ").concat(_this.response ? JSON.stringify(_this.response) : '') }, data));
40
40
  }; };
41
41
  this.addEventListener('load', handler('load'), false);
42
42
  this.addEventListener('error', handler('error'), false);
@@ -57,6 +57,7 @@ function getExtraData() {
57
57
  title: '',
58
58
  frontStatus: 3,
59
59
  occurTimeStamp: Date.now(),
60
+ // userAgent: new Parser().getResult()
60
61
  };
61
62
  }
62
63
  exports.default = new SendTracker();
@@ -36,6 +36,12 @@ declare class NumberClass {
36
36
  * @return {String} 123,456
37
37
  */
38
38
  formatMoney(money: number | string, signal?: string): string;
39
+ /**
40
+ * 格式化手机号
41
+ * @param {string} number 手机号
42
+ * @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
43
+ */
44
+ formatPhoneNumber(number: string | number): string;
39
45
  }
40
46
  declare const _default: NumberClass;
41
47
  export default _default;
@@ -92,12 +92,27 @@ var NumberClass = /** @class */ (function () {
92
92
  var price = money.split('.')[0] + '';
93
93
  var pricePoint = money.split('.')[1];
94
94
  result = price.length > 6 ?
95
- "" + price.substring(0, price.length - 6) + signal + price.substring(price.length - 6, price.length - 3) + "," + price.substring(price.length - 3, price.length)
95
+ "".concat(price.substring(0, price.length - 6)).concat(signal).concat(price.substring(price.length - 6, price.length - 3), ",").concat(price.substring(price.length - 3, price.length))
96
96
  :
97
- "" + price.substring(0, price.length - 3) + signal + price.substring(price.length - 3, price.length);
98
- result = pricePoint ? "" + result + signal + pricePoint : result;
97
+ "".concat(price.substring(0, price.length - 3)).concat(signal).concat(price.substring(price.length - 3, price.length));
98
+ result = pricePoint ? "".concat(result).concat(signal).concat(pricePoint) : result;
99
99
  return result;
100
100
  };
101
+ /**
102
+ * 格式化手机号
103
+ * @param {string} number 手机号
104
+ * @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
105
+ */
106
+ NumberClass.prototype.formatPhoneNumber = function (number) {
107
+ var numStr = String(number).replace(/\s/g, '');
108
+ if (numStr.length < 11) {
109
+ return numStr;
110
+ }
111
+ var firstPart = numStr.slice(0, 3);
112
+ var secondPart = numStr.slice(3, 7);
113
+ var thirdPart = numStr.slice(7, 11);
114
+ return "".concat(firstPart, " ").concat(secondPart, " ").concat(thirdPart);
115
+ };
101
116
  return NumberClass;
102
117
  }());
103
118
  exports.default = new NumberClass();
@@ -0,0 +1,83 @@
1
+ declare global {
2
+ interface Window {
3
+ AppCall?: {
4
+ has: (method: string) => boolean;
5
+ openOtherAppUrlRouter: (params: {
6
+ appUrlRouter: string;
7
+ }) => void;
8
+ };
9
+ }
10
+ }
11
+ interface EnvConfig {
12
+ motoAndroidScheme?: string;
13
+ motoIOSScheme?: string;
14
+ APPLINK?: string;
15
+ APPLINKIOS?: string;
16
+ emotofineAndroidScheme?: string;
17
+ emotofineIOSScheme?: string;
18
+ EMOTOFINEAPPLINK?: string;
19
+ EMOTOFINEAPPLINKIOS?: string;
20
+ biaofineAndroidScheme?: string;
21
+ biaofineIOSScheme?: string;
22
+ BIAOFINEAPPLINK?: string;
23
+ BIAOFINEAPPLINKIOS?: string;
24
+ APPLINKPRICE?: string;
25
+ APPLINKPRICEIOS?: string;
26
+ }
27
+ interface OpenAppState {
28
+ state?: {
29
+ openApps?: {
30
+ type?: string;
31
+ href?: string;
32
+ id?: number | string;
33
+ title?: string;
34
+ url?: string;
35
+ };
36
+ };
37
+ }
38
+ declare class OpenAppClass {
39
+ private env;
40
+ private postJddTrack;
41
+ private trackId;
42
+ private openAppState?;
43
+ private ua;
44
+ private _wx;
45
+ private _android;
46
+ private _isHarmonyos;
47
+ private _ios;
48
+ private _isPrice;
49
+ private currentEnv;
50
+ private appUrl?;
51
+ private appStoreUrl?;
52
+ private underway;
53
+ /**
54
+ * @param {Object} env - 环境配置,必须
55
+ * @param {Function} postJddTrack - 埋点方法,必须
56
+ * @param {String} trackId - 埋点id,可选
57
+ * @param {Object} openAppState - 打开app状态,可选
58
+ */
59
+ constructor(env: EnvConfig, postJddTrack: (trackId: string, data: {
60
+ tag: string;
61
+ }) => void, trackId?: string, openAppState?: OpenAppState);
62
+ /**
63
+ * 根据域名动态获取配置,保证多项目代码一样
64
+ */
65
+ getCurrentEnv(): void;
66
+ /**
67
+ * 打开APP主流程
68
+ */
69
+ invoke(): void;
70
+ /**
71
+ * 获取打开 app url
72
+ * @returns {string | undefined} 打开app的schema或跳转链接
73
+ * params:params={"type":"","id":0,"name":"","travelId":0}
74
+ * type:原生页面key(必须);id:页面id(可选);subject 短话题、版块名称 或 页面标题(可选);travelId 游记id(可选)
75
+ */
76
+ getUrl(): string | undefined;
77
+ /**
78
+ * 方法一(推荐):打开APP
79
+ * http://www.cnblogs.com/shadajin/p/5724117.html
80
+ */
81
+ open(openUrl: string | undefined): string | Promise<unknown> | undefined;
82
+ }
83
+ export default OpenAppClass;
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /**
7
+ * H5打开APP工具类
8
+ *
9
+ * feature
10
+ * 1、应用宝打开app指定页面,参考今日头条
11
+ * 2、浏览器中进入页面立即打开app,参考掘金
12
+ */
13
+ var qs_1 = __importDefault(require("qs"));
14
+ var tools_1 = __importDefault(require("../tools"));
15
+ var OpenAppClass = /** @class */ (function () {
16
+ /**
17
+ * @param {Object} env - 环境配置,必须
18
+ * @param {Function} postJddTrack - 埋点方法,必须
19
+ * @param {String} trackId - 埋点id,可选
20
+ * @param {Object} openAppState - 打开app状态,可选
21
+ */
22
+ function OpenAppClass(env, postJddTrack, trackId, openAppState) {
23
+ if (trackId === void 0) { trackId = 'S_00000000000108'; }
24
+ this.env = env; // 环境配置,必须
25
+ this.postJddTrack = postJddTrack; // 埋点方法,必须
26
+ this.trackId = trackId; // 埋点id,可选
27
+ this.openAppState = openAppState; // 打开app状态,可选
28
+ this.ua = navigator.userAgent.toLowerCase();
29
+ this._wx = this.ua.indexOf('micromessenger') > -1;
30
+ this._android = !!(this.ua.match(/android/i) || this.ua.match(/miuibrowser/i));
31
+ this._isHarmonyos = !!this.ua.match(/harmonyos/i);
32
+ this._ios = navigator.userAgent.match(/(iPhone|iPod|iPad);?/i);
33
+ this._isPrice = sessionStorage.getItem('isHaloenterprise') || false; // 厂家版,切换打开地址
34
+ this.currentEnv = env;
35
+ this.getCurrentEnv();
36
+ this.appUrl = this._isPrice ? env.APPLINKPRICE : this.currentEnv.APPLINK;
37
+ this.appStoreUrl = this._isPrice ? env.APPLINKPRICEIOS : this.currentEnv.APPLINKIOS;
38
+ this.underway = false;
39
+ }
40
+ /**
41
+ * 根据域名动态获取配置,保证多项目代码一样
42
+ */
43
+ OpenAppClass.prototype.getCurrentEnv = function () {
44
+ var host = location.host;
45
+ if (host.includes('58moto')) {
46
+ this.currentEnv = {
47
+ motoAndroidScheme: this.env.motoAndroidScheme,
48
+ motoIOSScheme: this.env.motoIOSScheme,
49
+ APPLINK: this.env.APPLINK,
50
+ APPLINKIOS: this.env.APPLINKIOS,
51
+ };
52
+ }
53
+ else if (host.includes('emotofine')) {
54
+ this.currentEnv = {
55
+ motoAndroidScheme: this.env.emotofineAndroidScheme,
56
+ motoIOSScheme: this.env.emotofineIOSScheme,
57
+ APPLINK: this.env.EMOTOFINEAPPLINK,
58
+ APPLINKIOS: this.env.EMOTOFINEAPPLINKIOS,
59
+ };
60
+ }
61
+ else if (host.includes('biaofine')) {
62
+ this.currentEnv = {
63
+ motoAndroidScheme: this.env.biaofineAndroidScheme,
64
+ motoIOSScheme: this.env.biaofineIOSScheme,
65
+ APPLINK: this.env.BIAOFINEAPPLINK,
66
+ APPLINKIOS: this.env.BIAOFINEAPPLINKIOS,
67
+ };
68
+ }
69
+ };
70
+ /**
71
+ * 打开APP主流程
72
+ */
73
+ OpenAppClass.prototype.invoke = function () {
74
+ if (this.underway) {
75
+ return;
76
+ }
77
+ // 微信里面 安卓、鸿蒙 不支持打开app(待确认)
78
+ if (this._wx && (this._android || this._isHarmonyos)) {
79
+ this.underway = false;
80
+ return;
81
+ }
82
+ this.underway = true;
83
+ // 生成url并且放到剪贴板
84
+ var url = this.getUrl();
85
+ if (url) {
86
+ tools_1.default.clipboard(url);
87
+ }
88
+ var apk = JSON.parse(sessionStorage.getItem('downloadApk') || '{}');
89
+ var tag = this._ios ? (apk.channelName ? "App Store-".concat(apk.channelName) : 'App Store') : (apk.channelName ? "\u6E20\u9053".concat(apk.channelName, "\u5305") : '安卓包');
90
+ this.postJddTrack(this.trackId, { tag: tag });
91
+ if (this._ios) {
92
+ url = this.appStoreUrl;
93
+ }
94
+ // 客户端打开app-下载页特殊处理
95
+ if (location.href.includes('download') && window.AppCall && window.AppCall.has('openOtherAppUrlRouter')) {
96
+ this.underway = false;
97
+ return window.AppCall.openOtherAppUrlRouter({ appUrlRouter: "https://".concat(location.host, "/home") });
98
+ }
99
+ // 客户端打开app
100
+ if (window.AppCall && window.AppCall.has('openOtherAppUrlRouter')) {
101
+ this.underway = false;
102
+ return window.AppCall.openOtherAppUrlRouter({ appUrlRouter: url || '' });
103
+ }
104
+ this.open(url);
105
+ };
106
+ /**
107
+ * 获取打开 app url
108
+ * @returns {string | undefined} 打开app的schema或跳转链接
109
+ * params:params={"type":"","id":0,"name":"","travelId":0}
110
+ * type:原生页面key(必须);id:页面id(可选);subject 短话题、版块名称 或 页面标题(可选);travelId 游记id(可选)
111
+ */
112
+ OpenAppClass.prototype.getUrl = function () {
113
+ var _a, _b;
114
+ var keys = {
115
+ '/posts/': 'thread_detail',
116
+ '/detailedForum/': 'forum_detail',
117
+ '/video/': 'video_detail',
118
+ '/answer-details/': 'topic_detail',
119
+ '/details-article/': 'essay_detail',
120
+ '/details-views/': 'opinion_detail',
121
+ '/topic-homepage': 'short_topic',
122
+ '/label-detail': 'tag_detail',
123
+ '/circle-article/': 'moment_detail',
124
+ '/vehicle-details/': 'car_detail',
125
+ '/car-detail': 'newcar_sale_detail',
126
+ '/myhomepage': 'person_detail',
127
+ '/dealer': 'shop_detail',
128
+ '/circle-preview': 'hoop_detail',
129
+ '/used-car-detail': 'used_detail',
130
+ '/coupon-detail': 'coupon_detail',
131
+ '/news/': 'essay_detail' // 文章详情
132
+ };
133
+ var target = Object.keys(keys).filter(function (value) {
134
+ return window.location.href.indexOf(value) > -1;
135
+ });
136
+ var type = target && target[0] && keys[target[0]];
137
+ var searchParams = qs_1.default.parse(location.search.slice(1)); // 路由的query
138
+ var id = parseInt(location.pathname.split('/').reverse()[0]) ||
139
+ parseInt(searchParams.id) ||
140
+ parseInt(searchParams.carId) ||
141
+ parseInt(searchParams.goodId); // 页面id
142
+ var subject = searchParams.subject || undefined; // 页面标题或name
143
+ var temp = {
144
+ relationType: type,
145
+ id: id,
146
+ name: subject
147
+ };
148
+ var data = ((_b = (_a = this.openAppState) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.openApps) || {};
149
+ var open_url = '';
150
+ if (data.type && data.href === window.location.href) {
151
+ temp.relationType = keys[data.type] || '';
152
+ temp.id = data.id || '';
153
+ temp.name = data.title || '';
154
+ open_url = data.url || '';
155
+ }
156
+ var openUrl = open_url || searchParams.customOpenUrl || window.location.href;
157
+ // activityId 大于零,type 为 activity
158
+ if (searchParams.activityId) {
159
+ temp.relationType = 'activity';
160
+ temp.link = decodeURIComponent(decodeURIComponent(openUrl));
161
+ }
162
+ temp.jumpUrl = decodeURIComponent(decodeURIComponent(openUrl));
163
+ var params = JSON.stringify(temp);
164
+ if (this._ios) {
165
+ return "".concat(this.currentEnv.motoIOSScheme, "?params=").concat(params);
166
+ }
167
+ if (this._android || this._isHarmonyos) {
168
+ var url = this._wx ? "".concat(this.appUrl, "&android_scheme=").concat(this.currentEnv.motoAndroidScheme, "?params=").concat(params) : "".concat(this.currentEnv.motoAndroidScheme, "?params=").concat(params);
169
+ return url;
170
+ }
171
+ return undefined;
172
+ };
173
+ /**
174
+ * 方法一(推荐):打开APP
175
+ * http://www.cnblogs.com/shadajin/p/5724117.html
176
+ */
177
+ OpenAppClass.prototype.open = function (openUrl) {
178
+ var _this = this;
179
+ if (!openUrl) {
180
+ this.underway = false;
181
+ return;
182
+ }
183
+ if (this._ios) {
184
+ this.underway = false;
185
+ setTimeout(function () { return (location.href = _this.appStoreUrl || ''); }, 3000);
186
+ return (location.href = openUrl);
187
+ }
188
+ if (this._android) {
189
+ var ifr_1 = document.createElement('iframe');
190
+ ifr_1.src = openUrl;
191
+ ifr_1.style.display = 'none';
192
+ document.body.appendChild(ifr_1);
193
+ setTimeout(function () {
194
+ document.body.removeChild(ifr_1);
195
+ }, 3000);
196
+ }
197
+ return new Promise(function (resolve, reject) {
198
+ // 检查APP是否打开
199
+ var check = function (elsTime) {
200
+ if (elsTime > 3000 || document.hidden) {
201
+ // @ts-ignore
202
+ resolve('成功打开APP');
203
+ }
204
+ else {
205
+ // @ts-ignore
206
+ window.location.href = "https://".concat(location.host, "/download");
207
+ reject('打开APP失败');
208
+ }
209
+ _this.underway = false;
210
+ };
211
+ var _count = 0;
212
+ var _clickTime = +new Date();
213
+ var intHandle = setInterval(function () {
214
+ _count++;
215
+ var elsTime = +new Date() - _clickTime;
216
+ if (_count >= 100 || elsTime > 3000) {
217
+ clearInterval(intHandle);
218
+ check(elsTime);
219
+ }
220
+ }, 20);
221
+ });
222
+ };
223
+ return OpenAppClass;
224
+ }());
225
+ exports.default = OpenAppClass;
@@ -25,7 +25,7 @@ var ToolsClass = /** @class */ (function () {
25
25
  body.style.overflow = 'hidden';
26
26
  body.style.height = '100%';
27
27
  if (className) {
28
- var dom = document.querySelector("." + className);
28
+ var dom = document.querySelector(".".concat(className));
29
29
  dom && dom.addEventListener('touchmove', _this.__setDefault__);
30
30
  }
31
31
  };
@@ -45,7 +45,7 @@ var ToolsClass = /** @class */ (function () {
45
45
  body.style.overflow = 'visible';
46
46
  body.style.height = 'auto';
47
47
  if (className) {
48
- var dom = document.querySelector("." + className);
48
+ var dom = document.querySelector(".".concat(className));
49
49
  dom && dom.removeEventListener('touchmove', _this.__setDefault__);
50
50
  }
51
51
  };
@@ -384,9 +384,9 @@ var ToolsClass = /** @class */ (function () {
384
384
  }
385
385
  // 匹配中文、英文、数字
386
386
  var regItem = '[\u4e00-\u9fa5a-zA-Z0-9]';
387
- var regExp = "(" + regItem + "{" + before + "})" + regItem + "*(" + regItem + "{" + after + "})";
387
+ var regExp = "(".concat(regItem, "{").concat(before, "})").concat(regItem, "*(").concat(regItem, "{").concat(after, "})");
388
388
  var reg = new RegExp(regExp);
389
- return field.replace(reg, "$1" + "*".repeat(sensitiveLen) + "$2");
389
+ return field.replace(reg, "$1".concat("*".repeat(sensitiveLen), "$2"));
390
390
  };
391
391
  return ToolsClass;
392
392
  }());