|
@@ -7,7 +7,7 @@ import { videoListV2 } from '@/http/api'
|
|
|
import VideoSwiper from '@/components/VideoSwiper'
|
|
|
import { sharePageAppMessage } from '@/shareHelper'
|
|
|
import Route from '@/class/Route'
|
|
|
-import { filterCardProps, pxToRpx } from '@/utils/index'
|
|
|
+import { filterCardProps, pxToRpx, pageHeight } from '@/utils/index'
|
|
|
import { CATEGORY_PAGESOURCE } from '@/const/index'
|
|
|
|
|
|
// import { getTopSafeHeight, throttle, formatSecondsAsTime, getPreIds } from '@/utils'
|
|
@@ -29,6 +29,8 @@ export default function Index() {
|
|
|
const [toSharePage, setToSharePage] = useState(false)
|
|
|
const [flushList, setFlushList] = useState(false)
|
|
|
const [botHeight, setBotHeight] = useState(0)
|
|
|
+ const [showNoView, setShowNoView] = useState(false)
|
|
|
+
|
|
|
useLoad(() => {
|
|
|
const { redirect } = params
|
|
|
let dur = 0
|
|
@@ -43,10 +45,8 @@ export default function Index() {
|
|
|
fecthVideoListV2()
|
|
|
}, dur);
|
|
|
|
|
|
- const systemInfo = Taro.$global.get('systemInfo')
|
|
|
- let { screenHeight = 0 } = systemInfo
|
|
|
- let { bottom = 0 } = systemInfo.safeArea || {}
|
|
|
- setBotHeight(screenHeight - bottom)
|
|
|
+ setBotHeight(pageHeight())
|
|
|
+
|
|
|
})
|
|
|
|
|
|
useDidShow(() => {
|
|
@@ -67,7 +67,13 @@ export default function Index() {
|
|
|
})
|
|
|
|
|
|
usePullDownRefresh(() => {
|
|
|
- console.log('usePullDownRefresh')
|
|
|
+ console.log('usePullDownRefresh', activeIndex)
|
|
|
+
|
|
|
+ if (activeIndex ==0 ) {
|
|
|
+ fecthVideoListV2(true)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
})
|
|
|
|
|
|
useShareAppMessage((shareRes) => {
|
|
@@ -81,6 +87,11 @@ export default function Index() {
|
|
|
|
|
|
// const fecthVideoList = throttle(fecthVideoListV2)
|
|
|
function fecthVideoListV2(cleanOldCardList = false) {
|
|
|
+ if (refresherTriggered) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setRefresherTriggered(true)
|
|
|
+
|
|
|
if (cleanOldCardList)
|
|
|
pageNo = 1
|
|
|
|
|
@@ -98,7 +109,6 @@ export default function Index() {
|
|
|
|
|
|
if (cleanOldCardList) {
|
|
|
oldCardList = []
|
|
|
- setRefresherTriggered(false)
|
|
|
}
|
|
|
|
|
|
pageNo++
|
|
@@ -114,17 +124,31 @@ export default function Index() {
|
|
|
}, 300);
|
|
|
}
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
+ setRefresherTriggered(false)
|
|
|
+ }, 300);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
+ setRefresherTriggered(false)
|
|
|
+ if (videoList.length == 0) {
|
|
|
+ setShowNoView(true)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ function onSwiperRefresh() {
|
|
|
+ showNoView && setShowNoView(false)
|
|
|
|
|
|
- function onAnimationFinish(current) {
|
|
|
- if (current == -99) {
|
|
|
+ if (activeIndex ==0 ) {
|
|
|
fecthVideoListV2(true)
|
|
|
-
|
|
|
- return
|
|
|
}
|
|
|
+ // fecthVideoListV2()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function onAnimationFinish(current) {
|
|
|
activeIndex = current
|
|
|
if (current >= videoList.length - 4) {
|
|
|
fecthVideoListV2()
|
|
@@ -133,11 +157,13 @@ export default function Index() {
|
|
|
|
|
|
return (
|
|
|
<View className='category-page' style={{ height: 'calc(100% - ' + `${Math.floor(pxToRpx(55))}px - ` + `${botHeight}px);` }}>
|
|
|
+ {showNoView && <View className='noData' onClick={onSwiperRefresh}>请刷新重试</View>}
|
|
|
<VideoSwiper
|
|
|
list={videoList}
|
|
|
flushList={flushList}
|
|
|
needResumePlay={needResumePlay}
|
|
|
onFinish={onAnimationFinish}
|
|
|
+ onRefresh={onSwiperRefresh}
|
|
|
/>
|
|
|
|
|
|
</View>
|