李志伟 3 vuotta sitten
vanhempi
commit
076d97c3be

+ 1
- 1
lib/main.dart Näytä tiedosto

@@ -24,7 +24,7 @@ class MyApp extends StatelessWidget {
24 24
       designSize: const Size(375, 812),
25 25
       minTextAdapt: true,
26 26
       splitScreenMode: true,
27
-      builder: (_) {
27
+      builder: (context , child) {
28 28
         return GetMaterialApp(
29 29
           initialRoute: '/',
30 30
           theme: getTheme(),

+ 18
- 13
lib/models/app.dart Näytä tiedosto

@@ -1,6 +1,7 @@
1 1
 import 'dart:convert';
2 2
 import 'dart:io';
3 3
 import 'package:amap_flutter_location/amap_flutter_location.dart';
4
+import 'package:fluttertoast/fluttertoast.dart';
4 5
 import 'package:get/get.dart';
5 6
 import 'package:get_storage/get_storage.dart';
6 7
 import 'package:worker_client/services/amap.dart';
@@ -14,7 +15,8 @@ class AppController extends GetxController {
14 15
   static AppController t = Get.find();
15 16
   GetStorage box = GetStorage();
16 17
   final user = Rx<Person>(Person());
17
-  final location = Rxn<Map<String, Object>>({'address':''});
18
+  final location = Rxn<Map<String, Object>>();
19
+  final address = Rxn<Map<String, Object>>({'address': ''});
18 20
   final testInt = 1.obs;
19 21
 
20 22
   AMapFlutterLocation? _location;
@@ -29,19 +31,22 @@ class AppController extends GetxController {
29 31
   }
30 32
 
31 33
   void onLocationChange(Map<String, Object> result) {
32
-    if (box.read('token') == null) {
34
+    if (result['errorCode'] == null) {
33 35
       location(result);
34
-    } else if (location.value!['address'] == '') {
35
-      setAmap({
36
-        //定位有问题
37
-        // 'params': 'location=${result['longitude'].toString()},${result['latitude'].toString()}',
38
-        'params': 'location=118.84002,31.95266',
39
-        'path': '/v3/geocode/regeo'
40
-      }).then((value) {
41
-        //json字符串转Map对象
42
-        result['address'] = jsonDecode(value)['regeocode']['formatted_address'];
43
-        location(result);
44
-      });
36
+      if (address.value!['address'] == '' &&
37
+          box.read('token') != null &&
38
+          location.value!['longitude'] != null) {
39
+        setAmap({
40
+          //定位有问题
41
+          'params':
42
+              'location=${result['longitude'].toString()},${result['latitude'].toString()}',
43
+          // 'params': 'location=116.397128,39.916527',
44
+          'path': '/v3/geocode/regeo'
45
+        }).then((value) {
46
+          //json字符串转Map对象
47
+          address({'address':jsonDecode(value)['regeocode']['formatted_address']});
48
+        });
49
+      }
45 50
     }
46 51
   }
47 52
 

+ 48
- 45
lib/pages/home/index.dart Näytä tiedosto

@@ -1,3 +1,5 @@
1
+import 'dart:convert';
2
+
1 3
 import 'package:flutter_easyloading/flutter_easyloading.dart';
2 4
 import 'package:fluttertoast/fluttertoast.dart';
3 5
 import 'package:get/get.dart';
@@ -8,6 +10,7 @@ import 'package:worker_client/models/app.dart';
8 10
 import 'package:worker_client/models/entities/Banner.dart';
9 11
 import 'package:worker_client/models/entities/Job.dart';
10 12
 import 'package:worker_client/pages/home/widgets/headers.dart';
13
+import 'package:worker_client/services/amap.dart';
11 14
 import 'package:worker_client/services/banner.dart';
12 15
 import 'package:worker_client/services/job.dart';
13 16
 import 'package:worker_client/widgets/MyCard/index.dart';
@@ -87,7 +90,7 @@ class Home extends BasicPage {
87 90
         Container(
88 91
           margin: EdgeInsets.fromLTRB(65.w, 0, 65.w, 50.h),
89 92
           child: Text(
90
-            AppController.t.location.value!['address'].toString(),
93
+            AppController.t.address.value!['address'].toString(),
91 94
             style: TextStyle(
92 95
               fontSize: 17.sp,
93 96
               fontWeight: FontWeight.w800,
@@ -186,52 +189,52 @@ class Home extends BasicPage {
186 189
   Widget builder(BuildContext context) {
187 190
     return Container(
188 191
       decoration: const BoxDecoration(color: Colors.white),
189
-      padding: EdgeInsets.all(15.w),
192
+      padding: EdgeInsets.only(top:15.w,left: 15.w,right: 15.w),
190 193
       child: Column(
191 194
         children: [
192
-          // const headers(),
193
-          // //banner
194
-          // Container(
195
-          //   margin: EdgeInsets.fromLTRB(0, 15.h, 0, 15.h),
196
-          //   child: Obx(() => CarouselSlider(
197
-          //         items: bannerList.value
198
-          //             .map((item) => Center(
199
-          //                 child: Image.network(item.thumb.toString(),
200
-          //                     fit: BoxFit.cover, width: 345.w)))
201
-          //             .toList(),
202
-          //         options: CarouselOptions(
203
-          //           autoPlay: true,
204
-          //           enlargeCenterPage: false,
205
-          //           //图片中心放大
206
-          //           viewportFraction: 1,
207
-          //           //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
208
-          //           // aspectRatio: 1.6,//纵横比
209
-          //           height: 214.w,
210
-          //           initialPage: 1, //初始页
211
-          //         ),
212
-          //       )),
213
-          // ),
214
-          // Container(
215
-          //   margin: EdgeInsets.fromLTRB(0, 15.h, 0, 20.h),
216
-          //   child: Row(
217
-          //     children: [
218
-          //       Padding(
219
-          //         padding: EdgeInsets.fromLTRB(0, 0, 10.w, 0),
220
-          //         child: Image.asset(
221
-          //           'images/index/orderList.png',
222
-          //           width: 20.w,
223
-          //         ),
224
-          //       ),
225
-          //       Text(
226
-          //         '作业列表',
227
-          //         style: TextStyle(
228
-          //             color: Color(0xff222222),
229
-          //             fontSize: 20.sp,
230
-          //             fontWeight: FontWeight.w800),
231
-          //       )
232
-          //     ],
233
-          //   ),
234
-          // ),
195
+          const headers(),
196
+          //banner
197
+          Container(
198
+            margin: EdgeInsets.fromLTRB(0, 15.h, 0, 15.h),
199
+            child: Obx(() => CarouselSlider(
200
+                  items: bannerList.value
201
+                      .map((item) => Center(
202
+                          child: Image.network(item.thumb.toString(),
203
+                              fit: BoxFit.cover, width: 345.w)))
204
+                      .toList(),
205
+                  options: CarouselOptions(
206
+                    autoPlay: true,
207
+                    enlargeCenterPage: false,
208
+                    //图片中心放大
209
+                    viewportFraction: 1,
210
+                    //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
211
+                    // aspectRatio: 1.6,//纵横比
212
+                    height: 214.w,
213
+                    initialPage: 1, //初始页
214
+                  ),
215
+                )),
216
+          ),
217
+          Container(
218
+            margin: EdgeInsets.fromLTRB(0, 15.h, 0, 20.h),
219
+            child: Row(
220
+              children: [
221
+                Padding(
222
+                  padding: EdgeInsets.fromLTRB(0, 0, 10.w, 0),
223
+                  child: Image.asset(
224
+                    'images/index/orderList.png',
225
+                    width: 20.w,
226
+                  ),
227
+                ),
228
+                Text(
229
+                  '作业列表',
230
+                  style: TextStyle(
231
+                      color: Color(0xff222222),
232
+                      fontSize: 20.sp,
233
+                      fontWeight: FontWeight.w800),
234
+                )
235
+              ],
236
+            ),
237
+          ),
235 238
           Expanded(
236 239
             flex: 1,
237 240
             child: RefreshMoreList(

+ 33
- 31
lib/pages/home/widgets/headers.dart Näytä tiedosto

@@ -26,38 +26,40 @@ class headers extends StatelessWidget {
26 26
           ),
27 27
         ),
28 28
         const Icon(Icons.arrow_drop_down),
29
-        Container(
30
-          margin: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
31
-          padding: EdgeInsets.symmetric(vertical: 0, horizontal: 15.w),
32
-          width: 246.w,
33
-          height: 34.h,
34
-          decoration: const BoxDecoration(
35
-            color: Color(0x30cccccc),
36
-            borderRadius: BorderRadius.all(Radius.circular(25)),
37
-          ),
38
-          child: GestureDetector(
39
-            onTap: () {
40
-              Get.offNamed('/order');
41
-            },
42
-            child: Row(
43
-              children: [
44
-                Container(
45
-                  margin: EdgeInsets.fromLTRB(0, 0, 3.w, 0),
46
-                  child: Image.asset(
47
-                    'images/index/search.png',
48
-                    width: 15.w,
49
-                    height: 15.w,
50
-                  ),
51
-                ),
52
-                Text(
53
-                  '请输入关键字查询订单',
54
-                  style: TextStyle(
55
-                      color: const Color(0xFFB6B6B6), fontSize: 14.sp),
29
+        Expanded(
30
+          flex: 1,
31
+            child: Container(
32
+              margin: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
33
+              padding: EdgeInsets.symmetric(vertical: 0, horizontal: 15.w),
34
+              height: 34.h,
35
+              decoration: const BoxDecoration(
36
+                color: Color(0x30cccccc),
37
+                borderRadius: BorderRadius.all(Radius.circular(25)),
38
+              ),
39
+              child: GestureDetector(
40
+                onTap: () {
41
+                  Get.offNamed('/order');
42
+                },
43
+                child: Row(
44
+                  children: [
45
+                    Container(
46
+                      margin: EdgeInsets.fromLTRB(0, 0, 3.w, 0),
47
+                      child: Image.asset(
48
+                        'images/index/search.png',
49
+                        width: 15.w,
50
+                        height: 15.w,
51
+                      ),
52
+                    ),
53
+                    Text(
54
+                      '请输入关键字查询订单',
55
+                      style: TextStyle(
56
+                          color: const Color(0xFFB6B6B6), fontSize: 14.sp),
57
+                    ),
58
+                  ],
56 59
                 ),
57
-              ],
58
-            ),
59
-          ),
60
-        ),
60
+              ),
61
+            ))
62
+        ,
61 63
       ],
62 64
     );
63 65
   }

+ 1
- 1
lib/pages/jobDetail/index.dart Näytä tiedosto

@@ -50,7 +50,7 @@ class JobDetail extends BasicPage {
50 50
         Container(
51 51
           margin: EdgeInsets.fromLTRB(65.w, 0, 65.w, 50.h),
52 52
           child: Text(
53
-            AppController.t.location.value!['address'].toString(),
53
+            AppController.t.address.value!['address'].toString(),
54 54
             style: TextStyle(
55 55
               fontSize: 17.sp,
56 56
               fontWeight: FontWeight.w800,

+ 4
- 1
lib/pages/machineryDetail/index.dart Näytä tiedosto

@@ -4,6 +4,7 @@ import 'package:get/get.dart';
4 4
 import 'package:flutter/material.dart';
5 5
 import 'package:flutter_easyloading/flutter_easyloading.dart';
6 6
 import 'package:flutter_screenutil/flutter_screenutil.dart';
7
+import 'package:worker_client/models/app.dart';
7 8
 import 'package:worker_client/models/entities/Machinery.dart';
8 9
 import 'package:worker_client/services/machinery.dart';
9 10
 import 'package:worker_client/widgets/Jianbian/index.dart';
@@ -15,13 +16,15 @@ class MachineryDetail extends BasicPage {
15 16
     naviTitle = '查看详情';
16 17
   }
17 18
   final machinery = Rx<Machinery>(Machinery());
19
+  String? location = AppController.t.locationStr;
20
+
18 21
   @override
19 22
   void beforeShow() {
20 23
     super.beforeShow();
21 24
     if (Get.arguments != null) {
22 25
       EasyLoading.show(status: '数据加载中...');
23 26
       getMachineryDetail(Get.arguments['id'],
24
-          {'attached': true, 'location': '118.84002,31.95266'}).then((res) {
27
+          {'attached': true, 'location': location}).then((res) {
25 28
         machinery(Machinery.fromJson(res));
26 29
         EasyLoading.dismiss();
27 30
       }).catchError((error) {

+ 2
- 2
lib/pages/machineryList/widgets/MachineryCard.dart Näytä tiedosto

@@ -46,8 +46,8 @@ class MachineryCard extends StatelessWidget {
46 46
                 child: Row(
47 47
                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
48 48
                   children: [
49
-                    SizedBox(
50
-                      width: 250.w,
49
+                    Expanded(
50
+                      flex: 1,
51 51
                       child: GestureDetector(
52 52
                         onTap: goDetail,
53 53
                         child: Text(

+ 2
- 1
lib/pages/machineryMap/index.dart Näytä tiedosto

@@ -21,6 +21,7 @@ class MachineryMap extends BasicPage {
21 21
   final current = Rx<Machinery>(Machinery());
22 22
   final visible = Rx<bool>(true);
23 23
 
24
+
24 25
   dynamic locList = [
25 26
     '32.685927, 112.106514',
26 27
     '32.673406, 112.100406',
@@ -41,7 +42,7 @@ class MachineryMap extends BasicPage {
41 42
       getMachineryDetail(Get.arguments['id'], {
42 43
         'attached': true,
43 44
         //查询农机详情时需要把当前定位传到服务端
44
-        'location': '118.84002,31.95266'
45
+        'location': location
45 46
       })
46 47
           .then((res) => {
47 48
                 getMachineryList({'pageSize': 500, 'location': location})

+ 1
- 1
lib/widgets/Cell.dart Näytä tiedosto

@@ -43,7 +43,7 @@ class Cell extends StatelessWidget {
43 43
           ),
44 44
           Expanded(child: child,),
45 45
           if (null != footer) ConstrainedBox (
46
-            constraints: BoxConstraints(maxWidth: 100.w),
46
+            constraints: const BoxConstraints(),
47 47
             child: footer,
48 48
           )
49 49
         ],

+ 1
- 1
lib/widgets/Jianbian/index.dart Näytä tiedosto

@@ -80,7 +80,7 @@ class Jianbian extends StatelessWidget {
80 80
           child: Transform.rotate(
81 81
             angle: -pi / 2.3,
82 82
             child: Transform.translate(
83
-              offset: Offset(38.w, 85.w),
83
+              offset: Offset(35.w, 85.w),
84 84
               child: Text(
85 85
                 Title(),
86 86
                 style: TextStyle(

+ 2
- 3
lib/widgets/MoneyCard/index.dart Näytä tiedosto

@@ -17,7 +17,6 @@ class _MoneyCardState extends State<MoneyCard> {
17 17
   Widget build(BuildContext context) {
18 18
     return Container(
19 19
       width: 345.w,
20
-      height: 172.5.w,
21 20
       padding: EdgeInsets.fromLTRB(40.w, 33.5.w, 0, 22.5.w),
22 21
       decoration: BoxDecoration(
23 22
         borderRadius: BorderRadius.all(Radius.circular(20.w)),
@@ -49,8 +48,8 @@ class _MoneyCardState extends State<MoneyCard> {
49 48
               ),
50 49
             ),
51 50
           ),
52
-          Visibility(
53
-            visible: !widget.type,
51
+          Opacity(
52
+            opacity: !widget.type?1:0,
54 53
             child: GestureDetector(
55 54
               onTap: widget.goWithDrawal,
56 55
               child: Container(

+ 7
- 10
lib/widgets/MyCard/index.dart Näytä tiedosto

@@ -55,16 +55,13 @@ class MyCard extends StatelessWidget {
55 55
                   padding: EdgeInsets.fromLTRB(19.w, 9.w, 0, 9.w),
56 56
                   child: Row(
57 57
                     children: [
58
-                      SizedBox(
59
-                        width: 70,
60
-                        child: Text(
61
-                          '需求时间',
62
-                          style: TextStyle(
63
-                              fontSize: 17.sp,
64
-                              color: const Color(0xFF606060),
65
-                              fontWeight: FontWeight.bold,
66
-                              letterSpacing: 2),
67
-                        ),
58
+                      Text(
59
+                        '需求时间',
60
+                        style: TextStyle(
61
+                            fontSize: 17.sp,
62
+                            color: const Color(0xFF606060),
63
+                            fontWeight: FontWeight.bold,
64
+                            letterSpacing: 2),
68 65
                       ),
69 66
                       Text(
70 67
                         ':',

+ 0
- 1
lib/widgets/MyCard/widgets/CardCell.dart Näytä tiedosto

@@ -21,7 +21,6 @@ class CardCell extends StatelessWidget {
21 21
         crossAxisAlignment: CrossAxisAlignment.start,
22 22
         children: [
23 23
           SizedBox(
24
-            width: 65.w,
25 24
             child: Text(
26 25
               lable,
27 26
               style: TextStyle(

+ 55
- 45
lib/widgets/RefreshMoreList.dart Näytä tiedosto

@@ -79,50 +79,60 @@ class _RefreshMoreList extends State<RefreshMoreList> {
79 79
 
80 80
   @override
81 81
   Widget build(BuildContext context) {
82
-    return Obx(() => dataList.value.isNotEmpty
83
-        ? EasyRefresh(
84
-            controller: _controller,
85
-            header: ClassicalHeader(
86
-              infoText:DateTime.now().toString().substring(0,19),
87
-              refreshedText: '刷新完成',
88
-              refreshText: '刷新中....',
89
-              refreshingText: '刷新中....',
90
-              refreshReadyText: '刷新完毕',
91
-              noMoreText: '',
92
-              textColor: const Color(0xff666666),
93
-              infoColor: const Color(0xff666666),
94
-            ),
95
-            footer: ClassicalFooter(
96
-              infoText: DateTime.now().toString().substring(0,19),
97
-              loadText: '上拉加载更多',
98
-              loadingText: '加载中....',
99
-              loadedText: '',
100
-              loadReadyText: '释放加载',
101
-              noMoreText: '暂无更多',
102
-              enableInfiniteLoad: false,
103
-              textColor: const Color(0xff666666),
104
-              infoColor: const Color(0xff666666),
105
-            ),
106
-            // firstRefresh: true,//是否首次刷新
107
-            onRefresh: () async {
108
-              await Future.delayed(const Duration(seconds: 1), () {
109
-                // print("下拉刷新-----");
110
-                getNewData();
111
-                _count = dataList.value.length;
112
-                // print("最新条数" + _count.toString());
113
-                _controller.resetLoadState();
114
-              });
115
-            },
116
-            onLoad: () async {
117
-              await Future.delayed(const Duration(seconds: 1), () {
118
-                // print("上拉加载-----");
119
-                getMoreData();
120
-                _count = dataList.value.length;
121
-                // print("加载更多条数" + _count.toString());
122
-                _controller.finishLoad(noMore: _count >= maxSum);
123
-              });
124
-            },
125
-            child: widget.builder(context: context, toggle: toggle))
126
-        : NullCard(text: cardText));
82
+    return Obx(
83
+      () => EasyRefresh(
84
+        controller: _controller,
85
+        header: ClassicalHeader(
86
+          infoText: DateTime.now().toString().substring(0, 19),
87
+          refreshedText: '刷新完成',
88
+          refreshText: '刷新中....',
89
+          refreshingText: '刷新中....',
90
+          refreshReadyText: '刷新完毕',
91
+          noMoreText: '',
92
+          textColor: const Color(0xff666666),
93
+          infoColor: const Color(0xff666666),
94
+        ),
95
+        footer: ClassicalFooter(
96
+          infoText: DateTime.now().toString().substring(0, 19),
97
+          loadText: '上拉加载更多',
98
+          loadingText: '加载中....',
99
+          loadedText: '',
100
+          loadReadyText: '释放加载',
101
+          noMoreText: '暂无更多',
102
+          enableInfiniteLoad: false,
103
+          textColor: const Color(0xff666666),
104
+          infoColor: const Color(0xff666666),
105
+        ),
106
+        // firstRefresh: true,//是否首次刷新
107
+        onRefresh: () async {
108
+          await Future.delayed(const Duration(seconds: 1), () {
109
+            // print("下拉刷新-----");
110
+            getNewData();
111
+            _count = dataList.value.length;
112
+            // print("最新条数" + _count.toString());
113
+            _controller.resetLoadState();
114
+          });
115
+        },
116
+        onLoad: () async {
117
+          await Future.delayed(const Duration(seconds: 1), () {
118
+            // print("上拉加载-----");
119
+            getMoreData();
120
+            _count = dataList.value.length;
121
+            // print("加载更多条数" + _count.toString());
122
+            _controller.finishLoad(noMore: _count >= maxSum);
123
+          });
124
+        },
125
+        child: Column(
126
+          children: [
127
+            widget.builder(context: context, toggle: toggle),
128
+            dataList.value.isEmpty
129
+                ? NullCard(text: cardText)
130
+                : const SizedBox(
131
+                    height: 0.1,
132
+                  )
133
+          ],
134
+        ),
135
+      ),
136
+    );
127 137
   }
128 138
 }

+ 8
- 8
pubspec.lock Näytä tiedosto

@@ -7,7 +7,7 @@ packages:
7 7
       name: _fe_analyzer_shared
8 8
       url: "https://pub.flutter-io.cn"
9 9
     source: hosted
10
-    version: "39.0.0"
10
+    version: "40.0.0"
11 11
   amap_flutter_base:
12 12
     dependency: transitive
13 13
     description:
@@ -35,14 +35,14 @@ packages:
35 35
       name: analyzer
36 36
       url: "https://pub.flutter-io.cn"
37 37
     source: hosted
38
-    version: "4.0.0"
38
+    version: "4.1.0"
39 39
   args:
40 40
     dependency: transitive
41 41
     description:
42 42
       name: args
43 43
       url: "https://pub.flutter-io.cn"
44 44
     source: hosted
45
-    version: "2.3.0"
45
+    version: "2.3.1"
46 46
   async:
47 47
     dependency: transitive
48 48
     description:
@@ -168,7 +168,7 @@ packages:
168 168
       name: ffi
169 169
       url: "https://pub.flutter-io.cn"
170 170
     source: hosted
171
-    version: "1.1.2"
171
+    version: "1.2.1"
172 172
   file:
173 173
     dependency: transitive
174 174
     description:
@@ -222,7 +222,7 @@ packages:
222 222
       name: flutter_screenutil
223 223
       url: "https://pub.flutter-io.cn"
224 224
     source: hosted
225
-    version: "5.5.2"
225
+    version: "5.5.3+1"
226 226
   flutter_spinkit:
227 227
     dependency: transitive
228 228
     description:
@@ -274,7 +274,7 @@ packages:
274 274
       name: http_parser
275 275
       url: "https://pub.flutter-io.cn"
276 276
     source: hosted
277
-    version: "4.0.0"
277
+    version: "4.0.1"
278 278
   js:
279 279
     dependency: transitive
280 280
     description:
@@ -400,7 +400,7 @@ packages:
400 400
       name: path_provider_platform_interface
401 401
       url: "https://pub.flutter-io.cn"
402 402
     source: hosted
403
-    version: "2.0.3"
403
+    version: "2.0.4"
404 404
   path_provider_windows:
405 405
     dependency: transitive
406 406
     description:
@@ -587,7 +587,7 @@ packages:
587 587
       name: yaml
588 588
       url: "https://pub.flutter-io.cn"
589 589
     source: hosted
590
-    version: "3.1.0"
590
+    version: "3.1.1"
591 591
 sdks:
592 592
   dart: ">=2.16.1 <3.0.0"
593 593
   flutter: ">=2.8.1"