@conecli/cone-render 0.10.1-isv2.1 → 0.10.1-isv2.4
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.
- package/dist/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/jssdk.ts +1 -1
- package/dist/common/pageType.ts +1 -1
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/wxappApi.ts +1 -1
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CountDown/index.module.scss +49 -44
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/common.ts +1 -0
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +11 -0
- package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -3
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +3 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +8 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +2 -2
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/components/remoteFloorItem.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/index.jd.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.jdb.ts +1 -1
- package/dist/jumpEventReport/web.jdjch.ts +1 -1
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
- package/dist/jumpEventReport/web.pc.ts +1 -1
- package/dist/jumpEventReport/web.tjapp.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -52
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/device.ts +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/request.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/sass/app.h5.scss +275 -221
- package/dist/sass/base.scss +183 -137
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
- package/dist/utils/jumpExtMapUtil.ts +1 -0
- package/dist/utils/log.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/sgmCodeUtils.ts +1 -1
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
- package/dist/wxapp/common/user_info.js +1 -1
- package/package.json +158 -135
- package/dist/utils/memberFormatUtils.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
showDayToSecondState,
|
|
2
|
+
import Taro from '@tarojs/taro';
|
|
3
3
|
const {
|
|
4
4
|
residueTime,
|
|
5
5
|
serverTime,
|
|
6
6
|
startTime,
|
|
7
7
|
endTime,
|
|
8
8
|
className,
|
|
9
9
|
info,
|
|
10
10
|
endTimeEndCallBack,
|
|
11
11
|
startTimeEndCallBack,
|
|
12
12
|
startTitleText,
|
|
13
13
|
endTitleText,
|
|
14
14
|
timeNumSpaceTextState,
|
|
15
15
|
showDaytimeNumSpaceTextState,
|
|
16
16
|
getDaysToHours,
|
|
17
17
|
onlyShowDayState,
|
|
18
18
|
showDayState,
|
|
19
19
|
showHourState,
|
|
20
20
|
showMinuteState,
|
|
21
21
|
showSecondState,
|
|
22
22
|
showDayToSecondState,
|
|
23
23
|
fromStartText,
|
|
24
24
|
fromEndText,
|
|
25
25
|
numTextColor,
|
|
26
26
|
textColor,
|
|
27
27
|
numTextBgColor,
|
|
28
28
|
} = props;
|
|
29
29
|
const [endTimeFormat, setEndTimeFormat] = useState<{
|
|
30
30
|
day: string | number;
|
|
31
31
|
hour: string | number;
|
|
32
32
|
minute: string | number;
|
|
33
33
|
second: string | number;
|
|
34
34
|
}>({
|
|
35
35
|
day: 0,
|
|
36
36
|
hour: 0,
|
|
37
37
|
minute: 0,
|
|
38
38
|
second: 0,
|
|
39
39
|
});
|
|
40
40
|
const countDownTimer = useRef<NodeJS.Timer | null>();
|
|
41
41
|
const countDownTypeText = useRef<ComponentInterFace.CountDownTimerRef>({
|
|
42
42
|
type: 'end',
|
|
43
43
|
text: endTitleText,
|
|
44
44
|
time: null,
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
const diffTimerRef = useRef({
|
|
48
48
|
stopDocumentTime: 0,
|
|
49
49
|
recoverDocumentTime: 0,
|
|
50
50
|
diffTime: 0,
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
54
|
Taro.eventCenter.on(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, (state) => {
|
|
55
55
|
if (state) {
|
|
56
56
|
if (diffTimerRef.current.stopDocumentTime && diffTimerRef.current.stopDocumentTime > 0) {
|
|
57
57
|
diffTimerRef.current.recoverDocumentTime = Date.now();
|
|
58
58
|
diffTimerRef.current.diffTime =
|
|
59
59
|
diffTimerRef.current.recoverDocumentTime - diffTimerRef.current.stopDocumentTime;
|
|
60
60
|
changeTimerSetInterval(true);
|
|
61
61
|
}
|
|
62
62
|
} else {
|
|
63
63
|
diffTimerRef.current.stopDocumentTime = Date.now();
|
|
64
64
|
if (countDownTimer.current) {
|
|
65
65
|
clearInterval(countDownTimer.current);
|
|
66
66
|
countDownTimer.current = null;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}, []);
|
|
71
71
|
useEffect(() => {
|
|
72
72
|
if (serverTime > 0 || residueTime > 0) {
|
|
73
73
|
let getNowEndTime = residueTime > 0 ? residueTime : endTime - serverTime;
|
|
74
74
|
if (startTime && endTime) {
|
|
75
75
|
if (serverTime <= startTime) {
|
|
76
76
|
getNowEndTime = startTime - serverTime;
|
|
77
77
|
countDownTypeText.current = {
|
|
78
78
|
type: 'start',
|
|
79
79
|
text: startTitleText,
|
|
80
80
|
time: null,
|
|
81
81
|
};
|
|
82
82
|
} else {
|
|
83
83
|
getNowEndTime = endTime - serverTime;
|
|
84
84
|
countDownTypeText.current = {
|
|
85
85
|
type: 'end',
|
|
86
86
|
text: endTitleText,
|
|
87
87
|
time: null,
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
} else {
|
|
91
91
|
countDownTypeText.current = {
|
|
92
92
|
type: 'end',
|
|
93
93
|
text: endTitleText,
|
|
94
94
|
time: null,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
if (getNowEndTime > 0) {
|
|
98
98
|
countDownTimeFormat(getNowEndTime);
|
|
99
99
|
countDownTypeText.current.time = getNowEndTime;
|
|
100
100
|
countDownTypeText.current.type === 'start' &&
|
|
101
101
|
(countDownTypeText.current.endTime = endTime - serverTime);
|
|
102
102
|
changeTimerSetInterval();
|
|
103
103
|
} else {
|
|
104
104
|
countDownTypeText.current = {
|
|
105
105
|
type: 'end',
|
|
106
106
|
text: endTitleText,
|
|
107
107
|
time: 0,
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
return () => {
|
|
112
112
|
countDownTimer.current && clearInterval(countDownTimer.current);
|
|
113
113
|
};
|
|
114
114
|
}, [serverTime]);
|
|
115
115
|
|
|
116
116
|
const changeTimerSetInterval = (recoverState = false) => {
|
|
117
117
|
countDownTimer.current && clearInterval(countDownTimer.current);
|
|
118
118
|
recoverState && changeTimerFunc();
|
|
119
119
|
countDownTimer.current = setInterval(changeTimerFunc, 1000);
|
|
120
120
|
};
|
|
121
121
|
const changeTimerFunc = () => {
|
|
122
122
|
if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
|
|
123
123
|
countDownTypeText.current.time -= diffTimerRef.current.diffTime;
|
|
124
124
|
countDownTypeText.current.type === 'start' &&
|
|
125
125
|
countDownTypeText.current.endTime &&
|
|
126
126
|
(countDownTypeText.current.endTime -= diffTimerRef.current.diffTime);
|
|
127
127
|
console.log(
|
|
128
128
|
'当前id倒计时获取倒计时息屏时间计算差值',
|
|
129
129
|
countDownTimer.current,
|
|
130
130
|
diffTimerRef.current,
|
|
131
131
|
countDownTypeText.current,
|
|
132
132
|
);
|
|
133
133
|
diffTimerRef.current.stopDocumentTime = 0;
|
|
134
134
|
diffTimerRef.current.recoverDocumentTime = 0;
|
|
135
135
|
diffTimerRef.current.diffTime = 0;
|
|
136
136
|
}
|
|
137
137
|
if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
|
|
138
138
|
countDownTypeText.current.time -= 1000;
|
|
139
139
|
countDownTypeText.current.type === 'start' &&
|
|
140
140
|
countDownTypeText.current.endTime &&
|
|
141
141
|
(countDownTypeText.current.endTime -= 1000);
|
|
142
142
|
countDownTimeFormat(countDownTypeText.current.time);
|
|
143
143
|
} else {
|
|
144
144
|
countDownTypeText.current.time = 0;
|
|
145
145
|
countDownTimeFormat(countDownTypeText.current.time);
|
|
146
146
|
countDownTimer.current && clearInterval(countDownTimer.current);
|
|
147
147
|
if (countDownTypeText.current.type === 'start') {
|
|
148
148
|
let triggerStartTimeEndCallBackState = true;
|
|
149
149
|
countDownTypeText.current = Object.assign({}, countDownTypeText.current, {
|
|
150
150
|
type: 'end',
|
|
151
151
|
text: endTitleText,
|
|
152
152
|
});
|
|
153
153
|
countDownTypeText.current.time = countDownTypeText.current.endTime;
|
|
154
154
|
countDownTypeText.current.time && (countDownTypeText.current.time -= 1000);
|
|
155
155
|
if (countDownTypeText.current.time && countDownTypeText.current.time > 0) {
|
|
156
156
|
countDownTimer.current = setInterval(() => {
|
|
157
157
|
if (countDownTypeText.current.time && diffTimerRef.current.diffTime > 0) {
|
|
158
158
|
countDownTypeText.current.time -= diffTimerRef.current.diffTime;
|
|
159
159
|
diffTimerRef.current.stopDocumentTime = 0;
|
|
160
160
|
diffTimerRef.current.recoverDocumentTime = 0;
|
|
161
161
|
diffTimerRef.current.diffTime = 0;
|
|
162
162
|
}
|
|
163
163
|
if (triggerStartTimeEndCallBackState && startTimeEndCallBack) {
|
|
164
164
|
startTimeEndCallBack({
|
|
165
165
|
type: 'start',
|
|
166
166
|
endState: true,
|
|
167
167
|
...info,
|
|
168
168
|
});
|
|
169
169
|
triggerStartTimeEndCallBackState = false;
|
|
170
170
|
}
|
|
171
171
|
if (countDownTypeText.current.time && countDownTypeText.current.time > 1000) {
|
|
172
172
|
countDownTypeText.current.time -= 1000;
|
|
173
173
|
countDownTimeFormat(countDownTypeText.current.time);
|
|
174
174
|
} else {
|
|
175
175
|
endTimeEndCallBack &&
|
|
176
176
|
endTimeEndCallBack({
|
|
177
177
|
type: 'end',
|
|
178
178
|
endState: true,
|
|
179
179
|
...info,
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
}, 1000);
|
|
183
183
|
}
|
|
184
184
|
} else {
|
|
185
185
|
endTimeEndCallBack &&
|
|
186
186
|
endTimeEndCallBack({
|
|
187
187
|
type: 'end',
|
|
188
188
|
endState: true,
|
|
189
189
|
...info,
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
const countDownTimeFormat = (nowEndTime) => {
|
|
195
195
|
let day = Math.floor(nowEndTime / 1000 / 86400);
|
|
196
196
|
let hour = Math.floor((nowEndTime / 1000 / 3600) % 24);
|
|
197
197
|
const minute = Math.floor((nowEndTime / 1000 / 60) % 60);
|
|
198
198
|
const second = Math.floor((nowEndTime / 1000) % 60);
|
|
199
199
|
if (getDaysToHours && day > 0) {
|
|
200
200
|
hour = hour + day * 24;
|
|
201
201
|
day = 0;
|
|
202
202
|
}
|
|
203
203
|
setEndTimeFormat({
|
|
204
204
|
day,
|
|
205
205
|
hour: `${hour}`.padStart(2, '0'),
|
|
206
206
|
minute: `${minute}`.padStart(2, '0'),
|
|
207
207
|
second: `${second}`.padStart(2, '0'),
|
|
208
208
|
});
|
|
209
209
|
};
|
|
210
210
|
const numCustomStyle = numTextColor
|
|
211
211
|
? useRef({ color: numTextColor, backgroundColor: numTextBgColor })
|
|
212
212
|
: useRef({});
|
|
213
213
|
const textCustomStyle = textColor ? useRef({ color: textColor }) : useRef({});
|
|
214
214
|
return (
|
|
215
215
|
<View
|
|
216
216
|
className={classNames(
|
|
217
217
|
countDownStyle['d-count-down'],
|
|
218
218
|
{
|
|
219
219
|
[countDownStyle['d-ios-10-count-down']]: ios10State && !devToolPlatformState,
|
|
220
220
|
},
|
|
221
221
|
{
|
|
222
222
|
[countDownStyle['d-en-count-down']]: isLanguageForEn,
|
|
223
223
|
},
|
|
224
224
|
className,
|
|
225
225
|
)}
|
|
226
226
|
>
|
|
227
227
|
{countDownTypeText.current && countDownTypeText.current.text && (
|
|
228
228
|
<Text className={classNames('d-count-down-title', 'font-jdzht')}>
|
|
229
229
|
{countDownTypeText.current.text}
|
|
230
230
|
</Text>
|
|
231
231
|
)}
|
|
232
232
|
<View className="display-inline-block">
|
|
233
233
|
{fromStartText && <Text className="d-count-from-start">{fromStartText}</Text>}
|
|
234
234
|
{onlyShowDayState && endTimeFormat.day > 0 ? (
|
|
235
235
|
<>
|
|
236
236
|
<Text
|
|
237
237
|
className={classNames('d-count-down-time', 'd-day-time', 'font-jdzht')}
|
|
238
238
|
style={numCustomStyle.current}
|
|
239
239
|
>
|
|
240
240
|
{endTimeFormat.day}
|
|
241
241
|
</Text>
|
|
242
242
|
<Text className="d-time-space-text d-day-space-text" style={textCustomStyle.current}>
|
|
243
243
|
{showDaytimeNumSpaceTextState ? countDownTimeDay : ':'}
|
|
244
244
|
</Text>
|
|
245
245
|
</>
|
|
246
246
|
) : (
|
|
247
247
|
<>
|
|
248
248
|
{(showDayState || showDayToSecondState) && endTimeFormat.day > 0 && (
|
|
249
249
|
<>
|
|
250
250
|
<Text
|
|
251
251
|
className={classNames('d-count-down-time', 'd-day-time', 'font-jdzht')}
|
|
252
252
|
style={numCustomStyle.current}
|
|
253
253
|
>
|
|
254
254
|
{endTimeFormat.day}
|
|
255
255
|
</Text>
|
|
256
256
|
<Text
|
|
257
257
|
className="d-time-space-text d-day-space-text"
|
|
258
258
|
style={textCustomStyle.current}
|
|
259
259
|
>
|
|
260
260
|
{showDaytimeNumSpaceTextState ? countDownTimeDay : ':'}
|
|
261
261
|
</Text>
|
|
262
262
|
</>
|
|
263
263
|
)}
|
|
264
264
|
{showHourState && (
|
|
265
265
|
<>
|
|
266
266
|
<Text
|
|
267
267
|
className={classNames('d-count-down-time', 'd-hour-time', 'font-jdzht')}
|
|
268
268
|
style={numCustomStyle.current}
|
|
269
269
|
>
|
|
270
270
|
{endTimeFormat.hour}
|
|
271
271
|
</Text>
|
|
272
272
|
<Text className="d-time-space-text" style={textCustomStyle.current}>
|
|
273
273
|
{(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
|
|
274
274
|
? countDownTimeHour
|
|
275
275
|
: ':'}
|
|
276
276
|
</Text>
|
|
277
277
|
</>
|
|
278
278
|
)}
|
|
279
279
|
{showMinuteState && (
|
|
280
280
|
<>
|
|
281
281
|
<Text
|
|
282
282
|
className={classNames('d-count-down-time', 'd-minute-time', 'font-jdzht')}
|
|
283
283
|
style={numCustomStyle.current}
|
|
284
284
|
>
|
|
285
285
|
{endTimeFormat.minute}
|
|
286
286
|
</Text>
|
|
287
287
|
<Text className="d-time-space-text" style={textCustomStyle.current}>
|
|
288
288
|
{(endTimeFormat.day > 0 && showDaytimeNumSpaceTextState) || timeNumSpaceTextState
|
|
289
289
|
? countDownTimeMin
|
|
290
290
|
: endTimeFormat.day > 0
|
|
291
291
|
? ''
|
|
292
292
|
: ':'}
|
|
293
293
|
</Text>
|
|
294
294
|
</>
|
|
295
295
|
)}
|
|
296
296
|
{showSecondState && (endTimeFormat.day <= 0 || showDayToSecondState) && (
|
|
297
297
|
<>
|
|
298
298
|
<Text
|
|
299
299
|
className={classNames('d-count-down-time', 'd-second-time', 'font-jdzht')}
|
|
300
300
|
style={numCustomStyle.current}
|
|
301
301
|
>
|
|
302
302
|
{endTimeFormat.second}
|
|
303
303
|
</Text>
|
|
304
304
|
{(timeNumSpaceTextState ||
|
|
305
305
|
(showDayToSecondState && showDaytimeNumSpaceTextState)) && (
|
|
306
306
|
<Text className="d-time-space-text" style={textCustomStyle.current}>
|
|
307
307
|
秒
|
|
308
308
|
</Text>
|
|
309
309
|
)}
|
|
310
310
|
</>
|
|
311
311
|
)}
|
|
312
312
|
</>
|
|
313
313
|
)}
|
|
314
314
|
{fromEndText && <Text className="d-count-from-end">{fromEndText}</Text>}
|
|
315
315
|
</View>
|
|
316
316
|
</View>
|
|
317
317
|
);
|
|
318
318
|
return useMemo(() => {
|
|
319
319
|
return <CountDownTimer {...props} />;
|
|
320
320
|
}, []);
|
|
321
321
|
residueTime: -1,
|
|
322
322
|
serverTime: null,
|
|
323
323
|
className: null,
|
|
324
324
|
startTime: null,
|
|
325
325
|
endTime: null,
|
|
326
326
|
info: null,
|
|
327
327
|
startTitleText: '距活动开始',
|
|
328
328
|
endTitleText: '距活动结束',
|
|
329
329
|
fromEndText: null,
|
|
330
330
|
startTimeEndCallBack: null,
|
|
331
331
|
endTimeEndCallBack: null,
|
|
332
332
|
timeNumSpaceTextState: false,
|
|
333
333
|
showDaytimeNumSpaceTextState: true,
|
|
334
334
|
onlyShowDayState: false,
|
|
335
335
|
showDayState: false,
|
|
336
336
|
showDayToSecondState: false,
|
|
337
337
|
getDaysToHours: false,
|
|
338
338
|
showHourState: true,
|
|
339
339
|
showMinuteState: true,
|
|
340
340
|
showSecondState: true,
|
|
341
341
|
numTextColor: null,
|
|
342
342
|
textColor: null,
|
|
343
343
|
numTextBgColor: null,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
isH5AndJdShopView,
|
|
1
3
|
isAndroidDevice,
|
|
2
4
|
isJdAndAndroidDevice,
|
|
3
5
|
isJdAndIosDevice,
|
|
4
6
|
isIosDevice,
|
|
5
7
|
isJdApp,
|
|
6
8
|
isWxMin,
|
|
7
9
|
isH5AndJdShopViewH5Scroll,
|
|
8
10
|
isH5AndJdShopH5CustomScrollView,
|
|
9
11
|
isH5,
|
|
10
12
|
isAppClassifyPage,
|
|
11
13
|
lodashThrottle,
|
|
12
14
|
START: 'start',
|
|
13
15
|
MOVE: 'move',
|
|
14
16
|
END: 'end',
|
|
15
17
|
const {
|
|
16
18
|
style = {},
|
|
17
19
|
scrollX = false,
|
|
18
20
|
scrollY = false,
|
|
19
21
|
scrollWithAnimation = true,
|
|
20
22
|
iosNeedDisableVertical = false,
|
|
21
23
|
className = null,
|
|
22
24
|
dispatchTouchMove = true,
|
|
23
25
|
children,
|
|
24
26
|
...otherProps
|
|
25
27
|
} = props;
|
|
26
28
|
const rootEleNode = isH5 && document?.querySelector('body');
|
|
27
29
|
const needShowHighVersion =
|
|
28
30
|
isH5AndJdShopViewH5Scroll && global.info.queryInfo?.downgraded !== 'true';
|
|
29
31
|
const mLastClientPosRef = useRef({
|
|
30
32
|
mLastClientX: 0,
|
|
31
33
|
mLastClientY: 0,
|
|
32
34
|
});
|
|
33
35
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
|
|
34
36
|
|
|
35
37
|
const touchstartEventBubbleFunc = (e) => {
|
|
36
38
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
37
39
|
if (!isH5SwiperCustomEle) {
|
|
38
40
|
const hasCustomEle = e
|
|
39
41
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
40
42
|
: false;
|
|
41
43
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
42
44
|
window.JdAndroid && window.JdAndroid.requestEvent(false);
|
|
43
45
|
}
|
|
44
46
|
!hasCustomEle &&
|
|
45
47
|
rootEleNode &&
|
|
46
48
|
rootEleNode.classList.contains('over-hidden') &&
|
|
47
49
|
rootEleNode.classList.remove('over-hidden');
|
|
48
50
|
}
|
|
49
51
|
};
|
|
50
52
|
const touchstartEventCaptureFunc = (e) => {
|
|
51
53
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
|
|
52
54
|
rootEleNode &&
|
|
53
55
|
rootEleNode.classList.contains('over-hidden') &&
|
|
54
56
|
rootEleNode.classList.remove('over-hidden');
|
|
55
57
|
}
|
|
56
58
|
};
|
|
57
59
|
useEffect(() => {
|
|
58
60
|
isJdApp &&
|
|
59
61
|
!window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
60
62
|
nativePageGetScaledTouchSlop((res) => {
|
|
61
63
|
console.log('获取安卓系统滑动阈值', res);
|
|
62
64
|
window.JDJshopViewInfo.androidTouchSlop = res;
|
|
63
65
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true;
|
|
64
66
|
});
|
|
65
67
|
if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
|
|
66
68
|
global?.removeJdAndroidRquestEventForTouchStart &&
|
|
67
69
|
global.removeJdAndroidRquestEventForTouchStart();
|
|
68
70
|
rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
69
71
|
|
|
70
72
|
rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
71
73
|
rootEleAddEventListenerState = true;
|
|
72
74
|
console.log('customScrollView 初始化document监听完成');
|
|
73
75
|
}
|
|
74
76
|
return () => {
|
|
75
77
|
if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
|
|
76
78
|
console.log('customScrollView document监听取消完成');
|
|
77
79
|
rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
78
80
|
rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
79
81
|
}
|
|
80
82
|
};
|
|
81
83
|
}, []);
|
|
82
84
|
|
|
83
85
|
const androidDeviceStopNativeScrollEvent = (touchType) => {
|
|
84
86
|
isJdApp &&
|
|
85
87
|
isAndroidDevice &&
|
|
86
88
|
window?.JdAndroid &&
|
|
87
89
|
window?.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
88
90
|
};
|
|
89
91
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
90
92
|
sendIosState && iosDeviceSendRouter(touchType);
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
const iosDeviceSendRouter = (state: string) => {
|
|
94
96
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
95
97
|
method: 'callRouterModuleWithParams',
|
|
96
98
|
params: {
|
|
97
99
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
98
100
|
routerParam: {
|
|
99
101
|
slideDirection: 'horizontal',
|
|
100
102
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
101
103
|
state,
|
|
102
104
|
},
|
|
103
105
|
callBackId: new Date().getTime(),
|
|
104
106
|
},
|
|
105
107
|
});
|
|
106
108
|
};
|
|
107
109
|
const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
|
|
108
110
|
if (isJdApp) {
|
|
109
111
|
if (isIosDevice && !isAppClassifyPage) {
|
|
110
112
|
iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
|
|
111
113
|
} else if (isAndroidDevice) {
|
|
112
114
|
androidDeviceStopNativeScrollEvent(touchType);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
const GetSlideAngle = (dx, dy) => {
|
|
118
120
|
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
119
121
|
};
|
|
120
122
|
|
|
121
123
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
122
124
|
const dy = startY - endY;
|
|
123
125
|
const dx = endX - startX;
|
|
124
126
|
let result = 0;
|
|
125
127
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
126
128
|
return result;
|
|
127
129
|
}
|
|
128
130
|
const angle = GetSlideAngle(dx, dy);
|
|
129
131
|
if (angle >= -45 && angle < 45) {
|
|
130
132
|
result = 4;
|
|
131
133
|
} else if (angle >= 45 && angle < 135) {
|
|
132
134
|
result = 1;
|
|
133
135
|
} else if (angle >= -135 && angle < -45) {
|
|
134
136
|
result = 2;
|
|
135
137
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
136
138
|
result = 3;
|
|
137
139
|
}
|
|
138
140
|
return result;
|
|
139
141
|
};
|
|
140
142
|
const changeTouchStart = (e) => {
|
|
141
143
|
if (isJdApp) {
|
|
142
144
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
|
|
143
145
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
144
146
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
145
147
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
146
148
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
|
|
147
149
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
};
|
|
151
153
|
const changeTouchEnd = (e) => {
|
|
152
154
|
stopNativeScrollEvent(e, TouchType.END);
|
|
153
155
|
mLastClientPosRef.current.mLastClientX = 0;
|
|
154
156
|
mLastClientPosRef.current.mLastClientY = 0;
|
|
155
157
|
};
|
|
156
158
|
const triggerIosTouchMove = () => {
|
|
157
159
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
|
|
158
160
|
};
|
|
159
161
|
|
|
160
162
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
|
|
161
163
|
|
|
162
164
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
163
165
|
const direction = GetSlideDirection(
|
|
164
166
|
mLastClientPosRef.current.mLastClientX,
|
|
165
167
|
mLastClientPosRef.current.mLastClientY,
|
|
166
168
|
touchEvent.clientX,
|
|
167
169
|
touchEvent.clientY,
|
|
168
170
|
);
|
|
169
171
|
if (direction === 1 || direction === 2) {
|
|
170
172
|
rootEleNode &&
|
|
171
173
|
rootEleNode.classList.contains('over-hidden') &&
|
|
172
174
|
rootEleNode.classList.remove('over-hidden');
|
|
173
175
|
}
|
|
174
176
|
};
|
|
175
177
|
const changeTouchMove = (e) => {
|
|
176
178
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
177
179
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
178
180
|
const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
|
|
179
181
|
2,
|
|
180
182
|
);
|
|
181
183
|
const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
|
|
182
184
|
2,
|
|
183
185
|
);
|
|
184
186
|
if (isJdApp) {
|
|
185
187
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
186
188
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
|
|
187
189
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
188
190
|
stopNativeScrollEvent(e, TouchType.END);
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
|
|
192
194
|
}
|
|
193
195
|
if (!dispatchTouchMove) {
|
|
194
196
|
return;
|
|
195
197
|
}
|
|
196
198
|
const parentNode = e.target?.parentNode;
|
|
197
199
|
if (!parentNode) {
|
|
198
200
|
return;
|
|
199
201
|
}
|
|
200
202
|
const event = new TouchEvent('touchmove', e);
|
|
201
203
|
parentNode.dispatchEvent(event);
|
|
202
204
|
};
|
|
203
205
|
if (scrollX && isJdApp && !isIgnorePreventNative) {
|
|
204
206
|
return (
|
|
205
207
|
<ScrollView
|
|
206
208
|
scrollX
|
|
207
209
|
onTouchStart={changeTouchStart}
|
|
208
210
|
onTouchEnd={changeTouchEnd}
|
|
209
211
|
onTouchCancel={changeTouchEnd}
|
|
210
212
|
onTouchMove={changeTouchMove}
|
|
211
213
|
enhanced
|
|
212
214
|
showScrollbar={false}
|
|
213
215
|
style={style}
|
|
214
216
|
className={classNames(
|
|
215
217
|
className,
|
|
216
218
|
{
|
|
217
219
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
218
220
|
},
|
|
219
221
|
'J_customScroll',
|
|
220
222
|
)}
|
|
221
223
|
scrollY
|
|
222
224
|
scrollWithAnimation
|
|
223
225
|
{...otherProps}
|
|
224
226
|
>
|
|
225
227
|
{children}
|
|
226
228
|
</ScrollView>
|
|
227
229
|
);
|
|
228
230
|
} else {
|
|
229
231
|
return (
|
|
230
232
|
<ScrollView
|
|
231
233
|
scrollX
|
|
232
234
|
scrollY
|
|
233
235
|
scrollWithAnimation
|
|
234
236
|
enhanced
|
|
235
237
|
showScrollbar={false}
|
|
236
238
|
{...otherProps}
|
|
237
239
|
className={classNames(
|
|
238
240
|
className,
|
|
239
241
|
{
|
|
240
242
|
[customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
|
|
241
243
|
isIosDevice && isWxMin && scrollX && style['borderRadius'],
|
|
242
244
|
},
|
|
243
245
|
{
|
|
244
246
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
245
247
|
},
|
|
246
248
|
{
|
|
247
249
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
|
|
248
250
|
},
|
|
249
251
|
)}
|
|
250
252
|
style={style}
|
|
251
253
|
>
|
|
252
254
|
{children}
|
|
253
255
|
</ScrollView>
|
|
254
256
|
);
|
|
255
257
|
}
|