@conecli/cone-render 0.10.1-shop-beta.55 → 0.10.1-shop-beta.56
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/const.ts +1 -1
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- 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
|
/harmony|android/i.test(navigator.userAgent) && /ascf/i.test(navigator.userAgent);
|
|
105
104
|
isWxMiniH5View && (/wx91d27dbf599dff74/i.test(userAgent) || urlCookie['wxapp_type'] == '1');
|
|
106
105
|
'harmony' === (userAgent.split(';')[1] || '').toLowerCase() || /arkweb/i.test(userAgent);
|
|
107
106
|
versionCompare(jdAppVersionStr, window.PAGE_DATA?.businessData?.jdHarmonyNativeVersion || '') >=
|
|
108
107
|
0 && isJdAndHarmonyDevice;
|
|
109
108
|
isJdApp &&
|
|
110
109
|
((setJdAppForNotMainUaFilterReg ? setJdAppForNotMainUaFilterReg.test(userAgent) : false) ||
|
|
111
110
|
(isJdAndHarmonyDevice && !isNewHarmonyShop));
|
|
112
111
|
window.shopGlobalSwitch?.isH5AndJdShopViewH5ScrollVersion || '';
|
|
113
112
|
!!document.getElementById('mallType') &&
|
|
114
113
|
!!document.getElementById('pageInstance_id') &&
|
|
115
114
|
!!document.getElementById('pageInstance_appId');
|
|
116
115
|
BUILD_TYPE.PC_CLASSIFY1 === buildType || BUILD_TYPE.PC_CLASSIFY2 === buildType;
|
|
117
116
|
isTjScence &&
|
|
118
117
|
isWxMiniH5View &&
|
|
119
118
|
(urlCookie['wxapp_type'] == '2' ||
|
|
120
119
|
cookie.get('wxapp_type') == '2' ||
|
|
121
120
|
parseQueryUrlObj['tjChannel'] === 'jxxcx');
|
|
122
121
|
isTjScence && isWxMiniH5View && parseQueryUrlObj['sourceApp'] === 'haowujie';
|
|
123
122
|
isTjScence &&
|
|
124
123
|
(parseQueryUrlObj['appCode'] === 'ms27cba806' ||
|
|
125
124
|
document.referrer?.match(/(?:https?:)?\/\/(?:kpl\.m|css|cs)\.jd\.com/i)?.length ||
|
|
126
125
|
(parseQueryUrlObj['sourceApp'] == 'jsb-m' && parseQueryUrlObj['appCode'] === '') ||
|
|
127
126
|
parseQueryUrlObj['tjChannel'] === 'tjm');
|
|
128
127
|
if (isH5AdnJxMini) {
|
|
129
128
|
return 'jxxcx';
|
|
130
129
|
} else if (isTJApp) {
|
|
131
130
|
return 'tjapp';
|
|
132
131
|
} else if (isTjM) {
|
|
133
132
|
return 'tjm';
|
|
134
133
|
} else if (isTjJxM) {
|
|
135
134
|
return 'jxh5';
|
|
136
135
|
}
|
|
137
136
|
return '';
|
|
138
137
|
START: 'start',
|
|
139
138
|
MOVE: 'move',
|
|
140
139
|
END: 'end',
|
|
141
140
|
x: 0,
|
|
142
141
|
y: 0,
|
|
143
142
|
const startX = startPos.x;
|
|
144
143
|
const startY = startPos.y;
|
|
145
144
|
const endX = touchEvent.clientX;
|
|
146
145
|
const endY = touchEvent.clientY;
|
|
147
146
|
const dy = startY - endY;
|
|
148
147
|
const dx = endX - startX;
|
|
149
148
|
let result = 0;
|
|
150
149
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
151
150
|
return result;
|
|
152
151
|
}
|
|
153
152
|
const angle = (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
154
153
|
if (angle >= -45 && angle < 45) {
|
|
155
154
|
result = 4;
|
|
156
155
|
} else if (angle >= 45 && angle < 135) {
|
|
157
156
|
result = 1;
|
|
158
157
|
} else if (angle >= -135 && angle < -45) {
|
|
159
158
|
result = 2;
|
|
160
159
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
161
160
|
result = 3;
|
|
162
161
|
}
|
|
163
162
|
return result;
|
|
164
163
|
e: Event,
|
|
165
164
|
touchType = TouchType.START,
|
|
166
165
|
stopTouchDocumentScrollState = false,
|
|
167
166
|
if (isJdApp && e) {
|
|
168
167
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
169
168
|
let _touchState = touchType;
|
|
170
169
|
let _getDirectionState = false;
|
|
171
170
|
if (touchType === TouchType.START) {
|
|
172
171
|
StopNativeScrollEventPos.x = touchEvent.clientX;
|
|
173
172
|
StopNativeScrollEventPos.y = touchEvent.clientY;
|
|
174
173
|
} else if (touchType === TouchType.MOVE) {
|
|
175
174
|
_getDirectionState = [1, 2].includes(
|
|
176
175
|
touchMoveGetSlideDirection(StopNativeScrollEventPos, touchEvent),
|
|
177
176
|
);
|
|
178
177
|
if (_getDirectionState) {
|
|
179
178
|
_touchState = TouchType.END;
|
|
180
179
|
}
|
|
181
180
|
console.log(
|
|
182
181
|
'对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向',
|
|
183
182
|
_getDirectionState,
|
|
184
183
|
);
|
|
185
184
|
} else if (touchType === TouchType.END) {
|
|
186
185
|
StopNativeScrollEventPos.x = 0;
|
|
187
186
|
StopNativeScrollEventPos.y = 0;
|
|
188
187
|
}
|
|
189
188
|
isIosDevice
|
|
190
189
|
? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
|
|
191
190
|
: androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState);
|
|
192
191
|
if (
|
|
193
192
|
!isAppHomeForMarketPage &&
|
|
194
193
|
stopTouchDocumentScrollState &&
|
|
195
194
|
_touchState === TouchType.START
|
|
196
195
|
) {
|
|
197
196
|
rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
198
197
|
}
|
|
199
198
|
if (_touchState === TouchType.MOVE && _getDirectionState) {
|
|
200
199
|
rootEleNode &&
|
|
201
200
|
rootEleNode.classList.contains('over-hidden') &&
|
|
202
201
|
rootEleNode.classList.remove('over-hidden');
|
|
203
202
|
} else if (_touchState === TouchType.END) {
|
|
204
203
|
setTimeout(
|
|
205
204
|
() => {
|
|
206
205
|
rootEleNode &&
|
|
207
206
|
rootEleNode.classList.contains('over-hidden') &&
|
|
208
207
|
rootEleNode.classList.remove('over-hidden');
|
|
209
208
|
},
|
|
210
209
|
isAppHomeForMarketPage || _getDirectionState ? 0 : 200,
|
|
211
210
|
);
|
|
212
211
|
}
|
|
213
212
|
}
|
|
214
213
|
touchType = TouchType.START,
|
|
215
214
|
stopTouchDocumentScrollState = false,
|
|
216
215
|
isJdApp &&
|
|
217
216
|
touchType !== TouchType.MOVE &&
|
|
218
217
|
isAndroidDevice &&
|
|
219
218
|
window?.JdAndroid &&
|
|
220
219
|
window?.JdAndroid?.requestEvent &&
|
|
221
220
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
222
221
|
console.log(
|
|
223
222
|
'对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为',
|
|
224
223
|
touchType,
|
|
225
224
|
'当前非move触发requestEvent状态为',
|
|
226
225
|
touchType === TouchType.START,
|
|
227
226
|
'当前stopTouchDocumentScrollState为',
|
|
228
227
|
stopTouchDocumentScrollState,
|
|
229
228
|
);
|
|
230
229
|
e,
|
|
231
230
|
touchType = TouchType.START,
|
|
232
231
|
stopTouchDocumentScrollState = false,
|
|
233
232
|
e && e.stopPropagation();
|
|
234
233
|
console.log(
|
|
235
234
|
'对外提供阻止ios横滑方法,当前touchType为',
|
|
236
235
|
touchType,
|
|
237
236
|
'当前stopTouchDocumentScrollState为',
|
|
238
237
|
stopTouchDocumentScrollState,
|
|
239
238
|
);
|
|
240
239
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
241
240
|
method: 'callRouterModuleWithParams',
|
|
242
241
|
params: {
|
|
243
242
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
244
243
|
routerParam: {
|
|
245
244
|
slideDirection: 'horizontal',
|
|
246
245
|
state: touchType,
|
|
247
246
|
},
|
|
248
247
|
callBackId: new Date().getTime(),
|
|
249
248
|
},
|
|
250
249
|
});
|
|
251
250
|
if (isH5AndJdShopView) {
|
|
252
251
|
return CHANNEL_TYPE[currentChannel] || CHANNEL_TYPE[JDShopViewBusinessPathType.HOME];
|
|
253
252
|
}
|
|
254
253
|
return null;
|
|
255
254
|
isH5 &&
|
|
256
255
|
isJdApp &&
|
|
257
256
|
[
|
|
258
257
|
'/app/home',
|
|
259
258
|
'/app/homeV2',
|
|
260
259
|
'/app/classify',
|
|
261
260
|
'/app/classifyV2',
|
|
262
261
|
'/member/shopcard',
|
|
263
262
|
'/favorite/home',
|
|
264
263
|
].includes(urlPathname);
|
|
265
264
|
isH5 && isJdApp && !['/app/home', '/app/homeV2'].includes(urlPathname);
|
|
266
265
|
['/app/home', '/app/homeV2'].includes(urlPathname) &&
|
|
267
266
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_PROMOTION &&
|
|
268
267
|
menuObj.tabActiveType != SECTION_HOME_TAB_TYPE.HOME_MEMBER;
|
|
269
268
|
isAppHomePage && parseQueryUrlObj['source'] === 'app-marketing';
|
|
270
269
|
isH5 &&
|
|
271
270
|
isAppHomePage &&
|
|
272
271
|
versionCompare(jdAppVersion?.full ? jdAppVersion.full : '', isH5AndJdShopViewH5ScrollVersion) >=
|
|
273
272
|
0;
|
|
274
273
|
return isJdApp ? versionCompare(nowVersion, compareVersion) : -2;
|
|
275
274
|
try {
|
|
276
275
|
await getNewDraSdkReadyPromise();
|
|
277
276
|
const draBurypointFlag = name ?? DraBuryPointFlags.BUSINESS;
|
|
278
277
|
const commonObj = {
|
|
279
278
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
280
279
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
281
280
|
taroRenderVersion: window?.taroRenderVersion,
|
|
282
281
|
environmentType: getEnvironmentType(),
|
|
283
282
|
pageType: getPageType(),
|
|
284
283
|
};
|
|
285
284
|
try {
|
|
286
285
|
window.dra.sendCustomEvent(
|
|
287
286
|
{
|
|
288
287
|
name: draBurypointFlag,
|
|
289
288
|
metrics: {
|
|
290
289
|
timeStamp: Date.now(),
|
|
291
290
|
...customMetricsObj,
|
|
292
291
|
},
|
|
293
292
|
context: {
|
|
294
293
|
...commonObj,
|
|
295
294
|
...customContextObj,
|
|
296
295
|
},
|
|
297
296
|
},
|
|
298
297
|
true,
|
|
299
298
|
);
|
|
300
299
|
} catch (e) {
|
|
301
300
|
console.info(
|
|
302
301
|
'当前新版烛龙sdk上报异常, 原始数据为',
|
|
303
302
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
304
303
|
'e',
|
|
305
304
|
e,
|
|
306
305
|
);
|
|
307
306
|
}
|
|
308
307
|
} catch (e) {
|
|
309
308
|
console.info(
|
|
310
309
|
'当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
|
|
311
310
|
JSON.stringify({ ...customContextObj, ...customMetricsObj }),
|
|
312
311
|
'e',
|
|
313
312
|
e,
|
|
314
313
|
);
|
|
315
314
|
}
|
|
316
315
|
try {
|
|
317
316
|
await getNewDraSdkReadyPromise();
|
|
318
317
|
const commonObj = {
|
|
319
318
|
shopId: `${global.info.queryInfo?.shopId || ''}`,
|
|
320
319
|
venderId: `${global.info.queryInfo?.venderId || ''}`,
|
|
321
320
|
taroRenderVersion: window?.taroRenderVersion,
|
|
322
321
|
environmentType: getEnvironmentType(),
|
|
323
322
|
pageType: getPageType(),
|
|
324
323
|
url: encodeURIComponent(window?.location?.href),
|
|
325
324
|
};
|
|
326
325
|
try {
|
|
327
326
|
window.dra.sendCustomLogEvent({
|
|
328
327
|
level,
|
|
329
328
|
content: logContent || '日志上报',
|
|
330
329
|
extra: JSON.stringify(commonObj),
|
|
331
330
|
timeStamp: Date.now(),
|
|
332
331
|
});
|
|
333
332
|
} catch (e) {
|
|
334
333
|
console.info('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e);
|
|
335
334
|
}
|
|
336
335
|
} catch (e2) {
|
|
337
336
|
console.info('日志等级', level, '当前新版烛龙sdk上报异常, 原始数据为', logContent, 'e', e2);
|
|
338
337
|
}
|
|
339
338
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE);
|
|
340
339
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE);
|
|
341
340
|
draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.BUSINESS);
|
|
342
341
|
const deviceRatio = window?.devicePixelRatio ?? 2;
|
|
343
342
|
if (isJdAndAndroidDevice && typeof displayObj === 'object') {
|
|
344
343
|
Object.keys(displayObj).forEach((key) => {
|
|
345
344
|
if (key === 'nativeHeaderHeight') {
|
|
346
345
|
displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2);
|
|
347
346
|
} else {
|
|
348
347
|
displayObj[key] = Math.ceil(displayObj[key] / deviceRatio);
|
|
349
348
|
}
|
|
350
349
|
});
|
|
351
350
|
} else if (isJdAndHarmonyDevice && isNewHarmonyShop && typeof displayObj === 'object') {
|
|
352
351
|
if (displayObj['bottomBarHeight'] && typeof displayObj['bottomBarHeight'] === 'number') {
|
|
353
352
|
displayObj['bottomBarHeight'] = Math.ceil(displayObj['bottomBarHeight'] / deviceRatio);
|
|
354
353
|
}
|
|
355
354
|
}
|
|
356
355
|
return displayObj;
|
|
357
356
|
isJdAndAndroidDevice && /TBS\/\d+/.test(window?.navigator?.userAgent);
|
|
358
357
|
rootEleNode &&
|
|
359
358
|
!rootEleNode.classList.contains('d-shop-lang-for-en') &&
|
|
360
359
|
rootEleNode.classList.add('d-shop-lang-for-en');
|
|
361
360
|
rootEleNode &&
|
|
362
361
|
!rootEleNode.classList.contains('d-shop-lang-for-hk') &&
|
|
363
362
|
rootEleNode.classList.add('d-shop-lang-for-hk');
|
|
363
|
+
import {
|
|
364
364
|
isApp,
|
|
365
365
|
isIOS,
|
|
366
366
|
getAppVersion,
|
|
367
367
|
version,
|
|
368
368
|
getUrlQuery,
|
|
369
369
|
assign,
|
|
370
370
|
isString,
|
|
371
371
|
isObject,
|
|
372
372
|
serialize,
|
|
373
373
|
isAndroid,
|
|
374
374
|
versionCompare,
|
|
375
375
|
isIPad,
|
|
376
376
|
isTablet,
|
|
377
377
|
CHANNEL_TYPE,
|
|
378
378
|
JDShopViewBusinessPathType,
|
|
379
379
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
380
380
|
SECTION_HOME_TAB_TYPE,
|
|
381
381
|
DraBuryPointFlags,
|
|
382
382
|
MPAAS_CONFIG_APP_VERSION,
|
|
383
383
|
BUILD_TYPE,
|
|
384
384
|
console.log(message);
|
|
385
385
|
reject(new Error(message));
|
|
386
386
|
return ready('dra', 2000)
|
|
387
387
|
.then(() => {
|
|
388
388
|
isNewDraSdkReadyError = false;
|
|
389
389
|
console.log('当前新版烛龙sdk初始化成功');
|
|
390
390
|
return true;
|
|
391
391
|
})
|
|
392
392
|
.catch(() => {
|
|
393
393
|
isNewDraSdkReadyError = true;
|
|
394
394
|
throw new Error('当前新版烛龙sdk初始化失败');
|
|
395
395
|
});
|
|
396
396
|
return new Promise((resolve, reject) => {
|
|
397
397
|
if (window?.dra) {
|
|
398
398
|
resolve(true);
|
|
399
399
|
} else if (isNewDraSdkReadyError) {
|
|
400
400
|
logAndReject('当前新版烛龙sdk初始化失败', reject);
|
|
401
401
|
} else {
|
|
402
402
|
initializeDraSdk()
|
|
403
403
|
.then(resolve)
|
|
404
404
|
.catch((error) => logAndReject(error.message, reject));
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
407
|
rootEleInitWidth = 0,
|
|
408
408
|
screenWidth = 0,
|
|
409
409
|
screenHeight = 0,
|
|
410
410
|
if (rootEleInitWidth > 0 && screenWidth > 0 && screenHeight > 0) {
|
|
411
411
|
const isRootEleWidthEqScreenWidth = Math.abs(rootEleInitWidth - screenWidth) < 60;
|
|
412
412
|
const getThisWinWidth = rootEleInitWidth;
|
|
413
413
|
const getThisWinHeight = isRootEleWidthEqScreenWidth ? screenHeight : screenWidth;
|
|
414
414
|
console.info(
|
|
415
415
|
'通过rootEleInitWidth对比屏幕宽高确认横竖屏幕方式',
|
|
416
416
|
'rootEleInitWidth',
|
|
417
417
|
rootEleInitWidth,
|
|
418
418
|
'screenWidth',
|
|
419
419
|
screenWidth,
|
|
420
420
|
'screenHeight',
|
|
421
421
|
screenHeight,
|
|
422
422
|
'isRootEleWidthEqScreenWidth(根元素宽度是否与屏幕本身宽度接近,主要是ios屏幕宽高不变)',
|
|
423
423
|
isRootEleWidthEqScreenWidth,
|
|
424
424
|
'getThisWinWidth',
|
|
425
425
|
getThisWinWidth,
|
|
426
426
|
'getThisWinHeight',
|
|
427
427
|
getThisWinHeight,
|
|
428
428
|
'是否是横屏',
|
|
429
429
|
getThisWinWidth > getThisWinHeight,
|
|
430
430
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏,带有landscape为横屏',
|
|
431
431
|
window.screen?.orientation?.type,
|
|
432
432
|
);
|
|
433
433
|
return getThisWinWidth > getThisWinHeight;
|
|
434
434
|
} else {
|
|
435
435
|
if (window.screen?.orientation?.type) {
|
|
436
436
|
console.info(
|
|
437
437
|
'通过window.screen?.orientation?.type方式获取当前pad屏幕是否是横屏',
|
|
438
438
|
window.screen?.orientation?.type,
|
|
439
439
|
'测试低版本通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
440
440
|
window?.orientation,
|
|
441
441
|
);
|
|
442
442
|
return /landscape/i.test(window.screen.orientation.type);
|
|
443
443
|
} else if (window?.orientation) {
|
|
444
444
|
console.info(
|
|
445
445
|
'通过window?.orientation方式获取当前pad屏幕是否是横屏,角度[90, -90]',
|
|
446
446
|
window?.orientation,
|
|
447
447
|
);
|
|
448
448
|
return [90, -90].includes(window?.orientation);
|
|
449
449
|
} else {
|
|
450
450
|
console.info(
|
|
451
451
|
'通过window.matchMedia((orientation: landscape))?.matches方式获取当前pad屏幕是否是横屏',
|
|
452
452
|
window.matchMedia('(orientation: landscape)')?.matches,
|
|
453
453
|
);
|
|
454
454
|
return window.matchMedia('(orientation: landscape)')?.matches;
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
try {
|
|
458
458
|
return JSON.parse(decodeURIComponent(getUrlQuery('cookie')));
|
|
459
459
|
} catch (e) {
|
|
460
460
|
return {};
|
|
461
461
|
}
|
|
462
462
|
isJdAppState && /com\.jd\.(jdlite|jdmobilelite|jdmobileliteske)/.test(userAgent);
|
|
463
463
|
window.shopGlobalSwitch?.jdAppForNotMainCheckUaList,
|
|
464
464
|
? new RegExp(window.shopGlobalSwitch?.jdAppForNotMainCheckUaList.join('|'), 'i')
|
|
465
465
|
: false;
|
|
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');
|