静态页面补充
This commit is contained in:
@@ -155,9 +155,58 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
// 司机端登录
|
||||
Get.offAll(() => BaseWidgetsPage());
|
||||
String password = controller.driverIdentityController.text;
|
||||
|
||||
if (password.isEmpty) {
|
||||
showToast("请输入密码");
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading('登录中...');
|
||||
|
||||
try {
|
||||
// 调用登录接口
|
||||
var responseData = await HttpService.to.post(
|
||||
'appointment/login/loginForDriver',
|
||||
data: {'idNo': password},
|
||||
);
|
||||
|
||||
if (responseData == null && responseData!.data == null) {
|
||||
dismissLoading();
|
||||
showToast('登录失败:无法获取凭证');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var result = BaseModel.fromJson(responseData.data);
|
||||
|
||||
//保存用户信息
|
||||
String token = result.data['token'] ?? '';
|
||||
String idCard = result.data['idCard'] ?? '';
|
||||
String name = result.data['name'] ?? '';
|
||||
String phone = result.data['phone'] ?? '';
|
||||
|
||||
await StorageService.to.saveLoginInfo(
|
||||
token: token,
|
||||
userId: "",
|
||||
channel: "driver",
|
||||
);
|
||||
|
||||
dismissLoading();
|
||||
showToast('登录成功,欢迎您');
|
||||
|
||||
// 跳转到主页,并清除所有历史页面
|
||||
Get.offAll(() => BaseWidgetsPage());
|
||||
} catch (e) {
|
||||
// 如果解析 JSON 失败
|
||||
dismissLoading();
|
||||
showToast('登录失败:数据异常');
|
||||
}
|
||||
} catch (e) {
|
||||
dismissLoading();
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.themeColor,
|
||||
|
||||
Reference in New Issue
Block a user