[baozhangchao] 3 лет назад
Родитель
Сommit
3f8edf1326

Двоичные данные
images/phoneCode.png Просмотреть файл


+ 2
- 1
lib/main.dart Просмотреть файл

9
 import 'components/UI/DefaultButton.dart';
9
 import 'components/UI/DefaultButton.dart';
10
 
10
 
11
 void main() {
11
 void main() {
12
+  Store().init();
12
   runApp(const MyApp());
13
   runApp(const MyApp());
13
 }
14
 }
14
 
15
 
18
   // This widget is the root of your application.
19
   // This widget is the root of your application.
19
   @override
20
   @override
20
   Widget build(BuildContext context) {
21
   Widget build(BuildContext context) {
21
-    Store().init();
22
 
22
 
23
     return MaterialApp(
23
     return MaterialApp(
24
       title: 'Flutter Demo',
24
       title: 'Flutter Demo',
35
         primarySwatch: Colors.blue,
35
         primarySwatch: Colors.blue,
36
       ),
36
       ),
37
       home: const MyHomePage(title: 'Flutter Demo Home Page'),
37
       home: const MyHomePage(title: 'Flutter Demo Home Page'),
38
+        // IndexPage()
38
     );
39
     );
39
   }
40
   }
40
 }
41
 }

+ 11
- 0
lib/pages/TabBar/Information_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class InformationPage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    // TODO: implement build
7
+    return Scaffold(
8
+      body: Center(child: Text('资讯')),
9
+    );
10
+  }
11
+}

+ 11
- 0
lib/pages/TabBar/Mine_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class MinePage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    // TODO: implement build
7
+    return Scaffold(
8
+      body: Center(child: Text('我的')),
9
+    );
10
+  }
11
+}

+ 11
- 0
lib/pages/TabBar/Orders_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class OrdersPage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    // TODO: implement build
7
+    return Scaffold(
8
+      body: Center(child: Text('订单')),
9
+    );
10
+  }
11
+}

+ 10
- 0
lib/pages/TabBar/home_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class HomePage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    return Scaffold(
7
+      body: Center(child: Text('首页')),
8
+    );
9
+  }
10
+}

+ 71
- 0
lib/pages/TabBar/index_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+import 'package:flutter/cupertino.dart';
3
+import 'home_page.dart';
4
+import 'Information_page.dart';
5
+import 'Mine_page.dart';
6
+import 'Orders_page.dart';
7
+
8
+class IndexPage extends StatefulWidget {
9
+  _IndexPageState createState() => _IndexPageState();
10
+}
11
+
12
+class _IndexPageState extends State<IndexPage> {
13
+
14
+
15
+  final List<BottomNavigationBarItem> bottomTabs = [
16
+     BottomNavigationBarItem(
17
+      icon: Icon(CupertinoIcons.home),
18
+      title: Text('首页'),
19
+    ),
20
+     BottomNavigationBarItem(
21
+      icon: Icon(CupertinoIcons.search),
22
+      title: Text('资讯'),
23
+
24
+    ),
25
+     BottomNavigationBarItem(
26
+      icon: Icon(CupertinoIcons.shopping_cart),
27
+      title: Text('订单'),
28
+
29
+    ),
30
+     BottomNavigationBarItem(
31
+      icon: Icon(CupertinoIcons.profile_circled),
32
+      title: Text('我的'),
33
+    ),
34
+  ];
35
+
36
+  final List tabBodies = [
37
+    HomePage(),
38
+    InformationPage(),
39
+    OrdersPage(),
40
+    MinePage(),
41
+  ];
42
+
43
+  int currentIndex = 0;
44
+  var currentPage;
45
+
46
+  @override
47
+  void initState() {
48
+    super.initState();
49
+    currentPage = tabBodies[currentIndex];
50
+  }
51
+
52
+  @override
53
+  Widget build(BuildContext context) {
54
+    // TODO: implement build
55
+    return Scaffold(
56
+      backgroundColor: Color.fromRGBO(244, 245, 245, 1),
57
+      bottomNavigationBar: BottomNavigationBar(
58
+        type: BottomNavigationBarType.fixed,
59
+        currentIndex: currentIndex,
60
+        items: bottomTabs,
61
+        onTap: (index){
62
+          setState(() {
63
+            currentIndex = index;
64
+            currentPage = tabBodies[currentIndex];
65
+          });
66
+        },
67
+      ),
68
+      body: currentPage,
69
+    );
70
+  }
71
+}

+ 1
- 0
lib/pages/TabBar/member_page.dart Просмотреть файл

1
+// TODO Implement this library.

+ 95
- 40
lib/pages/login/login.dart Просмотреть файл

4
 import 'package:flutter/material.dart';
4
 import 'package:flutter/material.dart';
5
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
 import 'package:flutter_screenutil/flutter_screenutil.dart';
6
 
6
 
7
+import '../../services/user.dart';
7
 import '../../widgets/Cell.dart';
8
 import '../../widgets/Cell.dart';
8
 
9
 
9
 class MyRouteLogin extends StatefulWidget {
10
 class MyRouteLogin extends StatefulWidget {
24
         //当按钮可点击时
25
         //当按钮可点击时
25
         isButtonEnable = false; //按钮状态标记
26
         isButtonEnable = false; //按钮状态标记
26
         _initTimer();
27
         _initTimer();
28
+        getSMSCaptch(handlePhones);
27
         return null; //返回null按钮禁止点击
29
         return null; //返回null按钮禁止点击
28
       } else {
30
       } else {
29
         //当按钮不可点击时
31
         //当按钮不可点击时
82
   @override
84
   @override
83
   Widget build(BuildContext context) {
85
   Widget build(BuildContext context) {
84
     return Container(
86
     return Container(
85
-        width: 12.w,
87
+
86
         decoration: const BoxDecoration(
88
         decoration: const BoxDecoration(
87
           image: DecorationImage(
89
           image: DecorationImage(
88
             image: AssetImage("images/icon_login.png"),
90
             image: AssetImage("images/icon_login.png"),
97
               title: const Text('登陆'),
99
               title: const Text('登陆'),
98
             ),
100
             ),
99
             body: Center(
101
             body: Center(
100
-                child: Column(
101
-              crossAxisAlignment: CrossAxisAlignment.start,
102
+                child:  ListView(
103
+              // crossAxisAlignment: CrossAxisAlignment.start,
102
               children: <Widget>[
104
               children: <Widget>[
103
-                Text(
105
+
106
+                const Text(
104
                   '您好!',
107
                   '您好!',
105
                   style: TextStyle(
108
                   style: TextStyle(
106
                     fontWeight: FontWeight.bold,
109
                     fontWeight: FontWeight.bold,
107
                     fontSize: 50,
110
                     fontSize: 50,
108
                   ),
111
                   ),
109
                 ),
112
                 ),
110
-                Text(
113
+                const Text(
111
                   '欢迎进入农户端应用!',
114
                   '欢迎进入农户端应用!',
112
                   style: TextStyle(
115
                   style: TextStyle(
113
                     fontWeight: FontWeight.bold,
116
                     fontWeight: FontWeight.bold,
184
                 //     )),
187
                 //     )),
185
 
188
 
186
                 Cell(
189
                 Cell(
187
-                  margin: EdgeInsets.symmetric(horizontal: 13.w),
190
+                  // margin: EdgeInsets.symmetric(horizontal: 13.w),
191
+                  margin: const EdgeInsets.fromLTRB(13, 43, 10,0 ),
188
                   header: Text(
192
                   header: Text(
189
                     "+86",
193
                     "+86",
190
-                    style: TextStyle(fontSize: 19.sp),
194
+                    style: TextStyle(fontSize: 19.sp,),
191
                   ),
195
                   ),
192
                   child: TextField(
196
                   child: TextField(
197
+                    maxLength: 11,
198
+                      keyboardType: TextInputType.number,
193
                       style: TextStyle(
199
                       style: TextStyle(
194
                         fontSize: 17.sp,
200
                         fontSize: 17.sp,
195
                       ),
201
                       ),
198
                         contentPadding:
204
                         contentPadding:
199
                             EdgeInsets.symmetric(vertical: 8, horizontal: 16),
205
                             EdgeInsets.symmetric(vertical: 8, horizontal: 16),
200
                         labelText: "请输入手机号码",
206
                         labelText: "请输入手机号码",
207
+                        counterText: '',//去掉计数
201
                         border: InputBorder.none,
208
                         border: InputBorder.none,
202
-                        // border: OutlineInputBorder(
203
-                        //   // borderSide: BorderSide.none,
204
-                        //   // gapPadding: 0,
205
-                        // ),
206
                         floatingLabelBehavior: FloatingLabelBehavior.never,
209
                         floatingLabelBehavior: FloatingLabelBehavior.never,
207
-                      )),
210
+                      ),
211
+                      onChanged: (e) {
212
+                                _handlePhone(e);
213
+                              },
214
+                  ),
208
                   footer: ElevatedButton(
215
                   footer: ElevatedButton(
209
                     onPressed: () => {
216
                     onPressed: () => {
210
                       setState(() {
217
                       setState(() {
227
                                 BorderRadius.all(Radius.circular(10)))),
234
                                 BorderRadius.all(Radius.circular(10)))),
228
                   ),
235
                   ),
229
                 ),
236
                 ),
237
+//          --------------FractionalOffset API--------------
238
+//                 FractionalOffset(0.0, 0.0):顶部左边
239
+//                 FractionalOffset(0.5, 0.0):顶部中间
240
+//                 FractionalOffset(1.0, 0.0):顶部右边
241
+//                 FractionalOffset(0.0, 0.5):中部左边
242
+//                 FractionalOffset(0.5, 0.5):中部中间
243
+//                 FractionalOffset(1.0, 0.5):中部右边
244
+//                 FractionalOffset(0.0, 1.0):底部左边
245
+//                 FractionalOffset(0.5, 1.0):底部中间
246
+//                 FractionalOffset(1.0, 1.0):底部右边
230
 
247
 
231
-                TextField(
232
-                  keyboardType: TextInputType.number,
233
-                  cursorColor: Color(0xD4D4D4FF),
234
-                  decoration: const InputDecoration(
235
-                      hintText: "请输入验证码", prefixIcon: Icon(Icons.beenhere)),
236
-                  onChanged: (e) {
237
-                    _handleCode(e);
238
-                  },
239
-                ),
240
-                // 登录按钮
248
+                Cell(
249
+                  // margin: EdgeInsets.symmetric(horizontal: 13.w),
250
+                  margin: const EdgeInsets.fromLTRB(13, 16, 10,0 ),
241
 
251
 
242
-                Container(
243
-                  child: DefaultButton(
244
-                    margin:
245
-                        EdgeInsets.fromLTRB(0, 30.0, 0, 0), //可选配置,自定义控件中有默认配置
246
-                    text: "登陆",
247
-                    width: 200.0,
248
-                    height: 50.0,
249
-                    fontSize: 20.0,
250
-                    backColor: Color(0xffff703b),
251
-                    color: Colors.white,
252
-                    onPressed: () {
253
-                      Navigator.push(
254
-                        context,
255
-                        MaterialPageRoute(builder: (context) {
256
-                          return MyRouteLogin();
257
-                        }),
258
-                      );
252
+                  header:        Align(
253
+                    alignment: FractionalOffset(0.1, 0.5),
254
+                    child: Image.asset(
255
+                      'images/phoneCode.png',
256
+                      width: 20,
257
+                      height: 20,
258
+                    ),
259
+                  ),
260
+
261
+                  child: TextField(
262
+                    keyboardType: TextInputType.number,
263
+                    style: TextStyle(
264
+                      fontSize: 17.sp,
265
+
266
+                    ),
267
+                    decoration: const InputDecoration(
268
+                      isCollapsed: true,
269
+
270
+                      contentPadding:
271
+                      EdgeInsets.symmetric(vertical: 8, horizontal: 16),
272
+                      labelText: "请输入验证码",
273
+                      border: InputBorder.none,
274
+                      floatingLabelBehavior: FloatingLabelBehavior.never,
275
+                    ),
276
+                    onChanged: (e) {
277
+                      _handleCode(e);
259
                     },
278
                     },
260
                   ),
279
                   ),
261
-                )
280
+
281
+                ),
282
+
283
+
284
+
285
+
286
+                // TextField(
287
+                //   style: TextStyle(
288
+                //     fontSize: 17.sp,
289
+                //   ),
290
+                //   keyboardType: TextInputType.number,
291
+                //   cursorColor: Color(0xD4D4D4FF),
292
+                //   decoration: const InputDecoration(
293
+                //       contentPadding:
294
+                //       EdgeInsets.symmetric(vertical: 8, horizontal: 16),
295
+                //       labelText: "请输入验证码",
296
+                //       prefixIcon: Icon(Icons.beenhere)),
297
+                //   onChanged: (e) {
298
+                //     _handleCode(e);
299
+                //   },
300
+                // ),
301
+                // 登录按钮
302
+                 Center(
303
+                    child: DefaultButton(
304
+                      margin: const EdgeInsets.fromLTRB(0, 30.0, 0, 0), //可选配置,自定义控件中有默认配置
305
+                      text: "登陆",
306
+                      width: 90.0,
307
+                      height: 50.0,
308
+                      fontSize: 20.0,
309
+                      backColor: const Color(0xffff703b),
310
+                      color: Colors.white,
311
+                      onPressed: () {
312
+                      },
313
+                    ),
314
+                  ) ,
315
+
316
+
262
               ],
317
               ],
263
             ))));
318
             ))));
264
   }
319
   }

+ 14
- 2
lib/services/user.dart Просмотреть файл

1
 
1
 
2
+
2
 import 'package:dio/dio.dart';
3
 import 'package:dio/dio.dart';
3
 import 'package:farmer_client/utils/Request.dart';
4
 import 'package:farmer_client/utils/Request.dart';
4
-import 'package:flutter/foundation.dart';
5
+import 'package:fluttertoast/fluttertoast.dart';
6
+
5
 
7
 
6
 Future getSMSCaptch(String phone) async {
8
 Future getSMSCaptch(String phone) async {
7
-  return request('/sms-captcha', options: Options(method: 'POST'), queryParameters: { 'phone': phone });
9
+  return request('/sms-captcha', options: Options(method: 'POST'), queryParameters: { 'phone': phone }).catchError((error) {
10
+    // var e = error.error ;
11
+    // var message = e['message'];
12
+    Fluttertoast.showToast(
13
+      msg: error.error['message']
14
+    );
15
+  }).then((value) {
16
+    Fluttertoast.showToast(
17
+        msg: '验证码发送成功!'
18
+    );
19
+  });
8
 }
20
 }

+ 2
- 1
lib/utils/Request.dart Просмотреть файл

48
       response.data = resp['data'];
48
       response.data = resp['data'];
49
       return handler.next(response);
49
       return handler.next(response);
50
     } else {
50
     } else {
51
-      return handler.reject(response.data);
51
+      DioError error = DioError(requestOptions: response.requestOptions, error: response.data, response: response);
52
+      return handler.reject(error);
52
     }
53
     }
53
   }, onError: (DioError e, handler) {
54
   }, onError: (DioError e, handler) {
54
     // Do something with response error
55
     // Do something with response error

+ 20
- 0
pubspec.lock Просмотреть файл

158
     description: flutter
158
     description: flutter
159
     source: sdk
159
     source: sdk
160
     version: "0.0.0"
160
     version: "0.0.0"
161
+  flutter_web_plugins:
162
+    dependency: transitive
163
+    description: flutter
164
+    source: sdk
165
+    version: "0.0.0"
166
+  fluttertoast:
167
+    dependency: "direct dev"
168
+    description:
169
+      name: fluttertoast
170
+      url: "https://pub.dartlang.org"
171
+    source: hosted
172
+    version: "8.0.9"
161
   get:
173
   get:
162
     dependency: "direct main"
174
     dependency: "direct main"
163
     description:
175
     description:
179
       url: "https://pub.dartlang.org"
191
       url: "https://pub.dartlang.org"
180
     source: hosted
192
     source: hosted
181
     version: "4.0.0"
193
     version: "4.0.0"
194
+  js:
195
+    dependency: transitive
196
+    description:
197
+      name: js
198
+      url: "https://pub.dartlang.org"
199
+    source: hosted
200
+    version: "0.6.3"
182
   json_annotation:
201
   json_annotation:
183
     dependency: transitive
202
     dependency: transitive
184
     description:
203
     description:
347
     version: "3.1.0"
366
     version: "3.1.0"
348
 sdks:
367
 sdks:
349
   dart: ">=2.16.1 <3.0.0"
368
   dart: ">=2.16.1 <3.0.0"
369
+  flutter: ">=1.10.0"

+ 2
- 0
pubspec.yaml Просмотреть файл

51
   flutter_lints: ^1.0.0
51
   flutter_lints: ^1.0.0
52
   json_serializable: ^6.1.5
52
   json_serializable: ^6.1.5
53
   flutter_screenutil: ^5.3.1
53
   flutter_screenutil: ^5.3.1
54
+  fluttertoast: ^8.0.9
54
 # For information on the generic Dart part of this file, see the
55
 # For information on the generic Dart part of this file, see the
55
 # following page: https://dart.dev/tools/pub/pubspec
56
 # following page: https://dart.dev/tools/pub/pubspec
56
 
57
 
64
   # To add images to your application, add an images section, like this:
65
   # To add images to your application, add an images section, like this:
65
   assets:
66
   assets:
66
     - images/icon_login.png
67
     - images/icon_login.png
68
+    - images/phoneCode.png
67
 
69
 
68
   # An image asset can refer to one or more resolution-specific "variants", see
70
   # An image asset can refer to one or more resolution-specific "variants", see
69
   # https://flutter.dev/assets-and-images/#resolution-aware.
71
   # https://flutter.dev/assets-and-images/#resolution-aware.