李志伟 3 vuotta sitten
vanhempi
commit
c07d82ced0
1 muutettua tiedostoa jossa 44 lisäystä ja 44 poistoa
  1. 44
    44
      lib/pages/login/login.dart

+ 44
- 44
lib/pages/login/login.dart Näytä tiedosto

@@ -10,6 +10,7 @@ import 'package:get/get.dart';
10 10
 import '../../models/entities/person.dart';
11 11
 import '../../services/user.dart';
12 12
 import '../../widgets/Cell.dart';
13
+import '../home/index.dart';
13 14
 
14 15
 
15 16
 class MyRouteLogin extends StatefulWidget {
@@ -19,30 +20,30 @@ class MyRouteLogin extends StatefulWidget {
19 20
 
20 21
 class _RouteLogin extends State<MyRouteLogin> {
21 22
 
22
-var  userInfo= AppController.t.user;
23
+  var  userInfo= AppController.t.user;
23 24
 
24
-bool isButtonEnable = true; //按钮状态  是否可点击
25
-String buttonText = '发送验证码'; //初始文本
26
-int count = 60; //初始倒计时时间
27
-var timer; //倒计时的计时器
28
-TextEditingController mController = TextEditingController();
25
+  bool isButtonEnable = true; //按钮状态  是否可点击
26
+  String buttonText = '发送验证码'; //初始文本
27
+  int count = 60; //初始倒计时时间
28
+  var timer; //倒计时的计时器
29
+  TextEditingController mController = TextEditingController();
29 30
 
30 31
 //获取验证码
31
-void _initTimer() {
32
-  timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
33
-    count--;
34
-    setState(() {
35
-      if (count == 0) {
36
-        timer.cancel(); //倒计时结束取消定时器
37
-        isButtonEnable = true; //按钮可点击
38
-        count = 60; //重置时间
39
-        buttonText = '发送验证码'; //重置按钮文本
40
-      } else {
41
-        buttonText = '重新发送($count)'; //更新文本内容
42
-      }
32
+  void _initTimer() {
33
+    timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
34
+      count--;
35
+      setState(() {
36
+        if (count == 0) {
37
+          timer.cancel(); //倒计时结束取消定时器
38
+          isButtonEnable = true; //按钮可点击
39
+          count = 60; //重置时间
40
+          buttonText = '发送验证码'; //重置按钮文本
41
+        } else {
42
+          buttonText = '重新发送($count)'; //更新文本内容
43
+        }
44
+      });
43 45
     });
44
-  });
45
-}
46
+  }
46 47
 
47 48
 
48 49
 
@@ -75,12 +76,12 @@ void _initTimer() {
75 76
 
76 77
 
77 78
   void _handlePhone(e) => {
78
-        setState(() => {handlePhones = e})
79
-      };
79
+    setState(() => {handlePhones = e})
80
+  };
80 81
 
81 82
   void _handleCode(e) => {
82
-        setState(() => {handleCodes = e})
83
-      };
83
+    setState(() => {handleCodes = e})
84
+  };
84 85
 
85 86
 
86 87
 
@@ -106,9 +107,8 @@ void _initTimer() {
106 107
       if(_newValue){
107 108
         print('已同意协议');
108 109
         userLogin(handlePhones,handleCodes).then((value) {
109
-          userInfo(Person.fromJson(value.date.person));
110
-          Get.back();
111
-
110
+          userInfo(Person.fromJson(value['person']));
111
+          Get.off(Home());
112 112
         });
113 113
       }else{
114 114
         Fluttertoast.showToast(msg: '请阅读并同意相关隐私政策!');
@@ -122,14 +122,14 @@ void _initTimer() {
122 122
       backgroundColor: Colors.transparent,
123 123
       resizeToAvoidBottomInset: false,
124 124
       body: Container(
125
-      decoration: const BoxDecoration(
126
-        image: DecorationImage(
127
-          image: AssetImage("images/icon_login.png"),
128
-          fit: BoxFit.cover,
125
+        decoration: const BoxDecoration(
126
+          image: DecorationImage(
127
+            image: AssetImage("images/icon_login.png"),
128
+            fit: BoxFit.cover,
129
+          ),
129 130
         ),
130
-      ),
131 131
 
132
-      child:  Container(
132
+        child:  Container(
133 133
           child: Column(
134 134
             mainAxisAlignment: MainAxisAlignment.end,
135 135
             crossAxisAlignment: CrossAxisAlignment.start,
@@ -149,7 +149,7 @@ void _initTimer() {
149 149
                 ),
150 150
               ),
151 151
               Cell(
152
-                  // margin: EdgeInsets.symmetric(horizontal: 13.w),
152
+                // margin: EdgeInsets.symmetric(horizontal: 13.w),
153 153
                   margin: const EdgeInsets.fromLTRB(13, 43, 10, 0),
154 154
                   header: Text(
155 155
                     "+86",
@@ -166,7 +166,7 @@ void _initTimer() {
166 166
                     decoration: const InputDecoration(
167 167
                       isCollapsed: true,
168 168
                       contentPadding:
169
-                          EdgeInsets.symmetric(vertical: 8, horizontal: 16),
169
+                      EdgeInsets.symmetric(vertical: 8, horizontal: 16),
170 170
                       labelText: "请输入手机号码",
171 171
                       counterText: '', //去掉计数
172 172
                       border: InputBorder.none,
@@ -194,11 +194,11 @@ void _initTimer() {
194 194
                         backgroundColor: isButtonEnable
195 195
                             ? MaterialStateProperty.all(const Color(0xFFFF703B))
196 196
                             : MaterialStateProperty.all(
197
-                                const Color(0xFFCBCBCB)),
197
+                            const Color(0xFFCBCBCB)),
198 198
                         shape: MaterialStateProperty.all(
199 199
                             const RoundedRectangleBorder(
200 200
                                 borderRadius:
201
-                                    BorderRadius.all(Radius.circular(10)))),
201
+                                BorderRadius.all(Radius.circular(10)))),
202 202
                       ),
203 203
                     ),
204 204
                   )),
@@ -223,7 +223,7 @@ void _initTimer() {
223 223
                   decoration: const InputDecoration(
224 224
                     isCollapsed: true,
225 225
                     contentPadding:
226
-                        EdgeInsets.symmetric(vertical: 8, horizontal: 16),
226
+                    EdgeInsets.symmetric(vertical: 8, horizontal: 16),
227 227
                     labelText: "请输入验证码",
228 228
                     border: InputBorder.none,
229 229
                     floatingLabelBehavior: FloatingLabelBehavior.never,
@@ -254,11 +254,11 @@ void _initTimer() {
254 254
                     style: ButtonStyle(
255 255
                       elevation: MaterialStateProperty.all(0),
256 256
                       backgroundColor:
257
-                          MaterialStateProperty.all(const Color(0xFFFF703B)),
257
+                      MaterialStateProperty.all(const Color(0xFFFF703B)),
258 258
                       shape: MaterialStateProperty.all(
259 259
                           const RoundedRectangleBorder(
260 260
                               borderRadius:
261
-                                  BorderRadius.all(Radius.circular(24.4)))),
261
+                              BorderRadius.all(Radius.circular(24.4)))),
262 262
                     ),
263 263
                   ),
264 264
                 ),
@@ -286,10 +286,10 @@ void _initTimer() {
286 286
                             text: '文本协议/隐私政策,',
287 287
                             style: TextStyle(color: Color(0xffce3800)),
288 288
                             recognizer:
289
-                                TapGestureRecognizer() //踩坑。。。recognizer 是手势交互 除了我现在些的是 点击交互,其他一般都是抽象类。
290
-                                  ..onTap = () {
291
-                                    print('阅读已同意!!!');
292
-                                  },
289
+                            TapGestureRecognizer() //踩坑。。。recognizer 是手势交互 除了我现在些的是 点击交互,其他一般都是抽象类。
290
+                              ..onTap = () {
291
+                                print('阅读已同意!!!');
292
+                              },
293 293
                           ),
294 294
                           const TextSpan(
295 295
                               text: '确认之后选择此项',