李志伟 3 years ago
parent
commit
99bf49e301

+ 1
- 4
android/app/build.gradle View File

55
     }
55
     }
56
 
56
 
57
     dependencies {
57
     dependencies {
58
-//        implementation fileTree(dir: 'libs', include: ['*.jar'])
59
-//        implementation('com.amap.api:map2d:6.0.0')
60
-//        implementation('com.amap.api:search:9.2.0')
61
-//        implementation('com.amap.api:location:6.1.0')
58
+//        implementation 'com.google.android.material:material:1.5.0'
62
         implementation('com.amap.api:3dmap:9.1.0')
59
         implementation('com.amap.api:3dmap:9.1.0')
63
     }
60
     }
64
 
61
 

+ 1
- 1
android/app/src/main/AndroidManifest.xml View File

25
     <!--允许读设备等信息,用于问题排查-->
25
     <!--允许读设备等信息,用于问题排查-->
26
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
26
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
27
    <application
27
    <application
28
-        android:label="farmer_client"
28
+        android:label="农忙助手"
29
         android:name="${applicationName}"
29
         android:name="${applicationName}"
30
         android:icon="@mipmap/ic_launcher">
30
         android:icon="@mipmap/ic_launcher">
31
         <activity
31
         <activity

+ 5
- 6
android/app/src/main/res/drawable/launch_background.xml View File

2
 <!-- Modify this file to customize your launch splash screen -->
2
 <!-- Modify this file to customize your launch splash screen -->
3
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4
     <item android:drawable="@android:color/white" />
4
     <item android:drawable="@android:color/white" />
5
-
6
     <!-- You can insert your own image images here -->
5
     <!-- You can insert your own image images here -->
7
-    <!-- <item>
8
-        <bitmap
9
-            android:gravity="center"
10
-            android:src="@mipmap/launch_image" />
11
-    </item> -->
6
+<!--    <item>-->
7
+<!--        <bitmap-->
8
+<!--            android:gravity="fill"-->
9
+<!--            android:src="@drawable/launch_image" />-->
10
+<!--    </item>-->
12
 </layer-list>
11
 </layer-list>

BIN
android/app/src/main/res/drawable/launch_image.png View File


+ 3
- 1
android/app/src/main/res/values/styles.xml View File

4
     <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
4
     <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
5
         <!-- Show a splash screen on the activity. Automatically removed when
5
         <!-- Show a splash screen on the activity. Automatically removed when
6
              Flutter draws its first frame -->
6
              Flutter draws its first frame -->
7
-        <item name="android:windowBackground">@drawable/launch_background</item>
7
+<!--        <item name="android:windowBackground">@drawable/launch_image</item>-->
8
+        <item name="android:windowBackground">@drawable/launch_image</item>
8
     </style>
9
     </style>
9
     <!-- Theme applied to the Android Window as soon as the process has started.
10
     <!-- Theme applied to the Android Window as soon as the process has started.
10
          This theme determines the color of the Android Window while your
11
          This theme determines the color of the Android Window while your
14
          This Theme is only used starting with V2 of Flutter's Android embedding. -->
15
          This Theme is only used starting with V2 of Flutter's Android embedding. -->
15
     <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
16
     <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
16
         <item name="android:windowBackground">?android:colorBackground</item>
17
         <item name="android:windowBackground">?android:colorBackground</item>
18
+<!--        <item name="android:windowBackground">@drawable/launch_background</item>-->
17
     </style>
19
     </style>
18
 </resources>
20
 </resources>

+ 1
- 1
lib/main.dart View File

37
             Locale('en', ''),
37
             Locale('en', ''),
38
           ],
38
           ],
39
           theme: getTheme(),
39
           theme: getTheme(),
40
-          initialRoute: '/splash',
40
+          initialRoute: '/',
41
           defaultTransition: Transition.native,
41
           defaultTransition: Transition.native,
42
           routingCallback: routingCallback,
42
           routingCallback: routingCallback,
43
           initialBinding: AppBindings(),
43
           initialBinding: AppBindings(),

+ 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
             )

+ 10
- 10
lib/routes/middleWares.dart View File

4
 import 'package:get_storage/get_storage.dart';
4
 import 'package:get_storage/get_storage.dart';
5
 
5
 
6
 void routingCallback (routing) {
6
 void routingCallback (routing) {
7
-  GetStorage box = GetStorage();
8
-  bool isLogin = box.hasData('token');
9
-  bool isSplashScreen = routing?.current == '/splash';
10
-  bool isLoginPage = routing?.current == '/login';
11
-  bool isAgreementPage = routing?.current == '/agreement';
12
-  if (!isLogin && !isSplashScreen && !isLoginPage&&!isAgreementPage) {
13
-    // addPostFrameCallback 作用是等当前帧绘制完成之后再加载
14
-    // https://github.com/jonataslaw/getx/issues/262
15
-    SchedulerBinding.instance?.addPostFrameCallback((_) => Get.offNamed('/login'));
16
-  }
7
+  // GetStorage box = GetStorage();
8
+  // bool isLogin = box.hasData('token');
9
+  // bool isSplashScreen = routing?.current == '/splash';
10
+  // bool isLoginPage = routing?.current == '/login';
11
+  // bool isAgreementPage = routing?.current == '/agreement';
12
+  // if (!isLogin && !isSplashScreen && !isLoginPage&&!isAgreementPage) {
13
+  //   // addPostFrameCallback 作用是等当前帧绘制完成之后再加载
14
+  //   // https://github.com/jonataslaw/getx/issues/262
15
+  //   SchedulerBinding.instance?.addPostFrameCallback((_) => Get.offNamed('/login'));
16
+  // }
17
 }
17
 }

+ 6
- 4
lib/routes/pages.dart View File

13
 import 'package:farmer_client/pages/search/index.jsx.dart';
13
 import 'package:farmer_client/pages/search/index.jsx.dart';
14
 import 'package:farmer_client/pages/userInfo/index.dart';
14
 import 'package:farmer_client/pages/userInfo/index.dart';
15
 import 'package:get/get.dart';
15
 import 'package:get/get.dart';
16
-
17
 import '../pages/home/index.dart';
16
 import '../pages/home/index.dart';
17
+import 'package:get_storage/get_storage.dart';
18
 import '../pages/index.dart';
18
 import '../pages/index.dart';
19
 
19
 
20
-
21
 List<GetPage> pages = [
20
 List<GetPage> pages = [
22
-  GetPage(name: '/', page: () =>  Home()),
21
+  GetPage(name: '/', page: () {
22
+    GetStorage box = GetStorage();
23
+    return box.hasData('token') ? Home() : MyRouteLogin();
24
+  }),
23
   GetPage(name: '/main', page: () =>  Main()),
25
   GetPage(name: '/main', page: () =>  Main()),
24
   GetPage(name: '/order', page: () =>  Order()),
26
   GetPage(name: '/order', page: () =>  Order()),
25
   GetPage(name: '/infomation', page: () =>  Infomation()),
27
   GetPage(name: '/infomation', page: () =>  Infomation()),
26
   GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
28
   GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
27
-  GetPage(name: '/splash', page: () => SplashScreen()),//SplashScreen
29
+  // GetPage(name: '/splash', page: () => SplashScreen()), // SplashScreen
28
   GetPage(name: '/login', page: () =>  MyRouteLogin()),
30
   GetPage(name: '/login', page: () =>  MyRouteLogin()),
29
   GetPage(name: '/addressList', page: () =>  AddressList()),
31
   GetPage(name: '/addressList', page: () =>  AddressList()),
30
   GetPage(name: '/addAddress', page: () =>  AddAddress()),
32
   GetPage(name: '/addAddress', page: () =>  AddAddress()),

+ 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
                         ],