李志伟 3 vuotta sitten
vanhempi
commit
7e003922ea
2 muutettua tiedostoa jossa 24 lisäystä ja 10 poistoa
  1. 7
    1
      src/pages/index/tabs/Recommend.jsx
  2. 17
    9
      src/pages/searchResult/searchResult.jsx

+ 7
- 1
src/pages/index/tabs/Recommend.jsx Näytä tiedosto

34
       setQueryParams({ location: location, pageNum: 1, pageSize: 10, typeId: '' })
34
       setQueryParams({ location: location, pageNum: 1, pageSize: 10, typeId: '' })
35
     }
35
     }
36
   }
36
   }
37
-
37
+  const [total,setTotal]=useState()
38
   useEffect(() => {
38
   useEffect(() => {
39
     //查询分类标签表
39
     //查询分类标签表
40
     getIndexType({ pageSize: 20 }).then((res) => {
40
     getIndexType({ pageSize: 20 }).then((res) => {
41
       setTypeList(res.records || [])
41
       setTypeList(res.records || [])
42
+    })
43
+    getResourceList(queryParams).then((res)=>{
44
+      setTotal(res.total)
42
     })    
45
     })    
43
   }, [])
46
   }, [])
47
+
48
+
44
   const onSearch = () => {
49
   const onSearch = () => {
45
     // 用绝对路径
50
     // 用绝对路径
46
     Taro.navigateTo({ url: '/pages/search/search' });
51
     Taro.navigateTo({ url: '/pages/search/search' });
85
             alllist.map((item) => <Card key={item.resourceNo} item={item} />)
90
             alllist.map((item) => <Card key={item.resourceNo} item={item} />)
86
           }
91
           }
87
         </view>
92
         </view>
93
+          <view className='botton' style={{display:alllist.length==total?'':'none'}}>已经到底了~</view>
88
       </List>
94
       </List>
89
     </view>
95
     </view>
90
   )
96
   )

+ 17
- 9
src/pages/searchResult/searchResult.jsx Näytä tiedosto

5
 import Taro from '@tarojs/taro'
5
 import Taro from '@tarojs/taro'
6
 import Card from '../index/components/Card'
6
 import Card from '../index/components/Card'
7
 import {getResourceList } from '@/services/home'
7
 import {getResourceList } from '@/services/home'
8
+import List from '@/components/List';
8
 import './searchResult.less'
9
 import './searchResult.less'
9
 import withLayout from '@/layouts'
10
 import withLayout from '@/layouts'
10
 
11
 
51
     // 用绝对路径
52
     // 用绝对路径
52
     Taro.navigateTo({ url: '/pages/search/search' });
53
     Taro.navigateTo({ url: '/pages/search/search' });
53
   }
54
   }
55
+  const [total,setTotal]=useState()
54
 
56
 
55
   useEffect(() => {
57
   useEffect(() => {
56
     getResourceList(queryParams).then((res) => {
58
     getResourceList(queryParams).then((res) => {
57
-      setAllList(res.records || [])
59
+      setTotal(res.total)
58
     })
60
     })
59
   }, [queryParams])
61
   }, [queryParams])
60
 
62
 
82
           >
84
           >
83
           </mp-tabs>
85
           </mp-tabs>
84
         </view>
86
         </view>
87
+        <List
88
+        style={{ height: 'calc(100% - 160px)' }}
89
+        request={getResourceList}
90
+        params={queryParams}
91
+        onDataChange={setAllList}
92
+      >
93
+        <view className='waterfall'>
94
+          {
95
+            alllist.map((item) => <Card key={item.resourceNo} item={item} />)
96
+          }
97
+        </view>
98
+          <view className='botton' style={{display:alllist.length==total?'none':''}}>已经到底了~</view>
99
+      </List>
100
+
85
 
101
 
86
-        <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" style={{height:'100vh'}} >
87
-          <view className="waterfall">
88
-            {
89
-              alllist?.map((item) => <Card key={item.resourceNo} item={item} />)
90
-            }
91
-          </view>
92
-          <view className='botton'>已经到底了~</view>
93
-        </scroll-view>
94
       </view>
102
       </view>
95
     </view>
103
     </view>
96
   )
104
   )