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

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