diff --git a/marking_app/lib/pages/login/index.dart b/marking_app/lib/pages/login/index.dart index a1655f3..5225ea5 100644 --- a/marking_app/lib/pages/login/index.dart +++ b/marking_app/lib/pages/login/index.dart @@ -29,6 +29,7 @@ import 'package:marking_app/common/model/user/user_login.dart'; import 'package:marking_app/common/model/user/user_login_params.dart'; import 'package:marking_app/provider/user_provider.dart'; import 'package:marking_app/routes/RouterManager.dart'; +import 'package:marking_app/utils/sys_protocol.dart'; class TheLogin extends StatefulHookConsumerWidget { const TheLogin({Key? key}) : super(key: key); @@ -71,6 +72,7 @@ class _TheLoginState extends ConsumerState with CommonMixin { @override void initState() { + Future.delayed(Duration(seconds: 3), () => sysProtocol(context)); Future(() { // 延迟更新 Provider ref.read(userTokenProvider.notifier).clean(); // 进入登录页先清空信息 @@ -387,8 +389,7 @@ class _TheLoginState extends ConsumerState with CommonMixin { EasyLoading.show(status: 'loading...'); try { BaseStructureResult resultData = await client.toLogin(UserLoginParams(userName, userPwdMd5)); - UserLogin? userData = - resultData.code == 200 && resultData.data != null ? UserLogin.fromJson(resultData.data) : null; + UserLogin? userData = resultData.code == 200 && resultData.data != null ? UserLogin.fromJson(resultData.data) : null; if (resultData.code != 200 || userData?.accessToken == null || userData?.accessToken == '') { return toMsg(resultData.message ?? '登录失败,请重试'); } diff --git a/marking_app/lib/pages/mainPage.dart b/marking_app/lib/pages/mainPage.dart index 5b7521b..e20c314 100644 --- a/marking_app/lib/pages/mainPage.dart +++ b/marking_app/lib/pages/mainPage.dart @@ -27,6 +27,7 @@ import 'package:marking_app/pages/marking/index.dart'; import 'package:marking_app/provider/user_provider.dart'; import 'package:marking_app/utils/index.dart'; import 'package:marking_app/utils/request/rest_client.dart'; +import 'package:marking_app/utils/sys_protocol.dart'; import 'package:package_info/package_info.dart'; import 'homework_correction/job_home.dart'; @@ -69,6 +70,7 @@ class TheMainPageState extends ConsumerState with CommonMixin { void initState() { _pageController = PageController(initialPage: tabIndex); _otherFocusNode = FocusNode(); + Future.delayed(Duration(seconds: 1), () => sysProtocol(context)); // 由于本项目必须登录才能浏览,所以APP升级校验在登录后 _userListener = ref.read(userProvider.notifier).addListener((state) { if (state.id != '0' && state.id != '') { diff --git a/marking_app/lib/utils/fast_data.dart b/marking_app/lib/utils/fast_data.dart index e8d0e8d..93bb949 100644 --- a/marking_app/lib/utils/fast_data.dart +++ b/marking_app/lib/utils/fast_data.dart @@ -39,6 +39,8 @@ class FastData { static const String _MARKING_PREFERENCES_WORK = "APP:MARKING:PREFERENCES:WORK"; // 键盘引导页 ==》 作业 static const String _INPUT_KEYBOARD_GUIDE_PAGE_WORK = "APP:MARKING:GUIDE_PAGE:WORK"; + // 系统协议确认 + static const String _SYS_PROTOCOL = "APP:SYS:PROTOCOL"; static SharedPreferences? _prefs; @@ -268,4 +270,20 @@ class FastData { SharedPreferences thePrefs = await getSharedInstance(); thePrefs.remove(_MARKING_ZOOM_SCALE_AND_POSITION); } + +/* 阅卷 ==> 缩放组件历史位置 */ + Future setSysProtocol(bool val) async { + SharedPreferences thePrefs = await getSharedInstance(); + return await thePrefs.setBool(_SYS_PROTOCOL, val); + } + + Future getSysProtocol([SharedPreferences? thePrefs]) async { + if (thePrefs == null) thePrefs = await getSharedInstance(); + return thePrefs.getBool(_SYS_PROTOCOL); + } + + void cleanSysProtocol() async { + SharedPreferences thePrefs = await getSharedInstance(); + thePrefs.remove(_SYS_PROTOCOL); + } } diff --git a/marking_app/lib/utils/sys_protocol.dart b/marking_app/lib/utils/sys_protocol.dart new file mode 100644 index 0000000..50891c3 --- /dev/null +++ b/marking_app/lib/utils/sys_protocol.dart @@ -0,0 +1,138 @@ +import 'dart:io'; + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:marking_app/routes/RouterManager.dart'; +import 'package:marking_app/utils/const_text.dart'; + +import 'index.dart'; +import 'my_text.dart'; + +class Protocol extends Dialog { + final BuildContext context; + const Protocol(this.context); + + @override + Widget build(BuildContext context) { + return Center( + child: Container( + width: isPad() ? 200.w : 260.w, + height: 400.h, + padding: EdgeInsets.symmetric(vertical: 16.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12.r), + ), + child: Column( + children: [ + quickText('用户协议与隐私政策', size: 15.sp, color: Color.fromRGBO(37, 37, 37, 1), fontWeight: FontWeight.bold), + Expanded( + child: ListView( + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.fromLTRB(16.w, 14.h, 16.w, 10.h), + children: [ + Text.rich(TextSpan(children: [ + TextSpan( + text: '感谢您选择学而有道APP ! 我们非常重视您的个人信息和隐私保护。为了更好地保障您的个人权益,在您使用我们的产品前,请务必审慎阅读', + style: TextStyle(fontSize: 13.sp, color: Color.fromRGBO(51, 51, 51, 1)), + ), + TextSpan( + text: '《隐私政策》', + style: TextStyle(fontSize: 13.sp, color: Color.fromRGBO(233, 85, 119, 1)), + recognizer: TapGestureRecognizer() + ..onTap = () async { + RouterManager.router.navigateTo( + context, + '${RouterManager.agreementPath}?type=${AGREEMENT_KEY.PRIVACY_GREEMENT.name}', + transition: getTransition(), + ); + }, + ), + TextSpan( + text: '和', + style: TextStyle(fontSize: 13.sp, color: Color.fromRGBO(51, 51, 51, 1)), + ), + TextSpan( + text: '《用户协议》', + style: TextStyle(fontSize: 13.sp, color: Color.fromRGBO(233, 85, 119, 1)), + recognizer: TapGestureRecognizer() + ..onTap = () async { + RouterManager.router.navigateTo( + context, + '${RouterManager.agreementPath}?type=${AGREEMENT_KEY.USER_AGREEMENT.name}', + transition: getTransition(), + ); + }, + ), + TextSpan( + text: + '内的所有条款,尤其是:1.我们对您的个人信息的收集/保存/使用/对外提供/保护等规则条款,以及您的用户权利等条款;2.约定我们的限制责任、免责条款;3.其他以颜色或加粗进行标识的重要条款。如您对以上协议有任何疑问,可通过人工客服或发邮件至xrydyj@outlook.com与我们联系。您点击"同意并继续”的行为即表示您已阅读完毕并同意以上协议的全部内容。如您同意以上协议内容,请点击"同意并继续”,开始使用我们的产品和服务!', + style: TextStyle(fontSize: 13.sp, color: Color.fromRGBO(51, 51, 51, 1)), + ), + ])), + ], + ), + ), + Row( + children: [ + Expanded( + child: InkWell( + onTap: () { + exit(0); + }, + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.only(top: 15.h), + decoration: BoxDecoration( + border: Border( + top: BorderSide(width: 0.5.r, color: Color.fromRGBO(238, 238, 238, 1)), + right: BorderSide(width: 0.5.r, color: Color.fromRGBO(238, 238, 238, 1)), + ), + ), + child: quickText('不同意', size: 14.sp), + ), + ), + ), + Expanded( + child: InkWell( + onTap: () { + FastData.getInstance().setSysProtocol(true); + Navigator.of(context).pop(true); + }, + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.only(top: 15.h), + decoration: BoxDecoration( + border: Border( + top: BorderSide(width: 0.5.r, color: Color.fromRGBO(238, 238, 238, 1)), + ), + ), + child: quickText('同意并继续', color: Color.fromRGBO(206, 97, 126, 1), size: 14.sp), + ), + ), + ) + ], + ), + ], + ), + ), + ); + } +} + +/// 系统协议 +void sysProtocol(BuildContext context) async { + bool? _sysProtocol = await FastData.getInstance().getSysProtocol(); + if (_sysProtocol == null || !_sysProtocol) { + print('进来这里....'); + + showDialog( + context: context, + barrierDismissible: false, + builder: (ctx) { + return Protocol(ctx); + }, + ); + } +}