@conecli/cone-render 0.10.1-shop3.10 → 0.10.1-shop3.100

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