登录调通
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||
import 'package:ln_jq_app/common/login_util.dart';
|
||||
@@ -255,19 +257,31 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
return;
|
||||
}
|
||||
|
||||
final responseMap = responseData.data as Map<String, dynamic>;
|
||||
try {
|
||||
var result = BaseModel.fromJson(responseData.data);
|
||||
|
||||
//保存用户信息
|
||||
String token = responseMap['token'] ?? '';
|
||||
//hydrogenId
|
||||
String userId = responseMap['userId'] ?? '';
|
||||
await StorageService.to.saveLoginInfo(token: token, userId: userId);
|
||||
//保存用户信息
|
||||
String token = result.data['token'] ?? '';
|
||||
//hydrogenId
|
||||
String userId = result.data['userId'] ?? '';
|
||||
|
||||
dismissLoading();
|
||||
showToast('登录成功,欢迎您');
|
||||
HttpService.to.setAuthorization(token);
|
||||
// 跳转到主页,并清除所有历史页面
|
||||
Get.offAll(() => B_BaseWidgetsPage());
|
||||
await StorageService.to.saveLoginInfo(
|
||||
token: token,
|
||||
userId: userId,
|
||||
channel: "station",
|
||||
);
|
||||
|
||||
dismissLoading();
|
||||
showToast('登录成功,欢迎您');
|
||||
HttpService.to.setAuthorization(token);
|
||||
|
||||
// 跳转到主页,并清除所有历史页面
|
||||
Get.offAll(() => B_BaseWidgetsPage());
|
||||
} catch (e) {
|
||||
// 如果解析 JSON 失败
|
||||
dismissLoading();
|
||||
showToast('登录失败:返回数据解析失败${e.toString()}');
|
||||
}
|
||||
} catch (e) {
|
||||
dismissLoading();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user