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