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