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