|
@@ -4,6 +4,7 @@ import 'package:farmer_client/components/UI/DefaultButton.dart';
|
4
|
4
|
import 'package:flutter/material.dart';
|
5
|
5
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
6
|
6
|
|
|
7
|
+import '../../services/user.dart';
|
7
|
8
|
import '../../widgets/Cell.dart';
|
8
|
9
|
|
9
|
10
|
class MyRouteLogin extends StatefulWidget {
|
|
@@ -24,6 +25,7 @@ class _RouteLogin extends State<MyRouteLogin> {
|
24
|
25
|
//当按钮可点击时
|
25
|
26
|
isButtonEnable = false; //按钮状态标记
|
26
|
27
|
_initTimer();
|
|
28
|
+ getSMSCaptch(handlePhones);
|
27
|
29
|
return null; //返回null按钮禁止点击
|
28
|
30
|
} else {
|
29
|
31
|
//当按钮不可点击时
|
|
@@ -82,7 +84,7 @@ class _RouteLogin extends State<MyRouteLogin> {
|
82
|
84
|
@override
|
83
|
85
|
Widget build(BuildContext context) {
|
84
|
86
|
return Container(
|
85
|
|
- width: 12.w,
|
|
87
|
+
|
86
|
88
|
decoration: const BoxDecoration(
|
87
|
89
|
image: DecorationImage(
|
88
|
90
|
image: AssetImage("images/icon_login.png"),
|
|
@@ -97,17 +99,18 @@ class _RouteLogin extends State<MyRouteLogin> {
|
97
|
99
|
title: const Text('登陆'),
|
98
|
100
|
),
|
99
|
101
|
body: Center(
|
100
|
|
- child: Column(
|
101
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
102
|
+ child: ListView(
|
|
103
|
+ // crossAxisAlignment: CrossAxisAlignment.start,
|
102
|
104
|
children: <Widget>[
|
103
|
|
- Text(
|
|
105
|
+
|
|
106
|
+ const Text(
|
104
|
107
|
'您好!',
|
105
|
108
|
style: TextStyle(
|
106
|
109
|
fontWeight: FontWeight.bold,
|
107
|
110
|
fontSize: 50,
|
108
|
111
|
),
|
109
|
112
|
),
|
110
|
|
- Text(
|
|
113
|
+ const Text(
|
111
|
114
|
'欢迎进入农户端应用!',
|
112
|
115
|
style: TextStyle(
|
113
|
116
|
fontWeight: FontWeight.bold,
|
|
@@ -184,12 +187,15 @@ class _RouteLogin extends State<MyRouteLogin> {
|
184
|
187
|
// )),
|
185
|
188
|
|
186
|
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
|
192
|
header: Text(
|
189
|
193
|
"+86",
|
190
|
|
- style: TextStyle(fontSize: 19.sp),
|
|
194
|
+ style: TextStyle(fontSize: 19.sp,),
|
191
|
195
|
),
|
192
|
196
|
child: TextField(
|
|
197
|
+ maxLength: 11,
|
|
198
|
+ keyboardType: TextInputType.number,
|
193
|
199
|
style: TextStyle(
|
194
|
200
|
fontSize: 17.sp,
|
195
|
201
|
),
|
|
@@ -198,13 +204,14 @@ class _RouteLogin extends State<MyRouteLogin> {
|
198
|
204
|
contentPadding:
|
199
|
205
|
EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
200
|
206
|
labelText: "请输入手机号码",
|
|
207
|
+ counterText: '',//去掉计数
|
201
|
208
|
border: InputBorder.none,
|
202
|
|
- // border: OutlineInputBorder(
|
203
|
|
- // // borderSide: BorderSide.none,
|
204
|
|
- // // gapPadding: 0,
|
205
|
|
- // ),
|
206
|
209
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
207
|
|
- )),
|
|
210
|
+ ),
|
|
211
|
+ onChanged: (e) {
|
|
212
|
+ _handlePhone(e);
|
|
213
|
+ },
|
|
214
|
+ ),
|
208
|
215
|
footer: ElevatedButton(
|
209
|
216
|
onPressed: () => {
|
210
|
217
|
setState(() {
|
|
@@ -227,38 +234,86 @@ class _RouteLogin extends State<MyRouteLogin> {
|
227
|
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
|
}
|