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