113 lines
3.7 KiB
Dart
113 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../common/user/login_user.dart';
|
|
import '/common/colorCom.dart';
|
|
import 'package:wms_app/page/layout/home.dart';
|
|
import 'package:dio/dio.dart';
|
|
|
|
class Login extends StatefulWidget {
|
|
const Login({super.key});
|
|
@override
|
|
State<Login> createState() => _LoginPageState();
|
|
}
|
|
|
|
|
|
class _LoginPageState extends State<Login> {
|
|
|
|
final dio = Dio();
|
|
final _userPwd = TextEditingController();
|
|
final _userId = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text(
|
|
"请登录(徐工料箱库)",
|
|
style: TextStyle(
|
|
color: Colors.white
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
backgroundColor: ColorCommon.colorScheme,
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
children: [
|
|
const Text("测试程序,禁止用于正式环境", style: TextStyle(color: Colors.redAccent)),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 120, left: 50, right: 50, bottom: 10),
|
|
child: TextField(
|
|
controller: _userId,
|
|
decoration: const InputDecoration(
|
|
labelText: "用户名:",
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 0, left: 50, right: 50, bottom: 10),
|
|
child: TextField(
|
|
controller: _userPwd,
|
|
decoration: const InputDecoration(
|
|
labelText: "密码:",
|
|
),
|
|
obscureText: true,
|
|
),
|
|
),
|
|
Padding( padding: const EdgeInsets.only(top: 15),
|
|
child: SizedBox(
|
|
width: 250,
|
|
child: ElevatedButton(
|
|
onPressed: login,
|
|
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(ColorCommon.colorScheme)),
|
|
child: const Text(
|
|
"进入系统",
|
|
style: TextStyle(color: Colors.white))
|
|
),
|
|
)
|
|
),
|
|
// Padding( padding: const EdgeInsets.only(top: 10),
|
|
// child: SizedBox(
|
|
// width: 250,
|
|
// child: ElevatedButton(
|
|
// onPressed: login,
|
|
// style: ButtonStyle(
|
|
// backgroundColor: WidgetStateProperty.all(ColorCommon.colorScheme),
|
|
// ),
|
|
// child: const Text(
|
|
// "网络检测",
|
|
// style: TextStyle(
|
|
// color: Colors.white
|
|
// ))
|
|
// ),
|
|
// )),
|
|
]
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
// Future<void> login() async {
|
|
// var response = await dio.post('https://dart.dev', data: {
|
|
// "userId": _userId.text,
|
|
// "userPwd" : _userPwd.text,
|
|
// });
|
|
// if(response.statusCode == 200) {
|
|
// var thisContext = context;
|
|
// if (thisContext.mounted) {
|
|
// Navigator.of(thisContext).pushAndRemoveUntil(
|
|
// MaterialPageRoute(builder: (context) => const Home()),
|
|
// (router) => false
|
|
// );
|
|
// }
|
|
// }
|
|
//}
|
|
void login() {
|
|
LoginUser.userName = "测试账号";
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
MaterialPageRoute(builder: (context) => const Home()),
|
|
(router) => false
|
|
);
|
|
}
|
|
}
|
|
|