@conecli/cone-render 0.10.1-shop3.1 → 0.10.1-shop3.100

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.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/dist/api/index.ts +1 -1
  3. package/dist/common/accessibility.h5.ts +1 -0
  4. package/dist/common/accessibility.ts +1 -0
  5. package/dist/common/const.ts +1 -1
  6. package/dist/common/index.h5.ts +1 -1
  7. package/dist/common/index.jd.ts +1 -1
  8. package/dist/common/index.ts +1 -1
  9. package/dist/common/index.weapp.ts +1 -1
  10. package/dist/common/jdplayerSdk.weapp.tsx +1 -0
  11. package/dist/common/jssdk.ts +1 -1
  12. package/dist/common/jssdk.weapp.ts +1 -0
  13. package/dist/common/pageType.ts +1 -1
  14. package/dist/common/token/index.h5.ts +1 -1
  15. package/dist/common/token/token.jd.ts +1 -1
  16. package/dist/common/wxappApi.ascf.ts +1 -0
  17. package/dist/common/wxappApi.ts +1 -1
  18. package/dist/components/ErrorBoundary.tsx +1 -1
  19. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  20. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  21. package/dist/components/base/CountDown/index.module.scss +49 -44
  22. package/dist/components/base/CountDown/index.tsx +1 -1
  23. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  24. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  25. package/dist/components/base/CustomVideo/index.tsx +1 -1
  26. package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
  27. package/dist/components/base/Dialog/index.module.scss +11 -0
  28. package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
  29. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  30. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  31. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  32. package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
  33. package/dist/components/base/InViewRender/index.tsx +1 -1
  34. package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
  35. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  36. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  37. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  38. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  39. package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
  40. package/dist/components/base/NetworkDataError/const.ts +1 -1
  41. package/dist/components/base/NetworkDataError/index.module.scss +118 -72
  42. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  43. package/dist/components/base/Price/Base/index.module.scss +12 -0
  44. package/dist/components/base/Price/Base/index.tsx +1 -1
  45. package/dist/components/base/Price/Double/index.module.scss +33 -1
  46. package/dist/components/base/Price/Double/index.tsx +1 -1
  47. package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
  48. package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
  49. package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
  50. package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
  51. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  52. package/dist/components/floorItem.tsx +1 -1
  53. package/dist/components/floorItem.weapp.tsx +1 -1
  54. package/dist/components/isv/Floor/index.tsx +1 -1
  55. package/dist/components/remoteFloorItem.tsx +1 -1
  56. package/dist/config/env.ts +1 -1
  57. package/dist/interface/common.ts +1 -1
  58. package/dist/interface/component.ts +1 -1
  59. package/dist/interface/jumpEventReport.ts +1 -1
  60. package/dist/interface/service.ts +1 -1
  61. package/dist/jumpEventReport/base.ts +1 -1
  62. package/dist/jumpEventReport/const.ts +1 -1
  63. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  64. package/dist/jumpEventReport/index.h5.ts +1 -1
  65. package/dist/jumpEventReport/index.jd.ts +1 -1
  66. package/dist/jumpEventReport/index.weapp.ts +1 -1
  67. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  68. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  69. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
  70. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  71. package/dist/jumpEventReport/web/report.ts +1 -1
  72. package/dist/jumpEventReport/web.base.ts +1 -1
  73. package/dist/jumpEventReport/web.jd.ts +1 -1
  74. package/dist/jumpEventReport/web.jdb.ts +1 -1
  75. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  76. package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
  77. package/dist/jumpEventReport/web.pc.ts +1 -1
  78. package/dist/jumpEventReport/web.tjapp.ts +1 -1
  79. package/dist/jumpEventReport/web.tjm.ts +1 -1
  80. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  81. package/dist/language/en_US.json +395 -0
  82. package/dist/language/zh_CN.json +395 -0
  83. package/dist/language/zh_HK.json +395 -0
  84. package/dist/libs/openShopBridge.js +161 -0
  85. package/dist/libs/openShopBridge.min.js +1 -0
  86. package/dist/libs/taroAppReport.js +2 -2
  87. package/dist/modules/ContainerFloorList/index.h5.module.scss +80 -53
  88. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  89. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  90. package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
  91. package/dist/open/api/environment.ts +1 -1
  92. package/dist/open/api/shopMember.ts +1 -1
  93. package/dist/open/api/shopMember.weapp.ts +1 -0
  94. package/dist/open/api/track.ts +1 -1
  95. package/dist/open/api/util.ts +1 -1
  96. package/dist/open/components/index.ts +1 -1
  97. package/dist/open/index.ts +1 -1
  98. package/dist/sass/app.h5.scss +278 -224
  99. package/dist/sass/base.scss +150 -145
  100. package/dist/service/fetchGateway.ts +1 -1
  101. package/dist/service/fetchGateway.weapp.ts +1 -0
  102. package/dist/service/fetchJsonp.weapp.ts +1 -0
  103. package/dist/service/http/colorSign.ts +1 -1
  104. package/dist/service/http/const.ts +1 -1
  105. package/dist/service/http/h5Http.ts +1 -1
  106. package/dist/service/http/httpInterceptors.weapp.ts +1 -0
  107. package/dist/service/requestServer.h5.ts +1 -1
  108. package/dist/service/requestServer.ts +1 -1
  109. package/dist/service/requestServer.weapp.ts +1 -0
  110. package/dist/utils/connectNativeJsBridge.ts +1 -1
  111. package/dist/utils/h5Utils.ts +1 -1
  112. package/dist/utils/harmonyCallRouter.h5.ts +1 -0
  113. package/dist/utils/harmonyCallRouter.ts +0 -0
  114. package/dist/utils/index.h5.ts +1 -1
  115. package/dist/utils/index.ts +1 -1
  116. package/dist/utils/index.weapp.ts +1 -1
  117. package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
  118. package/dist/utils/jumpExtMapUtil.ts +1 -0
  119. package/dist/utils/jumpExtMapUtil.weapp.ts +1 -0
  120. package/dist/utils/log.ts +1 -0
  121. package/dist/utils/sColor.ts +1 -0
  122. package/dist/utils/sColor.weapp.ts +1 -0
  123. package/dist/utils/utils.ts +1 -1
  124. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  125. package/dist/wxapp/common/user_info.js +1 -1
  126. package/package.json +162 -141
  127. package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
  128. package/dist/utils/memberFormatUtils.js +0 -1
  129. package/dist/utils/priceUtils.js +0 -1
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  showDayToSecondState,
2
+ import Taro from '@tarojs/taro';
3
3
  ? 'd'
4
4
  : taroJdBaseInfo?.languageJsonData?.timeUnitDay || '天';
5
5
  ? ':'
6
6
  : taroJdBaseInfo?.languageJsonData?.timeUnitHour || '时';
7
7
  ? ''
8
8
  : taroJdBaseInfo?.languageJsonData?.timeUnitMinute || '分';
9
9
  const {
10
10
  residueTime,
11
11
  serverTime,
12
12
  startTime,
13
13
  endTime,
14
14
  className,
15
15
  info,
16
16
  endTimeEndCallBack,
17
17
  startTimeEndCallBack,
18
18
  startTitleText,
19
19
  endTitleText,
20
20
  timeNumSpaceTextState,
21
21
  showDaytimeNumSpaceTextState,
22
22
  onlyShowDaySpaceTextState,
23
23
  getDaysToHours,
24
24
  onlyShowDayState,
25
25
  showDayState,
26
26
  showHourState,
27
27
  showMinuteState,
28
28
  showSecondState,
29
29
  showDayToSecondState,
30
30
  fromStartText,
31
31
  fromEndText,
32
32
  numTextColor,
33
33
  textColor,
34
34
  numTextBgColor,
35
35
  useFontV2,
36
36
  useFontV2Bold,
37
37
  } = props;
38
38
  const [endTimeFormat, setEndTimeFormat] = useState<{
39
39
  day: string | number;
40
40
  hour: string | number;
41
41
  minute: string | number;
42
42
  second: string | number;
43
43
  }>({
44
44
  day: 0,
45
45
  hour: 0,
46
46
  minute: 0,
47
47
  second: 0,
48
48
  });
49
49
  const countDownTimer = useRef<NodeJS.Timer | null>();
50
50
  const countDownTypeText = useRef<ComponentInterFace.CountDownTimerRef>({
51
51
  type: 'end',
52
52
  text: endTitleText,
53
53
  time: null,
54
54
  });
55
55
 
56
56
  const diffTimerRef = useRef({
57
57
  stopDocumentTime: 0,
58
58
  recoverDocumentTime: 0,
59
59
  diffTime: 0,
60
60
  });
61
61
 
62
62
  useEffect(() => {
63
63
  Taro.eventCenter.on(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, (state) => {
64
64
  if (state) {
65
65
  if (diffTimerRef.current.stopDocumentTime && diffTimerRef.current.stopDocumentTime > 0) {
66
66
  diffTimerRef.current.recoverDocumentTime = Date.now();
67
67
  diffTimerRef.current.diffTime =
68
68
  diffTimerRef.current.recoverDocumentTime - diffTimerRef.current.stopDocumentTime;
69
69
  changeTimerSetInterval(true);
70
70
  }
71
71
  } else {
72
72
  diffTimerRef.current.stopDocumentTime = Date.now();
73
73
  if (countDownTimer.current) {
74
74
  clearInterval(countDownTimer.current);
75
75
  countDownTimer.current = null;
76
76
  }
77
77
  }
78
78
  });
79
79
  }, []);
80
80
  useEffect(() => {
81
81
  if (serverTime > 0 || residueTime > 0) {
82
82
  let getNowEndTime = residueTime > 0 ? residueTime : endTime - serverTime;
83
83
  if (startTime && endTime) {
84
84
  if (serverTime <= startTime) {
85
85
  getNowEndTime = startTime - serverTime;
86
86
  countDownTypeText.current = {
87
87
  type: 'start',
88
88
  text: startTitleText,
89
89
  time: null,
90
90
  };
91
91
  } else {
92
92
  getNowEndTime = endTime - serverTime;
93
93
  countDownTypeText.current = {
94
94
  type: 'end',
95
95
  text: endTitleText,
96
96
  time: null,
97
97
  };
98
98
  }
99
99
  } else {
100
100
  countDownTypeText.current = {
101
101
  type: 'end',
102
102
  text: endTitleText,
103
103
  time: null,
104
104
  };
105
105
  }
106
106
  if (getNowEndTime > 0) {
107
107
  countDownTimeFormat(getNowEndTime);
108
108
  countDownTypeText.current.time = getNowEndTime;
109
109
  countDownTypeText.current.type === 'start' &&
110
110
  (countDownTypeText.current.endTime = endTime - serverTime);
111
111
  changeTimerSetInterval();
112
112
  } else {
113
113
  countDownTypeText.current = {
114
114
  type: 'end',
115
115
  text: endTitleText,
116
116
  time: 0,
117
117
  };
118
118
  }
119
119
  }
120
120
  return () => {
121
121
  countDownTimer.current && clearInterval(countDownTimer.current);
122
122
  };
123
123
  }, [serverTime, residueTime]);
124
124
 
125
125
  const changeTimerSetInterval = (recoverState = false) => {
126
126
  countDownTimer.current && clearInterval(countDownTimer.current);
127
127
  recoverState && changeTimerFunc();
128
128
  countDownTimer.current = setInterval(changeTimerFunc, 1000);
129
129
  };
130
130
  const changeTimerFunc = () => {
131
131
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
132
132
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
133
133
  countDownTypeText.current.type === 'start' &&
134
134
  countDownTypeText.current.endTime &&
135
135
  (countDownTypeText.current.endTime -= diffTimerRef.current.diffTime);
136
136
  console.log(
137
137
  '当前id倒计时获取倒计时息屏时间计算差值',
138
138
  countDownTimer.current,
139
139
  diffTimerRef.current,
140
140
  countDownTypeText.current,
141
141
  );
142
142
  diffTimerRef.current.stopDocumentTime = 0;
143
143
  diffTimerRef.current.recoverDocumentTime = 0;
144
144
  diffTimerRef.current.diffTime = 0;
145
145
  }
146
146
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
147
147
  countDownTypeText.current.time -= 1000;
148
148
  countDownTypeText.current.type === 'start' &&
149
149
  countDownTypeText.current.endTime &&
150
150
  (countDownTypeText.current.endTime -= 1000);
151
151
  countDownTimeFormat(countDownTypeText.current.time);
152
152
  } else {
153
153
  countDownTypeText.current.time = 0;
154
154
  countDownTimeFormat(countDownTypeText.current.time);
155
155
  countDownTimer.current && clearInterval(countDownTimer.current);
156
156
  if (countDownTypeText.current.type === 'start') {
157
157
  let triggerStartTimeEndCallBackState = true;
158
158
  countDownTypeText.current = Object.assign({}, countDownTypeText.current, {
159
159
  type: 'end',
160
160
  text: endTitleText,
161
161
  });
162
162
  if (endTime) {
163
163
  const now = Date.now();
164
164
  countDownTypeText.current.time = endTime - now;
165
165
  } else {
166
166
  countDownTypeText.current.time = countDownTypeText.current.endTime;
167
167
  countDownTypeText.current.time && (countDownTypeText.current.time -= 1000);
168
168
  }
169
169
  if (countDownTypeText.current.time && countDownTypeText.current.time > 0) {
170
170
  countDownTimer.current = setInterval(() => {
171
171
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
172
172
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
173
173
  diffTimerRef.current.stopDocumentTime = 0;
174
174
  diffTimerRef.current.recoverDocumentTime = 0;
175
175
  diffTimerRef.current.diffTime = 0;
176
176
  }
177
177
  if (triggerStartTimeEndCallBackState && startTimeEndCallBack) {
178
178
  startTimeEndCallBack({
179
179
  type: 'start',
180
180
  endState: true,
181
181
  ...info,
182
182
  });
183
183
  triggerStartTimeEndCallBackState = false;
184
184
  }
185
185
  const now = Date.now();
186
186
  let remainingTime = endTime ? endTime - now : 0;
187
187
  remainingTime = Math.max(0, remainingTime);
188
188
  if (endTime && remainingTime > 1000) {
189
189
  countDownTypeText.current.time = remainingTime;
190
190
  countDownTimeFormat(countDownTypeText.current.time);
191
191
  } else if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
192
192
  countDownTypeText.current.time -= 1000;
193
193
  countDownTimeFormat(countDownTypeText.current.time);
194
194
  } else {
195
195
  endTimeEndCallBack &&
196
196
  endTimeEndCallBack({
197
197
  type: 'end',
198
198
  endState: true,
199
199
  ...info,
200
200
  });
201
201
  }
202
202
  }, 1000);
203
203
  }
204
204
  } else {
205
205
  endTimeEndCallBack &&
206
206
  endTimeEndCallBack({
207
207
  type: 'end',
208
208
  endState: true,
209
209
  ...info,
210
210
  });
211
211
  }
212
212
  }
213
213
  };
214
214
  const countDownTimeFormat = (nowEndTime) => {
215
215
  let day = Math.floor(nowEndTime / 1000 / 86400);
216
216
  let hour = Math.floor((nowEndTime / 1000 / 3600) % 24);
217
217
  const minute = Math.floor((nowEndTime / 1000 / 60) % 60);
218
218
  const second = Math.floor((nowEndTime / 1000) % 60);
219
219
  if (getDaysToHours && day > 0) {
220
220
  hour = hour + day * 24;
221
221
  day = 0;
222
222
  }
223
223
  setEndTimeFormat({
224
224
  day,
225
225
  hour: `${hour}`.padStart(2, '0'),
226
226
  minute: `${minute}`.padStart(2, '0'),
227
227
  second: `${second}`.padStart(2, '0'),
228
228
  });
229
229
  };
230
230
  const numCustomStyle = numTextColor
231
231
  ? useRef({ color: numTextColor, backgroundColor: numTextBgColor })
232
232
  : useRef({});
233
233
  const textCustomStyle = textColor ? useRef({ color: textColor }) : useRef({});
234
234
  return (
235
235
  <View
236
236
  className={classNames(
237
237
  countDownStyle['d-count-down'],
238
238
  {
239
239
  [countDownStyle['d-ios-10-count-down']]: ios10State && !devToolPlatformState,
240
240
  },
241
241
  {
242
242
  [countDownStyle['d-en-count-down']]: isLanguageForEn,
243
243
  },
244
244
  className,
245
245
  )}
246
246
  >
247
247
  {countDownTypeText.current && countDownTypeText.current.text && (
248
248
  <Text
249
249
  className={classNames('d-count-down-title', {
250
250
  'font-jdzht-v2': useFontV2,
251
251
  'font-jdzht-v2-bold': useFontV2Bold,
252
252
  })}
253
253
  >
254
254
  {countDownTypeText.current.text}
255
255
  </Text>
256
256
  )}
257
257
  <View className="display-inline-block">
258
258
  {fromStartText && <Text className="d-count-from-start">{fromStartText}</Text>}
259
259
  {onlyShowDayState && endTimeFormat.day > 0 ? (
260
260
  <>
261
261
  <Text
262
262
  className={classNames('d-count-down-time', 'd-day-time', {
263
263
  'font-jdzht-v2': useFontV2,
264
264
  'font-jdzht-v2-bold': useFontV2Bold,
265
265
  })}
266
266
  style={numCustomStyle.current}
267
267
  >
268
268
  {endTimeFormat.day}
269
269
  </Text>
270
270
  <Text className="d-time-space-text d-day-space-text" style={textCustomStyle.current}>
271
271
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState ? countDownTimeDay : ':'}
272
272
  </Text>
273
273
  </>
274
274
  ) : (
275
275
  <>
276
276
  {(showDayState || showDayToSecondState) && endTimeFormat.day > 0 && (
277
277
  <>
278
278
  <Text
279
279
  className={classNames('d-count-down-time', 'd-day-time', {
280
280
  'font-jdzht-v2': useFontV2,
281
281
  'font-jdzht-v2-bold': useFontV2Bold,
282
282
  })}
283
283
  style={numCustomStyle.current}
284
284
  >
285
285
  {endTimeFormat.day}
286
286
  </Text>
287
287
  <Text
288
288
  className="d-time-space-text d-day-space-text"
289
289
  style={textCustomStyle.current}
290
290
  >
291
291
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState
292
292
  ? countDownTimeDay
293
293
  : ':'}
294
294
  </Text>
295
295
  </>
296
296
  )}
297
297
  {showHourState && (
298
298
  <>
299
299
  <Text
300
300
  className={classNames('d-count-down-time', 'd-hour-time', {
301
301
  'font-jdzht-v2': useFontV2,
302
302
  'font-jdzht-v2-bold': useFontV2Bold,
303
303
  })}
304
304
  style={numCustomStyle.current}
305
305
  >
306
306
  {endTimeFormat.hour}
307
307
  </Text>
308
308
  <Text className="d-time-space-text" style={textCustomStyle.current}>
309
309
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
310
310
  ? countDownTimeHour
311
311
  : ':'}
312
312
  </Text>
313
313
  </>
314
314
  )}
315
315
  {showMinuteState && (
316
316
  <>
317
317
  <Text
318
318
  className={classNames('d-count-down-time', 'd-minute-time', {
319
319
  'font-jdzht-v2': useFontV2,
320
320
  'font-jdzht-v2-bold': useFontV2Bold,
321
321
  })}
322
322
  style={numCustomStyle.current}
323
323
  >
324
324
  {endTimeFormat.minute}
325
325
  </Text>
326
326
  <Text className="d-time-space-text" style={textCustomStyle.current}>
327
327
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
328
328
  ? countDownTimeMin
329
329
  : endTimeFormat.day > 0 && !showDayToSecondState
330
330
  ? ''
331
331
  : ':'}
332
332
  </Text>
333
333
  </>
334
334
  )}
335
335
  {showSecondState && (endTimeFormat.day <= 0 || showDayToSecondState) && (
336
336
  <>
337
337
  <Text
338
338
  className={classNames('d-count-down-time', 'd-second-time', {
339
339
  'font-jdzht-v2': useFontV2,
340
340
  'font-jdzht-v2-bold': useFontV2Bold,
341
341
  })}
342
342
  style={numCustomStyle.current}
343
343
  >
344
344
  {endTimeFormat.second}
345
345
  </Text>
346
346
  {(timeNumSpaceTextState ||
347
347
  (showDayToSecondState && showDaytimeNumSpaceTextState)) && (
348
348
  <Text className="d-time-space-text" style={textCustomStyle.current}>
349
349
 
350
350
  </Text>
351
351
  )}
352
352
  </>
353
353
  )}
354
354
  </>
355
355
  )}
356
356
  {fromEndText && <Text className="d-count-from-end">{fromEndText}</Text>}
357
357
  </View>
358
358
  </View>
359
359
  );
360
360
  return useMemo(() => {
361
361
  return <CountDownTimer {...props} />;
362
362
  }, [props.residueTime]);
363
363
  residueTime: -1,
364
364
  serverTime: null,
365
365
  className: null,
366
366
  startTime: null,
367
367
  endTime: null,
368
368
  info: null,
369
369
  startTitleText: '距活动开始',
370
370
  endTitleText: '距活动结束',
371
371
  fromEndText: null,
372
372
  startTimeEndCallBack: null,
373
373
  endTimeEndCallBack: null,
374
374
  timeNumSpaceTextState: false,
375
375
  showDaytimeNumSpaceTextState: true,
376
376
  onlyShowDayState: false,
377
377
  onlyShowDaySpaceTextState: false,
378
378
  showDayState: false,
379
379
  showDayToSecondState: false,
380
380
  getDaysToHours: false,
381
381
  showHourState: true,
382
382
  showMinuteState: true,
383
383
  showSecondState: true,
384
384
  numTextColor: null,
385
385
  textColor: null,
386
386
  numTextBgColor: null,
387
387
  useFontV2: false,
388
388
  useFontV2Bold: false,
@@ -0,0 +1 @@
1
+ import React, { useRef, useEffect } from 'react';
2
  isH5AndJdShopView,
1
3
  isAndroidDevice,
2
4
  isJdAndAndroidDevice,
3
5
  isJdAndIosDevice,
4
6
  isIosDevice,
5
7
  isJdApp,
6
8
  isWxMin,
7
9
  isH5AndJdShopViewH5Scroll,
8
10
  isH5AndJdShopH5CustomScrollView,
9
11
  isH5,
10
12
  isAppClassifyPage,
11
13
  lodashThrottle,
12
14
  START: 'start',
13
15
  MOVE: 'move',
14
16
  END: 'end',
15
17
  const {
16
18
  style = {},
17
19
  scrollX = false,
18
20
  scrollY = false,
19
21
  scrollWithAnimation = true,
20
22
  iosNeedDisableVertical = false,
21
23
  className = null,
22
24
  dispatchTouchMove = true,
23
25
  children,
24
26
  ...otherProps
25
27
  } = props;
26
28
  const rootEleNode = isH5 && document?.querySelector('body');
27
29
  const needShowHighVersion =
28
30
  isH5AndJdShopViewH5Scroll && global.info.queryInfo?.downgraded !== 'true';
29
31
  const mLastClientPosRef = useRef({
30
32
  mLastClientX: 0,
31
33
  mLastClientY: 0,
32
34
  });
33
35
  const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
34
36
 
35
37
  const touchstartEventBubbleFunc = (e) => {
36
38
  const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
37
39
  if (!isH5SwiperCustomEle) {
38
40
  const hasCustomEle = e
39
41
  ? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
40
42
  : false;
41
43
  if (isJdAndAndroidDevice && !hasCustomEle) {
42
44
  window.JdAndroid && window.JdAndroid.requestEvent(false);
43
45
  }
44
46
  !hasCustomEle &&
45
47
  rootEleNode &&
46
48
  rootEleNode.classList.contains('over-hidden') &&
47
49
  rootEleNode.classList.remove('over-hidden');
48
50
  }
49
51
  };
50
52
  const touchstartEventCaptureFunc = (e) => {
51
53
  if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
52
54
  rootEleNode &&
53
55
  rootEleNode.classList.contains('over-hidden') &&
54
56
  rootEleNode.classList.remove('over-hidden');
55
57
  }
56
58
  };
57
59
  useEffect(() => {
58
60
  isJdApp &&
59
61
  !window.JDJshopViewInfo.getAndroidTouchSlopState &&
60
62
  nativePageGetScaledTouchSlop((res) => {
61
63
  console.log('获取安卓系统滑动阈值', res);
62
64
  window.JDJshopViewInfo.androidTouchSlop = res;
63
65
  window.JDJshopViewInfo.getAndroidTouchSlopState = true;
64
66
  });
65
67
  if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
66
68
  global?.removeJdAndroidRquestEventForTouchStart &&
67
69
  global.removeJdAndroidRquestEventForTouchStart();
68
70
  rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
69
71
 
70
72
  rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
71
73
  rootEleAddEventListenerState = true;
72
74
  console.log('customScrollView 初始化document监听完成');
73
75
  }
74
76
  return () => {
75
77
  if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
76
78
  console.log('customScrollView document监听取消完成');
77
79
  rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
78
80
  rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
79
81
  }
80
82
  };
81
83
  }, []);
82
84
 
83
85
  const androidDeviceStopNativeScrollEvent = (touchType) => {
84
86
  isJdApp &&
85
87
  isAndroidDevice &&
86
88
  window?.JdAndroid &&
87
89
  window?.JdAndroid.requestEvent(touchType === TouchType.START);
88
90
  };
89
91
  const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
90
92
  sendIosState && iosDeviceSendRouter(touchType);
91
93
  };
92
94
 
93
95
  const iosDeviceSendRouter = (state: string) => {
94
96
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
95
97
  method: 'callRouterModuleWithParams',
96
98
  params: {
97
99
  routerURL: 'router://JDShopModule/processShoph5SlideState',
98
100
  routerParam: {
99
101
  slideDirection: 'horizontal',
100
102
  needDisableVertical: `${iosNeedDisableVertical}`,
101
103
  state,
102
104
  },
103
105
  callBackId: new Date().getTime(),
104
106
  },
105
107
  });
106
108
  };
107
109
  const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
108
110
  if (isJdApp) {
109
111
  if (isIosDevice && !isAppClassifyPage) {
110
112
  iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
111
113
  } else if (isAndroidDevice) {
112
114
  androidDeviceStopNativeScrollEvent(touchType);
113
115
  }
114
116
  }
115
117
  };
116
118
 
117
119
  const GetSlideAngle = (dx, dy) => {
118
120
  return (Math.atan2(dy, dx) * 180) / Math.PI;
119
121
  };
120
122
 
121
123
  const GetSlideDirection = (startX, startY, endX, endY) => {
122
124
  const dy = startY - endY;
123
125
  const dx = endX - startX;
124
126
  let result = 0;
125
127
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
126
128
  return result;
127
129
  }
128
130
  const angle = GetSlideAngle(dx, dy);
129
131
  if (angle >= -45 && angle < 45) {
130
132
  result = 4;
131
133
  } else if (angle >= 45 && angle < 135) {
132
134
  result = 1;
133
135
  } else if (angle >= -135 && angle < -45) {
134
136
  result = 2;
135
137
  } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
136
138
  result = 3;
137
139
  }
138
140
  return result;
139
141
  };
140
142
  const changeTouchStart = (e) => {
141
143
  if (isJdApp) {
142
144
  stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
143
145
  if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
144
146
  isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
145
147
  const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
146
148
  mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
147
149
  mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
148
150
  }
149
151
  }
150
152
  };
151
153
  const changeTouchEnd = (e) => {
152
154
  stopNativeScrollEvent(e, TouchType.END);
153
155
  mLastClientPosRef.current.mLastClientX = 0;
154
156
  mLastClientPosRef.current.mLastClientY = 0;
155
157
  };
156
158
  const triggerIosTouchMove = () => {
157
159
  isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
158
160
  };
159
161
 
160
162
  const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
161
163
 
162
164
  const recoverRootEleVerticalScroll = (touchEvent) => {
163
165
  const direction = GetSlideDirection(
164
166
  mLastClientPosRef.current.mLastClientX,
165
167
  mLastClientPosRef.current.mLastClientY,
166
168
  touchEvent.clientX,
167
169
  touchEvent.clientY,
168
170
  );
169
171
  if (direction === 1 || direction === 2) {
170
172
  rootEleNode &&
171
173
  rootEleNode.classList.contains('over-hidden') &&
172
174
  rootEleNode.classList.remove('over-hidden');
173
175
  }
174
176
  };
175
177
  const changeTouchMove = (e) => {
176
178
  if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
177
179
  const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
178
180
  const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
179
181
  2,
180
182
  );
181
183
  const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
182
184
  2,
183
185
  );
184
186
  if (isJdApp) {
185
187
  if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
186
188
  iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
187
189
  } else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
188
190
  stopNativeScrollEvent(e, TouchType.END);
189
191
  }
190
192
  }
191
193
  isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
192
194
  }
193
195
  if (!dispatchTouchMove) {
194
196
  return;
195
197
  }
196
198
  const parentNode = e.target?.parentNode;
197
199
  if (!parentNode) {
198
200
  return;
199
201
  }
200
202
  const event = new TouchEvent('touchmove', e);
201
203
  parentNode.dispatchEvent(event);
202
204
  };
203
205
  if (scrollX && isJdApp && !isIgnorePreventNative) {
204
206
  return (
205
207
  <ScrollView
206
208
  scrollX
207
209
  onTouchStart={changeTouchStart}
208
210
  onTouchEnd={changeTouchEnd}
209
211
  onTouchCancel={changeTouchEnd}
210
212
  onTouchMove={changeTouchMove}
211
213
  enhanced
212
214
  showScrollbar={false}
213
215
  style={style}
214
216
  className={classNames(
215
217
  className,
216
218
  {
217
219
  [customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
218
220
  },
219
221
  'J_customScroll',
220
222
  )}
221
223
  scrollY
222
224
  scrollWithAnimation
223
225
  {...otherProps}
224
226
  >
225
227
  {children}
226
228
  </ScrollView>
227
229
  );
228
230
  } else {
229
231
  return (
230
232
  <ScrollView
231
233
  scrollX
232
234
  scrollY
233
235
  scrollWithAnimation
234
236
  enhanced
235
237
  showScrollbar={false}
236
238
  {...otherProps}
237
239
  className={classNames(
238
240
  className,
239
241
  {
240
242
  [customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
241
243
  isIosDevice && isWxMin && scrollX && style['borderRadius'],
242
244
  },
243
245
  {
244
246
  [customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
245
247
  },
246
248
  {
247
249
  [customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
248
250
  },
249
251
  )}
250
252
  style={style}
251
253
  >
252
254
  {children}
253
255
  </ScrollView>
254
256
  );
255
257
  }