|
@@ -1,35 +1,80 @@
|
1
|
1
|
|
2
|
2
|
import { View, Swiper, Image, SwiperItem, Text, Input } from "@tarojs/components"
|
|
3
|
+import { useEffect, useState, useMemo } from "react"
|
|
4
|
+import Taro, { useReachBottom } from "@tarojs/taro"
|
3
|
5
|
import ButtontWX from '@/components/ButtontWX'
|
4
|
|
-import Taro from "@tarojs/taro"
|
5
|
6
|
import addresss from '@/assets/mineImgaes/addresss.png'//地址
|
6
|
7
|
import searchs from '@/assets/homesImgaes/searchs.png'//搜索图片
|
7
|
8
|
import carsListImga from '@/assets/homesImgaes/carsListImga.png'//农机列表图片
|
8
|
9
|
|
|
10
|
+import { getHomeBanner, getMachinery, } from "@/services/homes"
|
|
11
|
+
|
9
|
12
|
|
10
|
13
|
|
11
|
14
|
import './HomesCss/style.less'
|
12
|
15
|
|
13
|
16
|
export default (props) => {
|
14
|
|
- // const { SwiperItem } = Swiper
|
15
|
|
-
|
16
|
|
- const carsList = [
|
17
|
|
- { carsName: '联合收割机', carsUrl: 'http://img3.jc001.cn/img/001/1/1512/15566fd0311736f.jpg', jiage: '300', carsLocation: '3.9' },
|
18
|
|
- { carsName: '水稻播种机', carsUrl: 'http://img3.jc001.cn/img/001/1/1512/15566fd031719b1.jpg', jiage: '300', carsLocation: '3.9' },
|
19
|
|
- { carsName: '秸秆统一处理 型号:GB2312', carsUrl: 'http://img3.jc001.cn/img/001/1/1512/15566fd03201503.jpg', jiage: '免费', carsLocation: '3.9' },
|
20
|
|
- { carsName: '花生稻子小麦收割一体机', carsUrl: 'http://img3.jc001.cn/img/001/1/1512/15566fd0324f649.jpg', jiage: '550', carsLocation: '3.9' },
|
21
|
|
- { carsName: '拖拉机', carsUrl: 'https://image.cnhnb.com/image/jpg/miniapp/2020/03/26/ef945970d2cc4948b61d45ce57ac1179.jpg', jiage: '180', carsLocation: '3.9' },
|
22
|
|
- { carsName: '自行车', carsUrl: 'https://image.cnhnb.com/image/jpg/miniapp/2020/03/26/e8745759793d48398f82e6658186686a.jpg', jiage: '20', carsLocation: '3.9' },
|
23
|
|
- ]
|
24
|
|
-
|
25
|
|
- const imglist = [
|
26
|
|
- { url: 'https://profile.csdnimg.cn/3/1/5/0_qq_42551866' },
|
27
|
|
- { url: 'https://profile.csdnimg.cn/3/1/5/0_qq_42551866' },
|
28
|
|
- { url: 'https://profile.csdnimg.cn/3/1/5/0_qq_42551866' },
|
29
|
|
- { url: 'https://profile.csdnimg.cn/3/1/5/0_qq_42551866' },
|
30
|
|
- { url: 'https://profile.csdnimg.cn/3/1/5/0_qq_42551866' },
|
31
|
|
- { url: 'https://profile.csdnimg.cn/3/1/5/0_qq_42551866' },
|
32
|
|
- ]
|
|
17
|
+ const location = Taro.getStorageSync('location')
|
|
18
|
+ const [bannerHome, setBannerHome] = useState([])
|
|
19
|
+ const [carsList, setCarsList] = useState([])
|
|
20
|
+
|
|
21
|
+ let pageSize = 10;//每页加载的数据量
|
|
22
|
+ let pageNum = 1;//当前页
|
|
23
|
+ let totalPage = 0;//总页数
|
|
24
|
+ let resultData = [];
|
|
25
|
+
|
|
26
|
+ useEffect(() => {
|
|
27
|
+ getHomeBanner({ position: 'banner' }).then((e) => {
|
|
28
|
+ console.log('e', e);
|
|
29
|
+ // let bame = e.filter(ele => ele.position == "banner")
|
|
30
|
+ setBannerHome(e)
|
|
31
|
+ })
|
|
32
|
+ getMachinery(location, {
|
|
33
|
+ pageSize: 3,
|
|
34
|
+ pageNum: 1,
|
|
35
|
+ }).then((e) => {
|
|
36
|
+ setCarsList(e.records)
|
|
37
|
+ })
|
|
38
|
+
|
|
39
|
+ }, [])
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+ useReachBottom(() => {
|
|
43
|
+ console.log('chufa',);
|
|
44
|
+
|
|
45
|
+ if (pageNum < totalPage) {
|
|
46
|
+ pageNum += 1;
|
|
47
|
+ //加载下一页
|
|
48
|
+ loadData()
|
|
49
|
+ console.log('chufa',);
|
|
50
|
+ } else {
|
|
51
|
+ Taro.showToast({
|
|
52
|
+ icon: "none",
|
|
53
|
+ title: '没有更多数据了',
|
|
54
|
+ })
|
|
55
|
+ }
|
|
56
|
+ }, [1])
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+ const loadData = () => {
|
|
62
|
+ getMachinery(location, {
|
|
63
|
+ pageSize: pageSize,
|
|
64
|
+ pageNum: pageNum,
|
|
65
|
+ }).then((e) => {
|
|
66
|
+ pageNum = e.data.content.pageNum;
|
|
67
|
+ totalPage = e.data.content.totalPageNum;
|
|
68
|
+ resultData = e.data.content.rows;
|
|
69
|
+
|
|
70
|
+ setCarsList(e.records)
|
|
71
|
+ })
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+ console.log("🚀 ~ file: Homes.jsx ~ line 36 ~ imglist ~ imglist", bannerHome)
|
|
76
|
+
|
|
77
|
+
|
33
|
78
|
|
34
|
79
|
const handleSearch = (e) => {
|
35
|
80
|
console.log(e.detail.value)
|
|
@@ -45,7 +90,7 @@ export default (props) => {
|
45
|
90
|
|
46
|
91
|
}
|
47
|
92
|
const goCarsInfo = (res) => {
|
48
|
|
- Taro.navigateTo({ url: `/pages/CheckDetails/index?id=${res}` })
|
|
93
|
+ Taro.navigateTo({ url: `/pages/CheckDetails/index?id=${res}&location=${location}` })
|
49
|
94
|
|
50
|
95
|
}
|
51
|
96
|
const goMapInfo = (res) => {
|
|
@@ -74,9 +119,9 @@ export default (props) => {
|
74
|
119
|
autoplay
|
75
|
120
|
className='swiper-box'
|
76
|
121
|
>
|
77
|
|
- {imglist.map((item, inx) => (
|
|
122
|
+ {bannerHome.map((item, inx) => (
|
78
|
123
|
<SwiperItem key={inx}>
|
79
|
|
- <Image src={item.url} mode='widthFix' className='storeImage' />
|
|
124
|
+ <Image src={item.thumb} mode='widthFix' className='storeImage' />
|
80
|
125
|
</SwiperItem>
|
81
|
126
|
))}
|
82
|
127
|
</Swiper>
|
|
@@ -92,20 +137,20 @@ export default (props) => {
|
92
|
137
|
carsList.map((item, index) => {
|
93
|
138
|
return (
|
94
|
139
|
<View key={index} className='carsListImga-bottom-box'>
|
95
|
|
- <Image src={item.carsUrl} onClick={() => goCarsInfo(item.id)} />
|
|
140
|
+ <Image src={item.thumb} onClick={() => goCarsInfo(item.machineryId)} />
|
96
|
141
|
<View className='carsListImga-bottom-box-flaxBox'>
|
97
|
142
|
<View className='carsListImga-bottom-box-flaxBox-liftText'>
|
98
|
|
- <View className='carsListImga-bottom-box-flaxBox-liftText-Titles'>{item.carsName}</View>
|
99
|
|
- <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{item.jiage}/<Text>公顷</Text></View>
|
|
143
|
+ <View className='carsListImga-bottom-box-flaxBox-liftText-Titles'>{item.name}</View>
|
|
144
|
+ <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{item.price}/<Text>公顷</Text></View>
|
100
|
145
|
</View>
|
101
|
146
|
<View className='carsListImga-bottom-box-flaxBox-rightBut'>
|
102
|
147
|
<ButtontWX onClick={startReserve} butText='预约' butWidth={80} butHeight={34} butFontSize={19} butBorderRadius={0} />
|
103
|
148
|
</View>
|
104
|
149
|
</View>
|
105
|
|
- <View className='content-header-box-map' onClick={() => goMapInfo(item.mapId)}>
|
|
150
|
+ <View className='content-header-box-map' onClick={() => goMapInfo(item.machineryId)}>
|
106
|
151
|
<View className='content-header-box-map-liftCentent'>
|
107
|
152
|
<Image src={addresss} />
|
108
|
|
- <View>距离当前位置{item.carsLocation}公里</View>
|
|
153
|
+ <View>距离当前位置公里</View>
|
109
|
154
|
</View>
|
110
|
155
|
<View className='content-header-box-map-rightCentent'>进入地图>></View>
|
111
|
156
|
</View>
|