2025.9.9 改bug

main
xufei 2025-09-09 20:08:10 +08:00
parent e86a91fc19
commit 0dc4773324
12 changed files with 291 additions and 123 deletions

View File

@ -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()},
);

View File

@ -306,7 +306,7 @@ class _DangerWaitListPageState extends State<DangerWaitListPage> {
),
SizedBox(height: 5),
Text(
'整改人:${item['CREATORNAME'] ?? ''}',
'整改人:${item['RECTIFICATIONORNAME'] ?? ''}',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
],

View File

@ -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');
}
}

View File

@ -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');
}

View File

@ -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(

View File

@ -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)),
)),
],

View File

@ -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),
],

View File

@ -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();

View File

@ -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)),
// )
//
// ],
// ),
],
),
),

View File

@ -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(

View File

@ -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,),

View File

@ -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;
}