From 2618fceec49a2cb48a9074abcc848eb258bab54b Mon Sep 17 00:00:00 2001 From: hs <873121290@qq.com> Date: Thu, 18 Sep 2025 15:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/ApiService.dart | 70 ++++++++++++++----- lib/pages/home/scan_page.dart | 58 ++++++++++----- .../home/study/face_ecognition_page.dart | 37 +++++----- lib/pages/home/study/study_detail_page.dart | 56 ++++++++------- lib/pages/home/tap/item_list_widget.dart | 4 +- .../hotwork_safe_func_sure.dart | 27 ++++--- .../cutroad_safe_func_sure.dart | 6 +- .../breakground_safe_func_sure.dart | 6 +- .../hoistwork_safe_func_sure.dart | 6 +- .../highwork_safe_func_sure.dart | 6 +- .../electricity_safe_func_sure.dart | 6 +- .../blindboard_safe_func_sure.dart | 6 +- .../spacework_safe_func_sure.dart | 6 +- lib/pages/login_page.dart | 32 +++++---- lib/pages/mine/mine_set_page.dart | 7 +- lib/tools/tools.dart | 17 +++++ 16 files changed, 216 insertions(+), 134 deletions(-) diff --git a/lib/http/ApiService.dart b/lib/http/ApiService.dart index 9e4df8a..c161ba9 100644 --- a/lib/http/ApiService.dart +++ b/lib/http/ApiService.dart @@ -184,14 +184,14 @@ U6Hzm1ninpWeE+awIDAQAB ); } - - static Future> getUpdateInfo() { return HttpManager().request( - projectManagerUrl, - '/projectDetails/findUpdate?code=cloud&type=APP', + basePath, + '/app/versionmanager/getVersion', method: Method.post, - data: {}, + data: { + 'FILETYPE':Platform.pathSeparator + }, ); } @@ -533,14 +533,10 @@ U6Hzm1ninpWeE+awIDAQAB ); } - /// 人脸比对上传接口 - static Future> getUserFace( + /// 教培人脸比对上传接口 + static Future> getStudyUserFace( String imagePath, - String studentId, - String VIDEOCOURSEWARE_ID, - String CURRICULUM_ID, - String CHAPTER_ID, - String CLASS_ID, + Map data ) async { final file = File(imagePath); if (!await file.exists()) { @@ -550,17 +546,53 @@ U6Hzm1ninpWeE+awIDAQAB return HttpManager().uploadFaceImage( baseUrl: baseFacePath, + path: '/app/user/compareFaceV2', + fromData: { + ...data, + 'USER_ID': SessionService.instance.loginUserId, + 'CORPINFO_ID': SessionService.instance.corpinfoId, + 'FFILE': await MultipartFile.fromFile(file.path, filename: fileName), + }, + ); + } + static Future> getUpdataUserFace( + String imagePath, + Map data + ) async { + final file = File(imagePath); + if (!await file.exists()) { + throw ApiException('file_not_found', '图片不存在:$imagePath'); + } + final fileName = file.path.split(Platform.pathSeparator).last; + + return HttpManager().uploadFaceImage( + baseUrl: basePath, + path: '/app/user/editUserFaceV2', + fromData: { + ...data, + 'USER_ID': SessionService.instance.loginUserId, + 'CORPINFO_ID': SessionService.instance.corpinfoId, + 'FFILE': await MultipartFile.fromFile(file.path, filename: fileName), + }, + ); + } + static Future> getScanUserFace( + String imagePath, + Map data + ) async { + final file = File(imagePath); + if (!await file.exists()) { + throw ApiException('file_not_found', '图片不存在:$imagePath'); + } + final fileName = file.path.split(Platform.pathSeparator).last; + + return HttpManager().uploadFaceImage( + baseUrl: basePath, path: '/app/user/compareFaceForH5V2', fromData: { + ...data, 'USER_ID': SessionService.instance.loginUserId, - 'STUDENT_ID': studentId, 'CORPINFO_ID': SessionService.instance.corpinfoId, - - "CLASS_ID":CLASS_ID, - "VIDEOCOURSEWARE_ID": VIDEOCOURSEWARE_ID, - "CURRICULUM_ID": CURRICULUM_ID, - "CHAPTER_ID": CHAPTER_ID, - 'FFILE': await MultipartFile.fromFile(file.path, filename: fileName), }, ); diff --git a/lib/pages/home/scan_page.dart b/lib/pages/home/scan_page.dart index f7778e2..e40644e 100644 --- a/lib/pages/home/scan_page.dart +++ b/lib/pages/home/scan_page.dart @@ -14,7 +14,9 @@ import 'package:qhd_prevention/tools/tools.dart'; class ScanPage extends StatefulWidget { // const ScanPage({Key? key}) : super(key: key,); const ScanPage({super.key, required this.totalList}); + final List totalList; + @override State createState() => _ScanPageState(); } @@ -99,9 +101,9 @@ class _ScanPageState extends State { } catch (e, st) { // 捕获解析或运行时错误 print('handleScanResult error: $e\n$st'); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('扫码处理失败: ${e.toString()}')), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text('扫码处理失败: ${e.toString()}'))); } } @@ -109,10 +111,17 @@ class _ScanPageState extends State { void goToFace(Map stuInfo) async { print('navigate to face with $stuInfo'); final passed = await pushPage( - FaceRecognitionPage(studentId: stuInfo['STUDENT_ID'], - VIDEOCOURSEWARE_ID: stuInfo['VIDEOCOURSEWARE_ID'],CURRICULUM_ID: stuInfo['CURRICULUM_ID'], - CHAPTER_ID: stuInfo['CHAPTER_ID'],CLASS_ID: stuInfo['CLASS_ID'], - mode: FaceMode.auto), + FaceRecognitionPage( + studentId: stuInfo['STUDENT_ID'], + data: { + 'VIDEOCOURSEWARE_ID': stuInfo['VIDEOCOURSEWARE_ID'], + 'CURRICULUM_ID': stuInfo['CURRICULUM_ID'], + 'CHAPTER_ID': stuInfo['CHAPTER_ID'], + 'CLASS_ID': stuInfo['CLASS_ID'], + 'STUDENT_ID':stuInfo['STUDENT_ID'], + }, + mode: FaceMode.scan, + ), context, ); if (passed == true) { @@ -127,8 +136,8 @@ class _ScanPageState extends State { // 跳转到清单页面 void goToList({required String listId, required String listName}) { print('navigate to list: $listId, name: $listName'); - Navigator.pop(context,Animation); - pushPage(RiskListPage(1, listId,""), context); + Navigator.pop(context, Animation); + pushPage(RiskListPage(1, listId, ""), context); } @override @@ -175,15 +184,20 @@ class _ScanPageState extends State { // 顶部 // 1. 顶部遮罩 Positioned( - left: 0, right: 0, top: 0, - height: top, // 从顶到底部到扫描框上边缘 + left: 0, + right: 0, + top: 0, + height: top, + // 从顶到底部到扫描框上边缘 child: Container(color: Colors.black54), ), // 2. 底部遮罩 Positioned( - left: 0, right: 0, - top: top + scanSize, // 从扫描框下边缘开始 + left: 0, + right: 0, + top: top + scanSize, + // 从扫描框下边缘开始 bottom: 0, child: Container(color: Colors.black54), ), @@ -192,8 +206,10 @@ class _ScanPageState extends State { Positioned( left: 0, top: top, - width: left, // 从屏幕左侧到扫描框左边缘 - height: scanSize, // 和扫描框一样高 + width: left, + // 从屏幕左侧到扫描框左边缘 + height: scanSize, + // 和扫描框一样高 child: Container(color: Colors.black54), ), @@ -202,7 +218,8 @@ class _ScanPageState extends State { left: left + scanSize, top: top, right: 0, - height: scanSize, // 和扫描框一样高 + height: scanSize, + // 和扫描框一样高 child: Container(color: Colors.black54), ), @@ -239,11 +256,15 @@ class _ScanPageState extends State { child: IconButton( iconSize: 32, color: Colors.white, - icon: Icon(_torchOn ? Icons.flashlight_off_outlined : Icons.flashlight_on_outlined), + icon: Icon( + _torchOn + ? Icons.flashlight_off_outlined + : Icons.flashlight_on_outlined, + ), onPressed: () { _controller.toggleTorch(); setState(() { - _torchOn = !_torchOn; + _torchOn = !_torchOn; }); }, ), @@ -273,5 +294,4 @@ class _ScanPageState extends State { ), ); } - } diff --git a/lib/pages/home/study/face_ecognition_page.dart b/lib/pages/home/study/face_ecognition_page.dart index c99837f..5321792 100644 --- a/lib/pages/home/study/face_ecognition_page.dart +++ b/lib/pages/home/study/face_ecognition_page.dart @@ -17,28 +17,18 @@ import 'package:qhd_prevention/tools/tools.dart'; const MethodChannel _platformChan = MethodChannel('qhd_prevention/permissions'); /// 人脸识别模式 -enum FaceMode { auto, manual } +enum FaceMode { setUpdata, study, scan } class FaceRecognitionPage extends StatefulWidget { final String studentId; - - final String VIDEOCOURSEWARE_ID; - final String CURRICULUM_ID; - final String CHAPTER_ID; - final String CLASS_ID; - + final Map data; final FaceMode mode; const FaceRecognitionPage({ Key? key, required this.studentId, - - required this.VIDEOCOURSEWARE_ID, - required this.CURRICULUM_ID, - required this.CHAPTER_ID, - required this.CLASS_ID, - - this.mode = FaceMode.auto, + required this.data, + this.mode = FaceMode.study, }) : super(key: key); @override @@ -55,7 +45,7 @@ class _FaceRecognitionPageState extends State static const Duration _interval = Duration(seconds: 2); String _errMsg = ''; - bool get _isManualMode => widget.mode == FaceMode.manual; + bool get _isManualMode => widget.mode == FaceMode.setUpdata; bool _isInitializing = false; bool _isTaking = false; @@ -271,9 +261,18 @@ class _FaceRecognitionPageState extends State } catch (_) {} final XFile pic = await _cameraController!.takePicture(); - final res = await ApiService.getUserFace(pic.path, widget.studentId, - widget.VIDEOCOURSEWARE_ID,widget.CURRICULUM_ID,widget.CHAPTER_ID,widget.CLASS_ID,); - + var res = {}; + switch(widget.mode) { + case FaceMode.study: + res = await ApiService.getStudyUserFace(pic.path, widget.data); + break; + case FaceMode.setUpdata: + res = await ApiService.getUpdataUserFace(pic.path, widget.data); + break; + case FaceMode.scan: + res = await ApiService.getScanUserFace(pic.path, widget.data); + break; + } if (res['result'] == 'success') { _onSuccess(); } else { @@ -335,7 +334,7 @@ class _FaceRecognitionPageState extends State void _onSuccess() { _timer?.cancel(); - if (widget.mode == FaceMode.manual) { + if (widget.mode == FaceMode.setUpdata) { ToastUtil.showSuccess(context, '已更新人脸信息'); Future.delayed(const Duration(milliseconds: 800), () { if (mounted) Navigator.of(context).pop(true); diff --git a/lib/pages/home/study/study_detail_page.dart b/lib/pages/home/study/study_detail_page.dart index ceda9ee..5947bb9 100644 --- a/lib/pages/home/study/study_detail_page.dart +++ b/lib/pages/home/study/study_detail_page.dart @@ -236,7 +236,7 @@ class _StudyDetailPageState extends State } } catch (_) {} - await _navigateFaceIfNeeded(() async { + await _navigateFaceIfNeeded(data,() async { if ((data['IS_VIDEO'] ?? 0) == 1) { // 文档 if (data['VIDEOFILES'] != null) { @@ -289,7 +289,7 @@ class _StudyDetailPageState extends State }); } - Future _navigateFaceIfNeeded(FutureOr Function() onPass) async { + Future _navigateFaceIfNeeded(Map data, FutureOr Function() onPass) async { if (!_isFace) { await onPass(); return; @@ -303,13 +303,16 @@ class _StudyDetailPageState extends State await _exitTopRouteAndWait(); await _lockPortrait(); final passed = await pushPage( - FaceRecognitionPage( + FaceRecognitionPage ( studentId: widget.studentId, - VIDEOCOURSEWARE_ID: "", - CURRICULUM_ID: "", - CHAPTER_ID: "", - CLASS_ID: "", - mode: FaceMode.auto, + data: { + 'CLASS_ID': widget.studyData['CLASS_ID'], + 'STUDENT_ID': widget.studyData['STUDENT_ID'], + 'CURRICULUM_ID': data['CURRICULUM_ID'], + 'CHAPTER_ID': data['CHAPTER_ID'], + 'VIDEOCOURSEWARE_ID': data['VIDEOCOURSEWARE_ID'] + }, + mode: FaceMode.study, ), context, ); @@ -332,17 +335,17 @@ class _StudyDetailPageState extends State if (ok) { await _exitTopRouteAndWait(); await _lockPortrait(); - await pushPage( - const FaceRecognitionPage( - studentId: '', - VIDEOCOURSEWARE_ID: '', - CURRICULUM_ID: '', - CHAPTER_ID: '', - CLASS_ID: '', - mode: FaceMode.manual, - ), - context, - ); + await pushPage(FaceRecognitionPage ( + studentId: widget.studentId, + data: { + 'CLASS_ID': widget.studyData['CLASS_ID'], + 'STUDENT_ID': widget.studyData['STUDENT_ID'], + 'CURRICULUM_ID': data['CURRICULUM_ID'], + 'CHAPTER_ID': data['CHAPTER_ID'], + 'VIDEOCOURSEWARE_ID': data['VIDEOCOURSEWARE_ID'] + }, + mode: FaceMode.study, + ), context); await _restoreDefaultOrientations(); } } @@ -695,13 +698,16 @@ class _StudyDetailPageState extends State await _lockPortrait(); final passed = await pushPage( - FaceRecognitionPage( + FaceRecognitionPage ( studentId: widget.studentId, - VIDEOCOURSEWARE_ID: "", - CURRICULUM_ID: "", - CHAPTER_ID: "", - CLASS_ID: "", - mode: FaceMode.auto, + data: { + 'CLASS_ID': widget.studyData['CLASS_ID'], + 'STUDENT_ID': widget.studyData['STUDENT_ID'], + 'CURRICULUM_ID': _currentVideoData?['CURRICULUM_ID'], + 'CHAPTER_ID': _currentVideoData?['CHAPTER_ID'], + 'VIDEOCOURSEWARE_ID': _currentVideoData?['VIDEOCOURSEWARE_ID'] + }, + mode: FaceMode.study, ), context, ); diff --git a/lib/pages/home/tap/item_list_widget.dart b/lib/pages/home/tap/item_list_widget.dart index 0a4d5bc..22adcd3 100644 --- a/lib/pages/home/tap/item_list_widget.dart +++ b/lib/pages/home/tap/item_list_widget.dart @@ -76,7 +76,7 @@ class ItemListWidget { onChanged: onChanged, onSubmitted: onFieldSubmitted, keyboardType: actualKeyboardType, - maxLength: showMaxLength?120:null, + maxLength: showMaxLength ? 120 : null, style: TextStyle(fontSize: fontSize), maxLines: 1, // 添加输入格式化器(如果是数字输入) @@ -146,6 +146,7 @@ class ItemListWidget { bool isRequired = true, String hintText = '请输入', ValueChanged? onChanged, + bool showMaxLength = false, }) { return Container( // 统一左右 padding,保证标题和内容在同一左侧基线 @@ -179,6 +180,7 @@ class ItemListWidget { maxLines: null, expands: true, onChanged: onChanged, + maxLength: showMaxLength ? 120 : null, // 垂直顶部对齐 textAlignVertical: TextAlignVertical.top, style: TextStyle(fontSize: fontSize), diff --git a/lib/pages/home/tap/tabList/special_wrok/dh_work/aqcs_work_detail/hotwork_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/dh_work/aqcs_work_detail/hotwork_safe_func_sure.dart index bd243ff..4804678 100644 --- a/lib/pages/home/tap/tabList/special_wrok/dh_work/aqcs_work_detail/hotwork_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/dh_work/aqcs_work_detail/hotwork_safe_func_sure.dart @@ -187,7 +187,6 @@ class _HotworkSafeFuncSureState extends State { /// 提交 1 提交 0暂存 Future _submit(String status) async { - if (imagePaths.isEmpty) { ToastUtil.showNormal(context, '请签字'); return; @@ -208,19 +207,19 @@ class _HotworkSafeFuncSureState extends State { title: '作废原因', hintText: '请输入作废原因', cancelText: '取消', - confirmText: '确定' + confirmText: '确定', ); // 用户取消(或点遮罩、返回键) -if (reasonText == null) { - // 取消时什么也不做,不提示 - return; -} + if (reasonText == null) { + // 取消时什么也不做,不提示 + return; + } -// 用户点击确认但没填内容 -if (reasonText.isEmpty) { - ToastUtil.showNormal(context, '请填写作废原因'); - return; -} + // 用户点击确认但没填内容 + if (reasonText.isEmpty) { + ToastUtil.showNormal(context, '请填写作废原因'); + return; + } } final Map formData = {}; // 提交参数 @@ -377,11 +376,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/dl_work/aqcs_work_detail/cutroad_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/dl_work/aqcs_work_detail/cutroad_safe_func_sure.dart index 554264e..33c60d3 100644 --- a/lib/pages/home/tap/tabList/special_wrok/dl_work/aqcs_work_detail/cutroad_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/dl_work/aqcs_work_detail/cutroad_safe_func_sure.dart @@ -430,11 +430,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/dt_work/aqcs_work_detail/breakground_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/dt_work/aqcs_work_detail/breakground_safe_func_sure.dart index 44c2a5f..015ccfc 100644 --- a/lib/pages/home/tap/tabList/special_wrok/dt_work/aqcs_work_detail/breakground_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/dt_work/aqcs_work_detail/breakground_safe_func_sure.dart @@ -389,11 +389,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/dz_work/aqcs_work_detail/hoistwork_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/dz_work/aqcs_work_detail/hoistwork_safe_func_sure.dart index 082ac7b..02f7a59 100644 --- a/lib/pages/home/tap/tabList/special_wrok/dz_work/aqcs_work_detail/hoistwork_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/dz_work/aqcs_work_detail/hoistwork_safe_func_sure.dart @@ -388,11 +388,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/gc_work/aqcs_work_detail/highwork_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/gc_work/aqcs_work_detail/highwork_safe_func_sure.dart index aa763b9..373f446 100644 --- a/lib/pages/home/tap/tabList/special_wrok/gc_work/aqcs_work_detail/highwork_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/gc_work/aqcs_work_detail/highwork_safe_func_sure.dart @@ -376,11 +376,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', + showMaxLength: true, isEditable: true, - showMaxLength:true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/lsyd_work/aqcs_work_detail/electricity_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/lsyd_work/aqcs_work_detail/electricity_safe_func_sure.dart index a4e63b6..7776f63 100644 --- a/lib/pages/home/tap/tabList/special_wrok/lsyd_work/aqcs_work_detail/electricity_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/lsyd_work/aqcs_work_detail/electricity_safe_func_sure.dart @@ -378,11 +378,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/mbcd_work/aqcs_work_detail/blindboard_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/mbcd_work/aqcs_work_detail/blindboard_safe_func_sure.dart index 5e6a44f..73adb85 100644 --- a/lib/pages/home/tap/tabList/special_wrok/mbcd_work/aqcs_work_detail/blindboard_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/mbcd_work/aqcs_work_detail/blindboard_safe_func_sure.dart @@ -391,11 +391,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/home/tap/tabList/special_wrok/sxkj_work/aqcs_work_detail/spacework_safe_func_sure.dart b/lib/pages/home/tap/tabList/special_wrok/sxkj_work/aqcs_work_detail/spacework_safe_func_sure.dart index 5692d93..fbcb750 100644 --- a/lib/pages/home/tap/tabList/special_wrok/sxkj_work/aqcs_work_detail/spacework_safe_func_sure.dart +++ b/lib/pages/home/tap/tabList/special_wrok/sxkj_work/aqcs_work_detail/spacework_safe_func_sure.dart @@ -376,11 +376,11 @@ if (reasonText.isEmpty) { ), ], ), - ItemListWidget.singleLineTitleText( - + ItemListWidget.multiLineTitleTextField( label: '其他安全措施:', - showMaxLength:true, + showMaxLength: true, isEditable: true, + isRequired: true, hintText: '请输入其他安全措施', controller: _otherController, ), diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 328aba0..fe592d4 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -5,6 +5,8 @@ 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 'package:qhd_prevention/tools/tools.dart'; +import 'package:qhd_prevention/tools/update/update_dialogs.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../tools/tools.dart'; import 'main_tab.dart'; @@ -97,19 +99,25 @@ class _LoginPageState extends State { try{ final result = await AuthService.checkUpdate(); if (FormUtils.hasValue(result, 'pd')) { - // 有更新 提示更新 Map pd = result['pd']; - CustomAlertDialog.showConfirm( - context, - title: '更新通知', - cancelText: '', - confirmText: '我知道了', - content: pd['UPLOAD_CONTENT'] ?? '', - onConfirm: () { - ToastUtil.showNormal(context, '更新去吧!'); - }, - ); - return; + final versionInfo = await getAppVersion(); + bool isWifi = await checkNetworkWifi(); + if (versionInfo.versionName != pd['VERSION']) { + //有更新 提示更新 + final ok = await CustomAlertDialog.showConfirm( + context, + title: '更新通知', + content: isWifi ? '发现新版本,是否更新?为了更好的体验,请更新到最新版本。' : '发现新版本,检查到您当前使用的是移动网络,是否更新?更新时请注意流量消耗。为了更好的体验,请更新到最新版本。', + cancelText: pd['ISUPDATE'] == '1' ? '' : '稍后更新', + confirmText: '立即更新' + ); + if (ok) { + // await showUpdateConfirmDialog(context, apkUrl: apkUrl); + + } + return; + } + } }catch(_) {} diff --git a/lib/pages/mine/mine_set_page.dart b/lib/pages/mine/mine_set_page.dart index f9866e4..c255b09 100644 --- a/lib/pages/mine/mine_set_page.dart +++ b/lib/pages/mine/mine_set_page.dart @@ -26,6 +26,7 @@ class _MineSetPageState extends State { final result = await AuthService.checkUpdate(); LoadingDialogHelper.hide(); if (FormUtils.hasValue(result, 'pd')) { + // 有更新 提示更新 Map pd = result['pd']; CustomAlertDialog.showConfirm( @@ -68,10 +69,8 @@ class _MineSetPageState extends State { child: _setItemWidget("更新人脸信息"), onTap: () { pushPage( - const FaceRecognitionPage(studentId: '', - VIDEOCOURSEWARE_ID: '',CURRICULUM_ID: '', - CHAPTER_ID: '',CLASS_ID: '', - mode: FaceMode.manual), + const FaceRecognitionPage(studentId: '',data: {}, + mode: FaceMode.setUpdata), context, ); }, diff --git a/lib/tools/tools.dart b/lib/tools/tools.dart index 88fdcba..adc53e1 100644 --- a/lib/tools/tools.dart +++ b/lib/tools/tools.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'dart:io'; import 'package:image_picker/image_picker.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:connectivity_plus/connectivity_plus.dart'; int getRandomWithNum(int min, int max) { if (max < min) { @@ -594,3 +595,19 @@ class CameraPermissionHelper { } } + +Future checkNetworkWifi() async { + final connectivityResult = await Connectivity().checkConnectivity(); + if (connectivityResult == ConnectivityResult.mobile) { + print("当前是移动网络(可能是 2G/3G/4G/5G)"); + } else if (connectivityResult == ConnectivityResult.wifi) { + return true; + print("当前是 WiFi"); + } else if (connectivityResult == ConnectivityResult.ethernet) { + print("当前是有线网络"); + } else if (connectivityResult == ConnectivityResult.none) { + print("当前无网络连接"); + } + return false; + +} \ No newline at end of file