@conecli/cone-render 0.10.1-shop-beta.63 → 0.10.1-shop-beta.65

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.
@@ -0,0 +1,52 @@
1
+
2
+ .d-count-down {
3
+ position: relative;
4
+ z-index: 2;
5
+ padding-top: 1px;
6
+ line-height: 28px;
7
+ font-size: 24px;
8
+ font-weight: bolder;
9
+ color: #fff;
10
+ text-align: center;
11
+ &.d-ios-10-count-down {
12
+ padding-top: 9px;
13
+ }
14
+ :global {
15
+ .d-count-down-title {
16
+ // position: relative;
17
+ // top: -2px;
18
+ display: inline-block;
19
+ padding-right: 5px;
20
+ height: 24px;
21
+ line-height: 24px;
22
+ font-size: 20px;
23
+ }
24
+ .d-count-down-time {
25
+ display: inline-block;
26
+ //margin: 0 2px;
27
+ min-width: 24px;
28
+ line-height: 28px;
29
+ font-size: 20px;
30
+ text-align: center;
31
+ }
32
+ .d-time-space-text {
33
+ display: inline-block;
34
+ //margin: 0 2px;
35
+ font-size: 20px;
36
+ }
37
+ .d-day-time {
38
+ min-width: 12px;
39
+ }
40
+ // .d-count-from-end {
41
+ // margin-right: 4px;
42
+ // font-size: 9px;
43
+ // }
44
+ }
45
+ &.d-en-count-down {
46
+ :global {
47
+ .d-day-space-text {
48
+ padding-right: 4px;
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro';
2
  ? 'd'
1
3
  : taroJdBaseInfo?.languageJsonData?.timeUnitDay || '天';
2
4
  ? ':'
3
5
  : taroJdBaseInfo?.languageJsonData?.timeUnitHour || '时';
4
6
  ? ''
5
7
  : taroJdBaseInfo?.languageJsonData?.timeUnitMinute || '分';
6
8
  const {
7
9
  residueTime,
8
10
  serverTime,
9
11
  startTime,
10
12
  endTime,
11
13
  className,
12
14
  info,
13
15
  endTimeEndCallBack,
14
16
  startTimeEndCallBack,
15
17
  startTitleText,
16
18
  endTitleText,
17
19
  timeNumSpaceTextState,
18
20
  showDaytimeNumSpaceTextState,
19
21
  onlyShowDaySpaceTextState,
20
22
  getDaysToHours,
21
23
  onlyShowDayState,
22
24
  showDayState,
23
25
  showHourState,
24
26
  showMinuteState,
25
27
  showSecondState,
26
28
  showDayToSecondState,
27
29
  fromStartText,
28
30
  fromEndText,
29
31
  numTextColor,
30
32
  textColor,
31
33
  numTextBgColor,
32
34
  useFontV2,
33
35
  useFontV2Bold,
34
36
  useDateNowCalc,
35
37
  } = props;
36
38
  const [endTimeFormat, setEndTimeFormat] = useState<{
37
39
  day: string | number;
38
40
  hour: string | number;
39
41
  minute: string | number;
40
42
  second: string | number;
41
43
  }>({
42
44
  day: 0,
43
45
  hour: 0,
44
46
  minute: 0,
45
47
  second: 0,
46
48
  });
47
49
  const countDownTimer = useRef<ReturnType<typeof setTimeout> | null>();
48
50
  const nextTickTimeRef = useRef<number>(0);
49
51
  const scheduleNextTickRef = useRef<(() => void) | null>(null);
50
52
  const countDownTypeText = useRef<ComponentInterFace.CountDownTimerRef>({
51
53
  type: 'end',
52
54
  text: endTitleText,
53
55
  time: null,
54
56
  });
55
57
 
56
58
  const diffTimerRef = useRef({
57
59
  stopDocumentTime: 0,
58
60
  recoverDocumentTime: 0,
59
61
  diffTime: 0,
60
62
  });
61
63
 
62
64
  useEffect(() => {
63
65
  if (useDateNowCalc) return;
64
66
  function visibilityChanged(state) {
65
67
  if (state) {
66
68
  if (diffTimerRef.current.stopDocumentTime && diffTimerRef.current.stopDocumentTime > 0) {
67
69
  diffTimerRef.current.recoverDocumentTime = Date.now();
68
70
  diffTimerRef.current.diffTime =
69
71
  diffTimerRef.current.recoverDocumentTime - diffTimerRef.current.stopDocumentTime;
70
72
  changeTimerSetInterval(true);
71
73
  }
72
74
  } else {
73
75
  diffTimerRef.current.stopDocumentTime = Date.now();
74
76
  if (countDownTimer.current) {
75
77
  clearTimeout(countDownTimer.current);
76
78
  countDownTimer.current = null;
77
79
  }
78
80
  }
79
81
  }
80
82
  Taro.eventCenter.on(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, visibilityChanged);
81
83
  return () => {
82
84
  Taro.eventCenter.off(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, visibilityChanged);
83
85
  };
84
86
  }, []);
85
87
  useEffect(() => {
86
88
  if (serverTime > 0 || residueTime > 0) {
87
89
  let getNowEndTime = residueTime > 0 ? residueTime : endTime - serverTime;
88
90
  if (useDateNowCalc && endTime) {
89
91
  const now = Date.now();
90
92
  getNowEndTime = endTime - now;
91
93
  }
92
94
  if (startTime && endTime) {
93
95
  if (serverTime <= startTime) {
94
96
  getNowEndTime = startTime - serverTime;
95
97
  countDownTypeText.current = {
96
98
  type: 'start',
97
99
  text: startTitleText,
98
100
  time: null,
99
101
  };
100
102
  } else {
101
103
  getNowEndTime = endTime - serverTime;
102
104
  countDownTypeText.current = {
103
105
  type: 'end',
104
106
  text: endTitleText,
105
107
  time: null,
106
108
  };
107
109
  }
108
110
  } else {
109
111
  countDownTypeText.current = {
110
112
  type: 'end',
111
113
  text: endTitleText,
112
114
  time: null,
113
115
  };
114
116
  }
115
117
  if (getNowEndTime > 0) {
116
118
  countDownTimeFormat(getNowEndTime);
117
119
  countDownTypeText.current.time = getNowEndTime;
118
120
  countDownTypeText.current.type === 'start' &&
119
121
  (countDownTypeText.current.endTime = endTime - serverTime);
120
122
  changeTimerSetInterval();
121
123
  } else {
122
124
  countDownTypeText.current = {
123
125
  type: 'end',
124
126
  text: endTitleText,
125
127
  time: 0,
126
128
  };
127
129
  }
128
130
  }
129
131
  return () => {
130
132
  countDownTimer.current && clearTimeout(countDownTimer.current);
131
133
  };
132
134
  }, [serverTime, residueTime]);
133
135
 
134
136
  const changeTimerSetInterval = (recoverState = false) => {
135
137
  countDownTimer.current && clearTimeout(countDownTimer.current);
136
138
  nextTickTimeRef.current = Date.now() + 1000;
137
139
  recoverState && changeTimerFunc();
138
140
  const scheduleNextTick = () => {
139
141
  const now = Date.now();
140
142
  const delay = Math.max(0, nextTickTimeRef.current - now);
141
143
  countDownTimer.current = setTimeout(() => {
142
144
  nextTickTimeRef.current += 1000;
143
145
  changeTimerFunc();
144
146
  }, delay);
145
147
  };
146
148
  scheduleNextTickRef.current = scheduleNextTick;
147
149
  scheduleNextTick();
148
150
  };
149
151
  const changeTimerFunc = () => {
150
152
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
151
153
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
152
154
  countDownTypeText.current.type === 'start' &&
153
155
  countDownTypeText.current.endTime &&
154
156
  (countDownTypeText.current.endTime -= diffTimerRef.current.diffTime);
155
157
  console.log(
156
158
  '当前id倒计时获取倒计时息屏时间计算差值',
157
159
  countDownTimer.current,
158
160
  diffTimerRef.current,
159
161
  countDownTypeText.current,
160
162
  );
161
163
  diffTimerRef.current.stopDocumentTime = 0;
162
164
  diffTimerRef.current.recoverDocumentTime = 0;
163
165
  diffTimerRef.current.diffTime = 0;
164
166
  }
165
167
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
166
168
  if (useDateNowCalc && endTime && countDownTypeText.current.type === 'end') {
167
169
  const now = Date.now();
168
170
  countDownTypeText.current.time = endTime - now;
169
171
  } else {
170
172
  countDownTypeText.current.time -= 1000;
171
173
  countDownTypeText.current.type === 'start' &&
172
174
  countDownTypeText.current.endTime &&
173
175
  (countDownTypeText.current.endTime -= 1000);
174
176
  }
175
177
  countDownTimeFormat(countDownTypeText.current.time);
176
178
  scheduleNextTickRef.current && scheduleNextTickRef.current();
177
179
  } else {
178
180
  countDownTypeText.current.time = 0;
179
181
  countDownTimeFormat(countDownTypeText.current.time);
180
182
  countDownTimer.current && clearTimeout(countDownTimer.current);
181
183
  if (countDownTypeText.current.type === 'start') {
182
184
  let triggerStartTimeEndCallBackState = true;
183
185
  countDownTypeText.current = Object.assign({}, countDownTypeText.current, {
184
186
  type: 'end',
185
187
  text: endTitleText,
186
188
  });
187
189
  countDownTypeText.current.time = countDownTypeText.current.endTime;
188
190
  countDownTypeText.current.time && (countDownTypeText.current.time -= 1000);
189
191
  if (countDownTypeText.current.time && countDownTypeText.current.time > 0) {
190
192
  nextTickTimeRef.current = Date.now() + 1000;
191
193
  const scheduleEndTick = () => {
192
194
  const now = Date.now();
193
195
  const delay = Math.max(0, nextTickTimeRef.current - now);
194
196
  countDownTimer.current = setTimeout(() => {
195
197
  nextTickTimeRef.current += 1000;
196
198
  if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
197
199
  countDownTypeText.current.time -= diffTimerRef.current.diffTime;
198
200
  diffTimerRef.current.stopDocumentTime = 0;
199
201
  diffTimerRef.current.recoverDocumentTime = 0;
200
202
  diffTimerRef.current.diffTime = 0;
201
203
  }
202
204
  if (triggerStartTimeEndCallBackState && startTimeEndCallBack) {
203
205
  startTimeEndCallBack({
204
206
  type: 'start',
205
207
  endState: true,
206
208
  ...info,
207
209
  });
208
210
  triggerStartTimeEndCallBackState = false;
209
211
  }
210
212
  if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
211
213
  countDownTypeText.current.time -= 1000;
212
214
  countDownTimeFormat(countDownTypeText.current.time);
213
215
  scheduleEndTick();
214
216
  } else {
215
217
  endTimeEndCallBack &&
216
218
  endTimeEndCallBack({
217
219
  type: 'end',
218
220
  endState: true,
219
221
  ...info,
220
222
  });
221
223
  }
222
224
  }, delay);
223
225
  };
224
226
  scheduleNextTickRef.current = scheduleEndTick;
225
227
  scheduleEndTick();
226
228
  }
227
229
  } else {
228
230
  endTimeEndCallBack &&
229
231
  endTimeEndCallBack({
230
232
  type: 'end',
231
233
  endState: true,
232
234
  ...info,
233
235
  });
234
236
  }
235
237
  }
236
238
  };
237
239
  const countDownTimeFormat = (nowEndTime) => {
238
240
  let day = Math.max(Math.floor(nowEndTime / 1000 / 86400), 0);
239
241
  let hour = Math.max(Math.floor((nowEndTime / 1000 / 3600) % 24), 0);
240
242
  const minute = Math.max(Math.floor((nowEndTime / 1000 / 60) % 60), 0);
241
243
  const second = Math.max(Math.floor((nowEndTime / 1000) % 60), 0);
242
244
  if (getDaysToHours && day > 0) {
243
245
  hour = hour + day * 24;
244
246
  day = 0;
245
247
  }
246
248
  setEndTimeFormat({
247
249
  day,
248
250
  hour: `${hour}`.padStart(2, '0'),
249
251
  minute: `${minute}`.padStart(2, '0'),
250
252
  second: `${second}`.padStart(2, '0'),
251
253
  });
252
254
  };
253
255
  const numCustomStyle = numTextColor
254
256
  ? useRef({ color: numTextColor, backgroundColor: numTextBgColor })
255
257
  : useRef({});
256
258
  const textCustomStyle = textColor ? useRef({ color: textColor }) : useRef({});
257
259
  return (
258
260
  <View
259
261
  className={classNames(
260
262
  countDownStyle['d-count-down'],
261
263
  {
262
264
  [countDownStyle['d-ios-10-count-down']]: ios10State && !devToolPlatformState,
263
265
  },
264
266
  {
265
267
  [countDownStyle['d-en-count-down']]: isLanguageForEn,
266
268
  },
267
269
  className,
268
270
  )}
269
271
  >
270
272
  {countDownTypeText.current && countDownTypeText.current.text && (
271
273
  <Text
272
274
  className={classNames('d-count-down-title', {
273
275
  'font-jdzht-v2': useFontV2,
274
276
  'font-jdzht-v2-bold': useFontV2Bold,
275
277
  })}
276
278
  >
277
279
  {countDownTypeText.current.text}
278
280
  </Text>
279
281
  )}
280
282
  <View className="display-inline-block">
281
283
  {fromStartText && <Text className="d-count-from-start">{fromStartText}</Text>}
282
284
  {onlyShowDayState && endTimeFormat.day > 0 ? (
283
285
  <>
284
286
  <Text
285
287
  className={classNames('d-count-down-time', 'd-day-time', {
286
288
  'font-jdzht-v2': useFontV2,
287
289
  'font-jdzht-v2-bold': useFontV2Bold,
288
290
  })}
289
291
  style={numCustomStyle.current}
290
292
  >
291
293
  {endTimeFormat.day}
292
294
  </Text>
293
295
  <Text className="d-time-space-text d-day-space-text" style={textCustomStyle.current}>
294
296
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState ? countDownTimeDay : ':'}
295
297
  </Text>
296
298
  </>
297
299
  ) : (
298
300
  <>
299
301
  {(showDayState || showDayToSecondState) && endTimeFormat.day > 0 && (
300
302
  <>
301
303
  <Text
302
304
  className={classNames('d-count-down-time', 'd-day-time', {
303
305
  'font-jdzht-v2': useFontV2,
304
306
  'font-jdzht-v2-bold': useFontV2Bold,
305
307
  })}
306
308
  style={numCustomStyle.current}
307
309
  >
308
310
  {endTimeFormat.day}
309
311
  </Text>
310
312
  <Text
311
313
  className="d-time-space-text d-day-space-text"
312
314
  style={textCustomStyle.current}
313
315
  >
314
316
  {showDaytimeNumSpaceTextState || onlyShowDaySpaceTextState
315
317
  ? countDownTimeDay
316
318
  : ':'}
317
319
  </Text>
318
320
  </>
319
321
  )}
320
322
  {showHourState && (
321
323
  <>
322
324
  <Text
323
325
  className={classNames('d-count-down-time', 'd-hour-time', {
324
326
  'font-jdzht-v2': useFontV2,
325
327
  'font-jdzht-v2-bold': useFontV2Bold,
326
328
  })}
327
329
  style={numCustomStyle.current}
328
330
  >
329
331
  {endTimeFormat.hour}
330
332
  </Text>
331
333
  <Text className="d-time-space-text" style={textCustomStyle.current}>
332
334
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
333
335
  ? countDownTimeHour
334
336
  : ':'}
335
337
  </Text>
336
338
  </>
337
339
  )}
338
340
  {showMinuteState && (
339
341
  <>
340
342
  <Text
341
343
  className={classNames('d-count-down-time', 'd-minute-time', {
342
344
  'font-jdzht-v2': useFontV2,
343
345
  'font-jdzht-v2-bold': useFontV2Bold,
344
346
  })}
345
347
  style={numCustomStyle.current}
346
348
  >
347
349
  {endTimeFormat.minute}
348
350
  </Text>
349
351
  <Text className="d-time-space-text" style={textCustomStyle.current}>
350
352
  {(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
351
353
  ? countDownTimeMin
352
354
  : endTimeFormat.day > 0 && !showDayToSecondState
353
355
  ? ''
354
356
  : ':'}
355
357
  </Text>
356
358
  </>
357
359
  )}
358
360
  {showSecondState && (endTimeFormat.day <= 0 || showDayToSecondState) && (
359
361
  <>
360
362
  <Text
361
363
  className={classNames('d-count-down-time', 'd-second-time', {
362
364
  'font-jdzht-v2': useFontV2,
363
365
  'font-jdzht-v2-bold': useFontV2Bold,
364
366
  })}
365
367
  style={numCustomStyle.current}
366
368
  >
367
369
  {endTimeFormat.second}
368
370
  </Text>
369
371
  {(timeNumSpaceTextState ||
370
372
  (showDayToSecondState && showDaytimeNumSpaceTextState)) && (
371
373
  <Text className="d-time-space-text" style={textCustomStyle.current}>
372
374
 
373
375
  </Text>
374
376
  )}
375
377
  </>
376
378
  )}
377
379
  </>
378
380
  )}
379
381
  {fromEndText && <Text className="d-count-from-end">{fromEndText}</Text>}
380
382
  </View>
381
383
  </View>
382
384
  );
383
385
  return useMemo(() => {
384
386
  return <CountDownTimer {...props} />;
385
387
  }, [props.residueTime, props.endTime]);
386
388
  residueTime: -1,
387
389
  serverTime: null,
388
390
  className: null,
389
391
  startTime: null,
390
392
  endTime: null,
391
393
  info: null,
392
394
  startTitleText: '距活动开始',
393
395
  endTitleText: '距活动结束',
394
396
  fromEndText: null,
395
397
  startTimeEndCallBack: null,
396
398
  endTimeEndCallBack: null,
397
399
  timeNumSpaceTextState: false,
398
400
  showDaytimeNumSpaceTextState: true,
399
401
  onlyShowDayState: false,
400
402
  onlyShowDaySpaceTextState: false,
401
403
  showDayState: false,
402
404
  showDayToSecondState: false,
403
405
  getDaysToHours: false,
404
406
  showHourState: true,
405
407
  showMinuteState: true,
406
408
  showSecondState: true,
407
409
  numTextColor: null,
408
410
  textColor: null,
409
411
  numTextBgColor: null,
410
412
  useFontV2: false,
411
413
  useFontV2Bold: false,
@@ -1 +1 @@
1
- import CountDown from '../../components/base/CountDown';
2
1
  CountDown,
3
2
  CustomScrollView,
4
3
  CustomImageLoadRealInfo,
5
4
  LazyLayoutLoad,
6
5
  LazyLoadImage,
7
6
  Dialog,
8
7
  Price,
9
8
  Exposure,
10
9
  ExposureSmart,
11
10
  ItemViewExposureSmart,
12
11
  InViewRender,
13
12
  InOrOutViewObserver,
14
13
  CustomVideo,
15
14
  MobileCommonHeader,
16
15
  NetworkDataError,
17
16
  ShopLeGaoTag,
17
+ import CountDown from '../../components/base/CountDown';
18
18
  CountDown,
19
19
  CountDownForApp,
20
20
  CustomScrollView,
21
21
  CustomImageLoadRealInfo,
22
22
  LazyLayoutLoad,
23
23
  LazyLoadImage,
24
24
  Dialog,
25
25
  Price,
26
26
  Exposure,
27
27
  ExposureSmart,
28
28
  ItemViewExposureSmart,
29
29
  InViewRender,
30
30
  InOrOutViewObserver,
31
31
  CustomVideo,
32
32
  MobileCommonHeader,
33
33
  NetworkDataError,
34
34
  ShopLeGaoTag,