@conecli/cone-render 0.10.1-shop3.42 → 0.10.1-shop3.43
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/utils/h5Utils.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
2
1
|
isApp,
|
|
3
2
|
isIOS,
|
|
4
3
|
getAppVersion,
|
|
5
4
|
version,
|
|
6
5
|
getUUID,
|
|
7
6
|
getUrlQuery,
|
|
8
7
|
assign,
|
|
9
8
|
isString,
|
|
10
9
|
isObject,
|
|
11
10
|
serialize,
|
|
12
11
|
isAndroid,
|
|
13
12
|
versionCompare,
|
|
14
13
|
isIPad,
|
|
15
14
|
isTablet,
|
|
16
15
|
CHANNEL_TYPE,
|
|
17
16
|
JDShopViewBusinessPathType,
|
|
18
17
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
19
18
|
SECTION_HOME_TAB_TYPE,
|
|
20
19
|
DraBuryPointFlags,
|
|
21
20
|
MPAAS_CONFIG_APP_VERSION,
|
|
22
21
|
new Promise((resolve, reject) => {
|
|
23
22
|
if (window?.__sgm__) {
|
|
24
23
|
resolve(true);
|
|
25
24
|
} else {
|
|
26
25
|
if (isSgmReadyError) {
|
|
27
26
|
console.log('当前sgm初始化失败');
|
|
28
27
|
reject(false);
|
|
29
28
|
} else {
|
|
30
29
|
ready('__sgm__', 2000)
|
|
31
30
|
.then(() => {
|
|
32
31
|
isSgmReadyError = false;
|
|
33
32
|
console.log('当前sgm初始化成功');
|
|
34
33
|
resolve(true);
|
|
35
34
|
})
|
|
36
35
|
.catch(() => {
|
|
37
36
|
isSgmReadyError = true;
|
|
38
37
|
console.log('当前sgm初始化失败');
|
|
39
38
|
reject(false);
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
});
|
|
44
43
|
console.log(message);
|
|
45
44
|
reject(new Error(message));
|
|
46
45
|
return ready('dra', 2000)
|
|
47
46
|
.then(() => {
|
|
48
47
|
isNewDraSdkReadyError = false;
|
|
49
48
|
console.log('当前新版烛龙sdk初始化成功');
|
|
50
49
|
return true;
|
|
51
50
|
})
|
|
52
51
|
.catch(() => {
|
|
53
52
|
isNewDraSdkReadyError = true;
|
|
54
53
|
throw new Error('当前新版烛龙sdk初始化失败');
|
|
55
54
|
});
|
|
56
55
|
return new Promise((resolve, reject) => {
|
|
57
56
|
if (window?.dra) {
|
|
58
57
|
resolve(true);
|
|
59
58
|
} else if (isNewDraSdkReadyError) {
|
|
60
59
|
logAndReject('当前新版烛龙sdk初始化失败', reject);
|
|
61
60
|
} else {
|
|
62
61
|
initializeDraSdk()
|
|
63
62
|
.then(resolve)
|
|
64
63
|
.catch((error) => logAndReject(error.message, reject));
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
66
|
rootEleInitWidth = 0,
|
|
68
67
|
screenWidth = 0,
|
|
69
68
|
screenHeight = 0,
|
|
70
69
|
if (rootEleInitWidth > 0 && screenWidth > 0 && screenHeight > 0) {
|
|
71
70
|
const isRootEleWidthEqScreenWidth = Math.abs(rootEleInitWidth - screenWidth) < 60;
|
|
72
71
|
const getThisWinWidth = rootEleInitWidth;
|
|
73
72
|
const getThisWinHeight = isRootEleWidthEqScreenWidth ? screenHeight : screenWidth;
|
|
74
73
|
console.info(
|
|
75
74
|
'通过rootEleInitWidth对比屏幕宽高确认横竖屏幕方式',
|
|
76
75
|
'rootEleInitWidth',
|
|
77
76
|
rootEleInitWidth,
|
|
78
77
|
'screenWidth',
|
|
79
78
|
screenWidth,
|
|
80
79
|
'screenHeight',
|
|
81
80
|
screenHeight,
|
|
82
81
|
'isRootEleWidthEqScreenWidth(根元素宽度是否与屏幕本身宽度接近,主要是ios屏幕宽高不变)',
|
|
83
82
|
isRootEleWidthEqScreenWidth,
|
|
84
83
|
'getThisWinWidth',
|
|
85
84
|
getThisWinWidth,
|
|
86
85
|
'getThisWinHeight',
|
|
87
86
|
getThisWinHeight,
|
|
88
87
|
'是否是横屏',
|
|
89
88
|
getThisWinWidth > getThisWinHeight,
|
|
90
89
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏,带有landscape为横屏',
|
|
91
90
|
window.screen?.orientation?.type,
|
|
92
91
|
);
|
|
93
92
|
return getThisWinWidth > getThisWinHeight;
|
|
94
93
|
} else {
|
|
95
94
|
if (window.screen?.orientation?.type) {
|
|
96
95
|
console.info(
|
|
97
96
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏',
|
|
98
97
|
window.screen?.orientation?.type,
|
|
99
98
|
'测试低版本通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
100
99
|
window?.orientation,
|
|
101
100
|
);
|
|
102
101
|
return /landscape/i.test(window.screen.orientation.type);
|
|
103
102
|
} else if (window?.orientation) {
|
|
104
103
|
console.info(
|
|
105
104
|
'通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
106
105
|
window?.orientation,
|
|
107
106
|
);
|
|
108
107
|
return [90, -90].includes(window?.orientation);
|
|
109
108
|
} else {
|
|
110
109
|
console.info(
|
|
111
110
|
'通过window.matchMedia((orientation: landscape))?.matches方式获取当前pad屏幕是否是横屏',
|
|
112
111
|
window.matchMedia('(orientation: landscape)')?.matches,
|
|
113
112
|
);
|
|
114
113
|
return window.matchMedia('(orientation: landscape)')?.matches;
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
try {
|
|
118
117
|
return JSON.parse(decodeURIComponent(getUrlQuery('cookie')));
|
|
119
118
|
} catch (e) {
|
|
120
119
|
return {};
|
|
121
120
|
}
|
|
122
121
|
'harmony' === (userAgent.split(';')[1] || '').toLowerCase() || /arkweb/i.test(userAgent);
|
|
123
122
|
window?.location?.hostname === 'pages.jd.com' && isJdAndHarmonyDevice;
|
|
124
123
|
window.shopGlobalSwitch?.isH5AndJdShopViewH5ScrollVersion || '';
|
|
125
124
|
!!document.getElementById('mallType') &&
|
|
126
125
|
!!document.getElementById('pageInstance_id') &&
|
|
127
126
|
!!document.getElementById('pageInstance_appId');
|
|
128
127
|
isTjScence &&
|
|
129
128
|
isWxMiniH5View &&
|
|
130
129
|
(urlCookie['wxapp_type'] == '2' ||
|
|
131
130
|
cookie.get('wxapp_type') == '2' ||
|
|
132
131
|
parseQueryUrlObj['tjChannel'] === 'jxxcx');
|
|
133
132
|
isTjScence && isWxMiniH5View && parseQueryUrlObj['sourceApp'] === 'haowujie';
|
|
134
133
|
isTjScence &&
|
|
135
134
|
(parseQueryUrlObj['appCode'] === 'ms27cba806' ||
|
|
136
135
|
document.referrer?.match(/(?:https?:)?\/\/(?:kpl\.m|css|cs)\.jd\.com/i)?.length ||
|
|
137
136
|
(parseQueryUrlObj['sourceApp'] == 'jsb-m' && parseQueryUrlObj['appCode'] === '') ||
|
|
138
137
|
parseQueryUrlObj['tjChannel'] === 'tjm');
|
|
139
138
|
if (isH5AdnJxMini) {
|
|
140
139
|
return 'jxxcx';
|
|
141
140
|
} else if (isTJApp) {
|
|
142
141
|
return 'tjapp';
|
|
143
142
|
} else if (isTjM) {
|
|
144
143
|
return 'tjm';
|
|
145
144
|
} else if (isTjJxM) {
|
|
146
145
|
return 'jxh5';
|
|
147
146
|
}
|
|
148
147
|
return '';
|
|
149
148
|
START: 'start',
|
|
150
149
|
MOVE: 'move',
|
|
151
150
|
END: 'end',
|
|
152
151
|
x: 0,
|
|
153
152
|
y: 0,
|
|
154
153
|
const startX = startPos.x;
|
|
155
154
|
const startY = startPos.y;
|
|
156
155
|
const endX = touchEvent.clientX;
|
|
157
156
|
const endY = touchEvent.clientY;
|
|
158
157
|
const dy = startY - endY;
|
|
159
158
|
const dx = endX - startX;
|
|
160
159
|
let result = 0;
|
|
161
160
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
162
161
|
return result;
|
|
163
162
|
}
|
|
164
163
|
const angle = (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
165
164
|
if (angle >= -45 && angle < 45) {
|
|
166
165
|
result = 4;
|
|
167
166
|
} else if (angle >= 45 && angle < 135) {
|
|
168
167
|
result = 1;
|
|
169
168
|
} else if (angle >= -135 && angle < -45) {
|
|
170
169
|
result = 2;
|
|
171
170
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
172
171
|
result = 3;
|
|
173
172
|
}
|
|
174
173
|
return result;
|
|
175
174
|
e: Event,
|
|
176
175
|
touchType = TouchType.START,
|
|
177
176
|
stopTouchDocumentScrollState = false,
|
|
178
177
|
if (isJdApp && e) {
|
|
179
178
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
180
179
|
let _touchState = touchType;
|
|
181
180
|
let _getDirectionState = false;
|
|
182
181
|
if (touchType === TouchType.START) {
|
|
183
182
|
StopNativeScrollEventPos.x = touchEvent.clientX;
|
|
184
183
|
StopNativeScrollEventPos.y = touchEvent.clientY;
|
|
185
184
|
} else if (touchType === TouchType.MOVE) {
|
|
186
185
|
_getDirectionState = [1, 2].includes(
|
|
187
186
|
touchMoveGetSlideDirection(StopNativeScrollEventPos, touchEvent),
|
|
188
187
|
);
|
|
189
188
|
if (_getDirectionState) {
|
|
190
189
|
_touchState = TouchType.END;
|
|
191
190
|
}
|
|
192
191
|
console.log(
|
|
193
192
|
'对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向',
|
|
194
193
|
_getDirectionState,
|
|
195
194
|
);
|
|
196
195
|
} else if (touchType === TouchType.END) {
|
|
197
196
|
StopNativeScrollEventPos.x = 0;
|
|
198
197
|
StopNativeScrollEventPos.y = 0;
|
|
199
198
|
}
|
|
200
199
|
isIosDevice
|
|
201
200
|
? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
|
|
202
201
|
: androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState);
|
|
203
202
|
if (
|
|
204
203
|
!isAppHomeForMarketPage &&
|
|
205
204
|
stopTouchDocumentScrollState &&
|
|
206
205
|
_touchState === TouchType.START
|
|
207
206
|
) {
|
|
208
207
|
rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
209
208
|
}
|
|
210
209
|
if (_touchState === TouchType.MOVE && _getDirectionState) {
|
|
211
210
|
rootEleNode &&
|
|
212
211
|
rootEleNode.classList.contains('over-hidden') &&
|
|
213
212
|
rootEleNode.classList.remove('over-hidden');
|
|
214
213
|
} else if (_touchState === TouchType.END) {
|
|
215
214
|
setTimeout(
|
|
216
215
|
() => {
|
|
217
216
|
rootEleNode &&
|
|
218
217
|
rootEleNode.classList.contains('over-hidden') &&
|
|
219
218
|
rootEleNode.classList.remove('over-hidden');
|
|
220
219
|
},
|
|
221
220
|
isAppHomeForMarketPage || _getDirectionState ? 0 : 200,
|
|
222
221
|
);
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
224
|
touchType = TouchType.START,
|
|
226
225
|
stopTouchDocumentScrollState = false,
|
|
227
226
|
isJdApp &&
|
|
228
227
|
touchType !== TouchType.MOVE &&
|
|
229
228
|
isAndroidDevice &&
|
|
230
229
|
window?.JdAndroid &&
|
|
231
230
|
window?.JdAndroid?.requestEvent &&
|
|
232
231
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
233
232
|
console.log(
|
|
234
233
|
'对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为',
|
|
235
234
|
touchType,
|
|
236
235
|
'当前非move触发requestEvent状态为',
|
|
237
236
|
touchType === TouchType.START,
|
|
238
237
|
'当前stopTouchDocumentScrollState为',
|
|
239
238
|
stopTouchDocumentScrollState,
|
|
240
239
|
);
|
|
241
240
|
e,
|
|
242
241
|
touchType = TouchType.START,
|
|
243
242
|
stopTouchDocumentScrollState = false,
|
|
244
243
|
e && e.stopPropagation();
|
|
245
244
|
console.log(
|
|
246
245
|
'对外提供阻止ios横滑方法,当前touchType为',
|
|
247
246
|
touchType,
|
|
248
247
|
'当前stopTouchDocumentScrollState为',
|
|
249
248
|
stopTouchDocumentScrollState,
|
|
250
249
|
);
|
|
251
250
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
252
251
|
method: 'callRouterModuleWithParams',
|
|
253
252
|
params: {
|
|
254
253
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
255
254
|
routerParam: {
|
|
256
255
|
slideDirection: 'horizontal',
|
|
257
256
|
state: touchType,
|
|
258
257
|
},
|
|
259
258
|
callBackId: new Date().getTime(),
|
|
260
259
|
},
|
|
261
260
|
});
|
|
262
261
|
if (isH5AndJdShopView) {
|
|
263
262
|
return CHANNEL_TYPE[currentChannel] || CHANNEL_TYPE[JDShopViewBusinessPathType.HOME];
|
|
264
263
|
}
|
|
265
264
|
return null;
|
|
266
265
|
isH5 &&
|
|
267
266
|
isJdApp &&
|
|
268
267
|
[
|
|
269
268
|
'/app/home',
|
|
270
269
|
'/app/homeV2',
|
|
271
270
|
'/app/classify',
|
|
272
271
|
'/app/classifyV2',
|
|
273
272
|
'/member/shopcard',
|
|
274
273
|
'/favorite/home',
|
|
275
274
|
].includes(urlPathname);
|
|
276
275
|
isH5 && isJdApp && !['/app/home', '/app/homeV2'].includes(urlPathname);
|
|
277
276
|
['/app/home', '/app/homeV2'].includes(urlPathname) &&
|
|
278
277
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_PROMOTION &&
|
|
279
278
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_MEMBER;
|
|
280
279
|
isAppHomePage && parseQueryUrlObj['source'] === 'app-marketing';
|
|
281
280
|
isH5 &&
|
|
282
281
|
isAppHomePage &&
|
|
283
282
|
versionCompare(jdAppVersion?.full ? jdAppVersion.full : '', isH5AndJdShopViewH5ScrollVersion) >=
|
|
284
283
|
0;
|
|
285
284
|
return isJdApp ? versionCompare(nowVersion, compareVersion) : -2;
|
|
286
285
|
getSgmReadyPromise()
|
|
287
286
|
.then(() => {
|
|
288
287
|
if (
|
|
289
288
|
customObj.hasOwnProperty('code') &&
|
|
290
289
|
customObj.code.indexOf(NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG) !== -1
|
|
291
290
|
) {
|
|
292
291
|
const originCode = customObj.code.substring(
|
|
293
292
|
NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG.length,
|
|
294
293
|
customObj.code.length,
|
|
295
294
|
);
|
|
296
295
|
customObj['code'] = getSgmCustomCode(handleSgmCodeTaroVersion(originCode));
|
|
297
296
|
}
|
|
298
297
|
const getCustomObj = {
|
|
299
298
|
type: 1,
|
|
300
299
|
code: 'all',
|
|
301
300
|
cost1: 1,
|
|
302
301
|
...customObj,
|
|
303
302
|
};
|
|
304
303
|
try {
|
|
305
304
|
window.__sgm__.custom(getCustomObj, '9HwAEg@fTtWBB3EnwA5VgLT');
|
|
306
305
|
} catch (e) {
|
|
307
306
|
console.log('当前sgm上报异常, 原始数据为', JSON.stringify(customObj));
|
|
308
307
|
}
|
|
309
308
|
})
|
|
310
309
|
.catch(() => {
|
|
311
310
|
console.error('当前页面sgm加载异常,无法进行异常上报, 原始数据为', JSON.stringify(customObj));
|
|
312
311
|
});
|
|
313
312
|
try {
|
|
314
313
|
await getNewDraSdkReadyPromise();
|
|
315
314
|
const draBurypointFlag = name ?? DraBuryPointFlags.BUSINESS;
|
|
316
315
|
const commonObj = {
|
|
317
316
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
318
317
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
319
318
|
taroRenderVersion: window?.taroRenderVersion,
|
|
320
319
|
environmentType: getEnvironmentType(),
|
|
321
320
|
pageType: getPageType(),
|
|
322
321
|
};
|
|
323
322
|
try {
|
|
324
323
|
window.dra.sendCustomEvent(
|
|
325
324
|
{
|
|
326
325
|
name: draBurypointFlag,
|
|
327
326
|
metrics: {
|
|
328
327
|
timeStamp: Date.now(),
|
|
329
328
|
...customMetricsObj,
|
|
330
329
|
},
|
|
331
330
|
context: {
|
|
332
331
|
...commonObj,
|
|
333
332
|
...customContextObj,
|
|
334
333
|
},
|
|
335
334
|
},
|
|
336
335
|
true,
|
|
337
336
|
);
|
|
338
337
|
} catch (e) {
|
|
339
338
|
console.error(
|
|
340
339
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
341
340
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
342
341
|
'e',
|
|
343
342
|
e,
|
|
344
343
|
);
|
|
345
344
|
}
|
|
346
345
|
} catch (e) {
|
|
347
346
|
console.error(
|
|
348
347
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
349
348
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
350
349
|
'e',
|
|
351
350
|
e,
|
|
352
351
|
);
|
|
353
352
|
}
|
|
354
353
|
try {
|
|
355
354
|
await getNewDraSdkReadyPromise();
|
|
356
355
|
const commonObj = {
|
|
357
356
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
358
357
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
359
358
|
taroRenderVersion: window?.taroRenderVersion,
|
|
360
359
|
environmentType: getEnvironmentType(),
|
|
361
360
|
pageType: getPageType(),
|
|
362
361
|
url: encodeURIComponent(window?.location?.href),
|
|
363
362
|
};
|
|
364
363
|
try {
|
|
365
364
|
window.dra.sendCustomLogEvent({
|
|
366
365
|
level,
|
|
367
366
|
content: logContent || '日志上报',
|
|
368
367
|
extra: JSON.stringify(commonObj),
|
|
369
368
|
timeStamp: Date.now(),
|
|
370
369
|
});
|
|
371
370
|
} catch (e) {
|
|
372
371
|
console.error('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e);
|
|
373
372
|
}
|
|
374
373
|
} catch (e2) {
|
|
375
374
|
console.error('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e2);
|
|
376
375
|
}
|
|
377
376
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE);
|
|
378
377
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE);
|
|
379
378
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.BUSINESS);
|
|
380
379
|
const deviceRatio = window?.devicePixelRatio ?? 2;
|
|
381
380
|
if (isJdAndAndroidDevice && typeof displayObj === 'object') {
|
|
382
381
|
Object.keys(displayObj).forEach((key) => {
|
|
383
382
|
if (key === 'nativeHeaderHeight') {
|
|
384
383
|
displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2);
|
|
385
384
|
} else {
|
|
386
385
|
displayObj[key] = Math.ceil(displayObj[key] / deviceRatio);
|
|
387
386
|
}
|
|
388
387
|
});
|
|
389
388
|
} else if (isJdAndHarmonyDevice && isNewHarmonyShop && typeof displayObj === 'object') {
|
|
390
389
|
if (displayObj['bottomBarHeight'] && typeof displayObj['bottomBarHeight'] === 'number') {
|
|
391
390
|
displayObj['bottomBarHeight'] = Math.ceil(displayObj['bottomBarHeight'] / deviceRatio);
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
393
|
return displayObj;
|
|
395
394
|
isJdAndAndroidDevice && /TBS\/\d+/.test(window?.navigator?.userAgent);
|
|
396
395
|
rootEleNode &&
|
|
397
396
|
!rootEleNode.classList.contains('d-shop-lang-for-en') &&
|
|
398
397
|
rootEleNode.classList.add('d-shop-lang-for-en');
|
|
399
398
|
rootEleNode &&
|
|
400
399
|
!rootEleNode.classList.contains('d-shop-lang-for-hk') &&
|
|
401
400
|
rootEleNode.classList.add('d-shop-lang-for-hk');
|
|
402
401
|
customContextObj = {},
|
|
403
402
|
customMetricsObj = {},
|
|
404
403
|
name?,
|
|
405
404
|
try {
|
|
406
405
|
const draBurypointFlag = name ?? DraBuryPointFlags.DECOSDM;
|
|
407
406
|
try {
|
|
408
407
|
let dra = null;
|
|
409
408
|
const iframe = window?.top?.document?.getElementsByTagName('iframe')[0];
|
|
410
409
|
if (iframe && iframe.contentWindow) {
|
|
411
410
|
dra = iframe.contentWindow?.dra;
|
|
412
411
|
}
|
|
413
412
|
if (window.dra) {
|
|
414
413
|
dra = window.dra;
|
|
415
414
|
}
|
|
416
415
|
dra &&
|
|
417
416
|
dra.sendCustomEvent(
|
|
418
417
|
{
|
|
419
418
|
name: draBurypointFlag,
|
|
420
419
|
metrics: {
|
|
421
420
|
timeStamp: Date.now(),
|
|
422
421
|
},
|
|
423
422
|
context: {
|
|
424
423
|
...customContextObj,
|
|
425
424
|
},
|
|
426
425
|
},
|
|
427
426
|
true,
|
|
428
427
|
);
|
|
429
428
|
} catch (e) {
|
|
430
429
|
console.error(
|
|
431
430
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
432
431
|
JSON.stringify({ ...customContextObj }),
|
|
433
432
|
'e',
|
|
434
433
|
e,
|
|
435
434
|
);
|
|
436
435
|
}
|
|
437
436
|
} catch (e) {
|
|
438
437
|
console.error(
|
|
439
438
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
440
439
|
JSON.stringify({ ...customContextObj }),
|
|
441
440
|
'e',
|
|
442
441
|
e,
|
|
443
442
|
);
|
|
444
443
|
}
|
|
444
|
+
import {
|
|
445
445
|
isApp,
|
|
446
446
|
isIOS,
|
|
447
447
|
getAppVersion,
|
|
448
448
|
version,
|
|
449
449
|
getUUID,
|
|
450
450
|
getUrlQuery,
|
|
451
451
|
assign,
|
|
452
452
|
isString,
|
|
453
453
|
isObject,
|
|
454
454
|
serialize,
|
|
455
455
|
isAndroid,
|
|
456
456
|
versionCompare,
|
|
457
457
|
isIPad,
|
|
458
458
|
isTablet,
|
|
459
459
|
CHANNEL_TYPE,
|
|
460
460
|
JDShopViewBusinessPathType,
|
|
461
461
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
462
462
|
SECTION_HOME_TAB_TYPE,
|
|
463
463
|
DraBuryPointFlags,
|
|
464
464
|
MPAAS_CONFIG_APP_VERSION,
|
|
465
465
|
new Promise((resolve, reject) => {
|
|
466
466
|
if (window?.__sgm__) {
|
|
467
467
|
resolve(true);
|
|
468
468
|
} else {
|
|
469
469
|
if (isSgmReadyError) {
|
|
470
470
|
console.log('当前sgm初始化失败');
|
|
471
471
|
reject(false);
|
|
472
472
|
} else {
|
|
473
473
|
ready('__sgm__', 2000)
|
|
474
474
|
.then(() => {
|
|
475
475
|
isSgmReadyError = false;
|
|
476
476
|
console.log('当前sgm初始化成功');
|
|
477
477
|
resolve(true);
|
|
478
478
|
})
|
|
479
479
|
.catch(() => {
|
|
480
480
|
isSgmReadyError = true;
|
|
481
481
|
console.log('当前sgm初始化失败');
|
|
482
482
|
reject(false);
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
});
|
|
487
487
|
console.log(message);
|
|
488
488
|
reject(new Error(message));
|
|
489
489
|
return ready('dra', 2000)
|
|
490
490
|
.then(() => {
|
|
491
491
|
isNewDraSdkReadyError = false;
|
|
492
492
|
console.log('当前新版烛龙sdk初始化成功');
|
|
493
493
|
return true;
|
|
494
494
|
})
|
|
495
495
|
.catch(() => {
|
|
496
496
|
isNewDraSdkReadyError = true;
|
|
497
497
|
throw new Error('当前新版烛龙sdk初始化失败');
|
|
498
498
|
});
|
|
499
499
|
return new Promise((resolve, reject) => {
|
|
500
500
|
if (window?.dra) {
|
|
501
501
|
resolve(true);
|
|
502
502
|
} else if (isNewDraSdkReadyError) {
|
|
503
503
|
logAndReject('当前新版烛龙sdk初始化失败', reject);
|
|
504
504
|
} else {
|
|
505
505
|
initializeDraSdk()
|
|
506
506
|
.then(resolve)
|
|
507
507
|
.catch((error) => logAndReject(error.message, reject));
|
|
508
508
|
}
|
|
509
509
|
});
|
|
510
510
|
rootEleInitWidth = 0,
|
|
511
511
|
screenWidth = 0,
|
|
512
512
|
screenHeight = 0,
|
|
513
513
|
if (rootEleInitWidth > 0 && screenWidth > 0 && screenHeight > 0) {
|
|
514
514
|
const isRootEleWidthEqScreenWidth = Math.abs(rootEleInitWidth - screenWidth) < 60;
|
|
515
515
|
const getThisWinWidth = rootEleInitWidth;
|
|
516
516
|
const getThisWinHeight = isRootEleWidthEqScreenWidth ? screenHeight : screenWidth;
|
|
517
517
|
console.info(
|
|
518
518
|
'通过rootEleInitWidth对比屏幕宽高确认横竖屏幕方式',
|
|
519
519
|
'rootEleInitWidth',
|
|
520
520
|
rootEleInitWidth,
|
|
521
521
|
'screenWidth',
|
|
522
522
|
screenWidth,
|
|
523
523
|
'screenHeight',
|
|
524
524
|
screenHeight,
|
|
525
525
|
'isRootEleWidthEqScreenWidth(根元素宽度是否与屏幕本身宽度接近,主要是ios屏幕宽高不变)',
|
|
526
526
|
isRootEleWidthEqScreenWidth,
|
|
527
527
|
'getThisWinWidth',
|
|
528
528
|
getThisWinWidth,
|
|
529
529
|
'getThisWinHeight',
|
|
530
530
|
getThisWinHeight,
|
|
531
531
|
'是否是横屏',
|
|
532
532
|
getThisWinWidth > getThisWinHeight,
|
|
533
533
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏,带有landscape为横屏',
|
|
534
534
|
window.screen?.orientation?.type,
|
|
535
535
|
);
|
|
536
536
|
return getThisWinWidth > getThisWinHeight;
|
|
537
537
|
} else {
|
|
538
538
|
if (window.screen?.orientation?.type) {
|
|
539
539
|
console.info(
|
|
540
540
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏',
|
|
541
541
|
window.screen?.orientation?.type,
|
|
542
542
|
'测试低版本通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
543
543
|
window?.orientation,
|
|
544
544
|
);
|
|
545
545
|
return /landscape/i.test(window.screen.orientation.type);
|
|
546
546
|
} else if (window?.orientation) {
|
|
547
547
|
console.info(
|
|
548
548
|
'通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
549
549
|
window?.orientation,
|
|
550
550
|
);
|
|
551
551
|
return [90, -90].includes(window?.orientation);
|
|
552
552
|
} else {
|
|
553
553
|
console.info(
|
|
554
554
|
'通过window.matchMedia((orientation: landscape))?.matches方式获取当前pad屏幕是否是横屏',
|
|
555
555
|
window.matchMedia('(orientation: landscape)')?.matches,
|
|
556
556
|
);
|
|
557
557
|
return window.matchMedia('(orientation: landscape)')?.matches;
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
try {
|
|
561
561
|
return JSON.parse(decodeURIComponent(getUrlQuery('cookie')));
|
|
562
562
|
} catch (e) {
|
|
563
563
|
return {};
|
|
564
564
|
}
|
|
565
565
|
isWxMiniH5View && (/wx91d27dbf599dff74/i.test(userAgent) || urlCookie['wxapp_type'] == '1');
|
|
566
566
|
'harmony' === (userAgent.split(';')[1] || '').toLowerCase() || /arkweb/i.test(userAgent);
|
|
567
567
|
window?.location?.hostname === 'pages.jd.com' && isJdAndHarmonyDevice;
|
|
568
568
|
window.shopGlobalSwitch?.isH5AndJdShopViewH5ScrollVersion || '';
|
|
569
569
|
!!document.getElementById('mallType') &&
|
|
570
570
|
!!document.getElementById('pageInstance_id') &&
|
|
571
571
|
!!document.getElementById('pageInstance_appId');
|
|
572
572
|
isTjScence &&
|
|
573
573
|
isWxMiniH5View &&
|
|
574
574
|
(urlCookie['wxapp_type'] == '2' ||
|
|
575
575
|
cookie.get('wxapp_type') == '2' ||
|
|
576
576
|
parseQueryUrlObj['tjChannel'] === 'jxxcx');
|
|
577
577
|
isTjScence && isWxMiniH5View && parseQueryUrlObj['sourceApp'] === 'haowujie';
|
|
578
578
|
isTjScence &&
|
|
579
579
|
(parseQueryUrlObj['appCode'] === 'ms27cba806' ||
|
|
580
580
|
document.referrer?.match(/(?:https?:)?\/\/(?:kpl\.m|css|cs)\.jd\.com/i)?.length ||
|
|
581
581
|
(parseQueryUrlObj['sourceApp'] == 'jsb-m' && parseQueryUrlObj['appCode'] === '') ||
|
|
582
582
|
parseQueryUrlObj['tjChannel'] === 'tjm');
|
|
583
583
|
if (isH5AdnJxMini) {
|
|
584
584
|
return 'jxxcx';
|
|
585
585
|
} else if (isTJApp) {
|
|
586
586
|
return 'tjapp';
|
|
587
587
|
} else if (isTjM) {
|
|
588
588
|
return 'tjm';
|
|
589
589
|
} else if (isTjJxM) {
|
|
590
590
|
return 'jxh5';
|
|
591
591
|
}
|
|
592
592
|
return '';
|
|
593
593
|
START: 'start',
|
|
594
594
|
MOVE: 'move',
|
|
595
595
|
END: 'end',
|
|
596
596
|
x: 0,
|
|
597
597
|
y: 0,
|
|
598
598
|
const startX = startPos.x;
|
|
599
599
|
const startY = startPos.y;
|
|
600
600
|
const endX = touchEvent.clientX;
|
|
601
601
|
const endY = touchEvent.clientY;
|
|
602
602
|
const dy = startY - endY;
|
|
603
603
|
const dx = endX - startX;
|
|
604
604
|
let result = 0;
|
|
605
605
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
606
606
|
return result;
|
|
607
607
|
}
|
|
608
608
|
const angle = (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
609
609
|
if (angle >= -45 && angle < 45) {
|
|
610
610
|
result = 4;
|
|
611
611
|
} else if (angle >= 45 && angle < 135) {
|
|
612
612
|
result = 1;
|
|
613
613
|
} else if (angle >= -135 && angle < -45) {
|
|
614
614
|
result = 2;
|
|
615
615
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
616
616
|
result = 3;
|
|
617
617
|
}
|
|
618
618
|
return result;
|
|
619
619
|
e: Event,
|
|
620
620
|
touchType = TouchType.START,
|
|
621
621
|
stopTouchDocumentScrollState = false,
|
|
622
622
|
if (isJdApp && e) {
|
|
623
623
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
624
624
|
let _touchState = touchType;
|
|
625
625
|
let _getDirectionState = false;
|
|
626
626
|
if (touchType === TouchType.START) {
|
|
627
627
|
StopNativeScrollEventPos.x = touchEvent.clientX;
|
|
628
628
|
StopNativeScrollEventPos.y = touchEvent.clientY;
|
|
629
629
|
} else if (touchType === TouchType.MOVE) {
|
|
630
630
|
_getDirectionState = [1, 2].includes(
|
|
631
631
|
touchMoveGetSlideDirection(StopNativeScrollEventPos, touchEvent),
|
|
632
632
|
);
|
|
633
633
|
if (_getDirectionState) {
|
|
634
634
|
_touchState = TouchType.END;
|
|
635
635
|
}
|
|
636
636
|
console.log(
|
|
637
637
|
'对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向',
|
|
638
638
|
_getDirectionState,
|
|
639
639
|
);
|
|
640
640
|
} else if (touchType === TouchType.END) {
|
|
641
641
|
StopNativeScrollEventPos.x = 0;
|
|
642
642
|
StopNativeScrollEventPos.y = 0;
|
|
643
643
|
}
|
|
644
644
|
isIosDevice
|
|
645
645
|
? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
|
|
646
646
|
: androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState);
|
|
647
647
|
if (
|
|
648
648
|
!isAppHomeForMarketPage &&
|
|
649
649
|
stopTouchDocumentScrollState &&
|
|
650
650
|
_touchState === TouchType.START
|
|
651
651
|
) {
|
|
652
652
|
rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
653
653
|
}
|
|
654
654
|
if (_touchState === TouchType.MOVE && _getDirectionState) {
|
|
655
655
|
rootEleNode &&
|
|
656
656
|
rootEleNode.classList.contains('over-hidden') &&
|
|
657
657
|
rootEleNode.classList.remove('over-hidden');
|
|
658
658
|
} else if (_touchState === TouchType.END) {
|
|
659
659
|
setTimeout(
|
|
660
660
|
() => {
|
|
661
661
|
rootEleNode &&
|
|
662
662
|
rootEleNode.classList.contains('over-hidden') &&
|
|
663
663
|
rootEleNode.classList.remove('over-hidden');
|
|
664
664
|
},
|
|
665
665
|
isAppHomeForMarketPage || _getDirectionState ? 0 : 200,
|
|
666
666
|
);
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
touchType = TouchType.START,
|
|
670
670
|
stopTouchDocumentScrollState = false,
|
|
671
671
|
isJdApp &&
|
|
672
672
|
touchType !== TouchType.MOVE &&
|
|
673
673
|
isAndroidDevice &&
|
|
674
674
|
window?.JdAndroid &&
|
|
675
675
|
window?.JdAndroid?.requestEvent &&
|
|
676
676
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
677
677
|
console.log(
|
|
678
678
|
'对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为',
|
|
679
679
|
touchType,
|
|
680
680
|
'当前非move触发requestEvent状态为',
|
|
681
681
|
touchType === TouchType.START,
|
|
682
682
|
'当前stopTouchDocumentScrollState为',
|
|
683
683
|
stopTouchDocumentScrollState,
|
|
684
684
|
);
|
|
685
685
|
e,
|
|
686
686
|
touchType = TouchType.START,
|
|
687
687
|
stopTouchDocumentScrollState = false,
|
|
688
688
|
e && e.stopPropagation();
|
|
689
689
|
console.log(
|
|
690
690
|
'对外提供阻止ios横滑方法,当前touchType为',
|
|
691
691
|
touchType,
|
|
692
692
|
'当前stopTouchDocumentScrollState为',
|
|
693
693
|
stopTouchDocumentScrollState,
|
|
694
694
|
);
|
|
695
695
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
696
696
|
method: 'callRouterModuleWithParams',
|
|
697
697
|
params: {
|
|
698
698
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
699
699
|
routerParam: {
|
|
700
700
|
slideDirection: 'horizontal',
|
|
701
701
|
state: touchType,
|
|
702
702
|
},
|
|
703
703
|
callBackId: new Date().getTime(),
|
|
704
704
|
},
|
|
705
705
|
});
|
|
706
706
|
if (isH5AndJdShopView) {
|
|
707
707
|
return CHANNEL_TYPE[currentChannel] || CHANNEL_TYPE[JDShopViewBusinessPathType.HOME];
|
|
708
708
|
}
|
|
709
709
|
return null;
|
|
710
710
|
isH5 &&
|
|
711
711
|
isJdApp &&
|
|
712
712
|
[
|
|
713
713
|
'/app/home',
|
|
714
714
|
'/app/homeV2',
|
|
715
715
|
'/app/classify',
|
|
716
716
|
'/app/classifyV2',
|
|
717
717
|
'/member/shopcard',
|
|
718
718
|
'/favorite/home',
|
|
719
719
|
].includes(urlPathname);
|
|
720
720
|
isH5 && isJdApp && !['/app/home', '/app/homeV2'].includes(urlPathname);
|
|
721
721
|
['/app/home', '/app/homeV2'].includes(urlPathname) &&
|
|
722
722
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_PROMOTION &&
|
|
723
723
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_MEMBER;
|
|
724
724
|
isAppHomePage && parseQueryUrlObj['source'] === 'app-marketing';
|
|
725
725
|
isH5 &&
|
|
726
726
|
isAppHomePage &&
|
|
727
727
|
versionCompare(jdAppVersion?.full ? jdAppVersion.full : '', isH5AndJdShopViewH5ScrollVersion) >=
|
|
728
728
|
0;
|
|
729
729
|
return isJdApp ? versionCompare(nowVersion, compareVersion) : -2;
|
|
730
730
|
getSgmReadyPromise()
|
|
731
731
|
.then(() => {
|
|
732
732
|
if (
|
|
733
733
|
customObj.hasOwnProperty('code') &&
|
|
734
734
|
customObj.code.indexOf(NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG) !== -1
|
|
735
735
|
) {
|
|
736
736
|
const originCode = customObj.code.substring(
|
|
737
737
|
NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG.length,
|
|
738
738
|
customObj.code.length,
|
|
739
739
|
);
|
|
740
740
|
customObj['code'] = getSgmCustomCode(handleSgmCodeTaroVersion(originCode));
|
|
741
741
|
}
|
|
742
742
|
const getCustomObj = {
|
|
743
743
|
type: 1,
|
|
744
744
|
code: 'all',
|
|
745
745
|
cost1: 1,
|
|
746
746
|
...customObj,
|
|
747
747
|
};
|
|
748
748
|
try {
|
|
749
749
|
window.__sgm__.custom(getCustomObj, '9HwAEg@fTtWBB3EnwA5VgLT');
|
|
750
750
|
} catch (e) {
|
|
751
751
|
console.log('当前sgm上报异常, 原始数据为', JSON.stringify(customObj));
|
|
752
752
|
}
|
|
753
753
|
})
|
|
754
754
|
.catch(() => {
|
|
755
755
|
console.error('当前页面sgm加载异常,无法进行异常上报, 原始数据为', JSON.stringify(customObj));
|
|
756
756
|
});
|
|
757
757
|
try {
|
|
758
758
|
await getNewDraSdkReadyPromise();
|
|
759
759
|
const draBurypointFlag = name ?? DraBuryPointFlags.BUSINESS;
|
|
760
760
|
const commonObj = {
|
|
761
761
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
762
762
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
763
763
|
taroRenderVersion: window?.taroRenderVersion,
|
|
764
764
|
environmentType: getEnvironmentType(),
|
|
765
765
|
pageType: getPageType(),
|
|
766
766
|
};
|
|
767
767
|
try {
|
|
768
768
|
window.dra.sendCustomEvent(
|
|
769
769
|
{
|
|
770
770
|
name: draBurypointFlag,
|
|
771
771
|
metrics: {
|
|
772
772
|
timeStamp: Date.now(),
|
|
773
773
|
...customMetricsObj,
|
|
774
774
|
},
|
|
775
775
|
context: {
|
|
776
776
|
...commonObj,
|
|
777
777
|
...customContextObj,
|
|
778
778
|
},
|
|
779
779
|
},
|
|
780
780
|
true,
|
|
781
781
|
);
|
|
782
782
|
} catch (e) {
|
|
783
783
|
console.error(
|
|
784
784
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
785
785
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
786
786
|
'e',
|
|
787
787
|
e,
|
|
788
788
|
);
|
|
789
789
|
}
|
|
790
790
|
} catch (e) {
|
|
791
791
|
console.error(
|
|
792
792
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
793
793
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
794
794
|
'e',
|
|
795
795
|
e,
|
|
796
796
|
);
|
|
797
797
|
}
|
|
798
798
|
try {
|
|
799
799
|
await getNewDraSdkReadyPromise();
|
|
800
800
|
const commonObj = {
|
|
801
801
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
802
802
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
803
803
|
taroRenderVersion: window?.taroRenderVersion,
|
|
804
804
|
environmentType: getEnvironmentType(),
|
|
805
805
|
pageType: getPageType(),
|
|
806
806
|
url: encodeURIComponent(window?.location?.href),
|
|
807
807
|
};
|
|
808
808
|
try {
|
|
809
809
|
window.dra.sendCustomLogEvent({
|
|
810
810
|
level,
|
|
811
811
|
content: logContent || '日志上报',
|
|
812
812
|
extra: JSON.stringify(commonObj),
|
|
813
813
|
timeStamp: Date.now(),
|
|
814
814
|
});
|
|
815
815
|
} catch (e) {
|
|
816
816
|
console.error('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e);
|
|
817
817
|
}
|
|
818
818
|
} catch (e2) {
|
|
819
819
|
console.error('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e2);
|
|
820
820
|
}
|
|
821
821
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE);
|
|
822
822
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE);
|
|
823
823
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.BUSINESS);
|
|
824
824
|
const deviceRatio = window?.devicePixelRatio ?? 2;
|
|
825
825
|
if (isJdAndAndroidDevice && typeof displayObj === 'object') {
|
|
826
826
|
Object.keys(displayObj).forEach((key) => {
|
|
827
827
|
if (key === 'nativeHeaderHeight') {
|
|
828
828
|
displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2);
|
|
829
829
|
} else {
|
|
830
830
|
displayObj[key] = Math.ceil(displayObj[key] / deviceRatio);
|
|
831
831
|
}
|
|
832
832
|
});
|
|
833
833
|
} else if (isJdAndHarmonyDevice && isNewHarmonyShop && typeof displayObj === 'object') {
|
|
834
834
|
if (displayObj['bottomBarHeight'] && typeof displayObj['bottomBarHeight'] === 'number') {
|
|
835
835
|
displayObj['bottomBarHeight'] = Math.ceil(displayObj['bottomBarHeight'] / deviceRatio);
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
return displayObj;
|
|
839
839
|
isJdAndAndroidDevice && /TBS\/\d+/.test(window?.navigator?.userAgent);
|
|
840
840
|
rootEleNode &&
|
|
841
841
|
!rootEleNode.classList.contains('d-shop-lang-for-en') &&
|
|
842
842
|
rootEleNode.classList.add('d-shop-lang-for-en');
|
|
843
843
|
rootEleNode &&
|
|
844
844
|
!rootEleNode.classList.contains('d-shop-lang-for-hk') &&
|
|
845
845
|
rootEleNode.classList.add('d-shop-lang-for-hk');
|
|
846
846
|
customContextObj = {},
|
|
847
847
|
customMetricsObj = {},
|
|
848
848
|
name?,
|
|
849
849
|
try {
|
|
850
850
|
const draBurypointFlag = name ?? DraBuryPointFlags.DECOSDM;
|
|
851
851
|
try {
|
|
852
852
|
let dra = null;
|
|
853
853
|
const iframe = window?.top?.document?.getElementsByTagName('iframe')[0];
|
|
854
854
|
if (iframe && iframe.contentWindow) {
|
|
855
855
|
dra = iframe.contentWindow?.dra;
|
|
856
856
|
}
|
|
857
857
|
if (window.dra) {
|
|
858
858
|
dra = window.dra;
|
|
859
859
|
}
|
|
860
860
|
dra &&
|
|
861
861
|
dra.sendCustomEvent(
|
|
862
862
|
{
|
|
863
863
|
name: draBurypointFlag,
|
|
864
864
|
metrics: {
|
|
865
865
|
timeStamp: Date.now(),
|
|
866
866
|
},
|
|
867
867
|
context: {
|
|
868
868
|
...customContextObj,
|
|
869
869
|
},
|
|
870
870
|
},
|
|
871
871
|
true,
|
|
872
872
|
);
|
|
873
873
|
} catch (e) {
|
|
874
874
|
console.error(
|
|
875
875
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
876
876
|
JSON.stringify({ ...customContextObj }),
|
|
877
877
|
'e',
|
|
878
878
|
e,
|
|
879
879
|
);
|
|
880
880
|
}
|
|
881
881
|
} catch (e) {
|
|
882
882
|
console.error(
|
|
883
883
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
884
884
|
JSON.stringify({ ...customContextObj }),
|
|
885
885
|
'e',
|
|
886
886
|
e,
|
|
887
887
|
);
|
|
888
888
|
}
|