[baozhangchao] пре 3 година
родитељ
комит
4eb2cf3034
8 измењених фајлова са 67 додато и 90 уклоњено
  1. 0
    14
      lib/main.dart
  2. 1
    0
      lib/models/Store.dart
  3. 1
    1
      lib/models/app.dart
  4. 1
    0
      lib/pages/home.dart
  5. 55
    65
      lib/pages/login/login.dart
  6. 0
    1
      lib/pages/splash/splash.dart
  7. 6
    6
      lib/services/user.dart
  8. 3
    3
      pubspec.lock

+ 0
- 14
lib/main.dart Прегледај датотеку

1
 
1
 
2
-<<<<<<< HEAD
3
-import 'package:farmer_client/models/Store.dart';
4
-import 'package:farmer_client/pages/home.dart';
5
-import 'package:farmer_client/pages/login/login.dart';
6
 import 'package:farmer_client/widgets/CarsCard.dart';
2
 import 'package:farmer_client/widgets/CarsCard.dart';
7
-import 'package:farmer_client/widgets/OrderInfoCard.dart';
8
-=======
9
->>>>>>> aab895cc95471d4dfd7cb90d05a35ccceb52c4e0
10
 import 'package:flutter/material.dart';
3
 import 'package:flutter/material.dart';
11
 import 'package:get/get.dart';
4
 import 'package:get/get.dart';
12
 import 'package:get_storage/get_storage.dart';
5
 import 'package:get_storage/get_storage.dart';
39
         return GetMaterialApp(
32
         return GetMaterialApp(
40
           initialRoute: '/splash',
33
           initialRoute: '/splash',
41
           defaultTransition: Transition.native,
34
           defaultTransition: Transition.native,
42
-<<<<<<< HEAD
43
-          getPages: [
44
-            // GetPage(name: '/home', page: () => OrderPage() ),
45
-            GetPage(name: '/home', page: () => box.hasData('token') ? Home() : MyRouteLogin()),
46
-          ],
47
-=======
48
           routingCallback: routingCallback,
35
           routingCallback: routingCallback,
49
           initialBinding: AppBindings(),
36
           initialBinding: AppBindings(),
50
           getPages: pages,
37
           getPages: pages,
51
->>>>>>> aab895cc95471d4dfd7cb90d05a35ccceb52c4e0
52
         );
38
         );
53
       },
39
       },
54
     );
40
     );

+ 1
- 0
lib/models/Store.dart Прегледај датотеку

1
+// TODO Implement this library.

+ 1
- 1
lib/models/app.dart Прегледај датотеку

11
   // 有了这句, 可以直接 AppController.t 调用
11
   // 有了这句, 可以直接 AppController.t 调用
12
   static AppController t = Get.find();
12
   static AppController t = Get.find();
13
 
13
 
14
-  final user = Person().obs;
14
+  final user = Rx<Person>(Person());
15
   final location = Rxn<LocationData>();
15
   final location = Rxn<LocationData>();
16
   final testInt = 1.obs;
16
   final testInt = 1.obs;
17
 
17
 

+ 1
- 0
lib/pages/home.dart Прегледај датотеку

1
+// TODO Implement this library.

+ 55
- 65
lib/pages/login/login.dart Прегледај датотеку

7
 import 'package:flutter_screenutil/flutter_screenutil.dart';
7
 import 'package:flutter_screenutil/flutter_screenutil.dart';
8
 import 'package:get/get.dart';
8
 import 'package:get/get.dart';
9
 
9
 
10
+import '../../models/entities/person.dart';
10
 import '../../services/user.dart';
11
 import '../../services/user.dart';
11
 import '../../widgets/Cell.dart';
12
 import '../../widgets/Cell.dart';
12
 
13
 
37
 }
38
 }
38
 
39
 
39
 class _RouteLogin extends State<MyRouteLogin> {
40
 class _RouteLogin extends State<MyRouteLogin> {
41
+
42
+var  userInfo= AppController.t.user;
43
+
44
+bool isButtonEnable = true; //按钮状态  是否可点击
45
+String buttonText = '发送验证码'; //初始文本
46
+int count = 60; //初始倒计时时间
47
+var timer; //倒计时的计时器
48
+TextEditingController mController = TextEditingController();
49
+
50
+//获取验证码
51
+void _initTimer() {
52
+  timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
53
+    count--;
54
+    setState(() {
55
+      if (count == 0) {
56
+        timer.cancel(); //倒计时结束取消定时器
57
+        isButtonEnable = true; //按钮可点击
58
+        count = 60; //重置时间
59
+        buttonText = '发送验证码'; //重置按钮文本
60
+      } else {
61
+        buttonText = '重新发送($count)'; //更新文本内容
62
+      }
63
+    });
64
+  });
65
+}
66
+
67
+
68
+
69
+
40
   @override
70
   @override
41
   void initState() {
71
   void initState() {
42
     super.initState();
72
     super.initState();
47
     print(location);
77
     print(location);
48
   }
78
   }
49
 
79
 
50
-  bool isButtonEnable = true; //按钮状态  是否可点击
51
-  String buttonText = '发送验证码'; //初始文本
52
-  int count = 60; //初始倒计时时间
53
-  var timer; //倒计时的计时器
54
-  TextEditingController mController = TextEditingController();
55
-
56
-  void _initTimer() {
57
-    timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
58
-      count--;
59
-      setState(() {
60
-        if (count == 0) {
61
-          timer.cancel(); //倒计时结束取消定时器
62
-          isButtonEnable = true; //按钮可点击
63
-          count = 60; //重置时间
64
-          buttonText = '发送验证码'; //重置按钮文本
65
-        } else {
66
-          buttonText = '重新发送($count)'; //更新文本内容
67
-        }
68
-      });
69
-    });
70
-  }
71
-
72
   @override
80
   @override
73
   void dispose() {
81
   void dispose() {
74
     timer?.cancel(); //销毁计时器
82
     timer?.cancel(); //销毁计时器
82
 // -------------逻辑分割-------------------------------------------
90
 // -------------逻辑分割-------------------------------------------
83
   var handlePhones = '';
91
   var handlePhones = '';
84
   var handleCodes = '';
92
   var handleCodes = '';
93
+  var userContent = {'phones': '', 'code': ''};
94
+  bool _newValue = false;
95
+
85
 
96
 
86
   void _handlePhone(e) => {
97
   void _handlePhone(e) => {
87
         setState(() => {handlePhones = e})
98
         setState(() => {handlePhones = e})
91
         setState(() => {handleCodes = e})
102
         setState(() => {handleCodes = e})
92
       };
103
       };
93
 
104
 
94
-  var userContent = {'phones': '', 'code': ''};
95
 
105
 
96
-  void phoneUser() => {
97
-        setState(() {
98
-          userContent['phones'] = handlePhones;
99
-          userContent['code'] = handleCodes;
100
-        }),
101
-        print('我输入的信息:${userContent},手机号:${userContent['phones']}')
102
-      };
103
-
104
-  bool _checkValue = false;
105
-  bool _newValue = false;
106
 
106
 
107
+// 获取验证码
107
   void _buttonClickListen() {
108
   void _buttonClickListen() {
108
     setState(() {
109
     setState(() {
109
       if (isButtonEnable) {
110
       if (isButtonEnable) {
113
           getSMSCaptch(handlePhones);
114
           getSMSCaptch(handlePhones);
114
         } else {
115
         } else {
115
           Fluttertoast.showToast(msg: '请正确输入手机号!');
116
           Fluttertoast.showToast(msg: '请正确输入手机号!');
116
-
117
         }
117
         }
118
-
119
         print('获取验证码按钮222222');
118
         print('获取验证码按钮222222');
120
       }
119
       }
121
     });
120
     });
122
   }
121
   }
122
+//登陆按钮
123
+  void _handelSubmit(){
124
+    if(handleCodes==''||handlePhones==''){
125
+      Fluttertoast.showToast(msg: '请输入验证码或手机号!');
126
+    }else{
127
+      if(_newValue){
128
+        print('已同意协议');
129
+        userLogin(handlePhones,handleCodes).then((value) {
130
+          userInfo(Person.fromJson(value.date.person));
131
+          Get.back();
132
+
133
+        });
134
+      }else{
135
+        Fluttertoast.showToast(msg: '请阅读并同意相关隐私政策!');
136
+      }
137
+    }
138
+  }
123
 
139
 
124
   @override
140
   @override
125
   Widget build(BuildContext context) {
141
   Widget build(BuildContext context) {
153
                   fontSize: 35,
169
                   fontSize: 35,
154
                 ),
170
                 ),
155
               ),
171
               ),
156
-
157
               Cell(
172
               Cell(
158
                   // margin: EdgeInsets.symmetric(horizontal: 13.w),
173
                   // margin: EdgeInsets.symmetric(horizontal: 13.w),
159
                   margin: const EdgeInsets.fromLTRB(13, 43, 10, 0),
174
                   margin: const EdgeInsets.fromLTRB(13, 43, 10, 0),
187
                     child: ElevatedButton(
202
                     child: ElevatedButton(
188
                       onPressed: () => {
203
                       onPressed: () => {
189
                         setState(() {
204
                         setState(() {
190
-                          // _buttonClickListen();
191
-                          setState(() {
192
-                            if (isButtonEnable) {
193
-                              if (handlePhones != '') {
194
-                                isButtonEnable = false; //按钮状态标记
195
-                                _initTimer();
196
-                                getSMSCaptch(handlePhones);
197
-                              } else {
198
-                                Fluttertoast.showToast(msg: '请正确输入手机号!');
199
-                              }
200
-
201
-                              print('获取验证码按钮222222');
202
-                            }
203
-                          });
204
-
205
+                          _buttonClickListen();
205
                         })
206
                         })
206
                       },
207
                       },
207
                       child: Text(
208
                       child: Text(
222
                       ),
223
                       ),
223
                     ),
224
                     ),
224
                   )),
225
                   )),
225
-//          --------------FractionalOffset API--------------
226
-
227
               Cell(
226
               Cell(
228
                 // margin: EdgeInsets.symmetric(horizontal: 13.w),
227
                 // margin: EdgeInsets.symmetric(horizontal: 13.w),
229
                 margin: const EdgeInsets.fromLTRB(13, 16, 10, 0),
228
                 margin: const EdgeInsets.fromLTRB(13, 16, 10, 0),
264
                   height: 49.h,
263
                   height: 49.h,
265
                   child: ElevatedButton(
264
                   child: ElevatedButton(
266
                     onPressed: () {
265
                     onPressed: () {
267
-                      if(handleCodes==''||handlePhones==''){
268
-                        Fluttertoast.showToast(msg: '请输入验证码或手机号!');
269
-                      }else{
270
-                        if(_newValue){
271
-                          print('已同意协议');
272
-                          userLogin(handlePhones,handleCodes);
273
-                        }else{
274
-                          Fluttertoast.showToast(msg: '请阅读并同意相关隐私政策!');
275
-                        }
276
-                      }
266
+                      _handelSubmit();
277
                     },
267
                     },
278
                     child: const Text(
268
                     child: const Text(
279
                       "登陆",
269
                       "登陆",
310
                           }),
300
                           }),
311
                       RichText(
301
                       RichText(
312
                         text: TextSpan(children: <InlineSpan>[
302
                         text: TextSpan(children: <InlineSpan>[
313
-                          TextSpan(
303
+                          const TextSpan(
314
                               text: '请认真查看',
304
                               text: '请认真查看',
315
                               style: TextStyle(color: Color(0xff2a2a2a))),
305
                               style: TextStyle(color: Color(0xff2a2a2a))),
316
                           TextSpan(
306
                           TextSpan(
322
                                     print('阅读已同意!!!');
312
                                     print('阅读已同意!!!');
323
                                   },
313
                                   },
324
                           ),
314
                           ),
325
-                          TextSpan(
315
+                          const TextSpan(
326
                               text: '确认之后选择此项',
316
                               text: '确认之后选择此项',
327
                               style: TextStyle(color: Color(0xff2a2a2a))),
317
                               style: TextStyle(color: Color(0xff2a2a2a))),
328
                         ]),
318
                         ]),

+ 0
- 1
lib/pages/splash/splash.dart Прегледај датотеку

9
   handleOnFinish () {
9
   handleOnFinish () {
10
     Get.off(Home(), routeName: '/');
10
     Get.off(Home(), routeName: '/');
11
   }
11
   }
12
-
13
   @override
12
   @override
14
   Widget build(BuildContext context) {
13
   Widget build(BuildContext context) {
15
     return countdown(3, handleOnFinish);
14
     return countdown(3, handleOnFinish);

+ 6
- 6
lib/services/user.dart Прегледај датотеку

18
   });
18
   });
19
 }
19
 }
20
 
20
 
21
-<<<<<<< HEAD
22
-
23
 //登陆
21
 //登陆
24
 Future userLogin(String userName,String password) async {
22
 Future userLogin(String userName,String password) async {
25
-  return request('/login', options: Options(method: 'POST'), data: { 'userName': userName,'password':password }, ).catchError((error)=>{ Fluttertoast.showToast(
26
-  msg: error.error['message']
23
+  return request('/login', options: Options(method: 'POST'),
24
+    data: { 'userName': userName, 'password': password},).catchError((error) =>
25
+  { Fluttertoast.showToast(
26
+      msg: error.error['message']
27
   ),});
27
   ),});
28
-=======
28
+}
29
+
29
 Future getCurrent() async {
30
 Future getCurrent() async {
30
   return request('/person/current');
31
   return request('/person/current');
31
->>>>>>> aab895cc95471d4dfd7cb90d05a35ccceb52c4e0
32
 }
32
 }

+ 3
- 3
pubspec.lock Прегледај датотеку

237
     dependency: "direct main"
237
     dependency: "direct main"
238
     description:
238
     description:
239
       name: location
239
       name: location
240
-      url: "https://pub.flutter-io.cn"
240
+      url: "https://pub.dartlang.org"
241
     source: hosted
241
     source: hosted
242
     version: "4.3.0"
242
     version: "4.3.0"
243
   location_platform_interface:
243
   location_platform_interface:
244
     dependency: transitive
244
     dependency: transitive
245
     description:
245
     description:
246
       name: location_platform_interface
246
       name: location_platform_interface
247
-      url: "https://pub.flutter-io.cn"
247
+      url: "https://pub.dartlang.org"
248
     source: hosted
248
     source: hosted
249
     version: "2.3.0"
249
     version: "2.3.0"
250
   location_web:
250
   location_web:
251
     dependency: transitive
251
     dependency: transitive
252
     description:
252
     description:
253
       name: location_web
253
       name: location_web
254
-      url: "https://pub.flutter-io.cn"
254
+      url: "https://pub.dartlang.org"
255
     source: hosted
255
     source: hosted
256
     version: "3.1.1"
256
     version: "3.1.1"
257
   logging:
257
   logging: