@conecli/cone-render 0.9.1-shop2.23 → 0.9.1-shop2.25

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
  parseQueryUrlObj,
197
197
  if (window?.__sgm__) {
198
198
  resolve(true)
199
199
  } else {
200
200
  if (isSgmReadyError) {
201
201
  console.log("当前sgm初始化失败")
202
202
  reject(false)
203
203
  } else {
204
204
  ready('__sgm__', 2000).then(() => {
205
205
  isSgmReadyError = false
206
206
  console.log("当前sgm初始化成功")
207
207
  resolve(true)
208
208
  }).catch(() => {
209
209
  isSgmReadyError = true
210
210
  console.log("当前sgm初始化失败")
211
211
  reject(false)
212
212
  })
213
213
  }
214
214
  }
215
215
  console.log(message)
216
216
  reject(new Error(message))
217
217
  return ready('dra', 2000)
218
218
  .then(() => {
219
219
  isNewDraSdkReadyError = false
220
220
  console.log('当前新版烛龙sdk初始化成功')
221
221
  return true
222
222
  })
223
223
  .catch(() => {
224
224
  isNewDraSdkReadyError = true
225
225
  throw new Error('当前新版烛龙sdk初始化失败')
226
226
  })
227
227
  return new Promise((resolve, reject) => {
228
228
  if (window?.dra) {
229
229
  resolve(true)
230
230
  } else if (isNewDraSdkReadyError) {
231
231
  logAndReject('当前新版烛龙sdk初始化失败', reject)
232
232
  } else {
233
233
  initializeDraSdk()
234
234
  .then(resolve)
235
235
  .catch(error => logAndReject(error.message, reject))
236
236
  }
237
237
  })
238
238
  try {
239
239
  return JSON.parse(decodeURIComponent(getUrlQuery('cookie')))
240
240
  } catch (e) {
241
241
  return {}
242
242
  }
243
243
  isWxMiniH5View && urlCookie['wxapp_type'] == '1'
244
244
  if (isH5AdnJxMini) {
245
245
  return 'jxxcx'
246
246
  } else if (isTJApp) {
247
247
  return 'tjapp'
248
248
  } else if (isTjM) {
249
249
  return 'tjm'
250
250
  } else if (isTjJxM) {
251
251
  return 'jxh5'
252
252
  }
253
253
  return ''
254
254
  START: 'start',
255
255
  MOVE: 'move',
256
256
  END: 'end',
257
257
  x: 0,
258
258
  y: 0
259
259
  const startX = startPos.x
260
260
  const startY = startPos.y
261
261
  const endX = touchEvent.clientX
262
262
  const endY = touchEvent.clientY
263
263
  const dy = startY - endY
264
264
  const dx = endX - startX
265
265
  let result = 0
266
266
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
267
267
  return result
268
268
  }
269
269
  const angle = Math.atan2(dy,dx) * 180 / Math.PI
270
270
  if (angle >= -45 && angle < 45) {
271
271
  result = 4
272
272
  } else if (angle >= 45 && angle < 135) {
273
273
  result = 1
274
274
  } else if (angle >= -135 && angle < -45) {
275
275
  result = 2
276
276
  } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
277
277
  result = 3
278
278
  }
279
279
  return result
280
280
  if (isJdApp && e) {
281
281
  const touchEvent =
282
282
  e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
283
283
  let _touchState = touchType
284
284
  let _getDirectionState = false
285
285
  if(touchType === TouchType.START){
286
286
  StopNativeScrollEventPos.x = touchEvent.clientX
287
287
  StopNativeScrollEventPos.y = touchEvent.clientY
288
288
  }else if(touchType === TouchType.MOVE){
289
289
  _getDirectionState = [1,2].includes(touchMoveGetSlideDirection(StopNativeScrollEventPos,touchEvent))
290
290
  if(_getDirectionState){
291
291
  _touchState = TouchType.END
292
292
  }
293
293
  console.log("对外提供阻止横滑方法,当前touchType为move,设定1、2向上或向下方向,当前计算后的滑动是否为纵向", _getDirectionState)
294
294
  }else if(touchType === TouchType.END){
295
295
  StopNativeScrollEventPos.x = 0
296
296
  StopNativeScrollEventPos.y = 0
297
297
  }
298
298
  isIosDevice
299
299
  ? iosDeviceStopNativeScrollEvent(e, _touchState, stopTouchDocumentScrollState)
300
300
  : androidDeviceStopNativeScrollEvent(_touchState, stopTouchDocumentScrollState)
301
301
  if(!isAppHomeForMarketPage && stopTouchDocumentScrollState && _touchState === TouchType.START){
302
302
  rootEleNode && rootEleNode.classList.add('over-hidden')
303
303
  }
304
304
  if(_touchState === TouchType.MOVE && _getDirectionState){
305
305
  rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
306
306
  }else if (_touchState === TouchType.END) {
307
307
  setTimeout(() => {
308
308
  rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
309
309
  },isAppHomeForMarketPage || _getDirectionState ? 0 : 200)
310
310
  }
311
311
  }
312
312
  isJdApp &&
313
313
  touchType !== TouchType.MOVE &&
314
314
  isAndroidDevice &&
315
315
  window?.JdAndroid &&
316
316
  window?.JdAndroid.requestEvent(touchType === TouchType.START)
317
317
  console.log("对外提供阻止安卓横滑方法,true-禁止外部事件H5可滑动,false-外部拦截h5事件,当前touchType为",touchType,"当前非move触发requestEvent状态为",touchType === TouchType.START,"当前stopTouchDocumentScrollState为",stopTouchDocumentScrollState)
318
318
  e && e.stopPropagation();
319
319
  console.log("对外提供阻止ios横滑方法,当前touchType为", touchType, "当前stopTouchDocumentScrollState为",stopTouchDocumentScrollState)
320
320
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
321
321
  method: 'callRouterModuleWithParams',
322
322
  params: {
323
323
  routerURL: 'router://JDShopModule/processShoph5SlideState',
324
324
  routerParam: {
325
325
  slideDirection: 'horizontal',
326
326
  state: touchType,
327
327
  },
328
328
  callBackId: new Date().getTime(),
329
329
  },
330
330
  })
331
331
  if (isH5AndJdShopView) {
332
332
  return (
333
333
  CHANNEL_TYPE[currentChannel] ||
334
334
  CHANNEL_TYPE[JDShopViewBusinessPathType.HOME]
335
335
  )
336
336
  }
337
337
  return null
338
338
  isH5 && isJdApp && ['/app/home', '/app/classify', '/member/shopcard','/favorite/list', '/favorite/home'].includes(urlPathname)
339
339
  isH5 && isJdApp && !['/app/home'].includes(urlPathname)
340
340
  return isJdApp ? versionCompare(nowVersion, compareVersion) : -2
341
341
  getSgmReadyPromise().then(() => {
342
342
  if (
343
343
  customObj.hasOwnProperty('code') &&
344
344
  customObj.code.indexOf(NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG) !== -1
345
345
  ) {
346
346
  const originCode = customObj.code.substring(
347
347
  NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG.length,
348
348
  customObj.code.length,
349
349
  )
350
350
  customObj['code'] = getSgmCustomCode(handleSgmCodeTaroVersion(originCode))
351
351
  }
352
352
  const getCustomObj = {
353
353
  type: 1,
354
354
  code: 'all',
355
355
  cost1: 1,
356
356
  ...customObj
357
357
  }
358
358
  try {
359
359
  window.__sgm__.custom(getCustomObj, '9HwAEg@fTtWBB3EnwA5VgLT')
360
360
  } catch (e) {
361
361
  console.log("当前sgm上报异常, 原始数据为",JSON.stringify(customObj))
362
362
  }
363
363
  }).catch(() => {
364
364
  console.error("当前页面sgm加载异常,无法进行异常上报, 原始数据为",JSON.stringify(customObj))
365
365
  })
366
366
  try {
367
367
  await getNewDraSdkReadyPromise()
368
368
  const draBurypointFlag = 'shop_h5_interface'
369
369
  try {
370
370
  window.dra.sendCustomEvent(
371
371
  {
372
372
  name: draBurypointFlag,
373
373
  metrics: {
374
374
  timeStamp: Date.now(),
375
375
  },
376
376
  context: customObj,
377
377
  },
378
378
  true,
379
379
  )
380
380
  } catch (e) {
381
381
  console.error(
382
382
  '当前新版烛龙sdk上报异常, 原始数据为',
383
383
  JSON.stringify(customObj),
384
384
  'e',
385
385
  e,
386
386
  )
387
387
  }
388
388
  } catch (e) {
389
389
  console.error(
390
390
  '当前页面新版烛龙sdk加载异常,无法进行异常上报, 原始数据为',
391
391
  JSON.stringify(customObj),
392
392
  'e',
393
393
  e
394
394
  )
395
395
  }
396
396
  if(isJdAndAndroidDevice && typeof displayObj === 'object'){
397
397
  const deviceRatio = window?.devicePixelRatio
398
398
  Object.keys(displayObj).forEach(key => {
399
399
  if(key === 'nativeHeaderHeight'){
400
400
  displayObj[key] = Math.ceil(displayObj[key] / (deviceRatio * deviceRatio) - 2)
401
401
  }else {
402
402
  displayObj[key] = Math.ceil(displayObj[key] / deviceRatio)
403
403
  }
404
404
  })
405
405
  }
406
406
  return displayObj