@conecli/cone-render 0.10.1-shop-beta.37 → 0.10.1-shop-beta.38

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