李志伟 hace 3 años
padre
commit
8201cd6782

+ 4
- 4
lib/models/app.dart Ver fichero

@@ -1,12 +1,12 @@
1 1
 import 'dart:convert';
2 2
 import 'dart:io';
3 3
 import 'package:amap_flutter_location/amap_flutter_location.dart';
4
+import 'package:get/get.dart';
4 5
 import 'package:get_storage/get_storage.dart';
5 6
 import 'package:worker_client/services/amap.dart';
6 7
 import 'package:worker_client/services/user.dart';
7
-import '/models/entities/person.dart';
8
+import 'entities/person.dart';
8 9
 import '/widgets/Modal.dart';
9
-import 'package:get/get.dart';
10 10
 import '../utils/location.dart';
11 11
 
12 12
 class AppController extends GetxController {
@@ -29,9 +29,9 @@ class AppController extends GetxController {
29 29
   }
30 30
 
31 31
   void onLocationChange(Map<String, Object> result) {
32
-    if (box.read('token') == null){
32
+    if (box.read('token') == null) {
33 33
       location(result);
34
-    }else if(result['address']==null ){
34
+    } else if (result['address'] == '') {
35 35
       setAmap({
36 36
         //定位有问题
37 37
         // 'params': 'location=${result['longitude'].toString()},${result['latitude'].toString()}',

+ 3
- 1
lib/pages/addBankCard/index.dart Ver fichero

@@ -89,7 +89,9 @@ class AddBankPage extends BasicPage {
89 89
         });
90 90
         bankList(list);
91 91
       },
92
-    );
92
+    ).catchError((error){
93
+      Fluttertoast.showToast(msg: error.error['message']);
94
+    });
93 95
   }
94 96
 
95 97
   @override

+ 6
- 0
lib/pages/bankList/index.dart Ver fichero

@@ -55,7 +55,13 @@ class BankListPages extends BasicPage {
55 55
           }
56 56
           bankCardListStore.bankCardList(list1);
57 57
           EasyLoading.dismiss();
58
+        }).catchError((error){
59
+          EasyLoading.dismiss();
60
+          Fluttertoast.showToast(msg: error.error['message']);
58 61
         });
62
+      }).catchError((error2){
63
+        EasyLoading.dismiss();
64
+        Fluttertoast.showToast(msg: error2.error['message']);
59 65
       });
60 66
     }
61 67
   }

+ 33
- 19
lib/pages/jobDetail/index.dart Ver fichero

@@ -1,5 +1,6 @@
1 1
 import 'dart:convert';
2 2
 import 'package:flutter/material.dart';
3
+import 'package:flutter_easyloading/flutter_easyloading.dart';
3 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4 5
 import 'package:fluttertoast/fluttertoast.dart';
5 6
 import 'package:get/get.dart';
@@ -67,7 +68,7 @@ class JobDetail extends BasicPage {
67 68
 
68 69
   Widget endContent() {
69 70
     return Container(
70
-        margin: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
71
+        margin: EdgeInsets.fromLTRB(15.w, 0, 15.w, 25.h),
71 72
         padding: EdgeInsets.symmetric(vertical: 18.h, horizontal: 15.w),
72 73
         decoration: BoxDecoration(
73 74
             border: Border.all(
@@ -102,7 +103,8 @@ class JobDetail extends BasicPage {
102 103
               ),
103 104
             )
104 105
           ],
105
-        ));
106
+        )
107
+    );
106 108
   }
107 109
 
108 110
   void changeJob(Job item) {
@@ -110,26 +112,38 @@ class JobDetail extends BasicPage {
110 112
       modal.showDialog(
111 113
           content: startContent(),
112 114
           onConfirm: () {
113
-            startJob(item.jobId.toString(), {'mode': true})
114
-                .then((value) => getJob());
115
+            EasyLoading.show(status: '请稍后');
116
+            startJob(item.jobId.toString(), {'mode': true}).then((value) {
117
+              getJob();
118
+              EasyLoading.dismiss();
119
+            }).catchError((error) {
120
+              Fluttertoast.showToast(msg: error.error['message']);
121
+              EasyLoading.dismiss();
122
+            });
115 123
           });
116 124
     } else {
117 125
       modal.showDialog(
118
-          content: endContent(),
119
-          onConfirm: () {
120
-            if (area.value == '') {
121
-              Fluttertoast.showToast(msg: '请输入正确的面积整数或最多两位小数');
122
-              return false;
123
-            } else {
124
-              overJob(item.jobId.toString(), {
125
-                ...item.toJson(),
126
-                'area': area.value.toString()
127
-              }).then((value) {
128
-                getJob();
129
-                Fluttertoast.showToast(msg: '恭喜完成作业');
130
-              });
131
-            }
132
-          },);
126
+        content: endContent(),
127
+        onConfirm: () {
128
+          if (area.value == '') {
129
+            Fluttertoast.showToast(msg: '请输入正确的面积整数或最多两位小数');
130
+            return false;
131
+          } else {
132
+            EasyLoading.show(status: '请稍后');
133
+            overJob(item.jobId.toString(), {
134
+              ...item.toJson(),
135
+              'area': area.value.toString()
136
+            }).then((value) {
137
+              getJob();
138
+              EasyLoading.dismiss();
139
+              Fluttertoast.showToast(msg: '恭喜完成作业');
140
+            }).catchError((error) {
141
+              Fluttertoast.showToast(msg: error.error['message']);
142
+              EasyLoading.dismiss();
143
+            });
144
+          }
145
+        },
146
+      );
133 147
     }
134 148
   }
135 149
 

+ 24
- 15
lib/pages/machineryDetail/index.dart Ver fichero

@@ -1,10 +1,13 @@
1 1
 import 'package:carousel_slider/carousel_slider.dart';
2
+import 'package:fluttertoast/fluttertoast.dart';
3
+import 'package:get/get.dart';
2 4
 import 'package:flutter/material.dart';
5
+import 'package:flutter_easyloading/flutter_easyloading.dart';
3 6
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
-import 'package:get/get.dart';
5 7
 import 'package:worker_client/models/entities/Machinery.dart';
6 8
 import 'package:worker_client/services/machinery.dart';
7 9
 import 'package:worker_client/widgets/Jianbian/index.dart';
10
+import 'package:worker_client/widgets/NullCard.dart';
8 11
 import 'package:worker_client/widgets/layout/BasicPage.dart';
9 12
 
10 13
 class MachineryDetail extends BasicPage {
@@ -14,13 +17,17 @@ class MachineryDetail extends BasicPage {
14 17
   final machinery = Rx<Machinery>(Machinery());
15 18
   @override
16 19
   void beforeShow() {
17
-    // TODO: implement beforeShow
18 20
     super.beforeShow();
19 21
     if (Get.arguments != null) {
20
-      getMachineryDetail(Get.arguments['id'], {
21
-        'attached': true,
22
-        'location': '118.84002,31.95266'
23
-      }).then((res) => {machinery(Machinery.fromJson(res))});
22
+      EasyLoading.show(status: '数据加载中...');
23
+      getMachineryDetail(Get.arguments['id'],
24
+          {'attached': true, 'location': '118.84002,31.95266'}).then((res) {
25
+        machinery(Machinery.fromJson(res));
26
+        EasyLoading.dismiss();
27
+      }).catchError((error){
28
+        EasyLoading.dismiss();
29
+        Fluttertoast.showToast(msg: error.error['message']);
30
+      });
24 31
     }
25 32
   }
26 33
 
@@ -117,11 +124,13 @@ class MachineryDetail extends BasicPage {
117 124
                               ],
118 125
                             ),
119 126
                           ),
120
-                          Container(
121
-                            margin: EdgeInsets.only(left: 15.w, right: 15.w),
122
-                            child: Column(
123
-                              children: machinery.value.contentList != null
124
-                                  ? machinery.value.contentList!.map((e) {
127
+                          machinery.value.contentList!.isNotEmpty
128
+                              ? Container(
129
+                                  margin:
130
+                                      EdgeInsets.only(left: 15.w, right: 15.w),
131
+                                  child: Column(
132
+                                    children:
133
+                                        machinery.value.contentList!.map((e) {
125 134
                                       if (e.contentType == 'image') {
126 135
                                         return Image.network(
127 136
                                             e.content.toString(),
@@ -141,10 +150,10 @@ class MachineryDetail extends BasicPage {
141 150
                                           ),
142 151
                                         );
143 152
                                       }
144
-                                    }).toList()
145
-                                  : [],
146
-                            ),
147
-                          )
153
+                                    }).toList(),
154
+                                  ),
155
+                                )
156
+                              : const NullCard(text: '该农机暂未添加详情'),
148 157
                         ],
149 158
                       )),
150 159
                 ],

+ 7
- 0
lib/pages/machineryList/index.dart Ver fichero

@@ -1,5 +1,7 @@
1 1
 import 'package:flutter/material.dart';
2
+import 'package:flutter_easyloading/flutter_easyloading.dart';
2 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:fluttertoast/fluttertoast.dart';
3 5
 import 'package:get/get.dart';
4 6
 import 'package:worker_client/models/app.dart';
5 7
 import 'package:worker_client/models/entities/Machinery.dart';
@@ -14,10 +16,15 @@ class MachineryList extends BasicPage {
14 16
   @override
15 17
   void beforeShow() {
16 18
     super.beforeShow();
19
+    EasyLoading.show(status: '数据加载中...');
17 20
     getMachineryList({'pageNum': 1, 'location': location}).then((res) {
18 21
       dynamic list = <Machinery>[];
19 22
       res['records'].forEach((item) => {list.add(Machinery.fromJson(item))});
20 23
       machineryList(list);
24
+      EasyLoading.dismiss();
25
+    }).catchError((error) {
26
+      EasyLoading.dismiss();
27
+      Fluttertoast.showToast(msg: error.error['message']);
21 28
     });
22 29
   }
23 30
 

+ 41
- 29
lib/pages/machineryMap/index.dart Ver fichero

@@ -1,6 +1,8 @@
1 1
 import 'dart:convert';
2 2
 import 'package:flutter/material.dart';
3
+import 'package:flutter_easyloading/flutter_easyloading.dart';
3 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
+import 'package:fluttertoast/fluttertoast.dart';
4 6
 import 'package:get/get.dart';
5 7
 import 'package:worker_client/models/app.dart';
6 8
 import 'package:worker_client/models/entities/Machinery.dart';
@@ -35,39 +37,49 @@ class MachineryMap extends BasicPage {
35 37
   void beforeShow() {
36 38
     super.beforeShow();
37 39
     if (Get.arguments != null) {
40
+      EasyLoading.show(status: '数据加载中...');
38 41
       getMachineryDetail(Get.arguments['id'], {
39 42
         'attached': true,
40 43
         //查询农机详情时需要把当前定位传到服务端
41 44
         'location': '118.84002,31.95266'
42
-      }).then((res) => {
43
-            getMachineryList({'pageSize': 500, 'location': location})
44
-                .then((value) {
45
-              dynamic list = <Machinery>[];
46
-              int index;
47
-              Machinery data = Machinery.fromJson(res);
48
-              List area = [];
49
-              value['records'].forEach((item) {
50
-                index = value['records'].indexOf(item);
51
-                item['location'] = locList[index % 10];
52
-                list.add(Machinery.fromJson(item));
53
-                if (data.machineryId == item['machineryId']) {
54
-                  data.location = item['location'];
55
-                  area = item['location'].toString().split(',');
56
-                  setAmap({
57
-                    'params': 'location=${area[1]},${area[0]}',
58
-                    'path': '/v3/geocode/regeo'
59
-                  }).then((value) {
60
-                    //json字符串转Map对象
61
-                    data.address =
62
-                        jsonDecode(value)['regeocode']['formatted_address'];
63
-                    machinery(data);
64
-                    current(data);
45
+      })
46
+          .then((res) => {
47
+                getMachineryList({'pageSize': 500, 'location': location})
48
+                    .then((value) {
49
+                  dynamic list = <Machinery>[];
50
+                  int index;
51
+                  Machinery data = Machinery.fromJson(res);
52
+                  List area = [];
53
+                  value['records'].forEach((item) {
54
+                    index = value['records'].indexOf(item);
55
+                    item['location'] = locList[index % 10];
56
+                    list.add(Machinery.fromJson(item));
57
+                    if (data.machineryId == item['machineryId']) {
58
+                      data.location = item['location'];
59
+                      area = item['location'].toString().split(',');
60
+                      setAmap({
61
+                        'params': 'location=${area[1]},${area[0]}',
62
+                        'path': '/v3/geocode/regeo'
63
+                      }).then((value) {
64
+                        //json字符串转Map对象
65
+                        data.address =
66
+                            jsonDecode(value)['regeocode']['formatted_address'];
67
+                        machinery(data);
68
+                        current(data);
69
+                      });
70
+                    }
65 71
                   });
66
-                }
67
-              });
68
-              machineryList(list);
69
-            }),
70
-          });
72
+                  machineryList(list);
73
+                  EasyLoading.dismiss();
74
+                }).catchError((error) {
75
+                  EasyLoading.dismiss();
76
+                  Fluttertoast.showToast(msg: error.error['message']);
77
+                }),
78
+              })
79
+          .catchError((error2) {
80
+        EasyLoading.dismiss();
81
+        Fluttertoast.showToast(msg: error2.error['message']);
82
+      });
71 83
     }
72 84
   }
73 85
 
@@ -100,7 +112,7 @@ class MachineryMap extends BasicPage {
100 112
   }
101 113
 
102 114
   void onCancel() {
103
-    if (!visible.value) {
115
+    if (visible.value) {
104 116
       visible(false);
105 117
     }
106 118
   }

+ 10
- 4
lib/pages/userInfo/index.dart Ver fichero

@@ -1,4 +1,5 @@
1 1
 import 'package:flutter/material.dart';
2
+import 'package:flutter_easyloading/flutter_easyloading.dart';
2 3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 4
 import 'package:fluttertoast/fluttertoast.dart';
4 5
 import 'package:get/get.dart';
@@ -9,7 +10,10 @@ import 'package:worker_client/widgets/MyButton/index.dart';
9 10
 import 'package:worker_client/widgets/layout/BasicPage.dart';
10 11
 
11 12
 class UserInfo extends BasicPage {
12
-  UserInfo({Key? key}) : super(key: key);
13
+  UserInfo({Key? key}) : super(key: key){
14
+    naviTitle = '个人信息';
15
+    isPop = true;
16
+  }
13 17
 
14 18
   AppController store = AppController.t;
15 19
   late String name;
@@ -19,7 +23,6 @@ class UserInfo extends BasicPage {
19 23
 
20 24
   @override
21 25
   void beforeShow() {
22
-    // TODO: implement beforeShow
23 26
     super.beforeShow();
24 27
     _cName = TextEditingController(text: store.user().nickName.toString());
25 28
     _cPhone = TextEditingController(text: store.user().phone.toString());
@@ -37,6 +40,7 @@ class UserInfo extends BasicPage {
37 40
       Fluttertoast.showToast(msg: '请输入正确的手机号');
38 41
       return;
39 42
     } else {
43
+      EasyLoading.show(status: '保存中', maskType: EasyLoadingMaskType.black);
40 44
       updateInfo(store.user().personId.toString(), {
41 45
         ...store.user().toJson(),
42 46
         'nickName': name,
@@ -44,15 +48,17 @@ class UserInfo extends BasicPage {
44 48
       }).then((value) {
45 49
         Fluttertoast.showToast(msg: '修改成功');
46 50
         store.user(Person.fromJson(value));
51
+        EasyLoading.dismiss();
47 52
         Get.offAllNamed('/main');
53
+      }).catchError((error) {
54
+        EasyLoading.dismiss();
55
+        Fluttertoast.showToast(msg: error.error['message']);
48 56
       });
49 57
     }
50 58
   }
51 59
 
52 60
   @override
53 61
   Widget builder(BuildContext context) {
54
-    naviTitle = '个人信息';
55
-    isPop = true;
56 62
     return Container(
57 63
       padding: EdgeInsets.all(15.w),
58 64
       decoration: const BoxDecoration(color: Colors.white),

+ 2
- 0
lib/pages/withdrawal/index.dart Ver fichero

@@ -82,6 +82,8 @@ class MyWithdrawal extends BasicPage {
82 82
         });
83 83
         bankPickerListStore.bankPickerList(pickerList);
84 84
         bankCardListStore.bankCardList(list);
85
+      }).catchError((error){
86
+        Fluttertoast.showToast(msg: error.error['message']);
85 87
       });
86 88
     }
87 89
   }

+ 3
- 8
lib/services/account.dart Ver fichero

@@ -6,10 +6,7 @@ import 'package:fluttertoast/fluttertoast.dart';
6 6
 /// @param {*} data
7 7
 /// @returns
8 8
 Future getAccount() async {
9
-  return request('/account/mine',
10
-      options: Options(method: 'GET'))
11
-      .catchError((error) =>
12
-  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
9
+  return request('/account/mine', options: Options(method: 'GET'));
13 10
 }
14 11
 
15 12
 /// 我的流水
@@ -17,7 +14,5 @@ Future getAccount() async {
17 14
 /// @returns
18 15
 Future getLogList(params) async {
19 16
   return request('/account-log',
20
-      options: Options(method: 'GET'), queryParameters: params)
21
-      .catchError((error) =>
22
-  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
23
-}
17
+      options: Options(method: 'GET'), queryParameters: params);
18
+}

+ 11
- 14
lib/services/bank.dart Ver fichero

@@ -7,27 +7,25 @@ import 'package:fluttertoast/fluttertoast.dart';
7 7
 /// @returns
8 8
 Future getBankList(params) async {
9 9
   return request('/bank',
10
-      options: Options(method: 'GET'), queryParameters: params)
11
-      .catchError((error) =>
12
-  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
10
+      options: Options(method: 'GET'), queryParameters: params);
13 11
 }
12
+
14 13
 /// 银行卡列表
15 14
 /// @param {*} data
16 15
 /// @returns
17 16
 Future getBankCardList(params) async {
18 17
   return request('/bankcard',
19
-      options: Options(method: 'GET'), queryParameters: params)
20
-      .catchError((error) =>
21
-  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
18
+      options: Options(method: 'GET'), queryParameters: params);
22 19
 }
20
+
23 21
 /// 银行卡详情
24 22
 /// @param {*} data
25 23
 /// @returns
26 24
 Future getBankCardDetail(String id) async {
27 25
   return request('/bankcard/$id', options: Options(method: 'GET'))
28 26
       .catchError((error) => {
29
-    Fluttertoast.showToast(msg: error.error['message']),
30
-  });
27
+            Fluttertoast.showToast(msg: error.error['message']),
28
+          });
31 29
 }
32 30
 
33 31
 /// 添加银行卡
@@ -39,19 +37,18 @@ Future addBankCard(data) async {
39 37
     options: Options(method: 'POST'),
40 38
     data: data,
41 39
   ).catchError((error) => {
42
-    Fluttertoast.showToast(msg: error.error['message']),
43
-  });
40
+        Fluttertoast.showToast(msg: error.error['message']),
41
+      });
44 42
 }
45 43
 
46 44
 /// 解绑银行卡
47 45
 /// @param {*}
48 46
 /// @returns
49 47
 Future unbindBankCard(String id) async {
50
-  return request('/bankcard/$id/pause',
51
-      options: Options(method: 'DELETE'))
48
+  return request('/bankcard/$id/pause', options: Options(method: 'DELETE'))
52 49
       .catchError((error) => {
53
-    Fluttertoast.showToast(msg: error.error['message']),
54
-  });
50
+            Fluttertoast.showToast(msg: error.error['message']),
51
+          });
55 52
 }
56 53
 
57 54
 /// 添加银行卡

+ 2
- 8
lib/services/job.dart Ver fichero

@@ -29,18 +29,12 @@ Future getJobDetail(String id) async {
29 29
  */
30 30
 Future startJob(String id, params) async {
31 31
   return request('/work-job/$id/pause',
32
-          options: Options(method: 'PUT'), queryParameters: params)
33
-      .catchError((error) => {
34
-            Fluttertoast.showToast(msg: error.error['message']),
35
-          });
32
+          options: Options(method: 'PUT'), queryParameters: params);
36 33
 }
37 34
 /// 开始作业
38 35
 /// @param {*}
39 36
 /// @returns
40 37
 Future overJob(String id, data) async {
41 38
   return request('/work-job/$id/stop',
42
-      options: Options(method: 'PUT'), data: data)
43
-      .catchError((error) => {
44
-    Fluttertoast.showToast(msg: error.error['message']),
45
-  });
39
+      options: Options(method: 'PUT'), data: data);
46 40
 }

+ 2
- 7
lib/services/machinery.dart Ver fichero

@@ -7,9 +7,7 @@ import 'package:fluttertoast/fluttertoast.dart';
7 7
 /// @returns
8 8
 Future getMachineryList(params) async {
9 9
   return request('/machinery',
10
-          options: Options(method: 'GET'), queryParameters: params)
11
-      .catchError((error) =>
12
-          {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
10
+      options: Options(method: 'GET'), queryParameters: params);
13 11
 }
14 12
 
15 13
 /// 农机详情
@@ -17,8 +15,5 @@ Future getMachineryList(params) async {
17 15
 /// @returns
18 16
 Future getMachineryDetail(String id, params) async {
19 17
   return request('/machinery-summary/$id',
20
-          options: Options(method: 'GET'), queryParameters: params)
21
-      .catchError((error) => {
22
-            Fluttertoast.showToast(msg: error.error['message']),
23
-          });
18
+      options: Options(method: 'GET'), queryParameters: params);
24 19
 }

+ 1
- 4
lib/services/user.dart Ver fichero

@@ -31,8 +31,5 @@ Future getCurrent() async {
31 31
  */
32 32
 
33 33
 Future updateInfo(String id, Map data) async {
34
-  return request('/person/${id}', options: Options(method: 'PUT'), data: data)
35
-      .catchError((error) => {
36
-            Fluttertoast.showToast(msg: error.error['message']),
37
-          });
34
+  return request('/person/${id}', options: Options(method: 'PUT'), data: data);
38 35
 }