@conecli/cone-render 0.9.1-shop2.32 → 0.9.1-shop2.34

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.
@@ -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
  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
  parseQueryUrlObj,
22
21
  if (window?.__sgm__) {
23
22
  resolve(true)
24
23
  } else {
25
24
  if (isSgmReadyError) {
26
25
  console.log("当前sgm初始化失败")
27
26
  reject(false)
28
27
  } else {
29
28
  ready('__sgm__', 2000).then(() => {
30
29
  isSgmReadyError = false
31
30
  console.log("当前sgm初始化成功")
32
31
  resolve(true)
33
32
  }).catch(() => {
34
33
  isSgmReadyError = true
35
34
  console.log("当前sgm初始化失败")
36
35
  reject(false)
37
36
  })
38
37
  }
39
38
  }
40
39
  console.log(message)
41
40
  reject(new Error(message))
42
41
  return ready('dra', 2000)
43
42
  .then(() => {
44
43
  isNewDraSdkReadyError = false
45
44
  console.log('当前新版烛龙sdk初始化成功')
46
45
  return true
47
46
  })
48
47
  .catch(() => {
49
48
  isNewDraSdkReadyError = true
50
49
  throw new Error('当前新版烛龙sdk初始化失败')
51
50
  })
52
51
  return new Promise((resolve, reject) => {
53
52
  if (window?.dra) {
54
53
  resolve(true)
55
54
  } else if (isNewDraSdkReadyError) {
56
55
  logAndReject('当前新版烛龙sdk初始化失败', reject)
57
56
  } else {
58
57
  initializeDraSdk()
59
58
  .then(resolve)
60
59
  .catch(error => logAndReject(error.message, reject))
61
60
  }
62
61
  })
63
62
  try {
64
63
  return JSON.parse(decodeURIComponent(getUrlQuery('cookie')))
65
64
  } catch (e) {
66
65
  return {}
67
66
  }
68
67
  isWxMiniH5View && urlCookie['wxapp_type'] == '1'
69
68
  if (isH5AdnJxMini) {
70
69
  return 'jxxcx'
71
70
  } else if (isTJApp) {
72
71
  return 'tjapp'
73
72
  } else if (isTjM) {
74
73
  return 'tjm'
75
74
  } else if (isTjJxM) {
76
75
  return 'jxh5'
77
76
  }
78
77
  return ''
79
78
  START: 'start',
80
79
  MOVE: 'move',
81
80
  END: 'end',
82
81
  x: 0,
83
82
  y: 0
84
83
  const startX = startPos.x
85
84
  const startY = startPos.y
86
85
  const endX = touchEvent.clientX
87
86
  const endY = touchEvent.clientY
88
87
  const dy = startY - endY
89
88
  const dx = endX - startX
90
89
  let result = 0
91
90
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
92
91
  return result
93
92
  }
94
93
  const angle = Math.atan2(dy,dx) * 180 / Math.PI
95
94
  if (angle >= -45 && angle < 45) {
96
95
  result = 4
97
96
  } else if (angle >= 45 && angle < 135) {
98
97
  result = 1
99
98
  } else if (angle >= -135 && angle < -45) {
100
99
  result = 2
101
100
  } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
102
101
  result = 3
103
102
  }
104
103
  return result
105
104
  if (isJdApp && e) {
106
105
  const touchEvent =
107
106
  e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
108
107
  let _touchState = touchType
109
108
  let _getDirectionState = false
110
109
  if(touchType === TouchType.START){
111
110
  StopNativeScrollEventPos.x = touchEvent.clientX
112
111
  StopNativeScrollEventPos.y = touchEvent.clientY
113
112
  }else if(touchType === TouchType.MOVE){
114
113
  _getDirectionState = [1,2].includes(touchMoveGetSlideDirection(StopNativeScrollEventPos,touchEvent))
115
114
  if(_getDirectionState){
116
115
  _touchState = TouchType.END
117
116
  }
118
117
  console.log("对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向", _getDirectionState)
119
118
  }else if(touchType === TouchType.END){
120
119
  StopNativeScrollEventPos.x = 0
121
120
  StopNativeScrollEventPos.y = 0
122
121
  }
123
122
  isIosDevice
124
123
  ? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
125
124
  : androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState)
126
125
  if(!isAppHomeForMarketPage && stopTouchDocumentScrollState && _touchState === TouchType.START){
127
126
  rootEleNode && rootEleNode.classList.add('over-hidden')
128
127
  }
129
128
  if(_touchState === TouchType.MOVE && _getDirectionState){
130
129
  rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
131
130
  }else if (_touchState === TouchType.END) {
132
131
  setTimeout(() => {
133
132
  rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
134
133
  },isAppHomeForMarketPage || _getDirectionState ? 0 : 200)
135
134
  }
136
135
  }
137
136
  isJdApp &&
138
137
  touchType !== TouchType.MOVE &&
139
138
  isAndroidDevice &&
140
139
  window?.JdAndroid &&
141
140
  window?.JdAndroid.requestEvent(touchType === TouchType.START)
142
141
  console.log("对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为",touchType,"当前非move触发requestEvent状态为",touchType === TouchType.START,"当前stopTouchDocumentScrollState为",stopTouchDocumentScrollState)
143
142
  e && e.stopPropagation();
144
143
  console.log("对外提供阻止ios横滑方法,当前touchType为", touchType, "当前stopTouchDocumentScrollState为",stopTouchDocumentScrollState)
145
144
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
146
145
  method: 'callRouterModuleWithParams',
147
146
  params: {
148
147
  routerURL: 'router://JDShopModule/processShoph5SlideState',
149
148
  routerParam: {
150
149
  slideDirection: 'horizontal',
151
150
  state: touchType,
152
151
  },
153
152
  callBackId: new Date().getTime(),
154
153
  },
155
154
  })
156
155
  if (isH5AndJdShopView) {
157
156
  return (
158
157
  CHANNEL_TYPE[currentChannel] ||
159
158
  CHANNEL_TYPE[JDShopViewBusinessPathType.HOME]
160
159
  )
161
160
  }
162
161
  return null
163
162
  isH5 && isJdApp && ['/app/home', '/app/classify', '/member/shopcard','/favorite/list', '/favorite/home'].includes(urlPathname)
164
163
  isH5 && isJdApp && !['/app/home'].includes(urlPathname)
165
164
  return isJdApp ? versionCompare(nowVersion, compareVersion) : -2
166
165
  getSgmReadyPromise().then(() => {
167
166
  if (
168
167
  customObj.hasOwnProperty('code') &&
169
168
  customObj.code.indexOf(NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG) !== -1
170
169
  ) {
171
170
  const originCode = customObj.code.substring(
172
171
  NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG.length,
173
172
  customObj.code.length,
174
173
  )
175
174
  customObj['code'] = getSgmCustomCode(handleSgmCodeTaroVersion(originCode))
176
175
  }
177
176
  const getCustomObj = {
178
177
  type: 1,
179
178
  code: 'all',
180
179
  cost1: 1,
181
180
  ...customObj
182
181
  }
183
182
  try {
184
183
  window.__sgm__.custom(getCustomObj, '9HwAEg@fTtWBB3EnwA5VgLT')
185
184
  } catch (e) {
186
185
  console.log("当前sgm上报异常, 原始数据为",JSON.stringify(customObj))
187
186
  }
188
187
  }).catch(() => {
189
188
  console.error("当前页面sgm加载异常,无法进行异常上报, 原始数据为",JSON.stringify(customObj))
190
189
  })
191
190
  try {
192
191
  await getNewDraSdkReadyPromise()
193
192
  const draBurypointFlag = name ?? DraBuryPointFlags.BUSINESS
194
193
  const commonObj = {
195
194
  shopId: `${global.info.queryInfo.shopId || ''}`,
196
195
  venderId: `${global.info.queryInfo.venderId || ''}`,
197
196
  taroRenderVersion: window?.taroRenderVersion,
198
197
  environmentType: getEnvironmentType(),
199
198
  pageType: getPageType(),
200
199
  }
201
200
  try {
202
201
  window.dra.sendCustomEvent(
203
202
  {
204
203
  name: draBurypointFlag,
205
204
  metrics: {
206
205
  timeStamp: Date.now(),
207
206
  ...customMetricsObj
208
207
  },
209
208
  context: {
210
209
  ...commonObj,
211
210
  ...customContextObj,
212
211
  },
213
212
  },
214
213
  true,
215
214
  )
216
215
  } catch (e) {
217
216
  console.error(
218
217
  '当前新版烛龙sdk上报异常, 原始数据为',
219
218
  JSON.stringify({ ...customContextObj, ...customMetricsObj }),
220
219
  'e',
221
220
  e,
222
221
  )
223
222
  }
224
223
  } catch (e) {
225
224
  console.error(
226
225
  '当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
227
226
  JSON.stringify({ ...customContextObj, ...customMetricsObj }),
228
227
  'e',
229
228
  e,
230
229
  )
231
230
  }
232
231
  draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE)
233
232
  customContextObj = {},
234
233
  customMetricsObj = {},
235
234
  draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE)
236
235
  customContextObj = {},
237
236
  customMetricsObj = {},
238
237
  draCustomReport(
239
238
  customContextObj,
240
239
  customMetricsObj,
241
240
  DraBuryPointFlags.BUSINESS,
242
241
  )
243
242
  if(isJdAndAndroidDevice && typeof displayObj === 'object'){
244
243
  const deviceRatio = window?.devicePixelRatio
245
244
  Object.keys(displayObj).forEach(key => {
246
245
  if(key === 'nativeHeaderHeight'){
247
246
  displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2)
248
247
  }else {
249
248
  displayObj[key] = Math.ceil(displayObj[key] / deviceRatio)
250
249
  }
251
250
  })
252
251
  }
253
252
  return displayObj
254
253
  jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0
254
+ import {
255
255
  isApp,
256
256
  isIOS,
257
257
  getAppVersion,
258
258
  version,
259
259
  getUUID,
260
260
  getUrlQuery,
261
261
  assign,
262
262
  isString,
263
263
  isObject,
264
264
  serialize,
265
265
  isAndroid,
266
266
  versionCompare,
267
267
  isIPad,
268
268
  CHANNEL_TYPE,
269
269
  JDShopViewBusinessPathType,
270
270
  SECTION_HOME_TAB_NAME_TYPE,
271
271
  SECTION_HOME_TAB_TYPE,
272
272
  DraBuryPointFlags,
273
273
  MPAAS_CONFIG_APP_VERSION,
274
274
  parseQueryUrlObj,
275
275
  if (window?.__sgm__) {
276
276
  resolve(true)
277
277
  } else {
278
278
  if (isSgmReadyError) {
279
279
  console.log("当前sgm初始化失败")
280
280
  reject(false)
281
281
  } else {
282
282
  ready('__sgm__', 2000).then(() => {
283
283
  isSgmReadyError = false
284
284
  console.log("当前sgm初始化成功")
285
285
  resolve(true)
286
286
  }).catch(() => {
287
287
  isSgmReadyError = true
288
288
  console.log("当前sgm初始化失败")
289
289
  reject(false)
290
290
  })
291
291
  }
292
292
  }
293
293
  console.log(message)
294
294
  reject(new Error(message))
295
295
  return ready('dra', 2000)
296
296
  .then(() => {
297
297
  isNewDraSdkReadyError = false
298
298
  console.log('当前新版烛龙sdk初始化成功')
299
299
  return true
300
300
  })
301
301
  .catch(() => {
302
302
  isNewDraSdkReadyError = true
303
303
  throw new Error('当前新版烛龙sdk初始化失败')
304
304
  })
305
305
  return new Promise((resolve, reject) => {
306
306
  if (window?.dra) {
307
307
  resolve(true)
308
308
  } else if (isNewDraSdkReadyError) {
309
309
  logAndReject('当前新版烛龙sdk初始化失败', reject)
310
310
  } else {
311
311
  initializeDraSdk()
312
312
  .then(resolve)
313
313
  .catch(error => logAndReject(error.message, reject))
314
314
  }
315
315
  })
316
316
  try {
317
317
  return JSON.parse(decodeURIComponent(getUrlQuery('cookie')))
318
318
  } catch (e) {
319
319
  return {}
320
320
  }
321
321
  isWxMiniH5View && urlCookie['wxapp_type'] == '1'
322
322
  if (isH5AdnJxMini) {
323
323
  return 'jxxcx'
324
324
  } else if (isTJApp) {
325
325
  return 'tjapp'
326
326
  } else if (isTjM) {
327
327
  return 'tjm'
328
328
  } else if (isTjJxM) {
329
329
  return 'jxh5'
330
330
  }
331
331
  return ''
332
332
  START: 'start',
333
333
  MOVE: 'move',
334
334
  END: 'end',
335
335
  x: 0,
336
336
  y: 0
337
337
  const startX = startPos.x
338
338
  const startY = startPos.y
339
339
  const endX = touchEvent.clientX
340
340
  const endY = touchEvent.clientY
341
341
  const dy = startY - endY
342
342
  const dx = endX - startX
343
343
  let result = 0
344
344
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
345
345
  return result
346
346
  }
347
347
  const angle = Math.atan2(dy,dx) * 180 / Math.PI
348
348
  if (angle >= -45 && angle < 45) {
349
349
  result = 4
350
350
  } else if (angle >= 45 && angle < 135) {
351
351
  result = 1
352
352
  } else if (angle >= -135 && angle < -45) {
353
353
  result = 2
354
354
  } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
355
355
  result = 3
356
356
  }
357
357
  return result
358
358
  if (isJdApp && e) {
359
359
  const touchEvent =
360
360
  e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
361
361
  let _touchState = touchType
362
362
  let _getDirectionState = false
363
363
  if(touchType === TouchType.START){
364
364
  StopNativeScrollEventPos.x = touchEvent.clientX
365
365
  StopNativeScrollEventPos.y = touchEvent.clientY
366
366
  }else if(touchType === TouchType.MOVE){
367
367
  _getDirectionState = [1,2].includes(touchMoveGetSlideDirection(StopNativeScrollEventPos,touchEvent))
368
368
  if(_getDirectionState){
369
369
  _touchState = TouchType.END
370
370
  }
371
371
  console.log("对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向", _getDirectionState)
372
372
  }else if(touchType === TouchType.END){
373
373
  StopNativeScrollEventPos.x = 0
374
374
  StopNativeScrollEventPos.y = 0
375
375
  }
376
376
  isIosDevice
377
377
  ? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
378
378
  : androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState)
379
379
  if(!isAppHomeForMarketPage && stopTouchDocumentScrollState && _touchState === TouchType.START){
380
380
  rootEleNode && rootEleNode.classList.add('over-hidden')
381
381
  }
382
382
  if(_touchState === TouchType.MOVE && _getDirectionState){
383
383
  rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
384
384
  }else if (_touchState === TouchType.END) {
385
385
  setTimeout(() => {
386
386
  rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
387
387
  },isAppHomeForMarketPage || _getDirectionState ? 0 : 200)
388
388
  }
389
389
  }
390
390
  isJdApp &&
391
391
  touchType !== TouchType.MOVE &&
392
392
  isAndroidDevice &&
393
393
  window?.JdAndroid &&
394
394
  window?.JdAndroid.requestEvent(touchType === TouchType.START)
395
395
  console.log("对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为",touchType,"当前非move触发requestEvent状态为",touchType === TouchType.START,"当前stopTouchDocumentScrollState为",stopTouchDocumentScrollState)
396
396
  e && e.stopPropagation();
397
397
  console.log("对外提供阻止ios横滑方法,当前touchType为", touchType, "当前stopTouchDocumentScrollState为",stopTouchDocumentScrollState)
398
398
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
399
399
  method: 'callRouterModuleWithParams',
400
400
  params: {
401
401
  routerURL: 'router://JDShopModule/processShoph5SlideState',
402
402
  routerParam: {
403
403
  slideDirection: 'horizontal',
404
404
  state: touchType,
405
405
  },
406
406
  callBackId: new Date().getTime(),
407
407
  },
408
408
  })
409
409
  if (isH5AndJdShopView) {
410
410
  return (
411
411
  CHANNEL_TYPE[currentChannel] ||
412
412
  CHANNEL_TYPE[JDShopViewBusinessPathType.HOME]
413
413
  )
414
414
  }
415
415
  return null
416
416
  isH5 && isJdApp && ['/app/home', '/app/classify', '/member/shopcard','/favorite/list', '/favorite/home'].includes(urlPathname)
417
417
  isH5 && isJdApp && !['/app/home'].includes(urlPathname)
418
418
  return isJdApp ? versionCompare(nowVersion, compareVersion) : -2
419
419
  getSgmReadyPromise().then(() => {
420
420
  if (
421
421
  customObj.hasOwnProperty('code') &&
422
422
  customObj.code.indexOf(NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG) !== -1
423
423
  ) {
424
424
  const originCode = customObj.code.substring(
425
425
  NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG.length,
426
426
  customObj.code.length,
427
427
  )
428
428
  customObj['code'] = getSgmCustomCode(handleSgmCodeTaroVersion(originCode))
429
429
  }
430
430
  const getCustomObj = {
431
431
  type: 1,
432
432
  code: 'all',
433
433
  cost1: 1,
434
434
  ...customObj
435
435
  }
436
436
  try {
437
437
  window.__sgm__.custom(getCustomObj, '9HwAEg@fTtWBB3EnwA5VgLT')
438
438
  } catch (e) {
439
439
  console.log("当前sgm上报异常, 原始数据为",JSON.stringify(customObj))
440
440
  }
441
441
  }).catch(() => {
442
442
  console.error("当前页面sgm加载异常,无法进行异常上报, 原始数据为",JSON.stringify(customObj))
443
443
  })
444
444
  try {
445
445
  await getNewDraSdkReadyPromise()
446
446
  const draBurypointFlag = name ?? DraBuryPointFlags.BUSINESS
447
447
  const commonObj = {
448
448
  shopId: `${global.info.queryInfo.shopId || ''}`,
449
449
  venderId: `${global.info.queryInfo.venderId || ''}`,
450
450
  taroRenderVersion: window?.taroRenderVersion,
451
451
  environmentType: getEnvironmentType(),
452
452
  pageType: getPageType(),
453
453
  }
454
454
  try {
455
455
  window.dra.sendCustomEvent(
456
456
  {
457
457
  name: draBurypointFlag,
458
458
  metrics: {
459
459
  timeStamp: Date.now(),
460
460
  ...customMetricsObj
461
461
  },
462
462
  context: {
463
463
  ...commonObj,
464
464
  ...customContextObj,
465
465
  },
466
466
  },
467
467
  true,
468
468
  )
469
469
  } catch (e) {
470
470
  console.error(
471
471
  '当前新版烛龙sdk上报异常, 原始数据为',
472
472
  JSON.stringify({ ...customContextObj, ...customMetricsObj }),
473
473
  'e',
474
474
  e,
475
475
  )
476
476
  }
477
477
  } catch (e) {
478
478
  console.error(
479
479
  '当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
480
480
  JSON.stringify({ ...customContextObj, ...customMetricsObj }),
481
481
  'e',
482
482
  e,
483
483
  )
484
484
  }
485
485
  draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.REMOTE)
486
486
  customContextObj = {},
487
487
  customMetricsObj = {},
488
488
  draCustomReport(customContextObj, customMetricsObj, DraBuryPointFlags.INTERFACE)
489
489
  customContextObj = {},
490
490
  customMetricsObj = {},
491
491
  draCustomReport(
492
492
  customContextObj,
493
493
  customMetricsObj,
494
494
  DraBuryPointFlags.BUSINESS,
495
495
  )
496
496
  if(isJdAndAndroidDevice && typeof displayObj === 'object'){
497
497
  const deviceRatio = window?.devicePixelRatio
498
498
  Object.keys(displayObj).forEach(key => {
499
499
  if(key === 'nativeHeaderHeight'){
500
500
  displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2)
501
501
  }else {
502
502
  displayObj[key] = Math.ceil(displayObj[key] / deviceRatio)
503
503
  }
504
504
  })
505
505
  }
506
506
  return displayObj
507
507
  jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0