Browse Source

orderHomePages

[baozhangchao] 3 years ago
parent
commit
86e88cbb36

+ 4
- 9
lib/models/app.dart View File

15
   final location = Rxn<LocationData>();
15
   final location = Rxn<LocationData>();
16
   final testInt = 1.obs;
16
   final testInt = 1.obs;
17
 
17
 
18
-  // get locationStr {
19
-  //   if(location.value!.longitude==null){
20
-  //     return null;
21
-  //
22
-  //   }else{
23
-  //   return location.value!.longitude.toString() + "," + location.value!.latitude.toString();
24
-  //
25
-  //   }
26
-  // }
18
+  get locationStr {
19
+    if (null == location.value) return null;
20
+    return location.value!.longitude.toString() + "," + location.value!.latitude.toString();
21
+  }
27
 
22
 
28
   @override
23
   @override
29
   void onInit() {
24
   void onInit() {

lib/models/entities/banner.dart → lib/models/entities/Banners.dart View File

1
-class banner {
1
+class Banners {
2
   String? bannerId;
2
   String? bannerId;
3
   String? title;
3
   String? title;
4
   String? thumb;
4
   String? thumb;
6
   num? sortNo;
6
   num? sortNo;
7
   num? status;
7
   num? status;
8
   String? createDat;
8
   String? createDat;
9
-  banner();
9
+  Banners();
10
 
10
 
11
-  banner.fromJson(Map<String, dynamic> json)
11
+  Banners.fromJson(Map<String, dynamic> json)
12
       : bannerId = json["bannerId"],
12
       : bannerId = json["bannerId"],
13
         title = json["title"],
13
         title = json["title"],
14
         thumb = json["thumb"],
14
         thumb = json["thumb"],

+ 2
- 2
lib/models/entities/CardInfo.dart View File

33
   int? status;
33
   int? status;
34
 
34
 
35
   // @ApiModelProperty(value = "内容详情")
35
   // @ApiModelProperty(value = "内容详情")
36
-  late List<dynamic> contentList;
36
+  late List<dynamic>? contentList;
37
 
37
 
38
   // @ApiModelProperty(value = "图片列表")
38
   // @ApiModelProperty(value = "图片列表")
39
-  late List<dynamic> imagesList;
39
+  late List<dynamic>? imagesList;
40
 
40
 
41
   CardInfo();
41
   CardInfo();
42
 
42
 

+ 1
- 4
lib/pages/MoreCars/index.dart View File

80
                 Container(
80
                 Container(
81
                   child: Column(
81
                   child: Column(
82
                     children: [
82
                     children: [
83
-                      CarsCard(),
84
-                      CarsCard(),
85
-                      CarsCard(),
86
-                      CarsCard(),
83
+
87
                     ],
84
                     ],
88
                   )
85
                   )
89
                   ,
86
                   ,

+ 29
- 16
lib/pages/TabBar/widgets/home/index.dart View File

5
 import 'package:get/get.dart';
5
 import 'package:get/get.dart';
6
 import 'package:get/get_core/src/get_main.dart';
6
 import 'package:get/get_core/src/get_main.dart';
7
 import '../../../../models/app.dart';
7
 import '../../../../models/app.dart';
8
-import '../../../../models/entities/banner.dart';
8
+import '../../../../models/entities/CardInfo.dart';
9
 import '../../../../services/homeAPI.dart';
9
 import '../../../../services/homeAPI.dart';
10
 import '../../../../widgets/CarsCard.dart';
10
 import '../../../../widgets/CarsCard.dart';
11
-import 'package:farmer_client/models/app.dart';
11
+import 'package:farmer_client/models/entities/Banners.dart';
12
 import '../../../MoreCars/index.dart';
12
 import '../../../MoreCars/index.dart';
13
 
13
 
14
 class HomePage extends StatefulWidget {
14
 class HomePage extends StatefulWidget {
15
-  const HomePage({Key? key}) : super(key: key);
15
+  const HomePage({Key? key, }) : super(key: key);
16
+
16
 
17
 
17
   @override
18
   @override
18
-  State<HomePage> createState() => _HomePageState();
19
+  _HomePageState createState() => _HomePageState();
19
 }
20
 }
20
 
21
 
21
 
22
 
22
 class _HomePageState extends State<HomePage> {
23
 class _HomePageState extends State<HomePage> {
23
   final CarouselController _controller = CarouselController();
24
   final CarouselController _controller = CarouselController();
24
-  List<banner> BannerList = [];
25
+  List<Banners> bannerList = [];
26
+
27
+  List<CardInfo> machineryLists = [];
28
+
29
+
30
+
25
 
31
 
26
   @override
32
   @override
27
   void initState() {
33
   void initState() {
28
     super.initState();
34
     super.initState();
29
-    final location = AppController.t.location;
30
-    print('location+$location');
35
+    // final location = AppController.t.location;
36
+    // print('location+$location');
31
 
37
 
32
     getHomeBanner('banner').then((value) {
38
     getHomeBanner('banner').then((value) {
33
       setState(() {
39
       setState(() {
34
         value.forEach((item) {
40
         value.forEach((item) {
35
-          BannerList.add(banner.fromJson(item));
41
+          bannerList.add(Banners.fromJson(item));
36
         });
42
         });
37
       });
43
       });
38
     });
44
     });
39
 
45
 
40
-    // getMachinery(location.value!.longitude.toString()).then((value) {
41
-    //   print('$value');
42
-    // });
46
+    getMachinery('112.087433,32.687692').then((value) {
47
+      setState(() {
48
+        value['records'].forEach((item) {
49
+          machineryLists.add(CardInfo.fromJson(item));
50
+        });
51
+      });
52
+    });
43
   }
53
   }
44
 
54
 
45
   @override
55
   @override
46
   Widget build(BuildContext context) {
56
   Widget build(BuildContext context) {
57
+
47
     return Container(
58
     return Container(
48
       alignment: Alignment.center,
59
       alignment: Alignment.center,
49
       padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
60
       padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
58
           Container(
69
           Container(
59
             margin: EdgeInsets.fromLTRB(0, 15, 0, 0),
70
             margin: EdgeInsets.fromLTRB(0, 15, 0, 0),
60
             child:
71
             child:
61
-                // Text('asdasdas')
62
                 CarouselSlider(
72
                 CarouselSlider(
63
-              items: BannerList.map((item) => Container(
73
+              items: bannerList.map((item) => Container(
64
                     child: Center(
74
                     child: Center(
65
                         child: Image.network(item.thumb.toString(),
75
                         child: Image.network(item.thumb.toString(),
66
                             fit: BoxFit.cover, width: 350.w)),
76
                             fit: BoxFit.cover, width: 350.w)),
115
                       )
125
                       )
116
                     ],
126
                     ],
117
                   ),
127
                   ),
118
-                  CarsCard(),
119
-                  CarsCard(),
120
-                  CarsCard(),
128
+            Column(
129
+              children: machineryLists.map((item) =>CarsCard(item:item)).toList(),
130
+            )
131
+
132
+
133
+
121
                 ],
134
                 ],
122
               )),
135
               )),
123
         ],
136
         ],

+ 0
- 4
lib/pages/search/index.jsx.dart View File

74
               child: Column(
74
               child: Column(
75
                 children: [
75
                 children: [
76
                   // NullCard(text: '暂无农机信息'),
76
                   // NullCard(text: '暂无农机信息'),
77
-                  CarsCard(),
78
-                  CarsCard(),
79
-                  CarsCard(),
80
-                  CarsCard(),
81
                 ],
77
                 ],
82
               ),
78
               ),
83
             )
79
             )

+ 21
- 0
lib/services/orderAPI.dart View File

1
+
2
+
3
+import 'package:dio/dio.dart';
4
+import 'package:farmer_client/utils/Request.dart';
5
+import 'package:fluttertoast/fluttertoast.dart';
6
+
7
+
8
+/**
9
+ * 订单列表
10
+ * @param {*} data
11
+ * @returns
12
+ */
13
+Future getOrderList(bool mine)async{
14
+  return request('/order',options: Options(method: 'GET'),data: { 'mine': mine}).catchError((error) =>
15
+  { Fluttertoast.showToast(
16
+      msg: error.error['message']
17
+  ),});
18
+
19
+}
20
+
21
+

+ 40
- 40
lib/widgets/CarsCard.dart View File

4
 import 'package:get/get.dart';
4
 import 'package:get/get.dart';
5
 import 'package:get/get_core/src/get_main.dart';
5
 import 'package:get/get_core/src/get_main.dart';
6
 
6
 
7
+import '../models/entities/CardInfo.dart';
7
 import '../pages/OrderConfirmation/index.dart';
8
 import '../pages/OrderConfirmation/index.dart';
8
 import '../pages/machinery/detail/index.dart';
9
 import '../pages/machinery/detail/index.dart';
9
 import '../pages/machinery/map/index.dart';
10
 import '../pages/machinery/map/index.dart';
10
 import 'LinearGradientText.dart';
11
 import 'LinearGradientText.dart';
11
 
12
 
12
-// class CarItem {
13
-//   late String name;
14
-//   late num? price;
15
-//   late num? distance;
16
-//   CarItem({required this.name, this.price, this.distance});
17
-// }
13
+class CarsCard extends StatefulWidget {
14
+  final CardInfo item;
18
 
15
 
19
-class CarsCard extends StatelessWidget {
20
-  // final CarItem item;
16
+  const CarsCard({Key? key, required this.item}) : super(key: key);
17
+
18
+  @override
19
+  _CarsCardPage createState() => _CarsCardPage(item);
20
+}
21
+
22
+class _CarsCardPage extends State<CarsCard> {
23
+  final CardInfo item;
24
+  _CarsCardPage(this.item);
21
 
25
 
22
-  // const CarsCard({
23
-  //   Key? key,
24
-  //   required this.item,
25
-  // }) : super(key: key);
26
 
26
 
27
   @override
27
   @override
28
   Widget build(BuildContext context) {
28
   Widget build(BuildContext context) {
36
       child: Column(
36
       child: Column(
37
         children: [
37
         children: [
38
           GestureDetector(
38
           GestureDetector(
39
-            onTap: (){
39
+            onTap: () {
40
               Get.to(MachineryDetailPage());
40
               Get.to(MachineryDetailPage());
41
             },
41
             },
42
-            child:Image.network(
43
-              "http://yz-shigongli.oss-accelerate.aliyuncs.com/2022-03/1648094119154-7b280bbf63105a8e90299e2d79c8c6ee.jpeg",
42
+            child: Image.network(
43
+              item.thumb.toString(),
44
               width: 345.w,
44
               width: 345.w,
45
               height: 230.h,
45
               height: 230.h,
46
               fit: BoxFit.cover,
46
               fit: BoxFit.cover,
55
               children: <Widget>[
55
               children: <Widget>[
56
                 Container(
56
                 Container(
57
                   child: Text(
57
                   child: Text(
58
-                    '联合收割机GB01235-0B',
58
+                    item.name.toString(),
59
                     style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
59
                     style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
60
                   ),
60
                   ),
61
                 ),
61
                 ),
76
                       Color(0xFFB61515),
76
                       Color(0xFFB61515),
77
                     ],
77
                     ],
78
                     child: RichText(
78
                     child: RichText(
79
-                      text: TextSpan(
80
-                          children: <InlineSpan>[
81
-                            TextSpan(
82
-                                text: "4508",
83
-                                style: TextStyle(
84
-                                  fontSize: 22,
85
-                                  fontWeight: FontWeight.bold,
86
-                                )),
87
-                            TextSpan(
88
-                                text: "元/",
89
-                                style: TextStyle(
90
-                                  fontSize: 22,
91
-                                  fontWeight: FontWeight.bold,
92
-                                )),
93
-                            TextSpan(
94
-                                text: "公顷",
95
-                                style: TextStyle(
96
-                                  fontSize: 12,
97
-                                  fontWeight: FontWeight.bold,
98
-                                )),
99
-                          ]
100
-                      ),
79
+                      text: TextSpan(children: <InlineSpan>[
80
+                        TextSpan(
81
+                            text: (item.price! / 100).toString(),
82
+                            style: TextStyle(
83
+                              fontSize: 22,
84
+                              fontWeight: FontWeight.bold,
85
+                            )),
86
+                        TextSpan(
87
+                            text: "元/",
88
+                            style: TextStyle(
89
+                              fontSize: 22,
90
+                              fontWeight: FontWeight.bold,
91
+                            )),
92
+                        TextSpan(
93
+                            text: "公顷",
94
+                            style: TextStyle(
95
+                              fontSize: 12,
96
+                              fontWeight: FontWeight.bold,
97
+                            )),
98
+                      ]),
101
                     ),
99
                     ),
102
                   ),
100
                   ),
103
                 ),
101
                 ),
111
                     height: 44.h, //+10
109
                     height: 44.h, //+10
112
                     child: ElevatedButton(
110
                     child: ElevatedButton(
113
                       onPressed: () {
111
                       onPressed: () {
114
-                        Get.to(OrderConfirmation());
112
+                        Get.toNamed('/orderConfirmation',
113
+                            arguments: {'machineryId': item.machineryId});
115
                       },
114
                       },
116
                       child: const Text(
115
                       child: const Text(
117
                         "预约",
116
                         "预约",
165
                             ),
164
                             ),
166
                             onTap: () {
165
                             onTap: () {
167
                               print('进入地图');
166
                               print('进入地图');
168
-                              Get.to(MachineryMapPage());
167
+                              Get.toNamed('/machineryMap',
168
+                                  arguments: {'machineryId': item.machineryId});
169
                             },
169
                             },
170
                           )
170
                           )
171
                         ],
171
                         ],