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