@conecli/cone-render 0.10.1-shop3.5 → 0.10.1-shop3.51

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 (99) hide show
  1. package/README.md +1 -1
  2. package/dist/common/accessibility.h5.ts +1 -0
  3. package/dist/common/accessibility.ts +0 -0
  4. package/dist/common/const.ts +1 -1
  5. package/dist/common/index.h5.ts +1 -1
  6. package/dist/common/index.jd.ts +1 -1
  7. package/dist/common/index.ts +1 -1
  8. package/dist/common/index.weapp.ts +1 -1
  9. package/dist/common/jdplayerSdk.weapp.tsx +1 -0
  10. package/dist/common/jssdk.ts +1 -1
  11. package/dist/common/jssdk.weapp.ts +1 -0
  12. package/dist/common/pageType.ts +1 -1
  13. package/dist/common/token/index.h5.ts +1 -1
  14. package/dist/common/token/token.jd.ts +1 -1
  15. package/dist/common/wxappApi.ts +1 -1
  16. package/dist/components/ErrorBoundary.tsx +1 -1
  17. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  18. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  19. package/dist/components/base/CountDown/index.tsx +1 -1
  20. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  21. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  22. package/dist/components/base/CustomVideo/index.tsx +1 -1
  23. package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
  24. package/dist/components/base/Dialog/index.module.scss +11 -0
  25. package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
  26. package/dist/components/base/InViewRender/index.tsx +1 -1
  27. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  28. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  29. package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
  30. package/dist/components/base/NetworkDataError/const.ts +1 -1
  31. package/dist/components/base/NetworkDataError/index.module.scss +118 -72
  32. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  33. package/dist/components/base/Price/Base/index.module.scss +12 -0
  34. package/dist/components/base/Price/Base/index.tsx +1 -1
  35. package/dist/components/base/Price/Double/index.module.scss +24 -0
  36. package/dist/components/base/Price/Double/index.tsx +1 -1
  37. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  38. package/dist/components/floorItem.weapp.tsx +1 -1
  39. package/dist/interface/common.ts +1 -1
  40. package/dist/interface/component.ts +1 -1
  41. package/dist/interface/jumpEventReport.ts +1 -1
  42. package/dist/jumpEventReport/base.ts +1 -1
  43. package/dist/jumpEventReport/const.ts +1 -1
  44. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  45. package/dist/jumpEventReport/index.h5.ts +1 -1
  46. package/dist/jumpEventReport/index.jd.ts +1 -1
  47. package/dist/jumpEventReport/index.weapp.ts +1 -1
  48. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  49. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  50. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
  51. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  52. package/dist/jumpEventReport/web/report.ts +1 -1
  53. package/dist/jumpEventReport/web.base.ts +1 -1
  54. package/dist/jumpEventReport/web.jd.ts +1 -1
  55. package/dist/jumpEventReport/web.pc.ts +1 -1
  56. package/dist/jumpEventReport/web.tjm.ts +1 -1
  57. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  58. package/dist/language/en_US.json +231 -0
  59. package/dist/language/zh_CN.json +231 -0
  60. package/dist/language/zh_HK.json +231 -0
  61. package/dist/libs/taroAppReport.js +2 -2
  62. package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -56
  63. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  64. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  65. package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
  66. package/dist/open/api/environment.ts +1 -1
  67. package/dist/open/api/shopMember.ts +1 -1
  68. package/dist/open/api/shopMember.weapp.ts +1 -0
  69. package/dist/open/api/util.ts +1 -1
  70. package/dist/open/index.ts +1 -1
  71. package/dist/sass/app.h5.scss +278 -224
  72. package/dist/service/fetchGateway.ts +1 -1
  73. package/dist/service/fetchGateway.weapp.ts +1 -0
  74. package/dist/service/fetchJsonp.weapp.ts +1 -0
  75. package/dist/service/http/colorSign.ts +1 -1
  76. package/dist/service/http/const.ts +1 -1
  77. package/dist/service/http/h5Http.ts +1 -1
  78. package/dist/service/http/httpInterceptors.weapp.ts +1 -0
  79. package/dist/service/requestServer.h5.ts +1 -1
  80. package/dist/service/requestServer.ts +1 -1
  81. package/dist/service/requestServer.weapp.ts +1 -0
  82. package/dist/utils/connectNativeJsBridge.ts +1 -1
  83. package/dist/utils/h5Utils.ts +1 -1
  84. package/dist/utils/harmonyCallRouter.h5.ts +1 -0
  85. package/dist/utils/harmonyCallRouter.ts +0 -0
  86. package/dist/utils/index.h5.ts +1 -1
  87. package/dist/utils/index.ts +1 -1
  88. package/dist/utils/index.weapp.ts +1 -1
  89. package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
  90. package/dist/utils/jumpExtMapUtil.ts +1 -0
  91. package/dist/utils/log.ts +1 -0
  92. package/dist/utils/{sColor.js → sColor.ts} +1 -1
  93. package/dist/utils/sColor.weapp.ts +1 -0
  94. package/dist/utils/utils.ts +1 -1
  95. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  96. package/dist/wxapp/common/user_info.js +1 -1
  97. package/package.json +160 -141
  98. package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
  99. package/dist/utils/priceUtils.js +0 -1
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro';
2
1
  const {
3
2
  residueTime,
4
3
  serverTime,
5
4
  startTime,
6
5
  endTime,
7
6
  className,
8
7
  info,
9
8
  endTimeEndCallBack,
10
9
  startTimeEndCallBack,
11
10
  startTitleText,
12
11
  endTitleText,
13
12
  timeNumSpaceTextState,
14
13
  showDaytimeNumSpaceTextState,
15
14
  getDaysToHours,
16
15
  onlyShowDayState,
17
16
  showDayState,
18
17
  showHourState,
19
18
  showMinuteState,
20
19
  showSecondState,
21
20
  showDayToSecondState,
22
21
  fromStartText,
23
22
  fromEndText,
24
23
  numTextColor,
25
24
  textColor,
26
25
  numTextBgColor,
27
26
  } = props;
28
27
  const [endTimeFormat, setEndTimeFormat] = useState<{
29
28
  day: string | number;
30
29
  hour: string | number;
31
30
  minute: string | number;
32
31
  second: string | number;
33
32
  }>({
34
33
  day: 0,
35
34
  hour: 0,
36
35
  minute: 0,
37
36
  second: 0,
38
37
  });
39
38
  const countDownTimer = useRef<NodeJS.Timer | null>();
40
39
  const countDownTypeText = useRef<ComponentInterFace.CountDownTimerRef>({
41
40
  type: 'end',
42
41
  text: endTitleText,
43
42
  time: null,
44
43
  });
45
44
 
46
45
  const diffTimerRef = useRef({
47
46
  stopDocumentTime: 0,
48
47
  recoverDocumentTime: 0,
49
48
  diffTime: 0,
50
49
  });
51
50
 
52
51
  useEffect(() => {
53
52
  Taro.eventCenter.on(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, (state) => {
54
53
  if (state) {
55
54
  if (diffTimerRef.current.stopDocumentTime && diffTimerRef.current.stopDocumentTime > 0) {
56
55
  diffTimerRef.current.recoverDocumentTime = Date.now();
57
56
  diffTimerRef.current.diffTime =
58
57
  diffTimerRef.current.recoverDocumentTime - diffTimerRef.current.stopDocumentTime;
59
58
  changeTimerSetInterval(true);
60
59
  }
61
60
  } else {
62
61
  diffTimerRef.current.stopDocumentTime = Date.now();
63
62
  if (countDownTimer.current) {
64
63
  clearInterval(countDownTimer.current);
65
64
  countDownTimer.current = null;
66
65
  }
67
66
  }
68
67
  });
69
68
  }, []);
70
69
  useEffect(() => {
71
70
  if (serverTime > 0 || residueTime > 0) {
72
71
  let getNowEndTime = residueTime > 0 ? residueTime : endTime - serverTime;
73
72
  if (startTime && endTime) {
74
73
  if (serverTime <= startTime) {
75
74
  getNowEndTime = startTime - serverTime;
76
75
  countDownTypeText.current = {
77
76
  type: 'start',
78
77
  text: startTitleText,
79
78
  time: null,
80
79
  };
81
80
  } else {
82
81
  getNowEndTime = endTime - serverTime;
83
82
  countDownTypeText.current = {
84
83
  type: 'end',
85
84
  text: endTitleText,
86
85
  time: null,
87
86
  };
88
87
  }
89
88
  } else {
90
89
  countDownTypeText.current = {
91
90
  type: 'end',
92
91
  text: endTitleText,
93
92
  time: null,
94
93
  };
95
94
  }
96
95
  if (getNowEndTime > 0) {
97
96
  countDownTimeFormat(getNowEndTime);
98
97
  countDownTypeText.current.time = getNowEndTime;
99
98
  countDownTypeText.current.type === 'start' &&
100
99
  (countDownTypeText.current.endTime = endTime - serverTime);
101
100
  changeTimerSetInterval();
102
101
  } else {
103
102
  countDownTypeText.current = {
104
103
  type: 'end',
105
104
  text: endTitleText,
106
105
  time: 0,
107
106
  };
108
107
  }
109
108
  }
110
109
  return () => {
111
110
  countDownTimer.current && clearInterval(countDownTimer.current);
112
111
  };
113
112
  }, [serverTime]);
114
113
 
115
114
  const changeTimerSetInterval = (recoverState = false) => {
116
115
  countDownTimer.current && clearInterval(countDownTimer.current);
117
116
  recoverState && changeTimerFunc();
118
117
  countDownTimer.current = setInterval(changeTimerFunc, 1000);
119
118
  };
120
119
  const changeTimerFunc = () => {
121
120
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
122
121
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
123
122
  countDownTypeText.current.type === 'start' &&
124
123
  countDownTypeText.current.endTime &&
125
124
  (countDownTypeText.current.endTime -= diffTimerRef.current.diffTime);
126
125
  console.log(
127
126
  '当前id倒计时获取倒计时息屏时间计算差值',
128
127
  countDownTimer.current,
129
128
  diffTimerRef.current,
130
129
  countDownTypeText.current,
131
130
  );
132
131
  diffTimerRef.current.stopDocumentTime = 0;
133
132
  diffTimerRef.current.recoverDocumentTime = 0;
134
133
  diffTimerRef.current.diffTime = 0;
135
134
  }
136
135
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
137
136
  countDownTypeText.current.time -= 1000;
138
137
  countDownTypeText.current.type === 'start' &&
139
138
  countDownTypeText.current.endTime &&
140
139
  (countDownTypeText.current.endTime -= 1000);
141
140
  countDownTimeFormat(countDownTypeText.current.time);
142
141
  } else {
143
142
  countDownTypeText.current.time = 0;
144
143
  countDownTimeFormat(countDownTypeText.current.time);
145
144
  countDownTimer.current && clearInterval(countDownTimer.current);
146
145
  if (countDownTypeText.current.type === 'start') {
147
146
  let triggerStartTimeEndCallBackState = true;
148
147
  countDownTypeText.current = Object.assign({}, countDownTypeText.current, {
149
148
  type: 'end',
150
149
  text: endTitleText,
151
150
  });
152
151
  countDownTypeText.current.time = countDownTypeText.current.endTime;
153
152
  countDownTypeText.current.time && (countDownTypeText.current.time -= 1000);
154
153
  if (countDownTypeText.current.time && countDownTypeText.current.time > 0) {
155
154
  countDownTimer.current = setInterval(() => {
156
155
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
157
156
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
158
157
  diffTimerRef.current.stopDocumentTime = 0;
159
158
  diffTimerRef.current.recoverDocumentTime = 0;
160
159
  diffTimerRef.current.diffTime = 0;
161
160
  }
162
161
  if (triggerStartTimeEndCallBackState && startTimeEndCallBack) {
163
162
  startTimeEndCallBack({
164
163
  type: 'start',
165
164
  endState: true,
166
165
  ...info,
167
166
  });
168
167
  triggerStartTimeEndCallBackState = false;
169
168
  }
170
169
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
171
170
  countDownTypeText.current.time -= 1000;
172
171
  countDownTimeFormat(countDownTypeText.current.time);
173
172
  } else {
174
173
  endTimeEndCallBack &&
175
174
  endTimeEndCallBack({
176
175
  type: 'end',
177
176
  endState: true,
178
177
  ...info,
179
178
  });
180
179
  }
181
180
  }, 1000);
182
181
  }
183
182
  } else {
184
183
  endTimeEndCallBack &&
185
184
  endTimeEndCallBack({
186
185
  type: 'end',
187
186
  endState: true,
188
187
  ...info,
189
188
  });
190
189
  }
191
190
  }
192
191
  };
193
192
  const countDownTimeFormat = (nowEndTime) => {
194
193
  let day = Math.floor(nowEndTime / 1000 / 86400);
195
194
  let hour = Math.floor((nowEndTime / 1000 / 3600) % 24);
196
195
  const minute = Math.floor((nowEndTime / 1000 / 60) % 60);
197
196
  const second = Math.floor((nowEndTime / 1000) % 60);
198
197
  if (getDaysToHours && day > 0) {
199
198
  hour = hour + day * 24;
200
199
  day = 0;
201
200
  }
202
201
  setEndTimeFormat({
203
202
  day,
204
203
  hour: `${hour}`.padStart(2, '0'),
205
204
  minute: `${minute}`.padStart(2, '0'),
206
205
  second: `${second}`.padStart(2, '0'),
207
206
  });
208
207
  };
209
208
  const numCustomStyle = numTextColor
210
209
  ? useRef({ color: numTextColor, backgroundColor: numTextBgColor })
211
210
  : useRef({});
212
211
  const textCustomStyle = textColor ? useRef({ color: textColor }) : useRef({});
213
212
  return (
214
213
  <View
215
214
  className={classNames(
216
215
  countDownStyle['d-count-down'],
217
216
  {
218
217
  [countDownStyle['d-ios-10-count-down']]: ios10State && !devToolPlatformState,
219
218
  },
220
219
  {
221
220
  [countDownStyle['d-en-count-down']]: isLanguageForEn,
222
221
  },
223
222
  className,
224
223
  )}
225
224
  >
226
225
  {countDownTypeText.current && countDownTypeText.current.text && (
227
226
  <Text className={classNames('d-count-down-title', 'font-jdzht')}>
228
227
  {countDownTypeText.current.text}
229
228
  </Text>
230
229
  )}
231
230
  <View className="display-inline-block">
232
231
  {fromStartText && <Text className="d-count-from-start">{fromStartText}</Text>}
233
232
  {onlyShowDayState && endTimeFormat.day > 0 ? (
234
233
  <>
235
234
  <Text
236
235
  className={classNames('d-count-down-time', 'd-day-time', 'font-jdzht')}
237
236
  style={numCustomStyle.current}
238
237
  >
239
238
  {endTimeFormat.day}
240
239
  </Text>
241
240
  <Text className="d-time-space-text d-day-space-text" style={textCustomStyle.current}>
242
241
  {showDaytimeNumSpaceTextState ? countDownTimeDay : ':'}
243
242
  </Text>
244
243
  </>
245
244
  ) : (
246
245
  <>
247
246
  {(showDayState || showDayToSecondState) && endTimeFormat.day > 0 && (
248
247
  <>
249
248
  <Text
250
249
  className={classNames('d-count-down-time', 'd-day-time', 'font-jdzht')}
251
250
  style={numCustomStyle.current}
252
251
  >
253
252
  {endTimeFormat.day}
254
253
  </Text>
255
254
  <Text
256
255
  className="d-time-space-text d-day-space-text"
257
256
  style={textCustomStyle.current}
258
257
  >
259
258
  {showDaytimeNumSpaceTextState ? countDownTimeDay : ':'}
260
259
  </Text>
261
260
  </>
262
261
  )}
263
262
  {showHourState && (
264
263
  <>
265
264
  <Text
266
265
  className={classNames('d-count-down-time', 'd-hour-time', 'font-jdzht')}
267
266
  style={numCustomStyle.current}
268
267
  >
269
268
  {endTimeFormat.hour}
270
269
  </Text>
271
270
  <Text className="d-time-space-text" style={textCustomStyle.current}>
272
271
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
273
272
  ? countDownTimeHour
274
273
  : ':'}
275
274
  </Text>
276
275
  </>
277
276
  )}
278
277
  {showMinuteState && (
279
278
  <>
280
279
  <Text
281
280
  className={classNames('d-count-down-time', 'd-minute-time', 'font-jdzht')}
282
281
  style={numCustomStyle.current}
283
282
  >
284
283
  {endTimeFormat.minute}
285
284
  </Text>
286
285
  <Text className="d-time-space-text" style={textCustomStyle.current}>
287
286
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
288
287
  ? countDownTimeMin
289
288
  : endTimeFormat.day > 0
290
289
  ? ''
291
290
  : ':'}
292
291
  </Text>
293
292
  </>
294
293
  )}
295
294
  {showSecondState && (endTimeFormat.day <= 0 || showDayToSecondState) && (
296
295
  <>
297
296
  <Text
298
297
  className={classNames('d-count-down-time', 'd-second-time', 'font-jdzht')}
299
298
  style={numCustomStyle.current}
300
299
  >
301
300
  {endTimeFormat.second}
302
301
  </Text>
303
302
  {(timeNumSpaceTextState ||
304
303
  (showDayToSecondState && showDaytimeNumSpaceTextState)) && (
305
304
  <Text className="d-time-space-text" style={textCustomStyle.current}>
306
305
 
307
306
  </Text>
308
307
  )}
309
308
  </>
310
309
  )}
311
310
  </>
312
311
  )}
313
312
  {fromEndText && <Text className="d-count-from-end">{fromEndText}</Text>}
314
313
  </View>
315
314
  </View>
316
315
  );
317
316
  return useMemo(() => {
318
317
  return <CountDownTimer {...props} />;
319
318
  }, []);
320
319
  residueTime: -1,
321
320
  serverTime: null,
322
321
  className: null,
323
322
  startTime: null,
324
323
  endTime: null,
325
324
  info: null,
326
325
  startTitleText: '距活动开始',
327
326
  endTitleText: '距活动结束',
328
327
  fromEndText: null,
329
328
  startTimeEndCallBack: null,
330
329
  endTimeEndCallBack: null,
331
330
  timeNumSpaceTextState: false,
332
331
  showDaytimeNumSpaceTextState: true,
333
332
  onlyShowDayState: false,
334
333
  showDayState: false,
335
334
  showDayToSecondState: false,
336
335
  getDaysToHours: false,
337
336
  showHourState: true,
338
337
  showMinuteState: true,
339
338
  showSecondState: true,
340
339
  numTextColor: null,
341
340
  textColor: null,
342
341
  numTextBgColor: null,
342
+ import Taro from '@tarojs/taro';
343
343
  ? 'd'
344
344
  : taroJdBaseInfo?.languageJsonData?.timeUnitDay || '天';
345
345
  ? ':'
346
346
  : taroJdBaseInfo?.languageJsonData?.timeUnitHour || '时';
347
347
  ? ''
348
348
  : taroJdBaseInfo?.languageJsonData?.timeUnitMinute || '分';
349
349
  const {
350
350
  residueTime,
351
351
  serverTime,
352
352
  startTime,
353
353
  endTime,
354
354
  className,
355
355
  info,
356
356
  endTimeEndCallBack,
357
357
  startTimeEndCallBack,
358
358
  startTitleText,
359
359
  endTitleText,
360
360
  timeNumSpaceTextState,
361
361
  showDaytimeNumSpaceTextState,
362
362
  onlyShowDaySpaceTextState,
363
363
  getDaysToHours,
364
364
  onlyShowDayState,
365
365
  showDayState,
366
366
  showHourState,
367
367
  showMinuteState,
368
368
  showSecondState,
369
369
  showDayToSecondState,
370
370
  fromStartText,
371
371
  fromEndText,
372
372
  numTextColor,
373
373
  textColor,
374
374
  numTextBgColor,
375
375
  useFontV2,
376
376
  useFontV2Bold,
377
377
  } = props;
378
378
  const [endTimeFormat, setEndTimeFormat] = useState<{
379
379
  day: string | number;
380
380
  hour: string | number;
381
381
  minute: string | number;
382
382
  second: string | number;
383
383
  }>({
384
384
  day: 0,
385
385
  hour: 0,
386
386
  minute: 0,
387
387
  second: 0,
388
388
  });
389
389
  const countDownTimer = useRef<NodeJS.Timer | null>();
390
390
  const countDownTypeText = useRef<ComponentInterFace.CountDownTimerRef>({
391
391
  type: 'end',
392
392
  text: endTitleText,
393
393
  time: null,
394
394
  });
395
395
 
396
396
  const diffTimerRef = useRef({
397
397
  stopDocumentTime: 0,
398
398
  recoverDocumentTime: 0,
399
399
  diffTime: 0,
400
400
  });
401
401
 
402
402
  useEffect(() => {
403
403
  Taro.eventCenter.on(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, (state) => {
404
404
  if (state) {
405
405
  if (diffTimerRef.current.stopDocumentTime && diffTimerRef.current.stopDocumentTime > 0) {
406
406
  diffTimerRef.current.recoverDocumentTime = Date.now();
407
407
  diffTimerRef.current.diffTime =
408
408
  diffTimerRef.current.recoverDocumentTime - diffTimerRef.current.stopDocumentTime;
409
409
  changeTimerSetInterval(true);
410
410
  }
411
411
  } else {
412
412
  diffTimerRef.current.stopDocumentTime = Date.now();
413
413
  if (countDownTimer.current) {
414
414
  clearInterval(countDownTimer.current);
415
415
  countDownTimer.current = null;
416
416
  }
417
417
  }
418
418
  });
419
419
  }, []);
420
420
  useEffect(() => {
421
421
  if (serverTime > 0 || residueTime > 0) {
422
422
  let getNowEndTime = residueTime > 0 ? residueTime : endTime - serverTime;
423
423
  if (startTime && endTime) {
424
424
  if (serverTime <= startTime) {
425
425
  getNowEndTime = startTime - serverTime;
426
426
  countDownTypeText.current = {
427
427
  type: 'start',
428
428
  text: startTitleText,
429
429
  time: null,
430
430
  };
431
431
  } else {
432
432
  getNowEndTime = endTime - serverTime;
433
433
  countDownTypeText.current = {
434
434
  type: 'end',
435
435
  text: endTitleText,
436
436
  time: null,
437
437
  };
438
438
  }
439
439
  } else {
440
440
  countDownTypeText.current = {
441
441
  type: 'end',
442
442
  text: endTitleText,
443
443
  time: null,
444
444
  };
445
445
  }
446
446
  if (getNowEndTime > 0) {
447
447
  countDownTimeFormat(getNowEndTime);
448
448
  countDownTypeText.current.time = getNowEndTime;
449
449
  countDownTypeText.current.type === 'start' &&
450
450
  (countDownTypeText.current.endTime = endTime - serverTime);
451
451
  changeTimerSetInterval();
452
452
  } else {
453
453
  countDownTypeText.current = {
454
454
  type: 'end',
455
455
  text: endTitleText,
456
456
  time: 0,
457
457
  };
458
458
  }
459
459
  }
460
460
  return () => {
461
461
  countDownTimer.current && clearInterval(countDownTimer.current);
462
462
  };
463
463
  }, [serverTime, residueTime]);
464
464
 
465
465
  const changeTimerSetInterval = (recoverState = false) => {
466
466
  countDownTimer.current && clearInterval(countDownTimer.current);
467
467
  recoverState && changeTimerFunc();
468
468
  countDownTimer.current = setInterval(changeTimerFunc, 1000);
469
469
  };
470
470
  const changeTimerFunc = () => {
471
471
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
472
472
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
473
473
  countDownTypeText.current.type === 'start' &&
474
474
  countDownTypeText.current.endTime &&
475
475
  (countDownTypeText.current.endTime -= diffTimerRef.current.diffTime);
476
476
  console.log(
477
477
  '当前id倒计时获取倒计时息屏时间计算差值',
478
478
  countDownTimer.current,
479
479
  diffTimerRef.current,
480
480
  countDownTypeText.current,
481
481
  );
482
482
  diffTimerRef.current.stopDocumentTime = 0;
483
483
  diffTimerRef.current.recoverDocumentTime = 0;
484
484
  diffTimerRef.current.diffTime = 0;
485
485
  }
486
486
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
487
487
  countDownTypeText.current.time -= 1000;
488
488
  countDownTypeText.current.type === 'start' &&
489
489
  countDownTypeText.current.endTime &&
490
490
  (countDownTypeText.current.endTime -= 1000);
491
491
  countDownTimeFormat(countDownTypeText.current.time);
492
492
  } else {
493
493
  countDownTypeText.current.time = 0;
494
494
  countDownTimeFormat(countDownTypeText.current.time);
495
495
  countDownTimer.current && clearInterval(countDownTimer.current);
496
496
  if (countDownTypeText.current.type === 'start') {
497
497
  let triggerStartTimeEndCallBackState = true;
498
498
  countDownTypeText.current = Object.assign({}, countDownTypeText.current, {
499
499
  type: 'end',
500
500
  text: endTitleText,
501
501
  });
502
502
  countDownTypeText.current.time = countDownTypeText.current.endTime;
503
503
  countDownTypeText.current.time && (countDownTypeText.current.time -= 1000);
504
504
  if (countDownTypeText.current.time && countDownTypeText.current.time > 0) {
505
505
  countDownTimer.current = setInterval(() => {
506
506
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
507
507
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
508
508
  diffTimerRef.current.stopDocumentTime = 0;
509
509
  diffTimerRef.current.recoverDocumentTime = 0;
510
510
  diffTimerRef.current.diffTime = 0;
511
511
  }
512
512
  if (triggerStartTimeEndCallBackState && startTimeEndCallBack) {
513
513
  startTimeEndCallBack({
514
514
  type: 'start',
515
515
  endState: true,
516
516
  ...info,
517
517
  });
518
518
  triggerStartTimeEndCallBackState = false;
519
519
  }
520
520
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
521
521
  countDownTypeText.current.time -= 1000;
522
522
  countDownTimeFormat(countDownTypeText.current.time);
523
523
  } else {
524
524
  endTimeEndCallBack &&
525
525
  endTimeEndCallBack({
526
526
  type: 'end',
527
527
  endState: true,
528
528
  ...info,
529
529
  });
530
530
  }
531
531
  }, 1000);
532
532
  }
533
533
  } else {
534
534
  endTimeEndCallBack &&
535
535
  endTimeEndCallBack({
536
536
  type: 'end',
537
537
  endState: true,
538
538
  ...info,
539
539
  });
540
540
  }
541
541
  }
542
542
  };
543
543
  const countDownTimeFormat = (nowEndTime) => {
544
544
  let day = Math.floor(nowEndTime / 1000 / 86400);
545
545
  let hour = Math.floor((nowEndTime / 1000 / 3600) % 24);
546
546
  const minute = Math.floor((nowEndTime / 1000 / 60) % 60);
547
547
  const second = Math.floor((nowEndTime / 1000) % 60);
548
548
  if (getDaysToHours && day > 0) {
549
549
  hour = hour + day * 24;
550
550
  day = 0;
551
551
  }
552
552
  setEndTimeFormat({
553
553
  day,
554
554
  hour: `${hour}`.padStart(2, '0'),
555
555
  minute: `${minute}`.padStart(2, '0'),
556
556
  second: `${second}`.padStart(2, '0'),
557
557
  });
558
558
  };
559
559
  const numCustomStyle = numTextColor
560
560
  ? useRef({ color: numTextColor, backgroundColor: numTextBgColor })
561
561
  : useRef({});
562
562
  const textCustomStyle = textColor ? useRef({ color: textColor }) : useRef({});
563
563
  return (
564
564
  <View
565
565
  className={classNames(
566
566
  countDownStyle['d-count-down'],
567
567
  {
568
568
  [countDownStyle['d-ios-10-count-down']]: ios10State && !devToolPlatformState,
569
569
  },
570
570
  {
571
571
  [countDownStyle['d-en-count-down']]: isLanguageForEn,
572
572
  },
573
573
  className,
574
574
  )}
575
575
  >
576
576
  {countDownTypeText.current && countDownTypeText.current.text && (
577
577
  <Text
578
578
  className={classNames('d-count-down-title', {
579
579
  'font-jdzht-v2': useFontV2,
580
580
  'font-jdzht-v2-bold': useFontV2Bold,
581
581
  })}
582
582
  >
583
583
  {countDownTypeText.current.text}
584
584
  </Text>
585
585
  )}
586
586
  <View className="display-inline-block">
587
587
  {fromStartText && <Text className="d-count-from-start">{fromStartText}</Text>}
588
588
  {onlyShowDayState && endTimeFormat.day > 0 ? (
589
589
  <>
590
590
  <Text
591
591
  className={classNames('d-count-down-time', 'd-day-time', {
592
592
  'font-jdzht-v2': useFontV2,
593
593
  'font-jdzht-v2-bold': useFontV2Bold,
594
594
  })}
595
595
  style={numCustomStyle.current}
596
596
  >
597
597
  {endTimeFormat.day}
598
598
  </Text>
599
599
  <Text className="d-time-space-text d-day-space-text" style={textCustomStyle.current}>
600
600
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState ? countDownTimeDay : ':'}
601
601
  </Text>
602
602
  </>
603
603
  ) : (
604
604
  <>
605
605
  {(showDayState || showDayToSecondState) && endTimeFormat.day > 0 && (
606
606
  <>
607
607
  <Text
608
608
  className={classNames('d-count-down-time', 'd-day-time', {
609
609
  'font-jdzht-v2': useFontV2,
610
610
  'font-jdzht-v2-bold': useFontV2Bold,
611
611
  })}
612
612
  style={numCustomStyle.current}
613
613
  >
614
614
  {endTimeFormat.day}
615
615
  </Text>
616
616
  <Text
617
617
  className="d-time-space-text d-day-space-text"
618
618
  style={textCustomStyle.current}
619
619
  >
620
620
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState
621
621
  ? countDownTimeDay
622
622
  : ':'}
623
623
  </Text>
624
624
  </>
625
625
  )}
626
626
  {showHourState && (
627
627
  <>
628
628
  <Text
629
629
  className={classNames('d-count-down-time', 'd-hour-time', {
630
630
  'font-jdzht-v2': useFontV2,
631
631
  'font-jdzht-v2-bold': useFontV2Bold,
632
632
  })}
633
633
  style={numCustomStyle.current}
634
634
  >
635
635
  {endTimeFormat.hour}
636
636
  </Text>
637
637
  <Text className="d-time-space-text" style={textCustomStyle.current}>
638
638
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
639
639
  ? countDownTimeHour
640
640
  : ':'}
641
641
  </Text>
642
642
  </>
643
643
  )}
644
644
  {showMinuteState && (
645
645
  <>
646
646
  <Text
647
647
  className={classNames('d-count-down-time', 'd-minute-time', {
648
648
  'font-jdzht-v2': useFontV2,
649
649
  'font-jdzht-v2-bold': useFontV2Bold,
650
650
  })}
651
651
  style={numCustomStyle.current}
652
652
  >
653
653
  {endTimeFormat.minute}
654
654
  </Text>
655
655
  <Text className="d-time-space-text" style={textCustomStyle.current}>
656
656
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
657
657
  ? countDownTimeMin
658
658
  : endTimeFormat.day > 0 && !showDayToSecondState
659
659
  ? ''
660
660
  : ':'}
661
661
  </Text>
662
662
  </>
663
663
  )}
664
664
  {showSecondState && (endTimeFormat.day <= 0 || showDayToSecondState) && (
665
665
  <>
666
666
  <Text
667
667
  className={classNames('d-count-down-time', 'd-second-time', {
668
668
  'font-jdzht-v2': useFontV2,
669
669
  'font-jdzht-v2-bold': useFontV2Bold,
670
670
  })}
671
671
  style={numCustomStyle.current}
672
672
  >
673
673
  {endTimeFormat.second}
674
674
  </Text>
675
675
  {(timeNumSpaceTextState ||
676
676
  (showDayToSecondState && showDaytimeNumSpaceTextState)) && (
677
677
  <Text className="d-time-space-text" style={textCustomStyle.current}>
678
678
 
679
679
  </Text>
680
680
  )}
681
681
  </>
682
682
  )}
683
683
  </>
684
684
  )}
685
685
  {fromEndText && <Text className="d-count-from-end">{fromEndText}</Text>}
686
686
  </View>
687
687
  </View>
688
688
  );
689
689
  return useMemo(() => {
690
690
  return <CountDownTimer {...props} />;
691
691
  }, [props.residueTime]);
692
692
  residueTime: -1,
693
693
  serverTime: null,
694
694
  className: null,
695
695
  startTime: null,
696
696
  endTime: null,
697
697
  info: null,
698
698
  startTitleText: '距活动开始',
699
699
  endTitleText: '距活动结束',
700
700
  fromEndText: null,
701
701
  startTimeEndCallBack: null,
702
702
  endTimeEndCallBack: null,
703
703
  timeNumSpaceTextState: false,
704
704
  showDaytimeNumSpaceTextState: true,
705
705
  onlyShowDayState: false,
706
706
  onlyShowDaySpaceTextState: false,
707
707
  showDayState: false,
708
708
  showDayToSecondState: false,
709
709
  getDaysToHours: false,
710
710
  showHourState: true,
711
711
  showMinuteState: true,
712
712
  showSecondState: true,
713
713
  numTextColor: null,
714
714
  textColor: null,
715
715
  numTextBgColor: null,
716
716
  useFontV2: false,
717
717
  useFontV2Bold: false,