@haluo/util 2.0.29 → 2.0.31
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 +350 -350
- package/dist/index.d.ts +39 -39
- package/dist/index.js +43 -43
- package/dist/modules/cookie/index.d.ts +27 -27
- package/dist/modules/cookie/index.js +49 -49
- package/dist/modules/date/index.d.ts +52 -52
- package/dist/modules/date/index.js +185 -185
- package/dist/modules/dom/index.d.ts +28 -28
- package/dist/modules/dom/index.js +55 -55
- package/dist/modules/filter/index.d.ts +24 -24
- package/dist/modules/filter/index.js +38 -38
- package/dist/modules/format/index.d.ts +15 -15
- package/dist/modules/format/index.js +16 -16
- package/dist/modules/match/index.d.ts +12 -12
- package/dist/modules/match/index.js +27 -27
- package/dist/modules/monitor/index.d.ts +3 -3
- package/dist/modules/monitor/index.js +10 -10
- package/dist/modules/monitor/lib/jsError.d.ts +1 -1
- package/dist/modules/monitor/lib/jsError.js +57 -57
- package/dist/modules/monitor/lib/timing.d.ts +1 -1
- package/dist/modules/monitor/lib/timing.js +65 -65
- package/dist/modules/monitor/lib/xhr.d.ts +1 -1
- package/dist/modules/monitor/lib/xhr.js +41 -41
- package/dist/modules/monitor/utils/onload.d.ts +1 -1
- package/dist/modules/monitor/utils/onload.js +8 -8
- package/dist/modules/monitor/utils/tracker.d.ts +7 -7
- package/dist/modules/monitor/utils/tracker.js +49 -49
- package/dist/modules/number/index.d.ts +47 -47
- package/dist/modules/number/index.js +114 -114
- package/dist/modules/open-app/index.d.ts +92 -84
- package/dist/modules/open-app/index.js +260 -244
- package/dist/modules/sentry/index.d.ts +15 -15
- package/dist/modules/sentry/index.js +73 -73
- package/dist/modules/tools/index.d.ts +166 -166
- package/dist/modules/tools/index.js +382 -382
- package/dist/modules/upload/aliOss.d.ts +291 -291
- package/dist/modules/upload/aliOss.js +629 -629
- package/dist/modules/upload/index.d.ts +38 -38
- package/dist/modules/upload/index.js +44 -44
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +1 -1
- package/dist/types/modules/cookie/index.d.ts +27 -27
- package/dist/types/modules/date/index.d.ts +52 -52
- package/dist/types/modules/dom/index.d.ts +28 -28
- package/dist/types/modules/filter/index.d.ts +24 -24
- package/dist/types/modules/format/index.d.ts +15 -15
- package/dist/types/modules/match/index.d.ts +12 -12
- package/dist/types/modules/monitor/index.d.ts +3 -3
- package/dist/types/modules/monitor/lib/jsError.d.ts +1 -1
- package/dist/types/modules/monitor/lib/timing.d.ts +1 -1
- package/dist/types/modules/monitor/lib/xhr.d.ts +1 -1
- package/dist/types/modules/monitor/utils/onload.d.ts +1 -1
- package/dist/types/modules/monitor/utils/tracker.d.ts +7 -7
- package/dist/types/modules/number/index.d.ts +41 -41
- package/dist/types/modules/sentry/index.d.ts +15 -15
- package/dist/types/modules/tools/index.d.ts +166 -166
- package/dist/types/types/index.d.ts +3 -3
- package/package.json +88 -88
|
@@ -1,244 +1,260 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* H5打开APP工具类
|
|
3
|
-
*
|
|
4
|
-
* feature
|
|
5
|
-
* 1、应用宝打开app指定页面,参考今日头条
|
|
6
|
-
* 2、浏览器中进入页面立即打开app,参考掘金
|
|
7
|
-
*/
|
|
8
|
-
import qs from 'qs';
|
|
9
|
-
import tools from '../tools';
|
|
10
|
-
class OpenAppClass {
|
|
11
|
-
env;
|
|
12
|
-
postJddTrack;
|
|
13
|
-
trackId;
|
|
14
|
-
openAppState;
|
|
15
|
-
ua;
|
|
16
|
-
_wx;
|
|
17
|
-
_android;
|
|
18
|
-
_isHarmonyos;
|
|
19
|
-
_ios;
|
|
20
|
-
_isPrice;
|
|
21
|
-
currentEnv;
|
|
22
|
-
appUrl;
|
|
23
|
-
appStoreUrl;
|
|
24
|
-
underway;
|
|
25
|
-
/**
|
|
26
|
-
* @param {Object} env - 环境配置,必须
|
|
27
|
-
* @param {Function} postJddTrack - 埋点方法,必须
|
|
28
|
-
* @param {String} trackId - 埋点id,可选
|
|
29
|
-
* @param {Object} openAppState - 打开app状态,可选
|
|
30
|
-
*/
|
|
31
|
-
constructor(env, postJddTrack, trackId = 'S_00000000000108', openAppState) {
|
|
32
|
-
this.env = env; // 环境配置,必须
|
|
33
|
-
this.postJddTrack = postJddTrack; // 埋点方法,必须
|
|
34
|
-
this.trackId = trackId; // 埋点id,可选
|
|
35
|
-
this.openAppState = openAppState; // 打开app状态,可选
|
|
36
|
-
this.ua = navigator.userAgent.toLowerCase();
|
|
37
|
-
this._wx = this.ua.indexOf('micromessenger') > -1;
|
|
38
|
-
this._android = !!(this.ua.match(/android/i) || this.ua.match(/miuibrowser/i));
|
|
39
|
-
this._isHarmonyos = !!this.ua.match(/harmonyos/i);
|
|
40
|
-
this._ios = navigator.userAgent.match(/(iPhone|iPod|iPad);?/i);
|
|
41
|
-
this._isPrice = sessionStorage.getItem('isHaloenterprise') || false; // 厂家版,切换打开地址
|
|
42
|
-
this.currentEnv = env;
|
|
43
|
-
this.getCurrentEnv();
|
|
44
|
-
this.appUrl = this._isPrice ? env.APPLINKPRICE : this.currentEnv.APPLINK;
|
|
45
|
-
this.appStoreUrl = this._isPrice ? env.APPLINKPRICEIOS : this.currentEnv.APPLINKIOS;
|
|
46
|
-
this.underway = false;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 根据域名动态获取配置,保证多项目代码一样
|
|
50
|
-
*/
|
|
51
|
-
getCurrentEnv() {
|
|
52
|
-
const host = location.host;
|
|
53
|
-
if (host.includes('58moto')) {
|
|
54
|
-
this.currentEnv = {
|
|
55
|
-
motoAndroidScheme: this.env.motoAndroidScheme,
|
|
56
|
-
motoIOSScheme: this.env.motoIOSScheme,
|
|
57
|
-
APPLINK: this.env.APPLINK,
|
|
58
|
-
APPLINKIOS: this.env.APPLINKIOS,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
else if (host.includes('emotofine')) {
|
|
62
|
-
this.currentEnv = {
|
|
63
|
-
motoAndroidScheme: this.env.emotofineAndroidScheme,
|
|
64
|
-
motoIOSScheme: this.env.emotofineIOSScheme,
|
|
65
|
-
APPLINK: this.env.EMOTOFINEAPPLINK,
|
|
66
|
-
APPLINKIOS: this.env.EMOTOFINEAPPLINKIOS,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
else if (host.includes('biaofine')) {
|
|
70
|
-
this.currentEnv = {
|
|
71
|
-
motoAndroidScheme: this.env.biaofineAndroidScheme,
|
|
72
|
-
motoIOSScheme: this.env.biaofineIOSScheme,
|
|
73
|
-
APPLINK: this.env.BIAOFINEAPPLINK,
|
|
74
|
-
APPLINKIOS: this.env.BIAOFINEAPPLINKIOS,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
'/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
1
|
+
/**
|
|
2
|
+
* H5打开APP工具类
|
|
3
|
+
*
|
|
4
|
+
* feature
|
|
5
|
+
* 1、应用宝打开app指定页面,参考今日头条
|
|
6
|
+
* 2、浏览器中进入页面立即打开app,参考掘金
|
|
7
|
+
*/
|
|
8
|
+
import qs from 'qs';
|
|
9
|
+
import tools from '../tools';
|
|
10
|
+
class OpenAppClass {
|
|
11
|
+
env;
|
|
12
|
+
postJddTrack;
|
|
13
|
+
trackId;
|
|
14
|
+
openAppState;
|
|
15
|
+
ua;
|
|
16
|
+
_wx;
|
|
17
|
+
_android;
|
|
18
|
+
_isHarmonyos;
|
|
19
|
+
_ios;
|
|
20
|
+
_isPrice;
|
|
21
|
+
currentEnv;
|
|
22
|
+
appUrl;
|
|
23
|
+
appStoreUrl;
|
|
24
|
+
underway;
|
|
25
|
+
/**
|
|
26
|
+
* @param {Object} env - 环境配置,必须
|
|
27
|
+
* @param {Function} postJddTrack - 埋点方法,必须
|
|
28
|
+
* @param {String} trackId - 埋点id,可选
|
|
29
|
+
* @param {Object} openAppState - 打开app状态,可选
|
|
30
|
+
*/
|
|
31
|
+
constructor(env, postJddTrack, trackId = 'S_00000000000108', openAppState) {
|
|
32
|
+
this.env = env; // 环境配置,必须
|
|
33
|
+
this.postJddTrack = postJddTrack; // 埋点方法,必须
|
|
34
|
+
this.trackId = trackId; // 埋点id,可选
|
|
35
|
+
this.openAppState = openAppState; // 打开app状态,可选
|
|
36
|
+
this.ua = navigator.userAgent.toLowerCase();
|
|
37
|
+
this._wx = this.ua.indexOf('micromessenger') > -1;
|
|
38
|
+
this._android = !!(this.ua.match(/android/i) || this.ua.match(/miuibrowser/i));
|
|
39
|
+
this._isHarmonyos = !!this.ua.match(/harmonyos/i);
|
|
40
|
+
this._ios = navigator.userAgent.match(/(iPhone|iPod|iPad);?/i);
|
|
41
|
+
this._isPrice = sessionStorage.getItem('isHaloenterprise') || false; // 厂家版,切换打开地址
|
|
42
|
+
this.currentEnv = env;
|
|
43
|
+
this.getCurrentEnv();
|
|
44
|
+
this.appUrl = this._isPrice ? env.APPLINKPRICE : this.currentEnv.APPLINK;
|
|
45
|
+
this.appStoreUrl = this._isPrice ? env.APPLINKPRICEIOS : this.currentEnv.APPLINKIOS;
|
|
46
|
+
this.underway = false;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 根据域名动态获取配置,保证多项目代码一样
|
|
50
|
+
*/
|
|
51
|
+
getCurrentEnv() {
|
|
52
|
+
const host = location.host;
|
|
53
|
+
if (host.includes('58moto')) {
|
|
54
|
+
this.currentEnv = {
|
|
55
|
+
motoAndroidScheme: this.env.motoAndroidScheme,
|
|
56
|
+
motoIOSScheme: this.env.motoIOSScheme,
|
|
57
|
+
APPLINK: this.env.APPLINK,
|
|
58
|
+
APPLINKIOS: this.env.APPLINKIOS,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else if (host.includes('emotofine')) {
|
|
62
|
+
this.currentEnv = {
|
|
63
|
+
motoAndroidScheme: this.env.emotofineAndroidScheme,
|
|
64
|
+
motoIOSScheme: this.env.emotofineIOSScheme,
|
|
65
|
+
APPLINK: this.env.EMOTOFINEAPPLINK,
|
|
66
|
+
APPLINKIOS: this.env.EMOTOFINEAPPLINKIOS,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else if (host.includes('biaofine')) {
|
|
70
|
+
this.currentEnv = {
|
|
71
|
+
motoAndroidScheme: this.env.biaofineAndroidScheme,
|
|
72
|
+
motoIOSScheme: this.env.biaofineIOSScheme,
|
|
73
|
+
APPLINK: this.env.BIAOFINEAPPLINK,
|
|
74
|
+
APPLINKIOS: this.env.BIAOFINEAPPLINKIOS,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else if (host.includes('evtolfine')) {
|
|
78
|
+
this.currentEnv = {
|
|
79
|
+
motoAndroidScheme: this.env.evtolfineAndroidScheme,
|
|
80
|
+
motoIOSScheme: this.env.evtolfineIOSScheme,
|
|
81
|
+
APPLINK: this.env.EVTOLFINEAPPLINK,
|
|
82
|
+
APPLINKIOS: this.env.EVTOLFINEAPPLINKIOS,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
else if (host.includes('dronefine')) {
|
|
86
|
+
this.currentEnv = {
|
|
87
|
+
motoAndroidScheme: this.env.dronefineAndroidScheme,
|
|
88
|
+
motoIOSScheme: this.env.dronefineIOSScheme,
|
|
89
|
+
APPLINK: this.env.dronefineAPPLINK,
|
|
90
|
+
APPLINKIOS: this.env.dronefineAPPLINKIOS,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 打开APP主流程
|
|
96
|
+
*/
|
|
97
|
+
invoke() {
|
|
98
|
+
if (this.underway) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// 微信里面 安卓、鸿蒙 不支持打开app(待确认)
|
|
102
|
+
if (this._wx && (this._android || this._isHarmonyos)) {
|
|
103
|
+
this.underway = false;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.underway = true;
|
|
107
|
+
// 生成url并且放到剪贴板
|
|
108
|
+
let url = this.getSechmaUrl();
|
|
109
|
+
if (url) {
|
|
110
|
+
tools.clipboard(url);
|
|
111
|
+
}
|
|
112
|
+
const apk = JSON.parse(sessionStorage.getItem('downloadApk') || '{}');
|
|
113
|
+
const tag = this._ios ? (apk.channelName ? `App Store-${apk.channelName}` : 'App Store') : (apk.channelName ? `渠道${apk.channelName}包` : '安卓包');
|
|
114
|
+
this.postJddTrack(this.trackId, { tag });
|
|
115
|
+
// 厂家版 app
|
|
116
|
+
if (this._android && location.href.includes('downloadPrise')) {
|
|
117
|
+
window.location.href = (apk && apk.path) || this.appUrl;
|
|
118
|
+
this.underway = false;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// 客户端打开app-下载页特殊处理
|
|
122
|
+
if (location.href.includes('download') && window.AppCall && window.AppCall.has('openOtherAppUrlRouter')) {
|
|
123
|
+
this.underway = false;
|
|
124
|
+
return window.AppCall.openOtherAppUrlRouter({ appUrlRouter: `https://${location.host}/home` });
|
|
125
|
+
}
|
|
126
|
+
// 客户端打开app
|
|
127
|
+
if (window.AppCall && window.AppCall.has('openOtherAppUrlRouter')) {
|
|
128
|
+
this.underway = false;
|
|
129
|
+
url = this.getUrl();
|
|
130
|
+
return window.AppCall.openOtherAppUrlRouter({ appUrlRouter: url || '' });
|
|
131
|
+
}
|
|
132
|
+
// IOS系统下,H5中的特殊处理,历史逻辑,应该是用了universal link,待确认
|
|
133
|
+
if (this._ios) {
|
|
134
|
+
url = this.appStoreUrl;
|
|
135
|
+
}
|
|
136
|
+
this.open(url);
|
|
137
|
+
}
|
|
138
|
+
// 获取自定义的url
|
|
139
|
+
getUrl() {
|
|
140
|
+
const searchParams = qs.parse(location.search.slice(1)); // 路由的query
|
|
141
|
+
const url = searchParams.customOpenUrl || window.location.href;
|
|
142
|
+
return url;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 获取打开 app sechma url
|
|
146
|
+
* @returns {string | undefined} 打开app的schema或跳转链接
|
|
147
|
+
* params:params={"type":"","id":0,"name":"","travelId":0}
|
|
148
|
+
* type:原生页面key(必须);id:页面id(可选);subject 短话题、版块名称 或 页面标题(可选);travelId 游记id(可选)
|
|
149
|
+
*/
|
|
150
|
+
getSechmaUrl() {
|
|
151
|
+
const keys = {
|
|
152
|
+
'/posts/': 'thread_detail',
|
|
153
|
+
'/detailedForum/': 'forum_detail',
|
|
154
|
+
'/video/': 'video_detail',
|
|
155
|
+
'/answer-details/': 'topic_detail',
|
|
156
|
+
'/details-article/': 'essay_detail',
|
|
157
|
+
'/details-views/': 'opinion_detail',
|
|
158
|
+
'/topic-homepage': 'short_topic',
|
|
159
|
+
'/label-detail': 'tag_detail',
|
|
160
|
+
'/circle-article/': 'moment_detail',
|
|
161
|
+
'/vehicle-details/': 'car_detail',
|
|
162
|
+
'/car-detail': 'newcar_sale_detail',
|
|
163
|
+
'/myhomepage': 'person_detail',
|
|
164
|
+
'/dealer': 'shop_detail',
|
|
165
|
+
'/circle-preview': 'hoop_detail',
|
|
166
|
+
'/used-car-detail': 'used_detail',
|
|
167
|
+
'/coupon-detail': 'coupon_detail',
|
|
168
|
+
'/news/': 'essay_detail' // 文章详情
|
|
169
|
+
};
|
|
170
|
+
const target = Object.keys(keys).filter(function (value) {
|
|
171
|
+
return window.location.href.indexOf(value) > -1;
|
|
172
|
+
});
|
|
173
|
+
const type = target && target[0] && keys[target[0]];
|
|
174
|
+
const searchParams = qs.parse(location.search.slice(1)); // 路由的query
|
|
175
|
+
const id = parseInt(location.pathname.split('/').reverse()[0]) ||
|
|
176
|
+
parseInt(searchParams.id) ||
|
|
177
|
+
parseInt(searchParams.carId) ||
|
|
178
|
+
parseInt(searchParams.goodId); // 页面id
|
|
179
|
+
const subject = searchParams.subject || undefined; // 页面标题或name
|
|
180
|
+
const temp = {
|
|
181
|
+
relationType: type,
|
|
182
|
+
id: id,
|
|
183
|
+
name: subject
|
|
184
|
+
};
|
|
185
|
+
const data = this.openAppState?.state?.openApps || {};
|
|
186
|
+
let open_url = '';
|
|
187
|
+
if (data.type && data.href === window.location.href) {
|
|
188
|
+
temp.relationType = keys[data.type] || '';
|
|
189
|
+
temp.id = data.id || '';
|
|
190
|
+
temp.name = data.title || '';
|
|
191
|
+
open_url = data.url || '';
|
|
192
|
+
}
|
|
193
|
+
const openUrl = open_url || searchParams.customOpenUrl || window.location.href;
|
|
194
|
+
// activityId 大于零,type 为 activity
|
|
195
|
+
if (searchParams.activityId) {
|
|
196
|
+
temp.relationType = 'activity';
|
|
197
|
+
temp.link = decodeURIComponent(decodeURIComponent(openUrl));
|
|
198
|
+
}
|
|
199
|
+
temp.jumpUrl = decodeURIComponent(decodeURIComponent(openUrl));
|
|
200
|
+
const params = JSON.stringify(temp);
|
|
201
|
+
if (this._ios) {
|
|
202
|
+
return `${this.currentEnv.motoIOSScheme}?params=${params}`;
|
|
203
|
+
}
|
|
204
|
+
if (this._android || this._isHarmonyos) {
|
|
205
|
+
const url = this._wx ? `${this.appUrl}&android_scheme=${this.currentEnv.motoAndroidScheme}?params=${params}` : `${this.currentEnv.motoAndroidScheme}?params=${params}`;
|
|
206
|
+
return url;
|
|
207
|
+
}
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* 方法一(推荐):打开APP
|
|
212
|
+
* http://www.cnblogs.com/shadajin/p/5724117.html
|
|
213
|
+
*/
|
|
214
|
+
open(openUrl) {
|
|
215
|
+
if (!openUrl) {
|
|
216
|
+
this.underway = false;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (this._ios) {
|
|
220
|
+
this.underway = false;
|
|
221
|
+
setTimeout(() => (location.href = this.appStoreUrl || ''), 3000);
|
|
222
|
+
return (location.href = openUrl);
|
|
223
|
+
}
|
|
224
|
+
if (this._android) {
|
|
225
|
+
const ifr = document.createElement('iframe');
|
|
226
|
+
ifr.src = openUrl;
|
|
227
|
+
ifr.style.display = 'none';
|
|
228
|
+
document.body.appendChild(ifr);
|
|
229
|
+
setTimeout(function () {
|
|
230
|
+
document.body.removeChild(ifr);
|
|
231
|
+
}, 3000);
|
|
232
|
+
}
|
|
233
|
+
return new Promise((resolve, reject) => {
|
|
234
|
+
// 检查APP是否打开
|
|
235
|
+
const check = (elsTime) => {
|
|
236
|
+
if (elsTime > 3000 || document.hidden) {
|
|
237
|
+
// @ts-ignore
|
|
238
|
+
resolve('成功打开APP');
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
window.location.href = `https://${location.host}/download`;
|
|
243
|
+
reject('打开APP失败');
|
|
244
|
+
}
|
|
245
|
+
this.underway = false;
|
|
246
|
+
};
|
|
247
|
+
let _count = 0;
|
|
248
|
+
const _clickTime = +new Date();
|
|
249
|
+
const intHandle = setInterval(() => {
|
|
250
|
+
_count++;
|
|
251
|
+
const elsTime = +new Date() - _clickTime;
|
|
252
|
+
if (_count >= 100 || elsTime > 3000) {
|
|
253
|
+
clearInterval(intHandle);
|
|
254
|
+
check(elsTime);
|
|
255
|
+
}
|
|
256
|
+
}, 20);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export default OpenAppClass;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
declare class Report {
|
|
2
|
-
static instance: any;
|
|
3
|
-
constructor(Vue: Object, options?: {});
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
static getInstance(Vue: Object, Option: Object): any;
|
|
6
|
-
install(): void;
|
|
7
|
-
/**
|
|
8
|
-
* 主动上报
|
|
9
|
-
* @param {String} data
|
|
10
|
-
* @param {String} type 'info','warning','error'
|
|
11
|
-
* @param {Object} options
|
|
12
|
-
*/
|
|
13
|
-
log(data?: any, type?: any, options?: any): void;
|
|
14
|
-
}
|
|
15
|
-
export default Report;
|
|
1
|
+
declare class Report {
|
|
2
|
+
static instance: any;
|
|
3
|
+
constructor(Vue: Object, options?: {});
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
static getInstance(Vue: Object, Option: Object): any;
|
|
6
|
+
install(): void;
|
|
7
|
+
/**
|
|
8
|
+
* 主动上报
|
|
9
|
+
* @param {String} data
|
|
10
|
+
* @param {String} type 'info','warning','error'
|
|
11
|
+
* @param {Object} options
|
|
12
|
+
*/
|
|
13
|
+
log(data?: any, type?: any, options?: any): void;
|
|
14
|
+
}
|
|
15
|
+
export default Report;
|