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