@conecli/cone-render 0.10.1-shop-beta.53 → 0.10.1-shop-beta.55

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