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