李志伟 3 年之前
父節點
當前提交
125d30c2f1

+ 2
- 1
lib/pages/index.dart 查看文件

@@ -4,4 +4,5 @@ export 'Login/index.dart';
4 4
 export 'order/index.dart';
5 5
 export 'main/index.dart';
6 6
 export 'jobDetail/index.dart';
7
-export 'orderDetail/index.dart';
7
+export 'orderDetail/index.dart';
8
+export 'machineryList/index.dart';

+ 2
- 6
lib/pages/jobDetail/index.dart 查看文件

@@ -105,16 +105,13 @@ class JobDetail extends BasicPage {
105 105
   void changeJob(Job item) {
106 106
     if (item.status == 0) {
107 107
       modal.showDialog(
108
-          title: '',
109 108
           content: startContent(),
110 109
           onConfirm: () {
111 110
             startJob(item.jobId.toString(), {'mode': true})
112 111
                 .then((value) => getJob());
113
-          },
114
-          onCancel: () => true);
112
+          });
115 113
     } else {
116 114
       modal.showDialog(
117
-          title: '',
118 115
           content: endContent(),
119 116
           onConfirm: () {
120 117
             if (area.value == '') {
@@ -129,8 +126,7 @@ class JobDetail extends BasicPage {
129 126
                 Fluttertoast.showToast(msg: '恭喜完成作业');
130 127
               });
131 128
             }
132
-          },
133
-          onCancel: () => true);
129
+          },);
134 130
     }
135 131
   }
136 132
 

+ 11
- 0
lib/pages/machineryList/index.dart 查看文件

@@ -0,0 +1,11 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:worker_client/widgets/layout/BasicPage.dart';
3
+
4
+class MachineryList extends BasicPage{
5
+  @override
6
+  Widget builder(BuildContext context) {
7
+    naviTitle = '我的';
8
+    return const Text('农机列表');
9
+  }
10
+
11
+}

+ 287
- 7
lib/pages/main/index.dart 查看文件

@@ -1,6 +1,11 @@
1 1
 import 'package:flutter/material.dart';
2
+import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+import 'package:get/get.dart';
4
+import 'package:get_storage/get_storage.dart';
5
+import 'package:worker_client/widgets/GradientButton.dart';
6
+import 'package:worker_client/widgets/MyCell/index.dart';
2 7
 import 'package:worker_client/widgets/layout/BasicPage.dart';
3
-
8
+import '/widgets/MyDialog.dart' as modal;
4 9
 
5 10
 class Main extends BasicPage {
6 11
   Main({Key? key}) : super(key: key) {
@@ -8,14 +13,289 @@ class Main extends BasicPage {
8 13
     naviTitle = '我的';
9 14
   }
10 15
 
16
+  GetStorage box = GetStorage();
17
+
18
+  void loginOut() {
19
+    modal.showAlert(
20
+        title: '提示',
21
+        message: '确定要退出登陆吗?',
22
+        onConfirm: () {
23
+          box.remove('token');
24
+          Get.offNamed('/login');
25
+          return true;
26
+        },
27
+        onCancel: () => true);
28
+  }
29
+  void goMachinery(){
30
+    Get.toNamed('/machineryList');
31
+  }
32
+
11 33
   @override
12 34
   Widget builder(BuildContext context) {
13
-    return Column(
14
-      children: [
15
-        Container(
16
-
17
-        )
18
-      ],
35
+    return Container(
36
+      decoration: const BoxDecoration(color: Colors.white),
37
+      child: ListView(
38
+        children: [
39
+          Stack(
40
+            children: [
41
+              Positioned(
42
+                top: 0,
43
+                child: Container(
44
+                  width: 375.w,
45
+                  height: 187.5.w,
46
+                  decoration: const BoxDecoration(
47
+                    image: DecorationImage(
48
+                      image: AssetImage("images/main/userBgi.png"),
49
+                      fit: BoxFit.cover,
50
+                    ),
51
+                  ),
52
+                  child: Row(
53
+                    crossAxisAlignment: CrossAxisAlignment.center,
54
+                    children: [
55
+                      Container(
56
+                        margin: EdgeInsets.fromLTRB(40.w, 0, 10.w, 0),
57
+                        child: Image.asset(
58
+                          'images/main/defaultAvatar.png',
59
+                          width: 63.w,
60
+                          height: 63.w,
61
+                        ),
62
+                      ),
63
+                      Column(
64
+                        mainAxisAlignment: MainAxisAlignment.center,
65
+                        crossAxisAlignment: CrossAxisAlignment.start,
66
+                        children: [
67
+                          Text(
68
+                            '姓名',
69
+                            style: TextStyle(
70
+                                color: Colors.white,
71
+                                fontWeight: FontWeight.w500,
72
+                                fontSize: 17.sp,
73
+                                letterSpacing: 2,
74
+                                shadows: [
75
+                                  BoxShadow(
76
+                                      color: const Color(0x66000000),
77
+                                      offset: Offset(0, 1.w),
78
+                                      blurRadius: 0)
79
+                                ]),
80
+                          ),
81
+                          Container(
82
+                            margin: EdgeInsets.fromLTRB(0, 19.h, 0, 0),
83
+                            child: Text(
84
+                              '手机号',
85
+                              style: TextStyle(
86
+                                  color: Colors.white,
87
+                                  fontWeight: FontWeight.w500,
88
+                                  fontSize: 17.sp,
89
+                                  letterSpacing: 2,
90
+                                  shadows: [
91
+                                    BoxShadow(
92
+                                        color: const Color(0x66000000),
93
+                                        offset: Offset(0, 1.w),
94
+                                        blurRadius: 0)
95
+                                  ]),
96
+                            ),
97
+                          )
98
+                        ],
99
+                      )
100
+                    ],
101
+                  ),
102
+                ),
103
+              ),
104
+              Positioned(
105
+                right: 0,
106
+                top: 0,
107
+                child: Container(
108
+                  decoration: const BoxDecoration(color: Color(0xb2000000)),
109
+                  child: Text(
110
+                    '该账号归。。。所属',
111
+                    style: TextStyle(color: Colors.white, fontSize: 12.sp),
112
+                  ),
113
+                ),
114
+              ),
115
+              Column(
116
+                children: [
117
+                  Container(
118
+                    margin: EdgeInsets.fromLTRB(15.w, 187.5.w - 15.h, 15.w, 0),
119
+                    height: 101.h,
120
+                    decoration: BoxDecoration(
121
+                        color: Colors.white,
122
+                        borderRadius: BorderRadius.all(Radius.circular(20.w)),
123
+                        boxShadow: [
124
+                          BoxShadow(
125
+                            color: const Color(0x14000000),
126
+                            offset: const Offset(0, 0),
127
+                            blurRadius: 22.w,
128
+                          ),
129
+                        ]),
130
+                    child: Row(
131
+                      mainAxisAlignment: MainAxisAlignment.spaceAround,
132
+                      children: [
133
+                        GestureDetector(
134
+                          onTap:(){
135
+                            goMachinery();
136
+                          },
137
+                          child: Column(
138
+                            mainAxisAlignment: MainAxisAlignment.center,
139
+                            children: [
140
+                              Image.asset(
141
+                                'images/main/machinery.png',
142
+                                width: 30.w,
143
+                              ),
144
+                              Text(
145
+                                '我的农机',
146
+                                style: TextStyle(
147
+                                    fontSize: 17.sp,
148
+                                    fontWeight: FontWeight.bold,
149
+                                    color: Color(0xFF333333)),
150
+                              )
151
+                            ],
152
+                          ),
153
+                        ),
154
+                        Column(
155
+                          mainAxisAlignment: MainAxisAlignment.center,
156
+                          children: [
157
+                            Image.asset(
158
+                              'images/main/wallet.png',
159
+                              width: 30.w,
160
+                            ),
161
+                            Text(
162
+                              '我的钱包',
163
+                              style: TextStyle(
164
+                                  fontSize: 17.sp,
165
+                                  fontWeight: FontWeight.bold,
166
+                                  color: Color(0xFF333333)),
167
+                            )
168
+                          ],
169
+                        ),
170
+                        Column(
171
+                          mainAxisAlignment: MainAxisAlignment.center,
172
+                          children: [
173
+                            Image.asset(
174
+                              'images/main/bankCard.png',
175
+                              width: 30.w,
176
+                            ),
177
+                            Text(
178
+                              '我的银行卡',
179
+                              style: TextStyle(
180
+                                  fontSize: 17.sp,
181
+                                  fontWeight: FontWeight.bold,
182
+                                  color: Color(0xFF333333)),
183
+                            )
184
+                          ],
185
+                        ),
186
+                      ],
187
+                    ),
188
+                  ),
189
+                  Container(
190
+                    margin: EdgeInsets.fromLTRB(0, 15.h, 0, 0),
191
+                    padding:
192
+                        EdgeInsets.symmetric(horizontal: 15.w, vertical: 0),
193
+                    child: Column(
194
+                      children: [
195
+                        MyCell(
196
+                          head: Image.asset(
197
+                            'images/main/account.png',
198
+                            width: 19.w,
199
+                          ),
200
+                          body: Text(
201
+                            '账号与安全',
202
+                            style: TextStyle(
203
+                              fontSize: 17.sp,
204
+                              color: Color(0xff333333),
205
+                              fontWeight: FontWeight.bold,
206
+                            ),
207
+                          ),
208
+                          action: Image.asset(
209
+                            'images/main/goto.png',
210
+                            width: 10.w,
211
+                          ),
212
+                          onClick: () {},
213
+                        ),
214
+                        MyCell(
215
+                          head: Image.asset(
216
+                            'images/main/aboutUs.png',
217
+                            width: 19.w,
218
+                          ),
219
+                          body: Text(
220
+                            '关于我们',
221
+                            style: TextStyle(
222
+                                fontSize: 17.sp,
223
+                                fontWeight: FontWeight.bold,
224
+                                color: Color(0xff333333)),
225
+                          ),
226
+                          action: Image.asset(
227
+                            'images/main/goto.png',
228
+                            width: 10.w,
229
+                          ),
230
+                          onClick: () {},
231
+                        ),
232
+                        MyCell(
233
+                          head: Image.asset(
234
+                            'images/main/update.png',
235
+                            width: 19.w,
236
+                          ),
237
+                          body: Text(
238
+                            '用户协议及隐私政策',
239
+                            style: TextStyle(
240
+                                fontSize: 17.sp,
241
+                                fontWeight: FontWeight.bold,
242
+                                color: Color(0xff333333)),
243
+                          ),
244
+                          action: Image.asset(
245
+                            'images/main/goto.png',
246
+                            width: 10.w,
247
+                          ),
248
+                          onClick: () {},
249
+                        ),
250
+                        MyCell(
251
+                          head: Image.asset(
252
+                            'images/main/Feedback.png',
253
+                            width: 19.w,
254
+                          ),
255
+                          body: Text(
256
+                            '意见反馈',
257
+                            style: TextStyle(
258
+                                fontSize: 17.sp,
259
+                                fontWeight: FontWeight.bold,
260
+                                color: Color(0xff333333)),
261
+                          ),
262
+                          action: Image.asset(
263
+                            'images/main/goto.png',
264
+                            width: 10.w,
265
+                          ),
266
+                          onClick: () {},
267
+                        ),
268
+                        Container(
269
+                            height: 45.5.h,
270
+                            width: 345.w,
271
+                            margin: EdgeInsets.only(top: 30.h, bottom: 30.h),
272
+                            child: GradientButton(
273
+                                colors: const [
274
+                                  Color(0xFFF8F8F8),
275
+                                  Color(0xFFF8F8F8)
276
+                                ],
277
+                                borderRadius:
278
+                                    BorderRadius.all(Radius.circular(24.5.w)),
279
+                                onPressed: () {
280
+                                  loginOut();
281
+                                },
282
+                                child: Text(
283
+                                  "退出登陆",
284
+                                  style: TextStyle(
285
+                                    fontSize: 20.sp,
286
+                                    fontWeight: FontWeight.bold,
287
+                                    color: const Color(0xFF333333),
288
+                                  ),
289
+                                )))
290
+                      ],
291
+                    ),
292
+                  ),
293
+                ],
294
+              )
295
+            ],
296
+          )
297
+        ],
298
+      ),
19 299
     );
20 300
   }
21 301
 }

+ 2
- 1
lib/routes/pages.dart 查看文件

@@ -8,9 +8,10 @@ List<GetPage> pages=[
8 8
     return box.hasData('token')?Home():Login();
9 9
   }),
10 10
   GetPage(name: '/order', page: () => Order()),
11
-  GetPage(name: '/login', page: () => Login()),
11
+  GetPage(name: '/login', page: () => const Login()),
12 12
   GetPage(name: '/home', page: () => Home()),
13 13
   GetPage(name: '/main', page: () => Main()),
14 14
   GetPage(name: '/jobDetail', page: () => JobDetail()),
15 15
   GetPage(name: '/orderDetail', page: () => OrderDetail()),
16
+  GetPage(name: '/machineryList', page: () => MachineryList()),
16 17
 ];

+ 2
- 1
lib/utils/Request.dart 查看文件

@@ -29,7 +29,8 @@ final client = GetPlatform.isAndroid ? 'android' : 'ios';
29 29
 
30 30
 Dio createRequest() {
31 31
   var options = BaseOptions(
32
-    baseUrl: 'https://machine.njyunzhi.com/api/' + client + '/worker',
32
+    baseUrl: 'http://192.168.89.147:7080/api/' + client + '/worker',
33
+    // baseUrl: 'https://machine.njyunzhi.com/api/' + client + '/worker',
33 34
     connectTimeout: 5000,
34 35
     receiveTimeout: 3000,
35 36
   );

+ 45
- 0
lib/widgets/MyCell/index.dart 查看文件

@@ -0,0 +1,45 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+
4
+class MyCell extends StatelessWidget {
5
+  final Widget head;
6
+  final Widget body;
7
+  final Widget? action;
8
+  final GestureTapCallback? onClick;
9
+
10
+  const MyCell(
11
+      {Key? key,
12
+      required this.head,
13
+      required this.body,
14
+      this.action,
15
+      this.onClick})
16
+      : super(key: key);
17
+  @override
18
+  Widget build(BuildContext context) {
19
+    return GestureDetector(
20
+      onTap: onClick,
21
+      child: Container(
22
+        margin: EdgeInsets.fromLTRB(0, 0, 0, 1.h),
23
+        padding: EdgeInsets.symmetric(horizontal: 17.5.w, vertical: 19.h),
24
+        decoration: BoxDecoration(
25
+            color: Colors.white,
26
+            boxShadow: [
27
+          BoxShadow(
28
+              color: const Color(0x1f000000),
29
+              offset: Offset(0, 1.w),
30
+              blurRadius: 0)
31
+        ]),
32
+        child: Row(
33
+          children: [
34
+            Container(
35
+              margin: EdgeInsets.fromLTRB(0, 0, 11.5.w, 0),
36
+              child: head,
37
+            ),
38
+            Expanded(flex: 1, child: body),
39
+            action ?? const Text(''),
40
+          ],
41
+        ),
42
+      ),
43
+    );
44
+  }
45
+}

+ 27
- 18
lib/widgets/MyDialog.dart 查看文件

@@ -29,18 +29,17 @@ void _handleFunc(ModalFunc? func) {
29 29
 
30 30
 /// 打开一个 dialog
31 31
 void showDialog(
32
-    {required String title,
32
+    {String? title,
33 33
     String? message,
34 34
     Widget? content,
35 35
     ModalFunc? onConfirm,
36
-    ModalFunc? onCancel}) {
36
+    }) {
37 37
   Get.dialog(Modal(
38 38
     type: 'dialog',
39 39
     title: title,
40 40
     message: message,
41 41
     content: content,
42 42
     onConfirm: () => _handleFunc(onConfirm),
43
-    onCancel: () => _handleFunc(onCancel),
44 43
   ));
45 44
 }
46 45
 
@@ -49,13 +48,16 @@ void showAlert(
49 48
     {required String title,
50 49
     String? message,
51 50
     Widget? content,
52
-    ModalFunc? onConfirm}) {
51
+    ModalFunc? onConfirm,
52
+      ModalFunc? onCancel
53
+    }) {
53 54
   Get.dialog(Modal(
54 55
     type: 'alert',
55 56
     title: title,
56 57
     message: message,
57 58
     content: content,
58 59
     onConfirm: () => _handleFunc(onConfirm),
60
+    onCancel: () => _handleFunc(onCancel),
59 61
   ));
60 62
 }
61 63
 
@@ -65,7 +67,7 @@ void _closeModal() {
65 67
 }
66 68
 
67 69
 class Modal extends StatelessWidget {
68
-  String title;
70
+  String? title;
69 71
   String type;
70 72
   String? message;
71 73
   Widget? content;
@@ -78,11 +80,11 @@ class Modal extends StatelessWidget {
78 80
       fontWeight: FontWeight.bold);
79 81
   final _messageStyle =
80 82
       TextStyle(color: const Color(0xFF666666), fontSize: 18.sp);
81
-  final _primaryColor = const Color(0xFFFF703B);
82
-  final _btnSize = Size(90.w, 36.w);
83
+  final _primaryColor = const Color(0xFF5BD583);
84
+  final _btnSize = Size(100.w, 49.h);
83 85
   final _btnShape = RoundedRectangleBorder(
84
-    side: const BorderSide(color: Color(0xFFFF703B), width: 2.0),
85
-    borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
86
+    side: const BorderSide(color: Color(0xFF00AE39), width: 1),
87
+    borderRadius: BorderRadius.all(Radius.circular(17.w)),
86 88
   );
87 89
 
88 90
   void _handleConfirm() {
@@ -100,7 +102,7 @@ class Modal extends StatelessWidget {
100 102
   Modal({
101 103
     Key? key,
102 104
     this.type = 'alert',
103
-    required this.title,
105
+    this.title,
104 106
     this.message,
105 107
     this.content,
106 108
     this.onConfirm,
@@ -108,8 +110,7 @@ class Modal extends StatelessWidget {
108 110
   }) : super(key: key);
109 111
 
110 112
   Widget _confirmBtn() {
111
-    return Container(
112
-      margin: EdgeInsets.fromLTRB(0, 25.w, 0, 0),
113
+    return SizedBox(
113 114
       width: 100.w,
114 115
       height: 49.h,
115 116
       child: GradientButton(
@@ -128,7 +129,7 @@ class Modal extends StatelessWidget {
128 129
     return ElevatedButton(
129 130
       child: Text("取消",
130 131
           style: TextStyle(
131
-              color: _primaryColor, fontSize: 18.sp, letterSpacing: 5.sp)),
132
+              color: _primaryColor, fontSize: 17.sp,letterSpacing: 2)),
132 133
       style: ElevatedButton.styleFrom(
133 134
         primary: Colors.white,
134 135
         elevation: 0,
@@ -140,18 +141,25 @@ class Modal extends StatelessWidget {
140 141
   }
141 142
 
142 143
   Widget _alert() {
144
+    Widget hSpacer = SizedBox(width: 16.w);
143 145
     return SimpleDialog(
144 146
         shape:
145 147
             RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.w)),
146 148
         titleTextStyle: _titleStyle,
147
-        title: Text(title, textAlign: TextAlign.center),
149
+        title: Text(title!, textAlign: TextAlign.center),
148 150
         children: [
149 151
           if (null != message)
150 152
             Text(message!, textAlign: TextAlign.center, style: _messageStyle),
151 153
           if (null != content) content!,
152
-          Center(
153
-            child: _confirmBtn(),
154
-          ),
154
+          SizedBox(height: 16.w),
155
+          Row(
156
+            mainAxisAlignment: MainAxisAlignment.center,
157
+            children: [
158
+              _confirmBtn(),
159
+              hSpacer,
160
+              _cancelBtn()
161
+            ],
162
+          )
155 163
         ]);
156 164
   }
157 165
 
@@ -160,9 +168,9 @@ class Modal extends StatelessWidget {
160 168
         shape:
161 169
             RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.w)),
162 170
         titleTextStyle: _titleStyle,
163
-        title: Text(title, textAlign: TextAlign.center),
164 171
         alignment: Alignment.center,
165 172
         children: [
173
+          SizedBox(height: 50.h),
166 174
           if (null != message)
167 175
             Text(message!, textAlign: TextAlign.center, style: _messageStyle),
168 176
           if (null != content) content!,
@@ -172,6 +180,7 @@ class Modal extends StatelessWidget {
172 180
               _confirmBtn(),
173 181
             ],
174 182
           ),
183
+          SizedBox(height: 50.h)
175 184
         ]);
176 185
   }
177 186
 

+ 2
- 1
pubspec.yaml 查看文件

@@ -70,9 +70,10 @@ flutter:
70 70
   # the material Icons class.
71 71
   uses-material-design: true
72 72
   assets:
73
+    - images/
73 74
     - images/login/
74 75
     - images/index/
75
-    - images/
76
+    - images/main/
76 77
   # To add assets to your application, add an assets section, like this:
77 78
   # assets:
78 79
   #   - images/a_dot_burr.jpeg