2024-11-30 20:45:12 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import '/common/colorCom.dart';
|
2024-12-06 08:13:16 +08:00
|
|
|
import 'package:wms_app/page/layout/home.dart';
|
2024-11-30 20:45:12 +08:00
|
|
|
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(
|
2024-12-29 13:05:26 +08:00
|
|
|
"请登录(景旺冷冻仓)",
|
2024-11-30 20:45:12 +08:00
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.white
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
backgroundColor: ColorCommon.colorScheme,
|
|
|
|
|
),
|
|
|
|
|
body: Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
2024-12-29 13:05:26 +08:00
|
|
|
const Text("测试程序,禁止用于正式环境", style: TextStyle(color: Colors.redAccent)),
|
2024-11-30 20:45:12 +08:00
|
|
|
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() {
|
|
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
|
MaterialPageRoute(builder: (context) => const Home()),
|
|
|
|
|
(router) => false
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|