|
@@ -12,17 +12,32 @@ import './style.less'
|
12
|
12
|
export default withLayout((props) => {
|
13
|
13
|
const [balance, setBlance] = useState(0)
|
14
|
14
|
const [logList, setLogList] = useState([])
|
|
15
|
+ const [currentPage, setCurrentPage] = useState(1)
|
|
16
|
+ const [isMore, setIsMore] = useState(false)
|
15
|
17
|
const goWithdrawal = () => {
|
16
|
18
|
Taro.navigateTo({ url: `/pages/withdrawal/index?balance=${balance}` });
|
17
|
19
|
}
|
|
20
|
+
|
|
21
|
+ // 上拉加载
|
|
22
|
+ const handleScrollToLower = () => {
|
|
23
|
+ setCurrentPage(currentPage + 1)
|
|
24
|
+ }
|
18
|
25
|
const getList = () => {
|
19
|
26
|
getAccount().then(res => {
|
20
|
27
|
setBlance(res.amounts / 100)
|
21
|
28
|
})
|
22
|
|
- getLogList().then(res => {
|
23
|
|
- setLogList(res.records)
|
24
|
|
- })
|
25
|
29
|
}
|
|
30
|
+ useEffect(() => {
|
|
31
|
+ getLogList({ pageNum: currentPage }).then(res => {
|
|
32
|
+ const lst = currentPage === 1 ? res.records || [] : logList.concat(res.records || [])
|
|
33
|
+ //长列表加载当下一页没有数据时
|
|
34
|
+ if (res.records.length == 0 && currentPage != 1) {
|
|
35
|
+ setIsMore(true)
|
|
36
|
+ return
|
|
37
|
+ }
|
|
38
|
+ setLogList(lst)
|
|
39
|
+ })
|
|
40
|
+ }, [currentPage])
|
26
|
41
|
useEffect(() => {
|
27
|
42
|
getList()
|
28
|
43
|
}, [])
|
|
@@ -32,7 +47,11 @@ export default withLayout((props) => {
|
32
|
47
|
<CustomNav title='我的钱包' />
|
33
|
48
|
</View>
|
34
|
49
|
<View className='index-container wallet'>
|
35
|
|
- <ScrollView scrollY style={{ height: '100%' }}>
|
|
50
|
+ <ScrollView
|
|
51
|
+ scrollY
|
|
52
|
+ style={{ height: '100%' }}
|
|
53
|
+ onScrollToLower={isMore ? '' : handleScrollToLower}
|
|
54
|
+ >
|
36
|
55
|
<WalletCard onClick={goWithdrawal} value={balance} />
|
37
|
56
|
<ListTitle value='零钱明细' />
|
38
|
57
|
{
|