2025.9.9 改bug
parent
e86a91fc19
commit
0dc4773324
|
@ -15,6 +15,8 @@ import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'
|
|||
show BMFMapSDK, BMF_COORD_TYPE;
|
||||
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
|
||||
|
||||
import 'pages/mine/mine_set_pwd_page.dart';
|
||||
|
||||
// 全局导航键
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
// 全局路由
|
||||
|
@ -69,7 +71,7 @@ Future<T?> showModalBottomSheetAfterUnfocus<T>({
|
|||
);
|
||||
}
|
||||
|
||||
void main() async {
|
||||
void main( ) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// 1) 同意 SDK 隐私(百度 SDK 要求)
|
||||
|
@ -122,25 +124,53 @@ void main() async {
|
|||
// 自动登录逻辑
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final savedLogin = prefs.getBool('isLoggedIn') ?? false;
|
||||
bool isLoggedIn = false;
|
||||
// bool isLoggedIn = false;
|
||||
Map<String, dynamic> data={};
|
||||
|
||||
if (savedLogin) {
|
||||
// 如果本地标记已登录,进一步验证 token 是否有效
|
||||
try {
|
||||
isLoggedIn = await AuthService.isLoggedIn();
|
||||
// isLoggedIn = await AuthService.isLoggedIn();
|
||||
data =await AuthService.isLoggedIn();
|
||||
// if (data.isEmpty||data['result']!= 'success') {
|
||||
// isLoggedIn =false;
|
||||
// }else{
|
||||
// isLoggedIn = true;
|
||||
// }
|
||||
} catch (e) {
|
||||
isLoggedIn = false;
|
||||
data={};
|
||||
// isLoggedIn = false;
|
||||
}
|
||||
}
|
||||
|
||||
runApp(MyApp(isLoggedIn: isLoggedIn));
|
||||
// runApp(MyApp(isLoggedIn: isLoggedIn));
|
||||
runApp(MyApp(data: data));
|
||||
}
|
||||
|
||||
/// MyApp:恢复为 Stateless(无需监听 viewInsets)
|
||||
class MyApp extends StatelessWidget {
|
||||
final bool isLoggedIn;
|
||||
// final bool isLoggedIn;
|
||||
final Map<String, dynamic> data;
|
||||
const MyApp({super.key, required this.data});
|
||||
|
||||
const MyApp({super.key, required this.isLoggedIn});
|
||||
Widget getHomePage() {
|
||||
|
||||
// isLoggedIn ? const MainPage() : const LoginPage(),
|
||||
if (data.isNotEmpty&&data['result'] == 'success') {
|
||||
// data['LONG_TERM_PASSWORD_NOT_CHANGED']='1';
|
||||
if(data['WEAK_PASSWORD']=='1'){
|
||||
return const MineSetPwdPage("3");
|
||||
|
||||
}else if(data['LONG_TERM_PASSWORD_NOT_CHANGED']=='1'){
|
||||
return const MineSetPwdPage("4");
|
||||
}else{
|
||||
return const MainPage();
|
||||
}
|
||||
|
||||
}else{
|
||||
return const LoginPage();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -214,7 +244,8 @@ class MyApp extends StatelessWidget {
|
|||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
home: isLoggedIn ? const MainPage() : const LoginPage(),
|
||||
home:getHomePage(),
|
||||
// isLoggedIn ? const MainPage() : const LoginPage(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
routes: {'/login': (_) => const LoginPage()},
|
||||
);
|
||||
|
|
|
@ -306,7 +306,7 @@ class _DangerWaitListPageState extends State<DangerWaitListPage> {
|
|||
),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
'整改人:${item['CREATORNAME'] ?? ''}',
|
||||
'整改人:${item['RECTIFICATIONORNAME'] ?? ''}',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -561,7 +561,7 @@ class _HiddenDangerAcceptancePageState extends State<HiddenDangerAcceptancePage>
|
|||
}
|
||||
|
||||
Future<void> _addHazardAcceptance() async {
|
||||
try {
|
||||
|
||||
|
||||
String type="1";
|
||||
String miaoshu="";
|
||||
|
@ -589,10 +589,21 @@ class _HiddenDangerAcceptancePageState extends State<HiddenDangerAcceptancePage>
|
|||
type="0";
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
LoadingDialogHelper.show();
|
||||
|
||||
final data = await ApiService.addHazardAcceptance( type, miaoshu, dataTime,widget.item['HIDDEN_ID'] ?? '');
|
||||
final Map<String, dynamic> data;
|
||||
if ("4"==widget.item['SOURCE' ]||"5"==widget.item['SOURCE' ]) {
|
||||
data = await ApiService.addHazardAcceptanceZero( type, miaoshu, dataTime,widget.item['HIDDEN_ID'] ?? '');
|
||||
} else if ("1"==widget.item['HIDDEN_RISKSTANDARD']) {
|
||||
data = await ApiService.addHazardAcceptance( type, miaoshu, dataTime,widget.item['HIDDEN_ID'] ?? '');
|
||||
} else
|
||||
// if ("2"==widget.item['HIDDEN_RISKSTANDARD'])
|
||||
{
|
||||
data = await ApiService.addHazardAcceptanceTwo( type, miaoshu, dataTime,widget.item['HIDDEN_ID'] ?? '',pd['HIDDENDESCR']?? '');
|
||||
}
|
||||
// final data = await ApiService.addHazardAcceptance( type, miaoshu, dataTime,widget.item['HIDDEN_ID'] ?? '');
|
||||
LoadingDialogHelper.hide();
|
||||
if (data['result'] == 'success') {
|
||||
|
||||
String hiddenCheckId="";
|
||||
|
@ -607,7 +618,7 @@ class _HiddenDangerAcceptancePageState extends State<HiddenDangerAcceptancePage>
|
|||
|
||||
}
|
||||
setState(() {
|
||||
LoadingDialogHelper.hide();
|
||||
|
||||
ToastUtil.showNormal(context, "提交成功");
|
||||
Navigator.of(context).pop();
|
||||
widget.onClose('关闭详情'); // 触发回调
|
||||
|
@ -615,10 +626,37 @@ class _HiddenDangerAcceptancePageState extends State<HiddenDangerAcceptancePage>
|
|||
|
||||
}else{
|
||||
LoadingDialogHelper.hide();
|
||||
ToastUtil.showNormal(context, "提交失败");
|
||||
// final data = await ApiService.addHazardAcceptanceTwo( type, miaoshu, dataTime,widget.item['HIDDEN_ID'] ?? '',pd['HIDDENDESCR']?? '');
|
||||
// if (data['result'] == 'success') {
|
||||
//
|
||||
// String hiddenCheckId="";
|
||||
// try{
|
||||
// hiddenCheckId= data['check']['HIDDENCHECK_ID'];
|
||||
// }catch(e){
|
||||
// hiddenCheckId="";
|
||||
// }
|
||||
//
|
||||
// for(int i=0;i<gaiHouImages.length;i++){
|
||||
// _addImgFiles(gaiHouImages[i],"5",hiddenCheckId) ;
|
||||
//
|
||||
// }
|
||||
// setState(() {
|
||||
// LoadingDialogHelper.hide();
|
||||
// ToastUtil.showNormal(context, "提交成功");
|
||||
// Navigator.of(context).pop();
|
||||
// widget.onClose('关闭详情'); // 触发回调
|
||||
// });
|
||||
//
|
||||
// }else{
|
||||
// ToastUtil.showNormal(context, "提交失败");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
LoadingDialogHelper.hide();
|
||||
ToastUtil.showNormal(context, "提交失败");
|
||||
print('Error fetching data: $e');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -648,11 +648,35 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
|
|||
|
||||
try {
|
||||
|
||||
final result = await ApiService.normalRectificationSubmission(
|
||||
dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
id, caertTime, listName,
|
||||
standard, method, fund, person,
|
||||
workTime, time, work, other, json);
|
||||
final Map<String, dynamic> result;
|
||||
// if ("4"==widget.item['SOURCE' ]||"5"==widget.item['SOURCE' ]) {
|
||||
// result = await ApiService.normalRectificationSubmission(
|
||||
// dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
// id, caertTime, listName,
|
||||
// standard, method, fund, person,
|
||||
// workTime, time, work, other, json);
|
||||
// } else if ("1"==widget.item['HIDDEN_RISKSTANDARD']) {
|
||||
// result = await ApiService.normalRectificationSubmission(
|
||||
// dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
// id, caertTime, listName,
|
||||
// standard, method, fund, person,
|
||||
// workTime, time, work, other, json);
|
||||
// } else
|
||||
if ("2"==widget.item['HIDDEN_RISKSTANDARD']) {
|
||||
result = await ApiService.normalRectificationSubmissionTwo(
|
||||
dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
id, caertTime, listName,
|
||||
standard, method, fund, person,
|
||||
workTime, time, work, other, json);
|
||||
}else{
|
||||
result = await ApiService.normalRectificationSubmission(
|
||||
dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
id, caertTime, listName,
|
||||
standard, method, fund, person,
|
||||
workTime, time, work, other, json);
|
||||
}
|
||||
|
||||
|
||||
if (result['result'] == 'success') {
|
||||
setState(() {
|
||||
LoadingDialogHelper.hide();
|
||||
|
@ -664,27 +688,28 @@ class _PendingRectificationDetailPageState extends State<PendingRectificationDet
|
|||
}else{
|
||||
LoadingDialogHelper.hide();
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
// final result = await ApiService.normalRectificationSubmissionTwo(
|
||||
// dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
// id, caertTime, listName,
|
||||
// standard, method, fund, person,
|
||||
// workTime, time, work, other, json);
|
||||
// // LoadingDialogHelper.hide();
|
||||
// if (result['result'] == 'success') {
|
||||
// setState(() {
|
||||
//
|
||||
// ToastUtil.showNormal(context, "提交成功");
|
||||
// Navigator.of(context).pop();
|
||||
// widget.onClose('关闭详情'); // 触发回调
|
||||
// });
|
||||
//
|
||||
// }else{
|
||||
// // LoadingDialogHelper.hide();
|
||||
// ToastUtil.showNormal(context, "加载数据失败");
|
||||
// }
|
||||
}
|
||||
} catch (e) {
|
||||
LoadingDialogHelper.hide();
|
||||
|
||||
final result = await ApiService.normalRectificationSubmissionTwo(
|
||||
dataTime, miaoShu, acceptedPrepareType, acceptedPlanType,
|
||||
id, caertTime, listName,
|
||||
standard, method, fund, person,
|
||||
workTime, time, work, other, json);
|
||||
if (result['result'] == 'success') {
|
||||
setState(() {
|
||||
LoadingDialogHelper.hide();
|
||||
ToastUtil.showNormal(context, "提交成功");
|
||||
Navigator.of(context).pop();
|
||||
widget.onClose('关闭详情'); // 触发回调
|
||||
});
|
||||
|
||||
}else{
|
||||
LoadingDialogHelper.hide();
|
||||
ToastUtil.showNormal(context, "加载数据失败");
|
||||
}
|
||||
// 出错时可以 Toast 或者在页面上显示错误状态
|
||||
print('加载数据失败:$e');
|
||||
}
|
||||
|
|
|
@ -807,6 +807,9 @@ class _SafecheckStartDetailState extends State<SafecheckStartDetail> {
|
|||
rawHiddenList
|
||||
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||
.toList();
|
||||
|
||||
delHiddens.add(hiddenList[index]["HIDDEN_ID"]);
|
||||
// _removeList();
|
||||
hiddenList.removeAt(index);
|
||||
form['hiddenList'] = hiddenList;
|
||||
});
|
||||
|
@ -814,6 +817,23 @@ class _SafecheckStartDetailState extends State<SafecheckStartDetail> {
|
|||
}
|
||||
}
|
||||
|
||||
// Future<void> _removeList() async {
|
||||
// try {
|
||||
// final typeListData = await ApiService.removeList();
|
||||
// if (typeListData['result'] == 'success') {
|
||||
// setState(() {
|
||||
//
|
||||
// });
|
||||
// }else{
|
||||
// ToastUtil.showNormal(context, "删除失败");
|
||||
// }
|
||||
//
|
||||
// } catch (e) {
|
||||
// ToastUtil.showNormal(context, "删除失败");
|
||||
// print('加载 typeList 失败: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
/// 弹出单位选择
|
||||
void chooseUnitHandle(String typeStr) {
|
||||
showModalBottomSheet(
|
||||
|
|
|
@ -264,6 +264,7 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
}
|
||||
|
||||
Widget _itemCell(final screenWidth, final item) {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
child: Column(
|
||||
|
@ -335,6 +336,14 @@ class _DangerProjectPageState extends State<DangerProjectPage> {
|
|||
width: screenWidth,
|
||||
padding: const EdgeInsets.all(10),
|
||||
child:
|
||||
// TextField(
|
||||
// controller: _controller,
|
||||
// decoration: InputDecoration(
|
||||
// labelText: '输入框',
|
||||
// hintText: '请输入内容',
|
||||
// ),
|
||||
// ),
|
||||
|
||||
Text(item["CHECK_QUALIFIED"], style: const TextStyle(color: Colors.black, fontSize: 12)),
|
||||
)),
|
||||
],
|
||||
|
|
|
@ -278,9 +278,9 @@ class _WorkSetPageState extends State<WorkSetPage> {
|
|||
Column(
|
||||
spacing: 5,
|
||||
children: [
|
||||
_itemCell("需进行${dayWork["fxyjcNum"]??"0"}项隐患排查", true),
|
||||
_itemCell("已进行${dayWork["fxyjcNum"]??"0"}项隐患排查", true),
|
||||
_itemCell("需进行${dayWork["fxwjcNum"]??"0"}项隐患排查", false),
|
||||
_itemCell("需进行${dayWork["yhyjcNum"]??"0"}项标准排查", true),
|
||||
_itemCell("已进行${dayWork["yhyjcNum"]??"0"}项标准排查", true),
|
||||
_itemCell("需进行${dayWork["yhwjcNum"]??"0"}项标准排查", false),
|
||||
],
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/gestures.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||||
import 'package:qhd_prevention/pages/mine/mine_set_pwd_page.dart';
|
||||
import 'package:qhd_prevention/services/auth_service.dart';
|
||||
import '../tools/tools.dart';
|
||||
import 'main_tab.dart';
|
||||
|
@ -351,16 +352,29 @@ class _LoginPageState extends State<LoginPage> {
|
|||
);
|
||||
|
||||
try {
|
||||
final success = await AuthService.login(userName, userPwd);
|
||||
final data = await AuthService.login(userName, userPwd);
|
||||
|
||||
Navigator.of(context).pop(); // 关loading
|
||||
setState(() => _isLoading = false);
|
||||
|
||||
if (success) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const MainPage()),
|
||||
);
|
||||
if(data.isEmpty){
|
||||
return;
|
||||
}
|
||||
|
||||
if (data['result'] == 'success') {
|
||||
if(data['WEAK_PASSWORD']=='1'){
|
||||
pushPage(const MineSetPwdPage("1"), context);
|
||||
|
||||
}else if(data['LONG_TERM_PASSWORD_NOT_CHANGED']=='1'){
|
||||
pushPage(const MineSetPwdPage("2"), context);
|
||||
|
||||
}else{
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const MainPage()),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
Navigator.of(context).pop();
|
||||
|
|
|
@ -209,55 +209,55 @@ class _MineDepartureRecordPage extends State<MineDepartureRecordPage> {
|
|||
// if( item["REVIEW_STATUS"]=="0"&&DateTime.now().isBefore(item["ENDTIME"])&&
|
||||
// (item["REVIEW_USER_ID"]==SessionService.instance.loginUserId)&&
|
||||
// SessionService.instance.loginUser?["USERNAME"]=="1"&&item['REVIEW_STATUS']=="0")
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => DutyDialog(
|
||||
item,1,
|
||||
onClose: (result) {
|
||||
// print('详情页面已关闭,返回结果: $result');
|
||||
refreshData();
|
||||
},
|
||||
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF1976D2),
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
),
|
||||
child: const Text("关 闭", style: TextStyle(color: Colors.white,fontSize: 12)),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => DutyDialog(
|
||||
item,2,
|
||||
onClose: (result) {
|
||||
// print('详情页面已关闭,返回结果: $result');
|
||||
refreshData();
|
||||
},
|
||||
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
),
|
||||
child: const Text("提 交", style: TextStyle(color: Colors.white,fontSize: 12)),
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => DutyDialog(
|
||||
// item,1,
|
||||
// onClose: (result) {
|
||||
// // print('详情页面已关闭,返回结果: $result');
|
||||
// refreshData();
|
||||
// },
|
||||
//
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: const Color(0xFF1976D2),
|
||||
// // padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
// ),
|
||||
// child: const Text("关 闭", style: TextStyle(color: Colors.white,fontSize: 12)),
|
||||
// ),
|
||||
//
|
||||
// const SizedBox(width: 16),
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => DutyDialog(
|
||||
// item,2,
|
||||
// onClose: (result) {
|
||||
// // print('详情页面已关闭,返回结果: $result');
|
||||
// refreshData();
|
||||
// },
|
||||
//
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: Colors.red,
|
||||
// // padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
// ),
|
||||
// child: const Text("提 交", style: TextStyle(color: Colors.white,fontSize: 12)),
|
||||
// )
|
||||
//
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -282,15 +282,18 @@ class _MineDutyManagementPageState extends State<MineDutyManagementPage> {
|
|||
const SizedBox(height: 4),
|
||||
|
||||
// 操作按钮
|
||||
if (item["REVIEW_STATUS"] == "0" &&
|
||||
isBeforeNow(item["ENDTIME"]) &&
|
||||
(item["REVIEW_USER_ID"] ==
|
||||
SessionService.instance.loginUserId) &&
|
||||
SessionService.instance.loginUser?["USERNAME"] == "1" &&
|
||||
item['REVIEW_STATUS'] == "0")
|
||||
// if (item["REVIEW_STATUS"] == "0" && isBeforeNow(item["ENDTIME"]) &&
|
||||
// (item["REVIEW_USER_ID"] == SessionService.instance.loginUserId) &&
|
||||
// SessionService.instance.loginUser?["USERNAME"] == "1" &&
|
||||
// item['REVIEW_STATUS'] == "0")
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if(item["REVIEW_STATUS"]== '0' &&
|
||||
(item["REVIEW_USER_ID"]== SessionService.instance.loginUserId ||
|
||||
item["REVIEW_USER_ID"]!=null &&
|
||||
SessionService.instance.loginUser?["ISLEADER"] == '1'))
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
|
@ -318,6 +321,9 @@ class _MineDutyManagementPageState extends State<MineDutyManagementPage> {
|
|||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
if(item["REVIEW_STATUS"]== '0'&&
|
||||
(item["REVIEW_USER_ID"]== SessionService.instance.loginUserId ||
|
||||
item["USER_ID"]==SessionService.instance.loginUserId))
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
|
|
|
@ -25,6 +25,34 @@ class _MineSetPwdPageState extends State<MineSetPwdPage> {
|
|||
final _newPwdController = TextEditingController();
|
||||
final _confirmPwdController = TextEditingController();
|
||||
|
||||
String textString="为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
switch(widget.type){
|
||||
case "0":
|
||||
textString="为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456";
|
||||
break;
|
||||
case "1":
|
||||
textString="检测到您的密码为弱密码,请修改密码后重新登录。为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456";
|
||||
break;
|
||||
case "2":
|
||||
textString="检测到您30天内未修改密码,请修改密码后重新登录。为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456";
|
||||
break;
|
||||
case "3":
|
||||
textString="检测到您的密码为弱密码,请修改密码后重新登录。为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456";
|
||||
break;
|
||||
case "4":
|
||||
textString="检测到您30天内未修改密码,请修改密码后重新登录。为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_oldPwdController.dispose();
|
||||
|
@ -63,27 +91,27 @@ class _MineSetPwdPageState extends State<MineSetPwdPage> {
|
|||
// }
|
||||
|
||||
if (newPwd != confirmPwd) {
|
||||
ToastUtil.showNormal(context, '两次输入的密码不一致');
|
||||
ToastUtil.showNormal(context, '新密码和确认密码两次输入的密码不一致');
|
||||
// _showMessage('新密码与确认密码不一致');
|
||||
return;
|
||||
}
|
||||
|
||||
// 示例验证:密码复杂度(实际可用正则加强)
|
||||
if (newPwd.length < 8 ) {
|
||||
ToastUtil.showNormal(context, '密码需要大于8位');
|
||||
ToastUtil.showNormal(context, '新密码需要大于8位');
|
||||
// _showMessage('密码长度需在8-18位之间');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( newPwd.length > 18) {
|
||||
ToastUtil.showNormal(context, '密码需要小于18位');
|
||||
ToastUtil.showNormal(context, '新密码需要小于18位');
|
||||
// _showMessage('密码长度需在8-18位之间');
|
||||
return;
|
||||
}
|
||||
|
||||
// final RegExp regex = RegExp(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,18}$');
|
||||
if (!isPasswordValid(newPwd)) {
|
||||
ToastUtil.showNormal(context, '必须包含大小字母,小写字母数字和特殊符号。');
|
||||
ToastUtil.showNormal(context, '新密码必须包含大小字母,小写字母数字和特殊符号。');
|
||||
// _showMessage('密码长度为6-18位,必须包含大小字母,小写字母数字和特殊符号。');
|
||||
return;
|
||||
}
|
||||
|
@ -150,8 +178,8 @@ class _MineSetPwdPageState extends State<MineSetPwdPage> {
|
|||
const SizedBox(height: 20),
|
||||
_buildPwdField('确认新密码', _confirmPwdController),
|
||||
const SizedBox(height: 15),
|
||||
const Text(
|
||||
'为了您的账户安全,请确保密码长度为 8-18 位,必须包含大小写字母+数字+特殊字符,例如:Aa@123456',
|
||||
Text(
|
||||
textString,
|
||||
style: TextStyle(color: Colors.grey, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 30,),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
import 'package:encrypt/encrypt.dart' as encrypt;
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:pointycastle/asymmetric/api.dart' show RSAPublicKey;
|
||||
import 'package:qhd_prevention/pages/mine/mine_set_pwd_page.dart';
|
||||
import 'package:qhd_prevention/tools/tools.dart';
|
||||
|
@ -14,7 +15,7 @@ class AuthService {
|
|||
static const _keyIsLoggedIn = 'isLoggedIn';
|
||||
|
||||
/// 登录
|
||||
static Future<bool> login(String username, String password) async {
|
||||
static Future<Map<String, dynamic>> login(String username, String password) async {
|
||||
final parser = encrypt.RSAKeyParser();
|
||||
final pub = parser.parse(ApiService.publicKey) as RSAPublicKey;
|
||||
final encrypter = encrypt.Encrypter(encrypt.RSA(publicKey: pub));
|
||||
|
@ -26,24 +27,19 @@ class AuthService {
|
|||
encrypted = encrypter.encrypt(plain).base64;
|
||||
} catch (e) {
|
||||
Fluttertoast.showToast(msg: '加密失败:$e');
|
||||
return false;
|
||||
return {} ;
|
||||
// return false;
|
||||
}
|
||||
|
||||
final data = await ApiService.loginCheck(encrypted);
|
||||
final result = data['result'] as String? ?? '';
|
||||
if (result != 'success') {
|
||||
Fluttertoast.showToast(msg: data['msg'] ?? '');
|
||||
|
||||
return false;
|
||||
return data;
|
||||
// return false;
|
||||
}
|
||||
|
||||
// if(data['result']['WEAK_PASSWORD']=='1'){
|
||||
// pushPage(const MineSetPwdPage("1"), context);
|
||||
// return false;
|
||||
// }else if(data['result']['LONG_TERM_PASSWORD_NOT_CHANGED']=='1'){
|
||||
// pushPage(const MineSetPwdPage("2"), context);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_keyUser, json.encode(data));
|
||||
|
@ -59,7 +55,8 @@ class AuthService {
|
|||
..setUsername(data['NAME'] as String)
|
||||
..setLoginUser(data);
|
||||
|
||||
return true;
|
||||
return data;
|
||||
// return true;
|
||||
}
|
||||
/// 检查更新
|
||||
static Future<Map<String, dynamic>> checkUpdate() async {
|
||||
|
@ -73,24 +70,24 @@ class AuthService {
|
|||
|
||||
|
||||
/// 验证是否已登录(通过重新登录)
|
||||
static Future<bool> isLoggedIn() async {
|
||||
static Future<Map<String, dynamic>> isLoggedIn() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final isLocalLoggedIn = prefs.getBool(_keyIsLoggedIn) ?? false;
|
||||
if (!isLocalLoggedIn) return false;
|
||||
if (!isLocalLoggedIn) return {};
|
||||
|
||||
final remember = prefs.getStringList(_keyRemember);
|
||||
if (remember == null || remember.length < 2) return false;
|
||||
if (remember == null || remember.length < 2) return {};
|
||||
|
||||
final username = remember[0];
|
||||
final password = remember[1];
|
||||
|
||||
// 用存储的账号密码重新登录
|
||||
final success = await login(username, password);
|
||||
if (!success) {
|
||||
final data = await login(username, password);
|
||||
if (data.isEmpty||data['result']!= 'success') {
|
||||
await logout();
|
||||
return false;
|
||||
return data;
|
||||
}
|
||||
return true;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue