@conecli/cone-render 0.10.1-shop3.27 → 0.10.1-shop3.28
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 +1 -1
- package/package.json +1 -1
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
|
{
|
|
367
366
|
level,
|
|
368
367
|
content: logContent || "日志上报",
|
|
369
368
|
extra: JSON.stringify(commonObj),
|
|
370
369
|
timeStamp: Date.now()
|
|
371
370
|
},
|
|
372
371
|
);
|
|
373
372
|
} catch (e) {
|
|
374
373
|
console.error(
|
|
375
374
|
'日志等级',
|
|
376
375
|
level,
|
|
377
376
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
378
377
|
logContent,
|
|
379
378
|
'e',
|
|
380
379
|
e,
|
|
381
380
|
);
|
|
382
381
|
}
|
|
383
382
|
} catch (e2) {
|
|
384
383
|
console.error(
|
|
385
384
|
'日志等级',
|
|
386
385
|
level,
|
|
387
386
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
388
387
|
logContent,
|
|
389
388
|
'e',
|
|
390
389
|
e2,
|
|
391
390
|
);
|
|
392
391
|
}
|
|
393
392
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE);
|
|
394
393
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE);
|
|
395
394
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.BUSINESS);
|
|
396
395
|
const deviceRatio = window?.devicePixelRatio ?? 2;
|
|
397
396
|
if (isJdAndAndroidDevice && typeof displayObj === 'object') {
|
|
398
397
|
Object.keys(displayObj).forEach((key) => {
|
|
399
398
|
if (key === 'nativeHeaderHeight') {
|
|
400
399
|
displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2);
|
|
401
400
|
} else {
|
|
402
401
|
displayObj[key] = Math.ceil(displayObj[key] / deviceRatio);
|
|
403
402
|
}
|
|
404
403
|
});
|
|
405
404
|
} else if (isJdAndHarmonyDevice && isNewHarmonyShop && typeof displayObj === 'object') {
|
|
406
405
|
if (displayObj['bottomBarHeight'] && typeof displayObj['bottomBarHeight'] === 'number') {
|
|
407
406
|
displayObj['bottomBarHeight'] = Math.ceil(displayObj['bottomBarHeight'] / deviceRatio);
|
|
408
407
|
}
|
|
409
408
|
}
|
|
410
409
|
return displayObj;
|
|
411
410
|
isJdAndAndroidDevice && /TBS\/\d+/.test(window?.navigator?.userAgent);
|
|
412
411
|
rootEleNode &&
|
|
413
412
|
!rootEleNode.classList.contains('d-shop-lang-for-en') &&
|
|
414
413
|
rootEleNode.classList.add('d-shop-lang-for-en');
|
|
415
414
|
rootEleNode &&
|
|
416
415
|
!rootEleNode.classList.contains('d-shop-lang-for-hk') &&
|
|
417
416
|
rootEleNode.classList.add('d-shop-lang-for-hk');
|
|
418
417
|
customContextObj = {},
|
|
419
418
|
customMetricsObj = {},
|
|
420
419
|
name?,
|
|
421
420
|
try {
|
|
422
421
|
const draBurypointFlag = name ?? DraBuryPointFlags.DECOSDM;
|
|
423
422
|
try {
|
|
424
423
|
let dra = null;
|
|
425
424
|
const iframe = window?.top?.document?.getElementsByTagName('iframe')[0];
|
|
426
425
|
if (iframe && iframe.contentWindow) {
|
|
427
426
|
dra = iframe.contentWindow?.dra;
|
|
428
427
|
}
|
|
429
428
|
if (window.dra) {
|
|
430
429
|
dra = window.dra;
|
|
431
430
|
}
|
|
432
431
|
dra &&
|
|
433
432
|
dra.sendCustomEvent(
|
|
434
433
|
{
|
|
435
434
|
name: draBurypointFlag,
|
|
436
435
|
metrics: {
|
|
437
436
|
timeStamp: Date.now(),
|
|
438
437
|
},
|
|
439
438
|
context: {
|
|
440
439
|
...customContextObj,
|
|
441
440
|
},
|
|
442
441
|
},
|
|
443
442
|
true,
|
|
444
443
|
);
|
|
445
444
|
} catch (e) {
|
|
446
445
|
console.error(
|
|
447
446
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
448
447
|
JSON.stringify({ ...customContextObj }),
|
|
449
448
|
'e',
|
|
450
449
|
e,
|
|
451
450
|
);
|
|
452
451
|
}
|
|
453
452
|
} catch (e) {
|
|
454
453
|
console.error(
|
|
455
454
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
456
455
|
JSON.stringify({ ...customContextObj }),
|
|
457
456
|
'e',
|
|
458
457
|
e,
|
|
459
458
|
);
|
|
460
459
|
}
|
|
460
|
+
import {
|
|
461
461
|
isApp,
|
|
462
462
|
isIOS,
|
|
463
463
|
getAppVersion,
|
|
464
464
|
version,
|
|
465
465
|
getUUID,
|
|
466
466
|
getUrlQuery,
|
|
467
467
|
assign,
|
|
468
468
|
isString,
|
|
469
469
|
isObject,
|
|
470
470
|
serialize,
|
|
471
471
|
isAndroid,
|
|
472
472
|
versionCompare,
|
|
473
473
|
isIPad,
|
|
474
474
|
isTablet,
|
|
475
475
|
CHANNEL_TYPE,
|
|
476
476
|
JDShopViewBusinessPathType,
|
|
477
477
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
478
478
|
SECTION_HOME_TAB_TYPE,
|
|
479
479
|
DraBuryPointFlags,
|
|
480
480
|
MPAAS_CONFIG_APP_VERSION,
|
|
481
481
|
new Promise((resolve, reject) => {
|
|
482
482
|
if (window?.__sgm__) {
|
|
483
483
|
resolve(true);
|
|
484
484
|
} else {
|
|
485
485
|
if (isSgmReadyError) {
|
|
486
486
|
console.log('当前sgm初始化失败');
|
|
487
487
|
reject(false);
|
|
488
488
|
} else {
|
|
489
489
|
ready('__sgm__', 2000)
|
|
490
490
|
.then(() => {
|
|
491
491
|
isSgmReadyError = false;
|
|
492
492
|
console.log('当前sgm初始化成功');
|
|
493
493
|
resolve(true);
|
|
494
494
|
})
|
|
495
495
|
.catch(() => {
|
|
496
496
|
isSgmReadyError = true;
|
|
497
497
|
console.log('当前sgm初始化失败');
|
|
498
498
|
reject(false);
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
});
|
|
503
503
|
console.log(message);
|
|
504
504
|
reject(new Error(message));
|
|
505
505
|
return ready('dra', 2000)
|
|
506
506
|
.then(() => {
|
|
507
507
|
isNewDraSdkReadyError = false;
|
|
508
508
|
console.log('当前新版烛龙sdk初始化成功');
|
|
509
509
|
return true;
|
|
510
510
|
})
|
|
511
511
|
.catch(() => {
|
|
512
512
|
isNewDraSdkReadyError = true;
|
|
513
513
|
throw new Error('当前新版烛龙sdk初始化失败');
|
|
514
514
|
});
|
|
515
515
|
return new Promise((resolve, reject) => {
|
|
516
516
|
if (window?.dra) {
|
|
517
517
|
resolve(true);
|
|
518
518
|
} else if (isNewDraSdkReadyError) {
|
|
519
519
|
logAndReject('当前新版烛龙sdk初始化失败', reject);
|
|
520
520
|
} else {
|
|
521
521
|
initializeDraSdk()
|
|
522
522
|
.then(resolve)
|
|
523
523
|
.catch((error) => logAndReject(error.message, reject));
|
|
524
524
|
}
|
|
525
525
|
});
|
|
526
526
|
rootEleInitWidth = 0,
|
|
527
527
|
screenWidth = 0,
|
|
528
528
|
screenHeight = 0,
|
|
529
529
|
if (rootEleInitWidth > 0 && screenWidth > 0 && screenHeight > 0) {
|
|
530
530
|
const isRootEleWidthEqScreenWidth = Math.abs(rootEleInitWidth - screenWidth) < 60;
|
|
531
531
|
const getThisWinWidth = rootEleInitWidth;
|
|
532
532
|
const getThisWinHeight = isRootEleWidthEqScreenWidth ? screenHeight : screenWidth;
|
|
533
533
|
console.info(
|
|
534
534
|
'通过rootEleInitWidth对比屏幕宽高确认横竖屏幕方式',
|
|
535
535
|
'rootEleInitWidth',
|
|
536
536
|
rootEleInitWidth,
|
|
537
537
|
'screenWidth',
|
|
538
538
|
screenWidth,
|
|
539
539
|
'screenHeight',
|
|
540
540
|
screenHeight,
|
|
541
541
|
'isRootEleWidthEqScreenWidth(根元素宽度是否与屏幕本身宽度接近,主要是ios屏幕宽高不变)',
|
|
542
542
|
isRootEleWidthEqScreenWidth,
|
|
543
543
|
'getThisWinWidth',
|
|
544
544
|
getThisWinWidth,
|
|
545
545
|
'getThisWinHeight',
|
|
546
546
|
getThisWinHeight,
|
|
547
547
|
'是否是横屏',
|
|
548
548
|
getThisWinWidth > getThisWinHeight,
|
|
549
549
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏,带有landscape为横屏',
|
|
550
550
|
window.screen?.orientation?.type,
|
|
551
551
|
);
|
|
552
552
|
return getThisWinWidth > getThisWinHeight;
|
|
553
553
|
} else {
|
|
554
554
|
if (window.screen?.orientation?.type) {
|
|
555
555
|
console.info(
|
|
556
556
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏',
|
|
557
557
|
window.screen?.orientation?.type,
|
|
558
558
|
'测试低版本通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
559
559
|
window?.orientation,
|
|
560
560
|
);
|
|
561
561
|
return /landscape/i.test(window.screen.orientation.type);
|
|
562
562
|
} else if (window?.orientation) {
|
|
563
563
|
console.info(
|
|
564
564
|
'通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
565
565
|
window?.orientation,
|
|
566
566
|
);
|
|
567
567
|
return [90, -90].includes(window?.orientation);
|
|
568
568
|
} else {
|
|
569
569
|
console.info(
|
|
570
570
|
'通过window.matchMedia((orientation: landscape))?.matches方式获取当前pad屏幕是否是横屏',
|
|
571
571
|
window.matchMedia('(orientation: landscape)')?.matches,
|
|
572
572
|
);
|
|
573
573
|
return window.matchMedia('(orientation: landscape)')?.matches;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
try {
|
|
577
577
|
return JSON.parse(decodeURIComponent(getUrlQuery('cookie')));
|
|
578
578
|
} catch (e) {
|
|
579
579
|
return {};
|
|
580
580
|
}
|
|
581
581
|
'harmony' === (userAgent.split(';')[1] || '').toLowerCase() || /arkweb/i.test(userAgent);
|
|
582
582
|
window?.location?.hostname === 'pages.jd.com' && isJdAndHarmonyDevice;
|
|
583
583
|
window.shopGlobalSwitch?.isH5AndJdShopViewH5ScrollVersion || '';
|
|
584
584
|
!!document.getElementById('mallType') &&
|
|
585
585
|
!!document.getElementById('pageInstance_id') &&
|
|
586
586
|
!!document.getElementById('pageInstance_appId');
|
|
587
587
|
isTjScence &&
|
|
588
588
|
isWxMiniH5View &&
|
|
589
589
|
(urlCookie['wxapp_type'] == '2' ||
|
|
590
590
|
cookie.get('wxapp_type') == '2' ||
|
|
591
591
|
parseQueryUrlObj['tjChannel'] === 'jxxcx');
|
|
592
592
|
isTjScence && isWxMiniH5View && parseQueryUrlObj['sourceApp'] === 'haowujie';
|
|
593
593
|
isTjScence &&
|
|
594
594
|
(parseQueryUrlObj['appCode'] === 'ms27cba806' ||
|
|
595
595
|
document.referrer?.match(/(?:https?:)?\/\/(?:kpl\.m|css|cs)\.jd\.com/i)?.length ||
|
|
596
596
|
(parseQueryUrlObj['sourceApp'] == 'jsb-m' && parseQueryUrlObj['appCode'] === '') ||
|
|
597
597
|
parseQueryUrlObj['tjChannel'] === 'tjm');
|
|
598
598
|
if (isH5AdnJxMini) {
|
|
599
599
|
return 'jxxcx';
|
|
600
600
|
} else if (isTJApp) {
|
|
601
601
|
return 'tjapp';
|
|
602
602
|
} else if (isTjM) {
|
|
603
603
|
return 'tjm';
|
|
604
604
|
} else if (isTjJxM) {
|
|
605
605
|
return 'jxh5';
|
|
606
606
|
}
|
|
607
607
|
return '';
|
|
608
608
|
START: 'start',
|
|
609
609
|
MOVE: 'move',
|
|
610
610
|
END: 'end',
|
|
611
611
|
x: 0,
|
|
612
612
|
y: 0,
|
|
613
613
|
const startX = startPos.x;
|
|
614
614
|
const startY = startPos.y;
|
|
615
615
|
const endX = touchEvent.clientX;
|
|
616
616
|
const endY = touchEvent.clientY;
|
|
617
617
|
const dy = startY - endY;
|
|
618
618
|
const dx = endX - startX;
|
|
619
619
|
let result = 0;
|
|
620
620
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
621
621
|
return result;
|
|
622
622
|
}
|
|
623
623
|
const angle = (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
624
624
|
if (angle >= -45 && angle < 45) {
|
|
625
625
|
result = 4;
|
|
626
626
|
} else if (angle >= 45 && angle < 135) {
|
|
627
627
|
result = 1;
|
|
628
628
|
} else if (angle >= -135 && angle < -45) {
|
|
629
629
|
result = 2;
|
|
630
630
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
631
631
|
result = 3;
|
|
632
632
|
}
|
|
633
633
|
return result;
|
|
634
634
|
e: Event,
|
|
635
635
|
touchType = TouchType.START,
|
|
636
636
|
stopTouchDocumentScrollState = false,
|
|
637
637
|
if (isJdApp && e) {
|
|
638
638
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
639
639
|
let _touchState = touchType;
|
|
640
640
|
let _getDirectionState = false;
|
|
641
641
|
if (touchType === TouchType.START) {
|
|
642
642
|
StopNativeScrollEventPos.x = touchEvent.clientX;
|
|
643
643
|
StopNativeScrollEventPos.y = touchEvent.clientY;
|
|
644
644
|
} else if (touchType === TouchType.MOVE) {
|
|
645
645
|
_getDirectionState = [1, 2].includes(
|
|
646
646
|
touchMoveGetSlideDirection(StopNativeScrollEventPos, touchEvent),
|
|
647
647
|
);
|
|
648
648
|
if (_getDirectionState) {
|
|
649
649
|
_touchState = TouchType.END;
|
|
650
650
|
}
|
|
651
651
|
console.log(
|
|
652
652
|
'对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向',
|
|
653
653
|
_getDirectionState,
|
|
654
654
|
);
|
|
655
655
|
} else if (touchType === TouchType.END) {
|
|
656
656
|
StopNativeScrollEventPos.x = 0;
|
|
657
657
|
StopNativeScrollEventPos.y = 0;
|
|
658
658
|
}
|
|
659
659
|
isIosDevice
|
|
660
660
|
? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
|
|
661
661
|
: androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState);
|
|
662
662
|
if (
|
|
663
663
|
!isAppHomeForMarketPage &&
|
|
664
664
|
stopTouchDocumentScrollState &&
|
|
665
665
|
_touchState === TouchType.START
|
|
666
666
|
) {
|
|
667
667
|
rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
668
668
|
}
|
|
669
669
|
if (_touchState === TouchType.MOVE && _getDirectionState) {
|
|
670
670
|
rootEleNode &&
|
|
671
671
|
rootEleNode.classList.contains('over-hidden') &&
|
|
672
672
|
rootEleNode.classList.remove('over-hidden');
|
|
673
673
|
} else if (_touchState === TouchType.END) {
|
|
674
674
|
setTimeout(
|
|
675
675
|
() => {
|
|
676
676
|
rootEleNode &&
|
|
677
677
|
rootEleNode.classList.contains('over-hidden') &&
|
|
678
678
|
rootEleNode.classList.remove('over-hidden');
|
|
679
679
|
},
|
|
680
680
|
isAppHomeForMarketPage || _getDirectionState ? 0 : 200,
|
|
681
681
|
);
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
touchType = TouchType.START,
|
|
685
685
|
stopTouchDocumentScrollState = false,
|
|
686
686
|
isJdApp &&
|
|
687
687
|
touchType !== TouchType.MOVE &&
|
|
688
688
|
isAndroidDevice &&
|
|
689
689
|
window?.JdAndroid &&
|
|
690
690
|
window?.JdAndroid?.requestEvent &&
|
|
691
691
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
692
692
|
console.log(
|
|
693
693
|
'对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为',
|
|
694
694
|
touchType,
|
|
695
695
|
'当前非move触发requestEvent状态为',
|
|
696
696
|
touchType === TouchType.START,
|
|
697
697
|
'当前stopTouchDocumentScrollState为',
|
|
698
698
|
stopTouchDocumentScrollState,
|
|
699
699
|
);
|
|
700
700
|
e,
|
|
701
701
|
touchType = TouchType.START,
|
|
702
702
|
stopTouchDocumentScrollState = false,
|
|
703
703
|
e && e.stopPropagation();
|
|
704
704
|
console.log(
|
|
705
705
|
'对外提供阻止ios横滑方法,当前touchType为',
|
|
706
706
|
touchType,
|
|
707
707
|
'当前stopTouchDocumentScrollState为',
|
|
708
708
|
stopTouchDocumentScrollState,
|
|
709
709
|
);
|
|
710
710
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
711
711
|
method: 'callRouterModuleWithParams',
|
|
712
712
|
params: {
|
|
713
713
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
714
714
|
routerParam: {
|
|
715
715
|
slideDirection: 'horizontal',
|
|
716
716
|
state: touchType,
|
|
717
717
|
},
|
|
718
718
|
callBackId: new Date().getTime(),
|
|
719
719
|
},
|
|
720
720
|
});
|
|
721
721
|
if (isH5AndJdShopView) {
|
|
722
722
|
return CHANNEL_TYPE[currentChannel] || CHANNEL_TYPE[JDShopViewBusinessPathType.HOME];
|
|
723
723
|
}
|
|
724
724
|
return null;
|
|
725
725
|
isH5 &&
|
|
726
726
|
isJdApp &&
|
|
727
727
|
[
|
|
728
728
|
'/app/home',
|
|
729
729
|
'/app/homeV2',
|
|
730
730
|
'/app/classify',
|
|
731
731
|
'/app/classifyV2',
|
|
732
732
|
'/member/shopcard',
|
|
733
733
|
'/favorite/home',
|
|
734
734
|
].includes(urlPathname);
|
|
735
735
|
isH5 && isJdApp && !['/app/home', '/app/homeV2'].includes(urlPathname);
|
|
736
736
|
['/app/home', '/app/homeV2'].includes(urlPathname) &&
|
|
737
737
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_PROMOTION &&
|
|
738
738
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_MEMBER;
|
|
739
739
|
isAppHomePage && parseQueryUrlObj['source'] === 'app-marketing';
|
|
740
740
|
isH5 &&
|
|
741
741
|
isAppHomePage &&
|
|
742
742
|
versionCompare(jdAppVersion?.full ? jdAppVersion.full : '', isH5AndJdShopViewH5ScrollVersion) >=
|
|
743
743
|
0;
|
|
744
744
|
return isJdApp ? versionCompare(nowVersion, compareVersion) : -2;
|
|
745
745
|
getSgmReadyPromise()
|
|
746
746
|
.then(() => {
|
|
747
747
|
if (
|
|
748
748
|
customObj.hasOwnProperty('code') &&
|
|
749
749
|
customObj.code.indexOf(NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG) !== -1
|
|
750
750
|
) {
|
|
751
751
|
const originCode = customObj.code.substring(
|
|
752
752
|
NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG.length,
|
|
753
753
|
customObj.code.length,
|
|
754
754
|
);
|
|
755
755
|
customObj['code'] = getSgmCustomCode(handleSgmCodeTaroVersion(originCode));
|
|
756
756
|
}
|
|
757
757
|
const getCustomObj = {
|
|
758
758
|
type: 1,
|
|
759
759
|
code: 'all',
|
|
760
760
|
cost1: 1,
|
|
761
761
|
...customObj,
|
|
762
762
|
};
|
|
763
763
|
try {
|
|
764
764
|
window.__sgm__.custom(getCustomObj, '9HwAEg@fTtWBB3EnwA5VgLT');
|
|
765
765
|
} catch (e) {
|
|
766
766
|
console.log('当前sgm上报异常, 原始数据为', JSON.stringify(customObj));
|
|
767
767
|
}
|
|
768
768
|
})
|
|
769
769
|
.catch(() => {
|
|
770
770
|
console.error('当前页面sgm加载异常,无法进行异常上报, 原始数据为', JSON.stringify(customObj));
|
|
771
771
|
});
|
|
772
772
|
try {
|
|
773
773
|
await getNewDraSdkReadyPromise();
|
|
774
774
|
const draBurypointFlag = name ?? DraBuryPointFlags.BUSINESS;
|
|
775
775
|
const commonObj = {
|
|
776
776
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
777
777
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
778
778
|
taroRenderVersion: window?.taroRenderVersion,
|
|
779
779
|
environmentType: getEnvironmentType(),
|
|
780
780
|
pageType: getPageType(),
|
|
781
781
|
};
|
|
782
782
|
try {
|
|
783
783
|
window.dra.sendCustomEvent(
|
|
784
784
|
{
|
|
785
785
|
name: draBurypointFlag,
|
|
786
786
|
metrics: {
|
|
787
787
|
timeStamp: Date.now(),
|
|
788
788
|
...customMetricsObj,
|
|
789
789
|
},
|
|
790
790
|
context: {
|
|
791
791
|
...commonObj,
|
|
792
792
|
...customContextObj,
|
|
793
793
|
},
|
|
794
794
|
},
|
|
795
795
|
true,
|
|
796
796
|
);
|
|
797
797
|
} catch (e) {
|
|
798
798
|
console.error(
|
|
799
799
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
800
800
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
801
801
|
'e',
|
|
802
802
|
e,
|
|
803
803
|
);
|
|
804
804
|
}
|
|
805
805
|
} catch (e) {
|
|
806
806
|
console.error(
|
|
807
807
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
808
808
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
809
809
|
'e',
|
|
810
810
|
e,
|
|
811
811
|
);
|
|
812
812
|
}
|
|
813
813
|
try {
|
|
814
814
|
await getNewDraSdkReadyPromise();
|
|
815
815
|
const commonObj = {
|
|
816
816
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
817
817
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
818
818
|
taroRenderVersion: window?.taroRenderVersion,
|
|
819
819
|
environmentType: getEnvironmentType(),
|
|
820
820
|
pageType: getPageType(),
|
|
821
821
|
url: encodeURIComponent(window?.location?.href),
|
|
822
822
|
};
|
|
823
823
|
try {
|
|
824
824
|
window.dra.sendCustomLogEvent({
|
|
825
825
|
level,
|
|
826
826
|
content: logContent || '日志上报',
|
|
827
827
|
extra: JSON.stringify(commonObj),
|
|
828
828
|
timeStamp: Date.now(),
|
|
829
829
|
});
|
|
830
830
|
} catch (e) {
|
|
831
831
|
console.error('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e);
|
|
832
832
|
}
|
|
833
833
|
} catch (e2) {
|
|
834
834
|
console.error('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e2);
|
|
835
835
|
}
|
|
836
836
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE);
|
|
837
837
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE);
|
|
838
838
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.BUSINESS);
|
|
839
839
|
const deviceRatio = window?.devicePixelRatio ?? 2;
|
|
840
840
|
if (isJdAndAndroidDevice && typeof displayObj === 'object') {
|
|
841
841
|
Object.keys(displayObj).forEach((key) => {
|
|
842
842
|
if (key === 'nativeHeaderHeight') {
|
|
843
843
|
displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2);
|
|
844
844
|
} else {
|
|
845
845
|
displayObj[key] = Math.ceil(displayObj[key] / deviceRatio);
|
|
846
846
|
}
|
|
847
847
|
});
|
|
848
848
|
} else if (isJdAndHarmonyDevice && isNewHarmonyShop && typeof displayObj === 'object') {
|
|
849
849
|
if (displayObj['bottomBarHeight'] && typeof displayObj['bottomBarHeight'] === 'number') {
|
|
850
850
|
displayObj['bottomBarHeight'] = Math.ceil(displayObj['bottomBarHeight'] / deviceRatio);
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
return displayObj;
|
|
854
854
|
isJdAndAndroidDevice && /TBS\/\d+/.test(window?.navigator?.userAgent);
|
|
855
855
|
rootEleNode &&
|
|
856
856
|
!rootEleNode.classList.contains('d-shop-lang-for-en') &&
|
|
857
857
|
rootEleNode.classList.add('d-shop-lang-for-en');
|
|
858
858
|
rootEleNode &&
|
|
859
859
|
!rootEleNode.classList.contains('d-shop-lang-for-hk') &&
|
|
860
860
|
rootEleNode.classList.add('d-shop-lang-for-hk');
|
|
861
861
|
customContextObj = {},
|
|
862
862
|
customMetricsObj = {},
|
|
863
863
|
name?,
|
|
864
864
|
try {
|
|
865
865
|
const draBurypointFlag = name ?? DraBuryPointFlags.DECOSDM;
|
|
866
866
|
try {
|
|
867
867
|
let dra = null;
|
|
868
868
|
const iframe = window?.top?.document?.getElementsByTagName('iframe')[0];
|
|
869
869
|
if (iframe && iframe.contentWindow) {
|
|
870
870
|
dra = iframe.contentWindow?.dra;
|
|
871
871
|
}
|
|
872
872
|
if (window.dra) {
|
|
873
873
|
dra = window.dra;
|
|
874
874
|
}
|
|
875
875
|
dra &&
|
|
876
876
|
dra.sendCustomEvent(
|
|
877
877
|
{
|
|
878
878
|
name: draBurypointFlag,
|
|
879
879
|
metrics: {
|
|
880
880
|
timeStamp: Date.now(),
|
|
881
881
|
},
|
|
882
882
|
context: {
|
|
883
883
|
...customContextObj,
|
|
884
884
|
},
|
|
885
885
|
},
|
|
886
886
|
true,
|
|
887
887
|
);
|
|
888
888
|
} catch (e) {
|
|
889
889
|
console.error(
|
|
890
890
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
891
891
|
JSON.stringify({ ...customContextObj }),
|
|
892
892
|
'e',
|
|
893
893
|
e,
|
|
894
894
|
);
|
|
895
895
|
}
|
|
896
896
|
} catch (e) {
|
|
897
897
|
console.error(
|
|
898
898
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
899
899
|
JSON.stringify({ ...customContextObj }),
|
|
900
900
|
'e',
|
|
901
901
|
e,
|
|
902
902
|
);
|
|
903
903
|
}
|