|
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
7
|
7
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
8
|
8
|
import 'package:get/get.dart';
|
9
|
9
|
|
|
10
|
+import '../../models/entities/person.dart';
|
10
|
11
|
import '../../services/user.dart';
|
11
|
12
|
import '../../widgets/Cell.dart';
|
12
|
13
|
|
|
@@ -37,6 +38,35 @@ class MyRouteLogin extends StatefulWidget {
|
37
|
38
|
}
|
38
|
39
|
|
39
|
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
|
70
|
@override
|
41
|
71
|
void initState() {
|
42
|
72
|
super.initState();
|
|
@@ -47,28 +77,6 @@ class _RouteLogin extends State<MyRouteLogin> {
|
47
|
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
|
80
|
@override
|
73
|
81
|
void dispose() {
|
74
|
82
|
timer?.cancel(); //销毁计时器
|
|
@@ -82,6 +90,9 @@ class _RouteLogin extends State<MyRouteLogin> {
|
82
|
90
|
// -------------逻辑分割-------------------------------------------
|
83
|
91
|
var handlePhones = '';
|
84
|
92
|
var handleCodes = '';
|
|
93
|
+ var userContent = {'phones': '', 'code': ''};
|
|
94
|
+ bool _newValue = false;
|
|
95
|
+
|
85
|
96
|
|
86
|
97
|
void _handlePhone(e) => {
|
87
|
98
|
setState(() => {handlePhones = e})
|
|
@@ -91,19 +102,9 @@ class _RouteLogin extends State<MyRouteLogin> {
|
91
|
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
|
108
|
void _buttonClickListen() {
|
108
|
109
|
setState(() {
|
109
|
110
|
if (isButtonEnable) {
|
|
@@ -113,13 +114,28 @@ class _RouteLogin extends State<MyRouteLogin> {
|
113
|
114
|
getSMSCaptch(handlePhones);
|
114
|
115
|
} else {
|
115
|
116
|
Fluttertoast.showToast(msg: '请正确输入手机号!');
|
116
|
|
-
|
117
|
117
|
}
|
118
|
|
-
|
119
|
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
|
140
|
@override
|
125
|
141
|
Widget build(BuildContext context) {
|
|
@@ -153,7 +169,6 @@ class _RouteLogin extends State<MyRouteLogin> {
|
153
|
169
|
fontSize: 35,
|
154
|
170
|
),
|
155
|
171
|
),
|
156
|
|
-
|
157
|
172
|
Cell(
|
158
|
173
|
// margin: EdgeInsets.symmetric(horizontal: 13.w),
|
159
|
174
|
margin: const EdgeInsets.fromLTRB(13, 43, 10, 0),
|
|
@@ -187,21 +202,7 @@ class _RouteLogin extends State<MyRouteLogin> {
|
187
|
202
|
child: ElevatedButton(
|
188
|
203
|
onPressed: () => {
|
189
|
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
|
208
|
child: Text(
|
|
@@ -222,8 +223,6 @@ class _RouteLogin extends State<MyRouteLogin> {
|
222
|
223
|
),
|
223
|
224
|
),
|
224
|
225
|
)),
|
225
|
|
-// --------------FractionalOffset API--------------
|
226
|
|
-
|
227
|
226
|
Cell(
|
228
|
227
|
// margin: EdgeInsets.symmetric(horizontal: 13.w),
|
229
|
228
|
margin: const EdgeInsets.fromLTRB(13, 16, 10, 0),
|
|
@@ -264,16 +263,7 @@ class _RouteLogin extends State<MyRouteLogin> {
|
264
|
263
|
height: 49.h,
|
265
|
264
|
child: ElevatedButton(
|
266
|
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
|
268
|
child: const Text(
|
279
|
269
|
"登陆",
|
|
@@ -310,7 +300,7 @@ class _RouteLogin extends State<MyRouteLogin> {
|
310
|
300
|
}),
|
311
|
301
|
RichText(
|
312
|
302
|
text: TextSpan(children: <InlineSpan>[
|
313
|
|
- TextSpan(
|
|
303
|
+ const TextSpan(
|
314
|
304
|
text: '请认真查看',
|
315
|
305
|
style: TextStyle(color: Color(0xff2a2a2a))),
|
316
|
306
|
TextSpan(
|
|
@@ -322,7 +312,7 @@ class _RouteLogin extends State<MyRouteLogin> {
|
322
|
312
|
print('阅读已同意!!!');
|
323
|
313
|
},
|
324
|
314
|
),
|
325
|
|
- TextSpan(
|
|
315
|
+ const TextSpan(
|
326
|
316
|
text: '确认之后选择此项',
|
327
|
317
|
style: TextStyle(color: Color(0xff2a2a2a))),
|
328
|
318
|
]),
|