李志伟 3 years ago
parent
commit
9978483e41
3 changed files with 24 additions and 8 deletions
  1. 0
    3
      src/pages/bankCard/index.jsx
  2. 23
    4
      src/pages/wallet/index.jsx
  3. 1
    1
      src/pages/withdrawal/index.jsx

+ 0
- 3
src/pages/bankCard/index.jsx View File

53
       })
53
       })
54
     })
54
     })
55
   }
55
   }
56
-  useEffect(() => {
57
-    getList()
58
-  }, [])
59
   return (
56
   return (
60
     <View className='page-index'>
57
     <View className='page-index'>
61
       <View className='index-navbar'>
58
       <View className='index-navbar'>

+ 23
- 4
src/pages/wallet/index.jsx View File

12
 export default withLayout((props) => {
12
 export default withLayout((props) => {
13
   const [balance, setBlance] = useState(0)
13
   const [balance, setBlance] = useState(0)
14
   const [logList, setLogList] = useState([])
14
   const [logList, setLogList] = useState([])
15
+  const [currentPage, setCurrentPage] = useState(1)
16
+  const [isMore, setIsMore] = useState(false)
15
   const goWithdrawal = () => {
17
   const goWithdrawal = () => {
16
     Taro.navigateTo({ url: `/pages/withdrawal/index?balance=${balance}` });
18
     Taro.navigateTo({ url: `/pages/withdrawal/index?balance=${balance}` });
17
   }
19
   }
20
+
21
+  // 上拉加载
22
+  const handleScrollToLower = () => {
23
+    setCurrentPage(currentPage + 1)
24
+  }
18
   const getList = () => {
25
   const getList = () => {
19
     getAccount().then(res => {
26
     getAccount().then(res => {
20
       setBlance(res.amounts / 100)
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
   useEffect(() => {
41
   useEffect(() => {
27
     getList()
42
     getList()
28
   }, [])
43
   }, [])
32
         <CustomNav title='我的钱包' />
47
         <CustomNav title='我的钱包' />
33
       </View>
48
       </View>
34
       <View className='index-container wallet'>
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
           <WalletCard onClick={goWithdrawal} value={balance} />
55
           <WalletCard onClick={goWithdrawal} value={balance} />
37
           <ListTitle value='零钱明细' />
56
           <ListTitle value='零钱明细' />
38
           {
57
           {

+ 1
- 1
src/pages/withdrawal/index.jsx View File

65
     Taro.navigateTo({ url: '/pages/addBankCard/index' });
65
     Taro.navigateTo({ url: '/pages/addBankCard/index' });
66
   }
66
   }
67
   const getList = () => {
67
   const getList = () => {
68
-    getBankList().then(res => {
68
+    getBankList({pageSize:500}).then(res => {
69
       if (res.records.length != 0) {
69
       if (res.records.length != 0) {
70
         setBankList(res.records)
70
         setBankList(res.records)
71
         setBankContentList(res.records.map(item => {
71
         setBankContentList(res.records.map(item => {