李志伟 3 years ago
parent
commit
a2cc04dc41

+ 2
- 1
config/dev.js View File

3
     NODE_ENV: '"development"',
3
     NODE_ENV: '"development"',
4
   },
4
   },
5
   defineConstants: {
5
   defineConstants: {
6
-    HOST: '"https://machine.njyunzhi.com"',
6
+    HOST: '"http://192.168.89.147:7080"',
7
+    // HOST: '"https://machine.njyunzhi.com"',
7
     // OSS: '"yz-shigongli.oss-accelerate.aliyuncs.com"',
8
     // OSS: '"yz-shigongli.oss-accelerate.aliyuncs.com"',
8
     // VERSION: '"3.0.3_2021-12-23"',
9
     // VERSION: '"3.0.3_2021-12-23"',
9
   },
10
   },

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

1
 import Taro from "@tarojs/taro";
1
 import Taro from "@tarojs/taro";
2
-import { useEffect, useState } from "react";
2
+import { useEffect } from "react";
3
 import { View, Image } from "@tarojs/components"
3
 import { View, Image } from "@tarojs/components"
4
 import withLayout from '@/layouts'
4
 import withLayout from '@/layouts'
5
 import CustomNav from "@/components/CustomNav";
5
 import CustomNav from "@/components/CustomNav";
6
-import LoginModel from "@/components/LoginModel";
7
 import indexImg from "@/assets/comm/index.png";
6
 import indexImg from "@/assets/comm/index.png";
8
 import indexActive from "@/assets/comm/indexActive.png";
7
 import indexActive from "@/assets/comm/indexActive.png";
9
 import job from "@/assets/comm/job.png";
8
 import job from "@/assets/comm/job.png";

+ 4
- 0
src/pages/machineryList/Card/style.less View File

17
     .machineryName{
17
     .machineryName{
18
       font-size: 36px;
18
       font-size: 36px;
19
       color: #222222;
19
       color: #222222;
20
+      width: 65vw;
21
+      text-overflow: ellipsis;
22
+      white-space: nowrap;
23
+      overflow: hidden;
20
     }
24
     }
21
     .goMap{
25
     .goMap{
22
       position: absolute;
26
       position: absolute;

+ 38
- 10
src/pages/machineryList/index.jsx View File

1
 import { useEffect, useState } from "react"
1
 import { useEffect, useState } from "react"
2
-import Taro from "@tarojs/taro"
2
+import Taro, {useDidShow}from "@tarojs/taro"
3
 import { View, ScrollView } from "@tarojs/components"
3
 import { View, ScrollView } from "@tarojs/components"
4
 import CustomNav from "@/components/CustomNav"
4
 import CustomNav from "@/components/CustomNav"
5
 import NullCard from "@/components/NullCard";
5
 import NullCard from "@/components/NullCard";
6
+import Footer from "@/components/Footer";
6
 import withLayout from '@/layouts'
7
 import withLayout from '@/layouts'
7
-import { getMachineryList } from '@/services/machinery'
8
 import { useModel } from "@/store"
8
 import { useModel } from "@/store"
9
+import { getMachineryList } from '@/services/machinery'
9
 import MachineryCard from './Card'
10
 import MachineryCard from './Card'
10
 import './style.less'
11
 import './style.less'
11
 
12
 
12
 export default withLayout((props) => {
13
 export default withLayout((props) => {
13
   const { location } = useModel('location')
14
   const { location } = useModel('location')
14
   const [machinery, setMachinery] = useState([])
15
   const [machinery, setMachinery] = useState([])
16
+  const [currentPage, setCurrentPage] = useState(1)
17
+  const [isMore, setIsMore] = useState(false)
18
+
15
   const goDetail = (val) => {
19
   const goDetail = (val) => {
16
     Taro.navigateTo({ url: `/pages/machineryDetail/index?id=${val}` });
20
     Taro.navigateTo({ url: `/pages/machineryDetail/index?id=${val}` });
17
   }
21
   }
18
   const goMap = (val) => {
22
   const goMap = (val) => {
19
     Taro.navigateTo({ url: `/pages/machineryMap/index?id=${val}` });
23
     Taro.navigateTo({ url: `/pages/machineryMap/index?id=${val}` });
20
   }
24
   }
21
-  useEffect(() => {
22
-    getMachineryList({ location: location }).then((res) => {
23
-      setMachinery(res.records)
25
+   // 上拉加载
26
+   const handleScrollToLower = () => {
27
+    setCurrentPage(currentPage + 1)
28
+  }
29
+  const getList = () => {
30
+    getMachineryList({ location: location,pageNum: currentPage }).then(res => {
31
+      const lst = currentPage === 1 ? res.records || [] : machinery.concat(res.records || [])
32
+      //长列表加载当下一页没有数据时
33
+      if (res.records.length == 0 && currentPage != 1) {
34
+        setIsMore(true)
35
+        return
36
+      }
37
+      setMachinery(lst)
24
     })
38
     })
25
-  }, [location])
39
+  }
40
+  useDidShow(() => {
41
+    getList();
42
+  })
43
+  useEffect(() => {
44
+    getList();
45
+  }, [currentPage,location])
46
+  
26
   return (
47
   return (
27
     <View className='page-index'>
48
     <View className='page-index'>
28
       <View className='index-navbar'>
49
       <View className='index-navbar'>
29
         <CustomNav title='农机列表' />
50
         <CustomNav title='农机列表' />
30
       </View>
51
       </View>
31
       <View className='index-container machineryListContent'>
52
       <View className='index-container machineryListContent'>
32
-        <ScrollView scrollY style={{ height: '100%' }}>
53
+        <ScrollView scrollY
54
+          enhanced
55
+          onScrollToLower={isMore ? '' : handleScrollToLower}
56
+          style={{ height: '100%' }}
57
+        >
33
           {
58
           {
34
             machinery.length === 0 ? <NullCard value='您还没有农机!' /> :
59
             machinery.length === 0 ? <NullCard value='您还没有农机!' /> :
35
-            machinery?.map((item) => {
36
-              return <MachineryCard value={item} key={item.machineryId} onClick={() => goDetail(item.machineryId)} goMap={() => goMap(item.machineryId)} />
37
-            })
60
+              machinery?.map((item) => {
61
+                return <MachineryCard value={item} key={item.machineryId} onClick={() => goDetail(item.machineryId)} goMap={() => goMap(item.machineryId)} />
62
+              })
63
+          }
64
+          {
65
+            machinery.length === 0 || isMore && <Footer />
38
           }
66
           }
39
         </ScrollView>
67
         </ScrollView>
40
       </View>
68
       </View>