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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/accessibility.h5.ts +1 -1
  3. package/dist/common/accessibility.ts +1 -0
  4. package/dist/common/const.ts +1 -1
  5. package/dist/common/index.h5.ts +1 -1
  6. package/dist/common/index.jd.ts +1 -1
  7. package/dist/common/index.ts +1 -1
  8. package/dist/common/index.weapp.ts +1 -1
  9. package/dist/components/base/CountDown/index.tsx +1 -1
  10. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  11. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  12. package/dist/interface/common.ts +1 -1
  13. package/dist/interface/jumpEventReport.ts +1 -1
  14. package/dist/interface/service.ts +1 -1
  15. package/dist/jumpEventReport/base.ts +1 -1
  16. package/dist/jumpEventReport/index.weapp.ts +1 -1
  17. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  18. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  19. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -1
  20. package/dist/jumpEventReport/web.jd.ts +1 -1
  21. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  22. package/dist/language/en_US.json +210 -149
  23. package/dist/language/zh_CN.json +210 -149
  24. package/dist/language/zh_HK.json +210 -149
  25. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  26. package/dist/open/api/shopMember.ts +1 -1
  27. package/dist/service/fetchGateway.ts +1 -1
  28. package/dist/service/requestServer.weapp.ts +1 -1
  29. package/dist/utils/connectNativeJsBridge.ts +1 -1
  30. package/dist/utils/index.h5.ts +1 -1
  31. package/dist/utils/index.ts +1 -1
  32. package/dist/utils/jumpExtMapUtil.weapp.ts +1 -0
  33. package/dist/utils/utils.ts +1 -1
  34. package/package.json +1 -1
@@ -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
  if (endTime) {
540
540
  const now = Date.now();
541
541
  countDownTypeText.current.time = endTime - now;
542
542
  } else {
543
543
  countDownTypeText.current.time = countDownTypeText.current.endTime;
544
544
  countDownTypeText.current.time && (countDownTypeText.current.time -= 1000);
545
545
  }
546
546
  if (countDownTypeText.current.time && countDownTypeText.current.time > 0) {
547
547
  countDownTimer.current = setInterval(() => {
548
548
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
549
549
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
550
550
  diffTimerRef.current.stopDocumentTime = 0;
551
551
  diffTimerRef.current.recoverDocumentTime = 0;
552
552
  diffTimerRef.current.diffTime = 0;
553
553
  }
554
554
  if (triggerStartTimeEndCallBackState && startTimeEndCallBack) {
555
555
  startTimeEndCallBack({
556
556
  type: 'start',
557
557
  endState: true,
558
558
  ...info,
559
559
  });
560
560
  triggerStartTimeEndCallBackState = false;
561
561
  }
562
562
  const now = Date.now();
563
563
  let remainingTime = endTime ? endTime - now : 0;
564
564
  remainingTime = Math.max(0, remainingTime);
565
565
  if (endTime && remainingTime > 1000) {
566
566
  countDownTypeText.current.time = remainingTime;
567
567
  countDownTimeFormat(countDownTypeText.current.time);
568
568
  } else if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
569
569
  countDownTypeText.current.time -= 1000;
570
570
  countDownTimeFormat(countDownTypeText.current.time);
571
571
  } else {
572
572
  endTimeEndCallBack &&
573
573
  endTimeEndCallBack({
574
574
  type: 'end',
575
575
  endState: true,
576
576
  ...info,
577
577
  });
578
578
  }
579
579
  }, 1000);
580
580
  }
581
581
  } else {
582
582
  endTimeEndCallBack &&
583
583
  endTimeEndCallBack({
584
584
  type: 'end',
585
585
  endState: true,
586
586
  ...info,
587
587
  });
588
588
  }
589
589
  }
590
590
  };
591
591
  const countDownTimeFormat = (nowEndTime) => {
592
592
  let day = Math.floor(nowEndTime / 1000 / 86400);
593
593
  let hour = Math.floor((nowEndTime / 1000 / 3600) % 24);
594
594
  const minute = Math.floor((nowEndTime / 1000 / 60) % 60);
595
595
  const second = Math.floor((nowEndTime / 1000) % 60);
596
596
  if (getDaysToHours && day > 0) {
597
597
  hour = hour + day * 24;
598
598
  day = 0;
599
599
  }
600
600
  setEndTimeFormat({
601
601
  day,
602
602
  hour: `${hour}`.padStart(2, '0'),
603
603
  minute: `${minute}`.padStart(2, '0'),
604
604
  second: `${second}`.padStart(2, '0'),
605
605
  });
606
606
  };
607
607
  const numCustomStyle = numTextColor
608
608
  ? useRef({ color: numTextColor, backgroundColor: numTextBgColor })
609
609
  : useRef({});
610
610
  const textCustomStyle = textColor ? useRef({ color: textColor }) : useRef({});
611
611
  return (
612
612
  <View
613
613
  className={classNames(
614
614
  countDownStyle['d-count-down'],
615
615
  {
616
616
  [countDownStyle['d-ios-10-count-down']]: ios10State && !devToolPlatformState,
617
617
  },
618
618
  {
619
619
  [countDownStyle['d-en-count-down']]: isLanguageForEn,
620
620
  },
621
621
  className,
622
622
  )}
623
623
  >
624
624
  {countDownTypeText.current && countDownTypeText.current.text && (
625
625
  <Text
626
626
  className={classNames('d-count-down-title', {
627
627
  'font-jdzht-v2': useFontV2,
628
628
  'font-jdzht-v2-bold': useFontV2Bold,
629
629
  })}
630
630
  >
631
631
  {countDownTypeText.current.text}
632
632
  </Text>
633
633
  )}
634
634
  <View className="display-inline-block">
635
635
  {fromStartText && <Text className="d-count-from-start">{fromStartText}</Text>}
636
636
  {onlyShowDayState && endTimeFormat.day > 0 ? (
637
637
  <>
638
638
  <Text
639
639
  className={classNames('d-count-down-time', 'd-day-time', {
640
640
  'font-jdzht-v2': useFontV2,
641
641
  'font-jdzht-v2-bold': useFontV2Bold,
642
642
  })}
643
643
  style={numCustomStyle.current}
644
644
  >
645
645
  {endTimeFormat.day}
646
646
  </Text>
647
647
  <Text className="d-time-space-text d-day-space-text" style={textCustomStyle.current}>
648
648
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState ? countDownTimeDay : ':'}
649
649
  </Text>
650
650
  </>
651
651
  ) : (
652
652
  <>
653
653
  {(showDayState || showDayToSecondState) && endTimeFormat.day > 0 && (
654
654
  <>
655
655
  <Text
656
656
  className={classNames('d-count-down-time', 'd-day-time', {
657
657
  'font-jdzht-v2': useFontV2,
658
658
  'font-jdzht-v2-bold': useFontV2Bold,
659
659
  })}
660
660
  style={numCustomStyle.current}
661
661
  >
662
662
  {endTimeFormat.day}
663
663
  </Text>
664
664
  <Text
665
665
  className="d-time-space-text d-day-space-text"
666
666
  style={textCustomStyle.current}
667
667
  >
668
668
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState
669
669
  ? countDownTimeDay
670
670
  : ':'}
671
671
  </Text>
672
672
  </>
673
673
  )}
674
674
  {showHourState && (
675
675
  <>
676
676
  <Text
677
677
  className={classNames('d-count-down-time', 'd-hour-time', {
678
678
  'font-jdzht-v2': useFontV2,
679
679
  'font-jdzht-v2-bold': useFontV2Bold,
680
680
  })}
681
681
  style={numCustomStyle.current}
682
682
  >
683
683
  {endTimeFormat.hour}
684
684
  </Text>
685
685
  <Text className="d-time-space-text" style={textCustomStyle.current}>
686
686
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
687
687
  ? countDownTimeHour
688
688
  : ':'}
689
689
  </Text>
690
690
  </>
691
691
  )}
692
692
  {showMinuteState && (
693
693
  <>
694
694
  <Text
695
695
  className={classNames('d-count-down-time', 'd-minute-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.minute}
702
702
  </Text>
703
703
  <Text className="d-time-space-text" style={textCustomStyle.current}>
704
704
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
705
705
  ? countDownTimeMin
706
706
  : endTimeFormat.day > 0 && !showDayToSecondState
707
707
  ? ''
708
708
  : ':'}
709
709
  </Text>
710
710
  </>
711
711
  )}
712
712
  {showSecondState && (endTimeFormat.day <= 0 || showDayToSecondState) && (
713
713
  <>
714
714
  <Text
715
715
  className={classNames('d-count-down-time', 'd-second-time', {
716
716
  'font-jdzht-v2': useFontV2,
717
717
  'font-jdzht-v2-bold': useFontV2Bold,
718
718
  })}
719
719
  style={numCustomStyle.current}
720
720
  >
721
721
  {endTimeFormat.second}
722
722
  </Text>
723
723
  {(timeNumSpaceTextState ||
724
724
  (showDayToSecondState && showDaytimeNumSpaceTextState)) && (
725
725
  <Text className="d-time-space-text" style={textCustomStyle.current}>
726
726
 
727
727
  </Text>
728
728
  )}
729
729
  </>
730
730
  )}
731
731
  </>
732
732
  )}
733
733
  {fromEndText && <Text className="d-count-from-end">{fromEndText}</Text>}
734
734
  </View>
735
735
  </View>
736
736
  );
737
737
  return useMemo(() => {
738
738
  return <CountDownTimer {...props} />;
739
739
  }, [props.residueTime]);
740
740
  residueTime: -1,
741
741
  serverTime: null,
742
742
  className: null,
743
743
  startTime: null,
744
744
  endTime: null,
745
745
  info: null,
746
746
  startTitleText: '距活动开始',
747
747
  endTitleText: '距活动结束',
748
748
  fromEndText: null,
749
749
  startTimeEndCallBack: null,
750
750
  endTimeEndCallBack: null,
751
751
  timeNumSpaceTextState: false,
752
752
  showDaytimeNumSpaceTextState: true,
753
753
  onlyShowDayState: false,
754
754
  onlyShowDaySpaceTextState: false,
755
755
  showDayState: false,
756
756
  showDayToSecondState: false,
757
757
  getDaysToHours: false,
758
758
  showHourState: true,
759
759
  showMinuteState: true,
760
760
  showSecondState: true,
761
761
  numTextColor: null,
762
762
  textColor: null,
763
763
  numTextBgColor: null,
764
764
  useFontV2: false,
765
765
  useFontV2Bold: false,