From fe7cb98cf91e6e53264a8e2998ff8a48d418f00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 7 Jun 2024 10:53:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E6=97=B6=E9=97=B4=E7=9A=843=E7=82=B9=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E7=BB=93=E6=9E=9C=20a=EF=BC=8C=E9=A2=86=E9=94=81?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB+=E5=8F=B7=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E8=8E=B7=E5=8F=96=E7=BD=91=E7=BB=9C=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=A4=B1=E8=B4=A5=EF=BC=8C=E4=B8=8D=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E4=B8=8B=E4=B8=80=E9=A1=B5=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E8=81=94=E7=BD=91=20b.=20=E5=BC=80=E9=94=81=E6=97=B6?= =?UTF-8?q?=EF=BC=9A=E6=9C=89=E7=BD=91=E7=BB=9C=E6=97=B6=E9=97=B4=E5=88=99?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=EF=BC=8C=E6=97=A0=E7=BD=91=E7=BB=9C=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E6=AD=A5=E6=97=B6=E9=97=B4=20c.=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=97=B6=E9=97=B4=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E6=9C=89=E7=BD=91=E6=89=8D=E5=90=8C=E6=AD=A5=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E7=A1=AE=E5=AE=9A=E5=92=8C=E9=80=9A=E9=80=9A?= =?UTF-8?q?=E9=94=81=E4=B8=8D=E4=B8=80=E8=87=B4=202=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=99=BB=E5=BD=95=E3=80=81=E6=B3=A8=E5=86=8C=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E9=80=89=E6=8B=A9=E8=B7=9F?= =?UTF-8?q?=E5=BD=93=E5=89=8Dip=E4=B8=8D=E6=98=AF=E7=94=A8=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=9B=BD=E5=AE=B6=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 8196 -> 8196 bytes images/.DS_Store | Bin 14340 -> 8196 bytes images/lan/lan_en.json | 8 +- images/lan/lan_keys.json | 8 +- images/lan/lan_zh.json | 9 +- .../starLock_forgetPassword_logic.dart | 35 +- .../starLock_forgetPassword_page.dart | 37 ++- .../starLock_forgetPassword_xhj_page.dart | 49 ++- lib/login/login/starLock_login_logic.dart | 13 +- lib/login/login/starLock_login_page.dart | 1 + lib/login/login/starLock_login_xhj_page.dart | 1 + .../entity/SendValidationCodeEntity.dart | 30 +- lib/login/register/entity/checkIP_entity.dart | 47 +++ .../register/starLock_register_logic.dart | 13 + .../register/starLock_register_page.dart | 1 + .../register/starLock_register_xhj_page.dart | 1 + .../checkingInDetail_entity.dart | 22 +- .../checkingInDetail_logic.dart | 4 - .../checkingInDetail_page.dart | 312 +++++++++--------- .../checkingInDetail_state.dart | 36 +- .../checkingInAddHolidays_logic.dart | 49 ++- .../checkingInAddHolidays_state.dart | 15 +- .../checkingInDeletHolidays_logic.dart | 6 +- .../checkingInDeletHolidays_page.dart | 13 +- .../checkingInDeletHolidays_state.dart | 4 +- .../checkingInSetHolidays_logic.dart | 6 +- .../checkingInSetHolidays_state.dart | 11 +- .../checkingInListDay_entity.dart | 32 +- .../checkingInListMonth_entity.dart | 26 +- .../checkingInListSeletMonth_page.dart | 98 ++++++ .../checkingInList/checkingInList_logic.dart | 52 ++- .../checkingInList/checkingInList_page.dart | 45 ++- .../checkingInList/checkingInList_state.dart | 32 +- .../checkingInSet/checkingInSet_entity.dart | 22 +- .../checkingInSet/checkingInSet_page.dart | 4 +- .../checkingInSetWorkTime_logic.dart | 10 +- .../checkingInSetWorkTime_page.dart | 39 +-- .../checkingInSetWorkTime_state.dart | 29 +- .../checkingInSetWorkdaySet_logic.dart | 36 +- .../checkingInSetWorkdaySet_page.dart | 47 +-- .../checkingInSetWorkdaySet_state.dart | 36 +- .../checkingInAddStaffSelectKey_entity.dart | 12 +- .../checkingInAddStaff_logic.dart | 1 + .../checkingInAddStaff_page.dart | 1 + .../checkingInStaffList_entity.dart | 24 +- .../checkingInStaffList_logic.dart | 15 +- .../checkingInStaffList_page.dart | 21 +- .../checkingInStaffList_state.dart | 12 +- .../checkingInStaffDetail_state.dart | 26 +- .../lockDetail/lockDetail_logic.dart | 15 +- .../lockDetail/lockDetail_state.dart | 4 +- .../uploadElectricQuantity_logic.dart | 42 +-- .../uploadElectricQuantity_page.dart | 2 +- .../uploadElectricQuantity_state.dart | 1 + .../lockSet/lockTime/lockTime_logic.dart | 26 +- .../lockSet/lockTime/lockTime_page.dart | 4 +- .../lockSet/lockTime/lockTime_state.dart | 2 + .../addLock/nearbyLock/nearbyLock_logic.dart | 48 +-- .../addLock/nearbyLock/nearbyLock_page.dart | 6 +- .../addLock/nearbyLock/nearbyLock_state.dart | 23 +- .../selectLockType/selectLockType_logic.dart | 2 +- .../lockGroupList/lockGroupList_page.dart | 2 +- lib/network/api.dart | 2 + lib/network/api_provider.dart | 10 +- lib/network/api_repository.dart | 11 +- lib/tools/showTFView.dart | 10 +- lib/tools/showTipView.dart | 18 +- 67 files changed, 881 insertions(+), 698 deletions(-) create mode 100644 lib/login/register/entity/checkIP_entity.dart create mode 100644 lib/main/lockDetail/checkingIn/checkingInList/checkingInListSeletMonth_page.dart diff --git a/.DS_Store b/.DS_Store index ed4e320f2ee064343447de46bd628e2ced192c0d..3035c4ed779c60f0963863631eba7089bc783d7d 100755 GIT binary patch delta 214 zcmZp1XmOa}&nUVvU^hRb=w=>)d=^PIhD?TBhD3&RhE#^)r1Ii|q@4UD1_p+0livsy zs)|)t8|WyQ8CurrC{$Y-0of+TX0^4P9HPql)AGL;)Mgqb(9OMGM5n8D5r0NG>07RUh%ljC`2ZBCMsVg%}a!3Y2i@*%1K literal 14340 zcmeHOON<;x8LnEd?OANcv-YlEfiPqh36#j$T|0;ffhU_qjujz09%F1d$uN)J*=BpX zNAuW?V;NaU2m}%jkrPr77Y-YFQ~&!pX9H6qm0nRbeR(zUMh{96*i6c?T!%%SuHm zRCU!w*`H`VSuuku_MgQ$uYA>V`g=fnM{TMvtMjS{+|HFCYBhtXiPjiO{Y6m3RFeZ@3ax@ybfT5zD?z$6D=Le)tTdxwab*HuFeamr|U zBL3DNk?}WB76nQVy$AT)F`0mN4$`;Ake+prM(SPs1&H5!sP_=vGc({JH!#FC#3+88 zH^|5q=nuxmI4#EL8&u{j+VR|Tat|||F|;!dny)&@TMR*E6LdE~@m4km)GJ7!d{*Qz zT~;Qc7nFZ~EW_Ycg%e$or>4 z-jch-On5s28ugvFl#NK4OT=d!Dg!*Vfx`^grm;yMHpOfm?L5fFrlmXBl3Lo}04S?S zA+D+mYQ_9r$U&qoNNS}A8iLlIneQ7pD3rZKkyb+)zlOPOgTAT!nUS+ZlXBjU`4@qr z9{5F@_6#S3n6KxNr|eDSC}G#L&j>lodF}wA1q}MyT-iD(2Mh(Fn-8Uw_G%S$R%)%N z+cVaozq*Ao?%$2p*W-L@sebhbgYW$PH=s9t+s=5~+mxt3BKTQQ6=6nO#(Fs?Y90B1 zQ*bZGLpU=i?IPZQ&+92~Y{rm(c6(>;hdz25R8C+@F8uBLTN~f7T-c*s%8#se4rdO1 zmzzfXK+e4E#zvzeUXlE@Nh3$dqTeB}p zbEUa@`OLk0FTK3-LgnJ>^8FVo_g-FI#{Gp)-oHOrT3mYZ)7R@;K{t%P$%$c`9dF0g zG5frGg@vc{_FLQWeDoiZ`TVt9PG&Usp(96+J$1Z1f8yl)!u;amsncf`&z^hwT)lj< z*=TKb`lR&LD2V!N!N|MQ>HF($FA#+qLD+Ha>-H}3Y(W+AOG zaF_d@7aF{)8yf>}cuU;hu9uGwTKy;pu0;cX=ttr0HwWPJm7&+Y5^h8oaT`3o+T*Li zO|L&dInn3V?MA=f2s_@|-M4~9(+jSKYte8Rb#M8tD72IxH?VlT*7pdxbm^gG<5KnY z(n3-dm-$;^kwXfqJab^-B!^Ox$5Ad|Bw2ra8xc$C- zCyi|M^RFdFw%fNGrN*__d&j6&mr2BK-|bpI45ARmgrL#Z!_>x|1()2}Zwpt<{-&Kn z_rc$enXWFudh`hQ zHbSRCF}fO|Hyu@-P62-rM##qFen!qx#?%dPj1h6pKAuj_!8j$HBi$wAX&I+xI83@Z z2TNukEEbmp#*J&BEt)0+p?>H{F?HO=b%HkgT}NJQODReu8I>hSbnfIlwV^M|@OJ=MRtTg(};J%ThL|PD%Y(fwC6-*-03>+gxi6e6&2~Hc>1E5*! zd?nVC3{);_`Y9nx`E3ntnt85FPSFw_1Q`pvn}jxW3qAq7&%vZcI+zu~vvjGaEr#aJ z>%e5Di+r?OwM?41B}wp&#eZT-eCkct%-{CVZm zPy-wcDXR@2*lcH>w7(*xEj_^oDBwJp`RU>0Q;wH1vX^+0q7D!?@(_%qC4$Ts*{$JS zbq)S9z~4ILy#uQ9WxF4u&FXc5KySjF$`-D9+DO?+MCqlt3ffstnZGqslxR{0iAFuf z_S#tRKdek2{tB8UJynWFsk+~^?YXAv7|H0U^q(mb^@P&MmI5tUVm*gm$v1l`7WJMM z+%pnpb}PxxyPhLMr;RPkk)#f$BV{2_zA=LF2GX-82$#VSOzwnguxp!HXJ|?*=em`t^OSgkYa}jL zdhR8O+b|wB6NeU^eyv)>|6?EX7V&?apfBQovq}}0C&7V(c97*GC_lIV_y13Vlwyp6 z0|f{EOB~R%>$UYY46gSffZy6xaDEAAa-gkgj*IgVARhQB-lvjwEYYSKmk(@dx}x56 lMfrq20<`}VK diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 447da036..3d951115 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -867,5 +867,11 @@ "自定义短信模版":"Custom SMS template", "自定义邮件模版":"Custom email template", "名称":"Name", - "星星锁": "Star lock" + "星星锁": "Star lock", + "无考勤记录": "No attendance record", + "大家干劲十足": "Everyone is full of energy", + "工作时长未出炉": "Working hours are not available", + "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续": "The selection of the country or region will affect data security. You have currently selected Albania. Please confirm before continuing", + "确认国家或地区": "Confirm country or region", + "我知道了": "I know", } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 1f83013b..a5dda05c 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -899,5 +899,11 @@ "自定义短信模版":"自定义短信模版", "自定义邮件模版":"自定义邮件模版", "名称":"名称", - "星星锁": "星星锁" + "星星锁": "星星锁", + "无考勤记录": "无考勤记录", + "大家干劲十足": "大家干劲十足", + "工作时长未出炉": "工作时长未出炉", + "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续": "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续", + "确认国家或地区": "确认国家或地区", + "我知道了": "我知道了" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 3c3bedf6..dc4826bb 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -867,5 +867,12 @@ "自定义短信模版":"自定义短信模版", "自定义邮件模版":"自定义邮件模版", "名称":"名称", - "星星锁": "星星锁" + "星星锁": "星星锁", + + "无考勤记录": "无考勤记录", + "大家干劲十足": "大家干劲十足", + "工作时长未出炉": "工作时长未出炉", + "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续": "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续", + "确认国家或地区": "确认国家或地区", + "我知道了": "我知道了" } diff --git a/lib/login/forgetPassword/starLock_forgetPassword_logic.dart b/lib/login/forgetPassword/starLock_forgetPassword_logic.dart index 18bd4673..a63fa172 100755 --- a/lib/login/forgetPassword/starLock_forgetPassword_logic.dart +++ b/lib/login/forgetPassword/starLock_forgetPassword_logic.dart @@ -3,16 +3,20 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_state.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; +import '../../tools/showTipView.dart'; +import '../register/entity/checkIP_entity.dart'; class StarLockForgetPasswordLogic extends BaseGetXController { final StarLockForgetPasswordState state = StarLockForgetPasswordState(); late Timer _timer; void _startTimer() { - _timer = Timer.periodic(1.seconds, (timer) { + _timer = Timer.periodic(1.seconds, (Timer timer) { if (state.currentSecond > 1) { state.currentSecond--; } else { @@ -28,22 +32,22 @@ class StarLockForgetPasswordLogic extends BaseGetXController { // _timer = null; } - void resetPassword() async { - var entity = await ApiRepository.to.resetPassword( + Future resetPassword() async { + final LoginEntity entity = await ApiRepository.to.resetPassword( state.countryCode.value, state.phoneStr.value, state.date.value, state.pwd.value, - "B748F838-94EE-4BDB-A0E6-7B2D16849792", + 'B748F838-94EE-4BDB-A0E6-7B2D16849792', state.verificationCode.value); if (entity.errorCode!.codeIsSuccessful) { - showToast("重置成功".tr); + showToast('重置成功'.tr); Get.back(); } } - void sendValidationCode() async { - var entity = await ApiRepository.to.sendValidationCodeUnLogin( + Future sendValidationCode() async { + final SendValidationCodeEntity entity = await ApiRepository.to.sendValidationCodeUnLogin( // state.countryCode.value, countryCode:state.countryCode.value, account:state.phoneStr.value, @@ -55,6 +59,17 @@ class StarLockForgetPasswordLogic extends BaseGetXController { } } + Future checkIpAction() async { + final CheckIPEntity entity = await ApiRepository.to.checkIpAction( + ip: '' + ); + if (entity.errorCode!.codeIsSuccessful) { + if(state.countryName.value == entity.data!.name){ + ShowTipView().showSureAlertDialog('国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr, tipTitle: '确认国家或地区'.tr, sureStr: '我知道了'.tr); + } + } + } + void checkNext(TextEditingController controller) { changeInput(controller); } @@ -62,10 +77,10 @@ class StarLockForgetPasswordLogic extends BaseGetXController { void changeInput(TextEditingController controller) { if (controller == state.phoneController) { state.phoneStr.value = controller.text; - if(state.phoneStr.value.contains("@")){ - state.codeType.value = "2"; + if(state.phoneStr.value.contains('@')){ + state.codeType.value = '2'; }else{ - state.codeType.value = "1"; + state.codeType.value = '1'; } state.phoneStrIsOK.value = state.phoneStr.value.isNotEmpty; } diff --git a/lib/login/forgetPassword/starLock_forgetPassword_page.dart b/lib/login/forgetPassword/starLock_forgetPassword_page.dart index f710d48e..3569619a 100755 --- a/lib/login/forgetPassword/starLock_forgetPassword_page.dart +++ b/lib/login/forgetPassword/starLock_forgetPassword_page.dart @@ -6,6 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_logic.dart'; +import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_state.dart'; import '../../appRouters.dart'; import '../../app_settings/app_colors.dart'; @@ -22,10 +23,9 @@ class StarLockForgetPasswordPage extends StatefulWidget { _StarLockForgetPasswordPageState(); } -class _StarLockForgetPasswordPageState - extends State { - final logic = Get.put(StarLockForgetPasswordLogic()); - final state = Get.find().state; +class _StarLockForgetPasswordPageState extends State { + final StarLockForgetPasswordLogic logic = Get.put(StarLockForgetPasswordLogic()); + final StarLockForgetPasswordState state = Get.find().state; @override Widget build(BuildContext context) { @@ -33,27 +33,28 @@ class _StarLockForgetPasswordPageState resizeToAvoidBottomInset: false, backgroundColor: const Color(0xFFFFFFFF), appBar: TitleAppBar( - barTitle: "忘记密码".tr, + barTitle: '忘记密码'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: ListView( padding: EdgeInsets.only(top: 40.h, left: 40.w, right: 40.w), - children: [ + children: [ GestureDetector( onTap: () async { - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; + logic.checkIpAction(); } // AppLog.log("路由返回值: $result, countryCode:${state.countryName.value} ,state.countryName.value:${state.countryName.value}"); }, child: SizedBox( height: 70.h, child: Row( - children: [ + children: [ SizedBox(width: 5.w), Expanded( child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr, @@ -62,7 +63,7 @@ class _StarLockForgetPasswordPageState SizedBox(width: 20.w), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Obx(() => Text( '${state.countryName} +${state.countryCode}', // state.isIphoneType.value @@ -103,7 +104,7 @@ class _StarLockForgetPasswordPageState ), hintText:TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, keyboardType: TextInputType.number, - inputFormatters: [ + inputFormatters: [ LengthLimitingTextInputFormatter(30), ]), SizedBox(height: 10.h), @@ -125,7 +126,7 @@ class _StarLockForgetPasswordPageState ), hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), SizedBox(height: 15.w), @@ -153,12 +154,12 @@ class _StarLockForgetPasswordPageState ), hintText: "${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), SizedBox(height: 10.h), Row( - children: [ + children: [ Expanded( child: LoginInput( controller: state.codeController, @@ -174,7 +175,7 @@ class _StarLockForgetPasswordPageState ), hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}", - inputFormatters: [ + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), ), @@ -185,11 +186,11 @@ class _StarLockForgetPasswordPageState onTap: (state.phoneStrIsOK.value && state.canResend.value) ? () async { // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.safetyVerificationPage, - arguments: { - "countryCode": state.countryCode.value, - "account": state.phoneStr.value + arguments: { + 'countryCode': state.countryCode.value, + 'account': state.phoneStr.value }); logic.state.xWidth.value = (result as Map)['xWidth']; diff --git a/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart b/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart index f8f569b0..0fe04748 100755 --- a/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart +++ b/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart @@ -1,4 +1,3 @@ -import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -7,6 +6,7 @@ import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_logic.dart'; +import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_state.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/tools/tf_loginInput.dart'; import 'package:star_lock/tools/titleAppBar.dart'; @@ -22,8 +22,8 @@ class StarLockForgetPasswordXHJPage extends StatefulWidget { class _StarLockForgetPasswordPageState extends State { - final logic = Get.put(StarLockForgetPasswordLogic()); - final state = Get.find().state; + final StarLockForgetPasswordLogic logic = Get.put(StarLockForgetPasswordLogic()); + final StarLockForgetPasswordState state = Get.find().state; @override Widget build(BuildContext context) { @@ -31,28 +31,29 @@ class _StarLockForgetPasswordPageState resizeToAvoidBottomInset: false, backgroundColor: const Color(0xFFFFFFFF), appBar: TitleAppBar( - barTitle: "忘记密码".tr, + barTitle: '忘记密码'.tr, haveBack: true, iconColor: AppColors.blackColor, titleColor: AppColors.blackColor, backgroundColor: Colors.white), body: ListView( padding: EdgeInsets.only(left: 40.w, right: 40.w), - children: [ + children: [ GestureDetector( onTap: () async { - var result = await Navigator.pushNamed( + Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; + logic.checkIpAction(); } }, child: SizedBox( height: 70.h, child: Row( - children: [ + children: [ SizedBox(width: 5.w), Text(TranslationLoader.lanKeys!.countryAndRegion!.tr, style: TextStyle( @@ -60,7 +61,7 @@ class _StarLockForgetPasswordPageState SizedBox(width: 60.w), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Obx(() => Text( '${state.countryName} +${state.countryCode}', textAlign: TextAlign.end, @@ -87,7 +88,7 @@ class _StarLockForgetPasswordPageState ), label: TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, keyboardType: TextInputType.number, - inputFormatters: [ + inputFormatters: [ LengthLimitingTextInputFormatter(30), ]), LoginInput( @@ -101,8 +102,8 @@ class _StarLockForgetPasswordPageState padding: EdgeInsets.only(top: 30.w, bottom: 20.w, left: 5.w), ), label: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), Text( @@ -121,12 +122,12 @@ class _StarLockForgetPasswordPageState padding: EdgeInsets.only(top: 30.w, bottom: 20.w, left: 5.w), ), label: - "${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), Row( - children: [ + children: [ Expanded( child: LoginInput( controller: state.codeController, @@ -135,22 +136,22 @@ class _StarLockForgetPasswordPageState }, leftWidget: SizedBox(), hintText: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), ), Obx(() => GestureDetector( onTap: (state.phoneStrIsOK.value && state.canResend.value) ? () async { - var result = await Navigator.pushNamed( + Object? result = await Navigator.pushNamed( context, Routers.safetyVerificationPage, - arguments: { - "countryCode": state.countryCode.value, - "account": state.phoneStr.value + arguments: { + 'countryCode': state.countryCode.value, + 'account': state.phoneStr.value }); logic.state.xWidth.value = - (result as Map)['xWidth']; + (result! as Map)['xWidth']; logic.sendValidationCode(); } : null, @@ -178,16 +179,14 @@ class _StarLockForgetPasswordPageState Obx(() { return SubmitBtn( btnName: - "${TranslationLoader.lanKeys!.reset!.tr}${TranslationLoader.lanKeys!.password!.tr}", + '${TranslationLoader.lanKeys!.reset!.tr}${TranslationLoader.lanKeys!.password!.tr}', // backgroundColorList: state.canSub.value ? [AppColors.mainColor] :[Colors.grey], fontSize: 30.sp, borderRadius: 20.w, padding: EdgeInsets.only(top: 25.w, bottom: 25.w), isDisabled: state.canSub.value, onClick: state.canSub.value - ? () { - logic.resetPassword(); - } + ? logic.resetPassword : null); }), ], diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index fd45814c..64b869e0 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -14,7 +14,9 @@ import 'package:star_lock/tools/xs_jPhush.dart'; import '../../mine/mine/starLockMine_logic.dart'; import '../../network/api_repository.dart'; import '../../tools/eventBusEventManage.dart'; +import '../../tools/showTipView.dart'; import '../../tools/storage.dart'; +import '../register/entity/checkIP_entity.dart'; import 'starLock_login_state.dart'; class StarLockLoginLogic extends BaseGetXController { @@ -58,7 +60,16 @@ class StarLockLoginLogic extends BaseGetXController { } } - + Future checkIpAction() async { + final CheckIPEntity entity = await ApiRepository.to.checkIpAction( + ip: '' + ); + if (entity.errorCode!.codeIsSuccessful) { + if(state.countryName.value == entity.data!.name){ + ShowTipView().showSureAlertDialog('国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr, tipTitle: '确认国家或地区'.tr, sureStr: '我知道了'.tr); + } + } + } void changeAgreeState() { _resetCanNext(); diff --git a/lib/login/login/starLock_login_page.dart b/lib/login/login/starLock_login_page.dart index ca2cc470..edf5acfd 100755 --- a/lib/login/login/starLock_login_page.dart +++ b/lib/login/login/starLock_login_page.dart @@ -101,6 +101,7 @@ class _StarLockLoginPageState extends State { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; + logic.checkIpAction(); } }, )), diff --git a/lib/login/login/starLock_login_xhj_page.dart b/lib/login/login/starLock_login_xhj_page.dart index 38fc886b..a6ce5e3f 100755 --- a/lib/login/login/starLock_login_xhj_page.dart +++ b/lib/login/login/starLock_login_xhj_page.dart @@ -80,6 +80,7 @@ class _StarLockLoginPageState extends State { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; + logic.checkIpAction(); } }, child: Container( diff --git a/lib/login/register/entity/SendValidationCodeEntity.dart b/lib/login/register/entity/SendValidationCodeEntity.dart index c93d258b..72bb6e14 100755 --- a/lib/login/register/entity/SendValidationCodeEntity.dart +++ b/lib/login/register/entity/SendValidationCodeEntity.dart @@ -1,4 +1,3 @@ -import 'Data.dart'; class SendValidationCodeEntity { SendValidationCodeEntity({ @@ -29,4 +28,33 @@ class SendValidationCodeEntity { return map; } +} + +class Data { + Data({ + this.originalImageBase64, + this.jigsawImageBase64, + this.secretKey, + this.token}); + + Data.fromJson(dynamic json) { + originalImageBase64 = json['originalImageBase64']; + jigsawImageBase64 = json['jigsawImageBase64']; + secretKey = json['secretKey']; + token = json['token']; + } + int? originalImageBase64; + String? jigsawImageBase64; + String? secretKey; + String? token; + + Map toJson() { + final map = {}; + map['originalImageBase64'] = originalImageBase64; + map['jigsawImageBase64'] = jigsawImageBase64; + map['secretKey'] = secretKey; + map['token'] = token; + return map; + } + } \ No newline at end of file diff --git a/lib/login/register/entity/checkIP_entity.dart b/lib/login/register/entity/checkIP_entity.dart new file mode 100644 index 00000000..374d4989 --- /dev/null +++ b/lib/login/register/entity/checkIP_entity.dart @@ -0,0 +1,47 @@ +class CheckIPEntity { + CheckIPEntity({this.errorCode, this.description, this.errorMsg, this.data}); + + CheckIPEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + + Data({this.ip, this.name, this.abbreviation}); + + Data.fromJson(Map json) { + ip = json['ip']; + name = json['name']; + abbreviation = json['abbreviation']; + } + String? ip; + String? name; + String? abbreviation; + + Map toJson() { + final Map data = {}; + data['ip'] = ip; + data['name'] = name; + data['abbreviation'] = abbreviation; + return data; + } +} diff --git a/lib/login/register/starLock_register_logic.dart b/lib/login/register/starLock_register_logic.dart index 53424f86..e19b5be7 100755 --- a/lib/login/register/starLock_register_logic.dart +++ b/lib/login/register/starLock_register_logic.dart @@ -15,6 +15,8 @@ import 'package:star_lock/tools/xs_jPhush.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; +import '../../tools/showTipView.dart'; +import 'entity/checkIP_entity.dart'; import 'starLock_register_state.dart'; class StarLockRegisterLogic extends BaseGetXController { @@ -77,6 +79,17 @@ class StarLockRegisterLogic extends BaseGetXController { } else {} } + Future checkIpAction() async { + final CheckIPEntity entity = await ApiRepository.to.checkIpAction( + ip: '' + ); + if (entity.errorCode!.codeIsSuccessful) { + if(state.countryName.value == entity.data!.name){ + ShowTipView().showSureAlertDialog('国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr, tipTitle: '确认国家或地区'.tr, sureStr: '我知道了'.tr); + } + } + } + void changeAgreeState() { _resetCanSub(); } diff --git a/lib/login/register/starLock_register_page.dart b/lib/login/register/starLock_register_page.dart index 334740fe..357095b1 100755 --- a/lib/login/register/starLock_register_page.dart +++ b/lib/login/register/starLock_register_page.dart @@ -148,6 +148,7 @@ class _StarLockRegisterPageState extends State { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; + logic.checkIpAction(); } AppLog.log( '路由返回值: $result, countryCode:${logic.state.countryCode}'); diff --git a/lib/login/register/starLock_register_xhj_page.dart b/lib/login/register/starLock_register_xhj_page.dart index ddace6a7..0185d9a3 100755 --- a/lib/login/register/starLock_register_xhj_page.dart +++ b/lib/login/register/starLock_register_xhj_page.dart @@ -104,6 +104,7 @@ class _StarLockRegisterPageState extends State { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; + logic.checkIpAction(); } Get.log("路由返回值: $result, countryCode:${logic.state.countryCode}"); }, diff --git a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart index 51e47ff1..dbc053d1 100755 --- a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart @@ -1,8 +1,4 @@ class CheckingInDetailEntity { - int? errorCode; - String? description; - String? errorMsg; - Data? data; CheckingInDetailEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -13,6 +9,10 @@ class CheckingInDetailEntity { errorMsg = json['errorMsg']; data = json['data'] != null ? Data.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + Data? data; Map toJson() { final Map data = {}; @@ -27,10 +27,6 @@ class CheckingInDetailEntity { } class Data { - int? noPunchTimes; - int? lateTimes; - int? earlyTimes; - List? monthList; Data({this.noPunchTimes, this.lateTimes, this.earlyTimes, this.monthList}); @@ -45,6 +41,10 @@ class Data { }); } } + int? noPunchTimes; + int? lateTimes; + int? earlyTimes; + List? monthList; Map toJson() { final Map data = {}; @@ -59,9 +59,6 @@ class Data { } class MonthList { - int? openingTimeStart; - int? openingTimeEnd; - int? colorType; MonthList({this.openingTimeStart, this.openingTimeEnd, this.colorType}); @@ -70,6 +67,9 @@ class MonthList { openingTimeEnd = json['openingTimeEnd']; colorType = json['colorType']; } + int? openingTimeStart; + int? openingTimeEnd; + int? colorType; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart index 2ebcc0c6..346d6767 100755 --- a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_logic.dart @@ -1,5 +1,4 @@ - import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; @@ -28,7 +27,6 @@ class CheckingInDetailLogic extends BaseGetXController{ @override void onReady() { - // TODO: implement onReady super.onReady(); // getCheckInDetailData(); @@ -36,14 +34,12 @@ class CheckingInDetailLogic extends BaseGetXController{ @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose } diff --git a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart index accf916e..a7f5fc6f 100755 --- a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; @@ -15,19 +16,17 @@ class CheckingInDetailPage extends StatefulWidget { } class _CheckingInDetailPageState extends State { - - final logic = Get.put(CheckingInDetailLogic()); - final state = Get.find().state; + final CheckingInDetailLogic logic = Get.put(CheckingInDetailLogic()); + final CheckingInDetailState state = Get.find().state; int _year = DateTime.now().year; int _month = DateTime.now().month; int _day = DateTime.now().day; - final List _datas = []; - final List _listDatas = []; + final List _datas = []; + final List _listDatas = []; @override void initState() { - // TODO: implement initState super.initState(); //设置默认当前月日期 @@ -35,7 +34,7 @@ class _CheckingInDetailPageState extends State { logic.getCheckInDetailData((){ //设置模拟数据,日历月事件,可根据接口返回的结果 - _loadAttendanceMonthRecord("$_year-$_month"); + _loadAttendanceMonthRecord('$_year-$_month'); }); //设置模拟数据,日历月事件,可根据接口返回的结果 @@ -47,9 +46,9 @@ class _CheckingInDetailPageState extends State { //加载月历事件,请求接口 _loadAttendanceMonthRecord(String dateTime) async { // 显示的上个月的天数 - var placeholderDays = _getPlaceholderDays(year: _year, month: _month); + final int placeholderDays = _getPlaceholderDays(year: _year, month: _month); // 当月多少天 - var currentMonthDays = _getCurrentMonthDays(year: _year, month: _month); + final int currentMonthDays = _getCurrentMonthDays(year: _year, month: _month); setState(() { // 因为_datas这个月上个月都包含的都有 遍历把本月的赋值 @@ -68,7 +67,7 @@ class _CheckingInDetailPageState extends State { state.checkDate.value = DateTime.parse(dateTime).millisecondsSinceEpoch; logic.getCheckInDetailData((){ //设置模拟数据,日历月事件,可根据接口返回的结果 - _loadAttendanceMonthRecord("$_year-$_month"); + _loadAttendanceMonthRecord('$_year-$_month'); }); } @@ -81,7 +80,7 @@ class _CheckingInDetailPageState extends State { backgroundColor: AppColors.mainColor), body: SingleChildScrollView( child: Column( - children: [ + children: [ Container( // margin: EdgeInsets.all(20.sp), decoration: BoxDecoration( @@ -91,7 +90,7 @@ class _CheckingInDetailPageState extends State { //设置四周边框 ), child: Column( - children: [ + children: [ _yearHeader(), SizedBox(height: 10.h), _weekHeader(), @@ -114,26 +113,17 @@ class _CheckingInDetailPageState extends State { margin: const EdgeInsets.only(top: 10), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ GestureDetector( - onTap: () { - _lastMonth(); - }, - child: Container( - // margin: EdgeInsets.only(left: 20.w), - child: Image(width: 50.w, height: 30.w, image: const AssetImage("images/icon_left_black.png"),), - ), + onTap: _lastMonth, + child: Image(width: 50.w, height: 30.w, image: const AssetImage('images/icon_left_black.png'),), ), SizedBox(width: 60.w,), - Text("$_year-$_month", style: TextStyle(fontSize: 28.sp, color: Colors.black, fontWeight: FontWeight.w500)), + Text('$_year-$_month', style: TextStyle(fontSize: 28.sp, color: Colors.black, fontWeight: FontWeight.w500)), SizedBox(width: 60.w), GestureDetector( - onTap: () { - _nextMonth(); - }, - child: Container( - child: Image(width: 50.w, height: 30.w, image: const AssetImage("images/icon_right_black.png")), - ), + onTap: _nextMonth, + child: Image(width: 50.w, height: 30.w, image: const AssetImage('images/icon_right_black.png')), ), ], ), @@ -142,7 +132,7 @@ class _CheckingInDetailPageState extends State { //中部周 Widget _weekHeader() { - var array = [ + final List array = [ TranslationLoader.lanKeys!.mondayShort!.tr, TranslationLoader.lanKeys!.tuesdayShort!.tr, TranslationLoader.lanKeys!.wednesdayShort!.tr, @@ -151,7 +141,7 @@ class _CheckingInDetailPageState extends State { TranslationLoader.lanKeys!.saturdayShort!.tr, TranslationLoader.lanKeys!.sundayShort!.tr ]; - return Container( + return SizedBox( height: 50.h, child: GridView.builder( padding: const EdgeInsets.only(left: 10, right: 10), @@ -167,7 +157,7 @@ class _CheckingInDetailPageState extends State { // crossAxisSpacing: ScreenUtil().setWidth(15), //子组件宽高长度比例 childAspectRatio: 2), - itemBuilder: (context, index) { + itemBuilder: (BuildContext context, int index) { return Container( alignment: Alignment.center, child: Text( @@ -186,122 +176,118 @@ class _CheckingInDetailPageState extends State { //底部日 Widget _everyDay() { - return Container( - child: GridView.builder( - padding: EdgeInsets.only(left: 10.sp, top: 10.sp, right: 10.sp), - itemCount: _getRowsForMonthYear(year: _year, month: _month) * 7, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - //横轴元素个数 - crossAxisCount: 7, - // //纵轴间距 - // mainAxisSpacing: ScreenUtil().setHeight(10), - // // 横轴间距 - // crossAxisSpacing: ScreenUtil().setWidth(10), - //子组件宽高长度比例 - childAspectRatio: 1), - itemBuilder: (context, index) { - Color backColor = Colors.white; - // Color textColor = const Color(0xFFFFFFFF); - if(_datas[index].workType == "1"){ - // 迟到 - backColor = const Color(0xFFE83523); - }else if( _datas[index].workType == "2"){ - // 早退 - backColor = const Color(0xFFEDB459); - }else if( _datas[index].workType == "3"){ - // 未打卡 - backColor = const Color(0xFF666666); - } - return GestureDetector( - onTap: () { - // setState(() { - // if (_datas[index].month == _month) { - // //判断点击的是否是当月日期,只对当前月点击的日期做处理 - // for (int i = 0; i < _datas.length; i++) { - // if (i == index) { - // //切换至选中的日期 - // _day = _datas[i].day!; - // _datas[i].isSelect = true; - // - // //加载选中的日期事件 - // _loadAttendanceDayRecord( - // "${_datas[i].year}-${_datas[i].month}-${_datas[i].day}"); - // } else { - // _datas[i].isSelect = false; - // } - // } - // } else { - // //不是当月的不做处理 - // // _datas[index].is_select=false; - // } - // }); - }, - child: Container( - child: Column( - children: [ - Container( - width: 40.w, - height: 40.w, - //设置底部背景 - decoration: BoxDecoration( - color: backColor, - shape: BoxShape.circle, - ), - child: Center( - child: Text( - //不是当前月不显示值 - _datas[index].month == _month - ? _datas[index].day.toString() - : "", - textAlign: TextAlign.center, - //设置选中字体颜色 休息的颜色都是黑色 其余的都是白色因为有背景色 - style: (int.parse(_datas[index].workType!) > 0) - ? TextStyle( - fontSize: 24.sp, color: const Color(0xFFFFFFFF)) - : TextStyle( - fontSize: 24.sp, - color: Colors.black), - ), - ), + return GridView.builder( + padding: EdgeInsets.only(left: 10.sp, top: 10.sp, right: 10.sp), + itemCount: _getRowsForMonthYear(year: _year, month: _month) * 7, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + //横轴元素个数 + crossAxisCount: 7, + // //纵轴间距 + // mainAxisSpacing: ScreenUtil().setHeight(10), + // // 横轴间距 + // crossAxisSpacing: ScreenUtil().setWidth(10), + //子组件宽高长度比例 + childAspectRatio: 1), + itemBuilder: (BuildContext context, int index) { + Color backColor = Colors.white; + // Color textColor = const Color(0xFFFFFFFF); + if(_datas[index].workType == '1'){ + // 迟到 + backColor = const Color(0xFFE83523); + }else if( _datas[index].workType == '2'){ + // 早退 + backColor = const Color(0xFFEDB459); + }else if( _datas[index].workType == '3'){ + // 未打卡 + backColor = const Color(0xFF666666); + } + return GestureDetector( + onTap: () { + // setState(() { + // if (_datas[index].month == _month) { + // //判断点击的是否是当月日期,只对当前月点击的日期做处理 + // for (int i = 0; i < _datas.length; i++) { + // if (i == index) { + // //切换至选中的日期 + // _day = _datas[i].day!; + // _datas[i].isSelect = true; + // + // //加载选中的日期事件 + // _loadAttendanceDayRecord( + // "${_datas[i].year}-${_datas[i].month}-${_datas[i].day}"); + // } else { + // _datas[i].isSelect = false; + // } + // } + // } else { + // //不是当月的不做处理 + // // _datas[index].is_select=false; + // } + // }); + }, + child: Column( + children: [ + Container( + width: 40.w, + height: 40.w, + //设置底部背景 + decoration: BoxDecoration( + color: backColor, + shape: BoxShape.circle, + ), + child: Center( + child: Text( + //不是当前月不显示值 + _datas[index].month == _month + ? _datas[index].day.toString() + : '', + textAlign: TextAlign.center, + //设置选中字体颜色 休息的颜色都是黑色 其余的都是白色因为有背景色 + style: (int.parse(_datas[index].workType!) > 0) + ? TextStyle( + fontSize: 24.sp, color: const Color(0xFFFFFFFF)) + : TextStyle( + fontSize: 24.sp, + color: Colors.black), ), - const SizedBox(height: 5), - //设置底部小圆点,非当前月的不显示,设置为透明,其余的根据状态判断显示 - // _datas[index].month == _month && - // _datas[index].workType != "" && - // _datas[index].workType != "0" - // ? Container( - // height: 6.0, - // width: 6.0, - // decoration: BoxDecoration( - // shape: BoxShape.circle, - // color: _datas[index].workType == "1" - // ? const Color(0xFFF48835) - // : const Color(0xFF2C91F6)), - // ) - // : Container(), - ], + ), ), - ), - ); - }, - ), + const SizedBox(height: 5), + //设置底部小圆点,非当前月的不显示,设置为透明,其余的根据状态判断显示 + // _datas[index].month == _month && + // _datas[index].workType != "" && + // _datas[index].workType != "0" + // ? Container( + // height: 6.0, + // width: 6.0, + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // color: _datas[index].workType == "1" + // ? const Color(0xFFF48835) + // : const Color(0xFF2C91F6)), + // ) + // : Container(), + ], + ), + ); + }, ); } Widget _bottomStatisticsWidget() { return Column( - children: [ + children: [ Row( - children: [ + children: [ Container( width: 1.sw, // height: 40.h, padding: EdgeInsets.only(left: 50.w, top: 5.h, bottom: 5.h), color: Colors.grey, child: Text( - "月统计".tr, + '月统计'.tr, style: TextStyle( color: Colors.white, fontSize: 26.sp, @@ -310,9 +296,9 @@ class _CheckingInDetailPageState extends State { ), ], ), - _bottomStatisticsItemWidget(const Color(0xFFE83523), "迟到".tr, state.lateTimes.value), - _bottomStatisticsItemWidget(const Color(0xFFEDB459), "早退".tr, state.earlyTimes.value), - _bottomStatisticsItemWidget(const Color(0xFF666666), "未打卡".tr, state.noPunchTimes.value), + _bottomStatisticsItemWidget(const Color(0xFFE83523), '迟到'.tr, state.lateTimes.value), + _bottomStatisticsItemWidget(const Color(0xFFEDB459), '早退'.tr, state.earlyTimes.value), + _bottomStatisticsItemWidget(const Color(0xFF666666), '未打卡'.tr, state.noPunchTimes.value), ], ); } @@ -323,13 +309,13 @@ class _CheckingInDetailPageState extends State { String rightTitle, ) { return Column( - children: [ + children: [ Container( // height: 70.h, padding: EdgeInsets.only(left: 20.w, right: 10.w, top: 20.w, bottom: 20.w), child: Row( - children: [ + children: [ SizedBox(width: 20.w), Container( width: 30.w, @@ -363,13 +349,13 @@ class _CheckingInDetailPageState extends State { // 获取行数 int _getRowsForMonthYear({int? year, int? month}) { // 当前月天数 - var currentMonthDays = _getCurrentMonthDays(year: year, month: month); + final int currentMonthDays = _getCurrentMonthDays(year: year, month: month); // 这个月1号前面有几天 - var placeholderDays = _getPlaceholderDays(year: year, month: month); + final int placeholderDays = _getPlaceholderDays(year: year, month: month); int rows = (currentMonthDays + placeholderDays) ~/ 7; - int remainder = (currentMonthDays + placeholderDays) % 7; + final int remainder = (currentMonthDays + placeholderDays) % 7; if (remainder > 0) { rows = rows + 1; } @@ -406,61 +392,61 @@ class _CheckingInDetailPageState extends State { /// 获取展示信息 _setDatas({int? year, int? month}) { /// 上个月占位 - var lastYear = year; - var lastMonth = month! - 1; + int? lastYear = year; + int lastMonth = month! - 1; if (month == 1) { lastYear = (year! - 1)!; lastMonth = 12; } - var placeholderDays = _getPlaceholderDays(year: year, month: month); - var lastMonthDays = _getCurrentMonthDays(year: lastYear, month: lastMonth); - var firstDay = lastMonthDays - placeholderDays; - for (var i = 0; i < placeholderDays; i++) { + final int placeholderDays = _getPlaceholderDays(year: year, month: month); + final int lastMonthDays = _getCurrentMonthDays(year: lastYear, month: lastMonth); + final int firstDay = lastMonthDays - placeholderDays; + for (int i = 0; i < placeholderDays; i++) { _datas.add(CalendarModel( year: lastYear, month: lastMonth, day: firstDay + i + 1, isSelect: false, - workType: "0")); + workType: '0')); } /// 本月显示 - var currentMonthDays = _getCurrentMonthDays(year: year, month: month); - for (var i = 0; i < currentMonthDays; i++) { + final int currentMonthDays = _getCurrentMonthDays(year: year, month: month); + for (int i = 0; i < currentMonthDays; i++) { if (i == _day - 1) { _datas.add(CalendarModel( year: year, month: month, day: i + 1, isSelect: true, - workType: "0")); + workType: '0')); } else { _datas.add(CalendarModel( year: year, month: month, day: i + 1, isSelect: false, - workType: "0")); + workType: '0')); } } /// 下个月占位 - var nextYear = year; - var nextMonth = month + 1; + int? nextYear = year; + int nextMonth = month + 1; if (month == 12) { - nextYear = (year! + 1)!; + nextYear = year! + 1; nextMonth = 1; } - var nextPlaceholderDays = + final int nextPlaceholderDays = _getPlaceholderDays(year: nextYear, month: nextMonth); - for (var i = 0; i < 7 - nextPlaceholderDays; i++) { + for (int i = 0; i < 7 - nextPlaceholderDays; i++) { _datas.add(CalendarModel( year: nextYear, month: nextMonth, day: i + 1, isSelect: false, - workType: "0")); + workType: '0')); } } @@ -519,7 +505,7 @@ class _CheckingInDetailPageState extends State { _datas.clear(); _setDatas(year: _year, month: _month); //更新月历事件 - _loadAttendanceMonthRecord("$_year-$_month"); + _loadAttendanceMonthRecord('$_year-$_month'); //更新日事件 // _loadAttendanceDayRecord("$_year-$_month-$_day"); _loadAttendanceDayRecord("$_year-${_month.toString().padLeft(2,'0')}-${_day.toString().padLeft(2,'0')}"); @@ -529,12 +515,12 @@ class _CheckingInDetailPageState extends State { //日历bean class CalendarModel { - int? year; - int? month; - int? day; - String? workType = ""; //日期事件,0休息,1迟到,2早退,3未打卡 - bool? isSelect = false; CalendarModel( {this.year, this.month, this.day, this.isSelect, this.workType}); + int? year; + int? month; + int? day; + String? workType = ''; //日期事件,0休息,1迟到,2早退,3未打卡 + bool? isSelect = false; } diff --git a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart index 7577b523..220a9c99 100755 --- a/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_state.dart @@ -4,29 +4,29 @@ import '../../../lockMian/entity/lockListInfo_entity.dart'; import 'checkingInDetail_entity.dart'; class CheckingInDetailState{ - - // final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; - final staffId = 0.obs; - final staffName = "".obs; - - final checkDate = DateTime.now().millisecondsSinceEpoch.obs; - - var lateTimes = "".obs;// 迟到 - var earlyTimes = "".obs;// 早退 - var noPunchTimes = "".obs;// 未打车 - final monthListData = [].obs; CheckingInDetailState() { Map map = Get.arguments; - if(companyId.value.isEmpty && map["companyId"] != null){ - companyId.value = map["companyId"]; + if(companyId.value.isEmpty && map['companyId'] != null){ + companyId.value = map['companyId']; } - if(map["staffId"] != null){ - staffId.value = map["staffId"]; + if(map['staffId'] != null){ + staffId.value = map['staffId']; } - if(staffName.value.isEmpty && map["staffName"] != null){ - staffName.value = map["staffName"]; + if(staffName.value.isEmpty && map['staffName'] != null){ + staffName.value = map['staffName']; } } + // final getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + final RxInt staffId = 0.obs; + final RxString staffName = ''.obs; + + final RxInt checkDate = DateTime.now().millisecondsSinceEpoch.obs; + + RxString lateTimes = ''.obs;// 迟到 + RxString earlyTimes = ''.obs;// 早退 + RxString noPunchTimes = ''.obs;// 未打车 + final RxList monthListData = [].obs; + } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart index 3f17db49..7216cf81 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_logic.dart @@ -1,5 +1,6 @@ import 'package:get/get.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../../network/api_repository.dart'; import 'checkingInAddHolidays_state.dart'; @@ -8,43 +9,41 @@ class CheckingInAddHolidaysLogic extends BaseGetXController{ CheckingInAddHolidaysState state = CheckingInAddHolidaysState(); // 添加假期 - void editStaffLoadData() async{ + Future editStaffLoadData() async{ if(state.staffNameController.text.isEmpty){ - showToast("请输入姓名"); + showToast('请输入姓名'); return; } - var entity = await ApiRepository.to.addHolidaysData( + LoginEntity entity = await ApiRepository.to.addHolidaysData( companyId: state.companyId.value, - fillClassDate: state.makeUpWorkDate.value.isNotEmpty ? DateTime.parse(state.makeUpWorkDate.value).millisecondsSinceEpoch.toString() : "", + fillClassDate: state.makeUpWorkDate.value.isNotEmpty ? DateTime.parse(state.makeUpWorkDate.value).millisecondsSinceEpoch.toString() : '', vacationEndDate: DateTime.parse(state.endDate.value).millisecondsSinceEpoch.toString(), vacationName: state.staffNameController.text, vacationStartDate: DateTime.parse(state.beginDate.value).millisecondsSinceEpoch.toString() ); if(entity.errorCode!.codeIsSuccessful){ - showToast("添加成功"); - Get.back(result: "addScuess"); + showToast('添加成功'); + Get.back(result: 'addScuess'); } } - @override - void onReady() { - // TODO: implement onReady - super.onReady(); - - } - - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - - } - - @override - void onClose() { - // TODO: implement onClose - - } + // @override + // void onReady() { + // super.onReady(); + // + // } + // + // @override + // void onInit() { + // super.onInit(); + // + // } + // + // @override + // void onClose() { + // super.onInit(); + // + // } } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart index d9fbfbe9..277e9dc7 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart @@ -1,19 +1,16 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; class CheckingInAddHolidaysState{ - final TextEditingController staffNameController = TextEditingController(); - - final companyId = "".obs; - final beginDate = "".obs; - final endDate = "".obs; - final makeUpWorkDate = "".obs; - CheckingInAddHolidaysState() { Map map = Get.arguments; - companyId.value = map["companyId"]; + companyId.value = map['companyId']; } + final TextEditingController staffNameController = TextEditingController(); + final RxString companyId = ''.obs; + final RxString beginDate = ''.obs; + final RxString endDate = ''.obs; + final RxString makeUpWorkDate = ''.obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart index de898e9d..cff44450 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_logic.dart @@ -8,13 +8,13 @@ class CheckingInDeletHolidaysLogic extends BaseGetXController{ CheckingInDeletHolidaysState state = CheckingInDeletHolidaysState(); // 删除假期 - void deletStaffLoadData() async{ + Future deletStaffLoadData() async{ var entity = await ApiRepository.to.deletHolidaysData( vacationId: state.listItem.value.vacationId.toString() ); if(entity.errorCode!.codeIsSuccessful){ - showToast("删除成功"); - Get.back(result: "deletScuess"); + showToast('删除成功'); + Get.back(result: 'deletScuess'); } } diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart index 6fad2d16..9f57c36c 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; @@ -18,8 +19,8 @@ class CheckingInDeletHolidaysPage extends StatefulWidget { } class _CheckingInDeletHolidaysPageState extends State { - final logic = Get.put(CheckingInDeletHolidaysLogic()); - final state = Get.find().state; + final CheckingInDeletHolidaysLogic logic = Get.put(CheckingInDeletHolidaysLogic()); + final CheckingInDeletHolidaysState state = Get.find().state; @override Widget build(BuildContext context) { @@ -29,15 +30,13 @@ class _CheckingInDeletHolidaysPageState extends State[ TextButton( child: Text( TranslationLoader.lanKeys!.delete!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), - onPressed: () { - logic.deletStaffLoadData(); - }, + onPressed: logic.deletStaffLoadData, ), // GestureDetector( // onTap: () async { @@ -53,7 +52,7 @@ class _CheckingInDeletHolidaysPageState extends State Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, rightTitle: state.listItem.value.vacationName, diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart index d380556c..f15825c3 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_state.dart @@ -3,10 +3,10 @@ import 'package:get/get.dart'; import '../checkingInSetHolidays/checkingInSetHolidays_entity.dart'; class CheckingInDeletHolidaysState{ - final listItem = ListItem().obs; CheckingInDeletHolidaysState() { Map map = Get.arguments; - listItem.value = map["listItem"]; + listItem.value = map['listItem']; } + final Rx listItem = ListItem().obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart index 70fc8e32..d5142cb3 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_logic.dart @@ -9,7 +9,7 @@ class CheckingInSetHolidaysLogic extends BaseGetXController{ CheckingInSetHolidaysState state = CheckingInSetHolidaysState(); // 获取员工列表 - void editStaffLoadData() async{ + Future editStaffLoadData() async{ var entity = await ApiRepository.to.holidaysListData( companyId: state.companyId.value, vacationYear: state.selectYear.value.toString(), @@ -21,7 +21,6 @@ class CheckingInSetHolidaysLogic extends BaseGetXController{ @override void onReady() { - // TODO: implement onReady super.onReady(); editStaffLoadData(); @@ -29,14 +28,13 @@ class CheckingInSetHolidaysLogic extends BaseGetXController{ @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose + super.onInit(); } diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart index 184158f7..b94652d9 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart @@ -1,18 +1,17 @@ - import 'package:get/get.dart'; import 'checkingInSetHolidays_entity.dart'; class CheckingInSetHolidaysState{ - final companyId = "".obs; - final mouth = "".obs; - final selectYear = DateTime.now().year.obs; - final holidaysListData = [].obs; CheckingInSetHolidaysState() { Map map = Get.arguments; - companyId.value = map["companyId"]; + companyId.value = map['companyId']; } + final RxString companyId = ''.obs; + final RxString mouth = ''.obs; + final RxInt selectYear = DateTime.now().year.obs; + final RxList holidaysListData = [].obs; } diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart index 9bfbaaaa..0673a6c6 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart @@ -1,8 +1,4 @@ class CheckingInListDayEntity { - int? errorCode; - String? description; - String? errorMsg; - Data? data; CheckingInListDayEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -13,6 +9,10 @@ class CheckingInListDayEntity { errorMsg = json['errorMsg']; data = json['data'] != null ? Data.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + Data? data; Map toJson() { final Map data = {}; @@ -27,10 +27,6 @@ class CheckingInListDayEntity { } class Data { - int? noPunchTimes; - int? lateTimes; - int? earlyTimes; - List? attendanceRecordList; Data( {this.noPunchTimes, @@ -49,6 +45,10 @@ class Data { }); } } + int? noPunchTimes; + int? lateTimes; + int? earlyTimes; + List? attendanceRecordList; Map toJson() { final Map data = {}; @@ -64,14 +64,6 @@ class Data { } class AttendanceRecordDayList { - String? headurl; - int? isSelf; - String? staffName; - int? staffId; - int? attendanceType; - int? openingTimeEnd; - int? openingTimeStart; - int? colorType; AttendanceRecordDayList( {this.headurl, @@ -93,6 +85,14 @@ class AttendanceRecordDayList { openingTimeStart = json['openingTimeStart']; colorType = json['colorType']; } + String? headurl; + int? isSelf; + String? staffName; + int? staffId; + int? attendanceType; + int? openingTimeEnd; + int? openingTimeStart; + int? colorType; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart index ec6fc9ae..c44842f0 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart @@ -1,8 +1,4 @@ class CheckingInListMonthEntity { - int? errorCode; - String? description; - String? errorMsg; - List? data; CheckingInListMonthEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -18,6 +14,10 @@ class CheckingInListMonthEntity { }); } } + int? errorCode; + String? description; + String? errorMsg; + List? data; Map toJson() { final Map data = {}; @@ -32,15 +32,6 @@ class CheckingInListMonthEntity { } class AttendanceRecordMonthList { - String? headurl; - int? isSelf; - String? staffName; - int? staffId; - int? attendanceType; - int? countryCode; - int? openingTimeStart; - String? attendanceWay; - int? avgTime; AttendanceRecordMonthList( {this.headurl, @@ -64,6 +55,15 @@ class AttendanceRecordMonthList { attendanceWay = json['attendanceWay']; avgTime = json['avgTime']; } + String? headurl; + int? isSelf; + String? staffName; + int? staffId; + int? attendanceType; + int? countryCode; + int? openingTimeStart; + String? attendanceWay; + int? avgTime; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInListSeletMonth_page.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInListSeletMonth_page.dart new file mode 100644 index 00000000..7e584566 --- /dev/null +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInListSeletMonth_page.dart @@ -0,0 +1,98 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +class CheckingInListSeletMonthPage extends StatefulWidget { + const CheckingInListSeletMonthPage({Key? key}) : super(key: key); + + @override + State createState() => _CheckingInListSeletMonthPageState(); +} + +class _CheckingInListSeletMonthPageState extends State { + var _selectMonth = 1; + + @override + Widget build(BuildContext context) { + return Dialog( + // insetPadding: EdgeInsets.all(10), //距离 + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.w))), //形状 + backgroundColor: Colors.white, + clipBehavior: Clip.antiAlias, //强制裁剪 + elevation: 10, + child: SizedBox( + //需要在内部限制下高度和宽度才能更好的显示 + height: 270.h, + width: 1.sw - 20.w, + child: Column( + children: [ + SizedBox(height: 10.h), + SizedBox( + height: 80.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap:(){ + + }, + child: Image(width: 50.w, height: 40.w, image: const AssetImage('images/icon_left_black.png'),), + ), + SizedBox(width: 50.w,), + Text('2024', style: TextStyle(fontSize: 30.sp, color: Colors.black, fontWeight: FontWeight.w500)), + SizedBox(width: 50.w), + GestureDetector( + onTap: (){ + + }, + child: Image(width: 50.w, height: 40.w, image: const AssetImage('images/icon_right_black.png')), + ), + ] + ), + ), + SizedBox(height: 10.h), + Container( + // padding: EdgeInsets.only(left: 20.w, right: 20.w), + child: Expanded( + child: Padding( + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 6, + // crossAxisSpacing: 5.w, + // mainAxisSpacing: 5.h, + // childAspectRatio: 1.0, + ), + itemCount: 12, + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: (){ + setState(() { + Get.back(); + _selectMonth = index + 1; + }); + }, + child: Container( + width: 60.w, + height: 60.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: index+1 == _selectMonth ? Colors.blue : null, + // color: Colors.blue, + borderRadius: BorderRadius.circular(40.w), + ), + child: Text('${index + 1}月', style: TextStyle(fontSize: 24.sp, color: index+1 == _selectMonth ? Colors.white : Colors.black)), + ), + ); + }, + ), + ), + ),), + ], + ) + ), + ); + } + +} diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart index 116e84cf..b2b8a1a4 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart @@ -1,20 +1,23 @@ - import 'dart:async'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; + import '../../../../network/api_repository.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; + import 'checkingInList_state.dart'; class CheckingInListLogic extends BaseGetXController{ CheckingInListState state = CheckingInListState(); // 开启考勤获取是否有公司 - void openCheckingInData() async{ - var entity = await ApiRepository.to.openCheckingInData( + Future openCheckingInData() async{ + final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData( lockId:state.getKeyInfosData.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ @@ -24,16 +27,16 @@ class CheckingInListLogic extends BaseGetXController{ } void loadDataByType(){ - if(state.isDay.value == true && (state.listType.value == "1")){ + if(state.isDay.value == true && (state.listType.value == '1')){ // 早到日榜 getCheckInListEarlyArrivalWithDateData(); - }else if(state.isDay.value == false && (state.listType.value == "1")){ + }else if(state.isDay.value == false && (state.listType.value == '1')){ // 早到月榜 getCheckInListEarlyArrivalWithMonthData(); - }else if(state.isDay.value == true && (state.listType.value == "2")){ + }else if(state.isDay.value == true && (state.listType.value == '2')){ // 迟到日榜 getCheckInListLateTimesWithDateData(); - }else if(state.isDay.value == false && (state.listType.value == "2")){ + }else if(state.isDay.value == false && (state.listType.value == '2')){ // 迟到月榜 getCheckInListLateTimesWithMonthData(); }else { @@ -43,8 +46,8 @@ class CheckingInListLogic extends BaseGetXController{ } // 获取考勤信息列表--早到榜(按日期查询) - void getCheckInListEarlyArrivalWithDateData() async{ - var entity = await ApiRepository.to.getCheckInListEarlyArrivalWithDateData( + Future getCheckInListEarlyArrivalWithDateData() async{ + final CheckingInListDayEntity entity = await ApiRepository.to.getCheckInListEarlyArrivalWithDateData( companyId: state.companyId.value, attendanceDate:state.checkListDateTimestamp.value.toString(), ); @@ -57,8 +60,8 @@ class CheckingInListLogic extends BaseGetXController{ } // 获取考勤信息列表--早到榜(按月榜查询) - void getCheckInListEarlyArrivalWithMonthData() async{ - var entity = await ApiRepository.to.getCheckInListEarlyArrivalWithMonthData( + Future getCheckInListEarlyArrivalWithMonthData() async{ + final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListEarlyArrivalWithMonthData( companyId: state.companyId.value, attendanceDate:state.checkListDateTimestamp.value.toString(), ); @@ -68,8 +71,8 @@ class CheckingInListLogic extends BaseGetXController{ } // 获取考勤信息列表--迟到榜(按日期查询) - void getCheckInListLateTimesWithDateData() async{ - var entity = await ApiRepository.to.getCheckInListLateTimesWithDateData( + Future getCheckInListLateTimesWithDateData() async{ + final CheckingInListDayEntity entity = await ApiRepository.to.getCheckInListLateTimesWithDateData( companyId: state.companyId.value, attendanceDate:state.checkListDateTimestamp.value.toString(), ); @@ -82,8 +85,8 @@ class CheckingInListLogic extends BaseGetXController{ } // 获取考勤信息列表--迟到榜(按月榜查询) - void getCheckInListLateTimesWithMonthData() async{ - var entity = await ApiRepository.to.getCheckInListLateTimesWithMonthData( + Future getCheckInListLateTimesWithMonthData() async{ + final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListLateTimesWithMonthData( companyId: state.companyId.value, attendanceDate:state.checkListDateTimestamp.value.toString(), ); @@ -93,11 +96,11 @@ class CheckingInListLogic extends BaseGetXController{ } // 获取考勤信息列表--勤奋榜(按月榜查询) - void getCheckInListHardworkingData() async{ - var entity = await ApiRepository.to.getCheckInListHardworkingData( + Future getCheckInListHardworkingData() async{ + final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListHardworkingData( companyId: state.companyId.value, attendanceDate:state.checkListDateTimestamp.value.toString(), - type: state.isDay.value == true ? "1" : "2", + type: state.isDay.value == true ? '1' : '2', ); if(entity.errorCode!.codeIsSuccessful){ state.checkingInMonthListData.value = entity.data!; @@ -106,18 +109,17 @@ class CheckingInListLogic extends BaseGetXController{ late StreamSubscription _teamEvent; void _initLoadDataAction() { - _teamEvent = eventBus.on().listen((event) { + _teamEvent = eventBus.on().listen((RefreshCheckInListEvent event) { loadDataByType(); }); } @override Future onReady() async { - // TODO: implement onReady super.onReady(); // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if(isDemoMode == false){ _initLoadDataAction(); @@ -125,16 +127,8 @@ class CheckingInListLogic extends BaseGetXController{ } } - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - - } - @override void onClose() { - // TODO: implement onClose super.onClose(); _teamEvent.cancel(); diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 68b8ca4a..a8b44f0e 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -16,6 +16,7 @@ import '../../../../tools/storage.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'checkingInListDay_entity.dart'; +import 'checkingInListSeletMonth_page.dart'; import 'checkingInList_logic.dart'; class CheckingInListPage extends StatefulWidget { @@ -51,7 +52,7 @@ class _CheckingInListPageState extends State { }); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast('演示模式'); + logic.showToast('演示模式'.tr); } }, child: Image.asset( @@ -122,7 +123,7 @@ class _CheckingInListPageState extends State { }); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast('演示模式'); + logic.showToast('演示模式'.tr); } }, child: Container( @@ -205,28 +206,26 @@ class _CheckingInListPageState extends State { ), GestureDetector( onTap: () async { - final bool? isDemoMode = - await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { await showDialog( context: Get.context!, builder: (BuildContext context) { - return ShowCalendar( - datePickerMode: DatePickerMode.day, - selectAction: (DateTime dateTime) { - setState(() { - state.checkListDateTimestamp.value = - dateTime.millisecondsSinceEpoch; - final String beginDate = formatDate( - dateTime, - state.isDay.value - ? [mm, '-', dd] - : [mm]); - state.checkListDate.value = beginDate; - logic.loadDataByType(); - Get.back(); + // if(state.isDay.value){ + return ShowCalendar( + datePickerMode: DatePickerMode.day, + selectAction: (DateTime dateTime) { + setState(() { + state.checkListDateTimestamp.value = dateTime.millisecondsSinceEpoch; + final String beginDate = formatDate(dateTime, state.isDay.value ? [mm, '-', dd] : [mm]); + state.checkListDate.value = beginDate; + logic.loadDataByType(); + Get.back(); + }); }); - }); + // }else{ + // return CheckingInListSeletMonthPage(); + // } }); } else { // Get.toNamed(Routers.selectLockTypePage); @@ -485,7 +484,7 @@ class _CheckingInListPageState extends State { showListType(); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast('演示模式'); + logic.showToast('演示模式'.tr); } }, child: Obx(() => Container( @@ -561,11 +560,11 @@ class _CheckingInListPageState extends State { String getTopTitle() { if (state.listType.value == '1') { - return '无考勤记录'; + return '无考勤记录'.tr; } else if (state.listType.value == '2') { - return '大家干劲十足'; + return '大家干劲十足'.tr; } else { - return '工作时长未出炉'; + return '工作时长未出炉'.tr; } } } diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart index ffd03b4b..21726b4b 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart @@ -7,24 +7,24 @@ import '../../../lockMian/entity/lockListInfo_entity.dart'; import 'checkingInListDay_entity.dart'; import 'checkingInListMonth_entity.dart'; -class CheckingInListState{ - final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; - - final listType = "1".obs;// 1早到榜 2迟到榜 3勤奋榜 - final listTypeStr = TranslationLoader.lanKeys!.earlyArrivalList!.tr.obs;// 1早到榜 2迟到榜 3勤奋榜 - final isDay = true.obs;// 日榜还是月榜 - final checkListDateTimestamp = DateTime.now().millisecondsSinceEpoch.obs;// 查询日期时间戳 - final checkListDate = formatDate(DateTime.now(), [mm,'-',dd]).obs;// 查询日期 - - final checkingInDayListData = [].obs; - final checkingInMonthListData = [].obs; - - var lateTimes = "".obs;// 迟到 - var earlyTimes = "".obs;// 早退 - var noPunchTimes = "".obs;// 未打车 +class CheckingInListState{// 未打车 CheckingInListState() { getKeyInfosData.value = Get.arguments as LockListInfoItemEntity; } + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + + final RxString listType = '1'.obs;// 1早到榜 2迟到榜 3勤奋榜 + final RxString listTypeStr = TranslationLoader.lanKeys!.earlyArrivalList!.tr.obs;// 1早到榜 2迟到榜 3勤奋榜 + final RxBool isDay = true.obs;// 日榜还是月榜 + final RxInt checkListDateTimestamp = DateTime.now().millisecondsSinceEpoch.obs;// 查询日期时间戳 + final RxString checkListDate = formatDate(DateTime.now(), [mm,'-',dd]).obs;// 查询日期 + + final RxList checkingInDayListData = [].obs; + final RxList checkingInMonthListData = [].obs; + + RxString lateTimes = ''.obs;// 迟到 + RxString earlyTimes = ''.obs;// 早退 + RxString noPunchTimes = ''.obs; } diff --git a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart index 5ff3067f..61b8797f 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart @@ -1,9 +1,5 @@ class CheckingInSetEntity { - int? errorCode; - String? description; - String? errorMsg; - CheckingInSetInfo? data; CheckingInSetEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -14,6 +10,10 @@ class CheckingInSetEntity { errorMsg = json['errorMsg']; data = json['data'] != null ? CheckingInSetInfo.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + CheckingInSetInfo? data; Map toJson() { final Map data = {}; @@ -28,13 +28,6 @@ class CheckingInSetEntity { } class CheckingInSetInfo { - int? staffNum; - int? workEndTime; - int? attendanceType; - int? companyId; - String? companyName; - int? workStartTime; - List? workDay; CheckingInSetInfo( {this.staffNum, @@ -54,6 +47,13 @@ class CheckingInSetInfo { workStartTime = json['workStartTime']; workDay = json['workDay'].cast(); } + int? staffNum; + int? workEndTime; + int? attendanceType; + int? companyId; + String? companyName; + int? workStartTime; + List? workDay; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart index 51f82718..4943900c 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart @@ -61,7 +61,7 @@ class _CheckingInSetPageState extends State { })), Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}", + '${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}', rightTitle: (state.beginTime.value.isNotEmpty) ? '${state.beginTime.value} - ${state.endTime.value}' : '', isHaveLine: true, isHaveDirection: true, @@ -78,7 +78,7 @@ class _CheckingInSetPageState extends State { })), Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}", + '${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}', rightTitle: state.isCustom.value == true ? state.weekDaysStr.value : (state.weekDays.value.length == 6 ? '单休' : '双休'), isHaveLine: true, isHaveDirection: true, diff --git a/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart b/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart index 090525bd..8a4a2cdd 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_logic.dart @@ -9,19 +9,19 @@ class CheckingInSetWorkTimeLogic extends BaseGetXController{ CheckingInSetWorkTimeState state = CheckingInSetWorkTimeState(); // 编辑考勤设置信息 - void editCheckInSetInfoData() async{ + Future editCheckInSetInfoData() async{ var entity = await ApiRepository.to.editCheckInSetInfoData( attendanceType: state.checkingInSetInfo.value.attendanceType.toString(), companyId: state.checkingInSetInfo.value.companyId.toString(), - type: "2", - companyName: state.checkingInSetInfo.value.companyName ?? "", + type: '2', + companyName: state.checkingInSetInfo.value.companyName ?? '', workEndTime: state.endTimeTimestamp.value.toString(), workStartTime: state.beginTimeTimestamp.value.toString(), workDay:state.checkingInSetInfo.value.workDay!, ); if(entity.errorCode!.codeIsSuccessful){ - showToast("修改成功", something: (){ - Get.back(result: "scuess"); + showToast('修改成功', something: (){ + Get.back(result: 'scuess'); }); } } diff --git a/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart b/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart index a10da5ab..77d3282b 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; @@ -22,8 +23,8 @@ class CheckingInSetWorkTimePage extends StatefulWidget { } class _CheckingInSetWorkTimePageState extends State { - final logic = Get.put(CheckingInSetWorkTimeLogic()); - final state = Get.find().state; + final CheckingInSetWorkTimeLogic logic = Get.put(CheckingInSetWorkTimeLogic()); + final CheckingInSetWorkTimeState state = Get.find().state; @override Widget build(BuildContext context) { @@ -31,7 +32,7 @@ class _CheckingInSetWorkTimePageState extends State { backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.work!.tr} ${TranslationLoader.lanKeys!.time!.tr} ${TranslationLoader.lanKeys!.set!.tr}", + '${TranslationLoader.lanKeys!.work!.tr} ${TranslationLoader.lanKeys!.time!.tr} ${TranslationLoader.lanKeys!.set!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: buildMainUI(), @@ -40,16 +41,16 @@ class _CheckingInSetWorkTimePageState extends State { Widget buildMainUI() { return Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.officeHours!.tr, rightTitle: state.beginTime.value, isHaveDirection: true, isHaveLine: true, action: () { - PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.beginTime.value, 0)); + final PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.beginTime.value, 0)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) { + selectDate: selectDate, mode: DateMode.HM, onConfirm: (PDuration p) { setState(() { state.beginTime.value = DateTool().getYMDHNDateString(p, 3); state.beginTimeTimestamp.value = DateTool() @@ -63,9 +64,9 @@ class _CheckingInSetWorkTimePageState extends State { rightTitle: state.endTime.value, isHaveDirection: true, action: () { - PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0)); + final PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) { + selectDate: selectDate, mode: DateMode.HM, onConfirm: (PDuration p) { setState(() { state.endTime.value = DateTool().getYMDHNDateString(p, 3); state.endTimeTimestamp.value = DateTool() @@ -85,28 +86,28 @@ class _CheckingInSetWorkTimePageState extends State { padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { if (state.beginTimeTimestamp.value.isEmpty) { - logic.showToast("请选择开始时间"); + logic.showToast('请选择开始时间'); return; } if (state.endTimeTimestamp.value.isEmpty) { - logic.showToast("请选择结束时间"); + logic.showToast('请选择结束时间'); return; } if (int.parse(state.beginTimeTimestamp.value) >= int.parse(state.endTimeTimestamp.value)) { - logic.showToast("结束时间必须要比开始时间晚,请重新选择"); + logic.showToast('结束时间必须要比开始时间晚,请重新选择'); return; } - if (state.pushType.value == "2") { + if (state.pushType.value == '2') { logic.editCheckInSetInfoData(); } else { - Get.back(result: { - "beginTime": state.beginTime.value, - "beginTimeTimestamp": state.beginTimeTimestamp.value, - "endTime": state.endTime.value, - "endTimeTimestamp": state.endTimeTimestamp.value, + Get.back(result: { + 'beginTime': state.beginTime.value, + 'beginTimeTimestamp': state.beginTimeTimestamp.value, + 'endTime': state.endTime.value, + 'endTimeTimestamp': state.endTimeTimestamp.value, }); } }), @@ -116,8 +117,8 @@ class _CheckingInSetWorkTimePageState extends State { String getNowDate() { // 获取当前时间对象 - DateTime today = DateTime.now(); - String dateSlug = + final DateTime today = DateTime.now(); + final String dateSlug = "${today.hour.toString().padLeft(2, '0')}:${today.minute.toString().padLeft(2, '0')}"; // //获取当前时间的年 diff --git a/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart b/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart index 6716e698..692c72a0 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSetWorkTime/checkingInSetWorkTime_state.dart @@ -4,25 +4,15 @@ import '../../../../tools/dateTool.dart'; import '../../../lockMian/entity/lockListInfo_entity.dart'; import '../checkingInSet/checkingInSet_entity.dart'; -class CheckingInSetWorkTimeState{ - // final getKeyInfosData = LockListInfoItemEntity().obs; - final checkingInSetInfo = CheckingInSetInfo().obs; - final companyId = "".obs; - - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 - var beginTimeTimestamp = "".obs;// 开始时间时间戳 - var endTimeTimestamp = "".obs;// 结束时间时间戳 - - var pushType = "".obs;// 2考勤设置信息选择时间 +class CheckingInSetWorkTimeState{// 2考勤设置信息选择时间 CheckingInSetWorkTimeState() { Map map = Get.arguments; - pushType.value = map["pushType"]; + pushType.value = map['pushType']; // getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; - checkingInSetInfo.value = map["checkingInSetInfo"]; - if(pushType.value != "0"){ + companyId.value = map['companyId']; + checkingInSetInfo.value = map['checkingInSetInfo']; + if(pushType.value != '0'){ beginTime.value = DateTool().dateToHNString(checkingInSetInfo.value.workStartTime.toString()); endTime.value = DateTool().dateToHNString(checkingInSetInfo.value.workEndTime.toString()); beginTimeTimestamp.value = checkingInSetInfo.value.workStartTime.toString(); @@ -30,5 +20,14 @@ class CheckingInSetWorkTimeState{ } } + // final getKeyInfosData = LockListInfoItemEntity().obs; + final Rx checkingInSetInfo = CheckingInSetInfo().obs; + final RxString companyId = ''.obs; + RxString beginTime = ''.obs;// 开始时间 + RxString endTime = ''.obs;// 结束时间 + RxString beginTimeTimestamp = ''.obs;// 开始时间时间戳 + RxString endTimeTimestamp = ''.obs;// 结束时间时间戳 + + RxString pushType = ''.obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart b/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart index cf5cafe4..f1581530 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart @@ -1,4 +1,5 @@ import 'package:get/get.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; @@ -9,22 +10,22 @@ class CheckingInSetWorkdaySetLogic extends BaseGetXController{ CheckingInSetWorkdaySetState state = CheckingInSetWorkdaySetState(); // 编辑考勤设置信息 - void editCheckInSetInfoData() async{ - var entity = await ApiRepository.to.editCheckInSetInfoData( - attendanceType: (state.isCustom.value == true) ? "0" : "1", + Future editCheckInSetInfoData() async{ + final LoginEntity entity = await ApiRepository.to.editCheckInSetInfoData( + attendanceType: (state.isCustom.value == true) ? '0' : '1', companyId: state.checkingInSetInfo.value.companyId.toString(), - type: (state.isCustom.value == true) ? "3" : "4", - companyName: state.checkingInSetInfo.value.companyName ?? "", + type: (state.isCustom.value == true) ? '3' : '4', + companyName: state.checkingInSetInfo.value.companyName ?? '', workEndTime: state.checkingInSetInfo.value.workEndTime.toString(), workStartTime: state.checkingInSetInfo.value.workStartTime.toString(), workDay:state.weekDays.value, ); if(entity.errorCode!.codeIsSuccessful){ - showToast("修改成功", something: (){ + showToast('修改成功', something: (){ eventBus.fire(RefreshCheckInSetDataEvent()); - Get.back(result: { - "attendanceType":state.isCustom.value, - "weekDays":state.weekDays.value, + Get.back(result: { + 'attendanceType':state.isCustom.value, + 'weekDays':state.weekDays.value, }); }); } @@ -32,18 +33,17 @@ class CheckingInSetWorkdaySetLogic extends BaseGetXController{ @override void onReady() { - // TODO: implement onReady super.onReady(); - Map map = Get.arguments; - state.pushType.value = map["pushType"]; - if(state.pushType.value == "2"){ - state.getKeyInfosData.value = map["getKeyInfosData"]; - state.companyId.value = map["companyId"]; - state.checkingInSetInfo.value = map["checkingInSetInfo"]; + final Map map = Get.arguments; + state.pushType.value = map['pushType']; + if(state.pushType.value == '2'){ + state.getKeyInfosData.value = map['getKeyInfosData']; + state.companyId.value = map['companyId']; + state.checkingInSetInfo.value = map['checkingInSetInfo']; state.weekDays.value = state.checkingInSetInfo.value.workDay!; - state.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0) ? true : false; + state.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0); if(state.isCustom.value == false){ if(state.checkingInSetInfo.value.workDay!.length == 5){ state.isSingledayWeekend.value = 1; @@ -56,14 +56,12 @@ class CheckingInSetWorkdaySetLogic extends BaseGetXController{ @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose // _teamEvent.cancel(); } } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart b/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart index 871c8fb7..594ae4ed 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; @@ -18,8 +19,8 @@ class CheckingInSetWorkdaySet extends StatefulWidget { } class _CheckingInSetWorkdaySetState extends State { - final logic = Get.put(CheckingInSetWorkdaySetLogic()); - final state = Get.find().state; + final CheckingInSetWorkdaySetLogic logic = Get.put(CheckingInSetWorkdaySetLogic()); + final CheckingInSetWorkdaySetState state = Get.find().state; @override Widget build(BuildContext context) { @@ -27,11 +28,11 @@ class _CheckingInSetWorkdaySetState extends State { backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.workday!.tr} ${TranslationLoader.lanKeys!.set!.tr}", + '${TranslationLoader.lanKeys!.workday!.tr} ${TranslationLoader.lanKeys!.set!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: ListView( - children: [ + children: [ topBtnWidget(), Obx(() => Visibility(visible: state.isCustom.value, child: bottomCustomSelectBtn())), Obx(() => Visibility(visible: !state.isCustom.value, child: bottomOddOrEvenDaysOffSelectBtn())), @@ -39,12 +40,12 @@ class _CheckingInSetWorkdaySetState extends State { Container( margin: EdgeInsets.only(left: 20.w, right: 20.w), child: SubmitBtn(btnName: TranslationLoader.lanKeys!.sure!.tr, onClick: () { - if(state.pushType.value == "2"){ + if(state.pushType.value == '2'){ logic.editCheckInSetInfoData(); }else{ - Get.back(result: { - "attendanceType":state.isCustom.value, - "weekDays":state.weekDays.value, + Get.back(result: { + 'attendanceType':state.isCustom.value, + 'weekDays':state.weekDays.value, }); } @@ -63,7 +64,7 @@ class _CheckingInSetWorkdaySetState extends State { padding: EdgeInsets.all(10.w), child: Obx(() => Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ GestureDetector( onTap: (){ setState(() { @@ -76,7 +77,7 @@ class _CheckingInSetWorkdaySetState extends State { color: state.isCustom.value ? AppColors.mainColor : AppColors.btnDisableColor, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Center(child: Text(TranslationLoader.lanKeys!.custom!.tr, style: TextStyle(fontSize: 26.sp, color: Colors.white))), ], ), @@ -96,7 +97,7 @@ class _CheckingInSetWorkdaySetState extends State { padding: EdgeInsets.all(10.w), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Expanded( child: Center( child: Text( @@ -117,44 +118,44 @@ class _CheckingInSetWorkdaySetState extends State { return Container( padding: EdgeInsets.only(left: 10.w, right: 10.w), child: Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.thisWeek!.tr, - rightTitle: "", + rightTitle: '', allHeight: 60.h, isHaveLine: true), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.singleDayWeekend!.tr, - rightTitle: "", + rightTitle: '', allHeight: 60.h, isHaveLine: true, isHaveRightWidget: true, action: (){ setState(() { state.isSingledayWeekend.value = 0; - state.weekDays.value = [1, 2 , 3, 4, 5, 6]; + state.weekDays.value = [1, 2 , 3, 4, 5, 6]; }); }, rightWidget: Row( - children: [ + children: [ Image.asset(state.isSingledayWeekend.value == 0 ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w,), ], ) )), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.twoDaysOff!.tr, - rightTitle: "", + rightTitle: '', allHeight: 60.h, isHaveLine: false, isHaveRightWidget: true, action: (){ setState(() { state.isSingledayWeekend.value = 1; - state.weekDays.value = [1, 2 , 3, 4, 5]; + state.weekDays.value = [1, 2 , 3, 4, 5]; }); }, rightWidget: Row( - children: [ + children: [ Image.asset(state.isSingledayWeekend.value == 1 ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w,), ], ) @@ -171,7 +172,7 @@ class _CheckingInSetWorkdaySetState extends State { child: ListView.builder( itemCount: 7, physics: const NeverScrollableScrollPhysics(), - itemBuilder: (c, index) { + itemBuilder: (BuildContext c, int index) { index += 1; String dateStr; switch (index) { @@ -197,12 +198,12 @@ class _CheckingInSetWorkdaySetState extends State { dateStr = TranslationLoader.lanKeys!.sunday!.tr; break; default: - dateStr = ""; + dateStr = ''; break; } return Obx(() => CommonItem( leftTitel: dateStr, - rightTitle: "", + rightTitle: '', allHeight: 60.h, isHaveLine: true, isHaveRightWidget: true, @@ -218,7 +219,7 @@ class _CheckingInSetWorkdaySetState extends State { }); }, rightWidget: Row( - children: [ + children: [ Image.asset(state.weekDays.value.contains(index) ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w,), ], ) diff --git a/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart b/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart index 4ea5923e..57c0fdff 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart @@ -3,29 +3,18 @@ import 'package:get/get.dart'; import '../../../lockMian/entity/lockListInfo_entity.dart'; import '../checkingInSet/checkingInSet_entity.dart'; -class CheckingInSetWorkdaySetState{ - var isCustom = true.obs; // 自定义 - var isSingledayWeekend = 2.obs; // 0单休 1双休 - var weekDays = [].obs;// 工作天数 - - final getKeyInfosData = LockListInfoItemEntity().obs; - final checkingInSetInfo = CheckingInSetInfo().obs; - final companyId = "".obs; - - // var changeType = "3".obs;// 3修改workDay自定义 4修改workDay - - var pushType = "".obs;// 2考勤设置信息 1考勤创建公司 +class CheckingInSetWorkdaySetState{// 2考勤设置信息 1考勤创建公司 CheckingInSetWorkdaySetState() { Map map = Get.arguments; - pushType.value = map["pushType"]; - if(pushType.value == "2"){ - getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; - checkingInSetInfo.value = map["checkingInSetInfo"]; + pushType.value = map['pushType']; + if(pushType.value == '2'){ + getKeyInfosData.value = map['getKeyInfosData']; + companyId.value = map['companyId']; + checkingInSetInfo.value = map['checkingInSetInfo']; weekDays.value = checkingInSetInfo.value.workDay!; - isCustom.value = (checkingInSetInfo.value.attendanceType! == 0) ? true : false; + isCustom.value = (checkingInSetInfo.value.attendanceType! == 0); if(isCustom.value == false){ if(checkingInSetInfo.value.workDay!.length == 5){ isSingledayWeekend.value = 1; @@ -35,4 +24,15 @@ class CheckingInSetWorkdaySetState{ } } } + RxBool isCustom = true.obs; // 自定义 + RxInt isSingledayWeekend = 2.obs; // 0单休 1双休 + RxList weekDays = [].obs;// 工作天数 + + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final Rx checkingInSetInfo = CheckingInSetInfo().obs; + final RxString companyId = ''.obs; + + // var changeType = "3".obs;// 3修改workDay自定义 4修改workDay + + RxString pushType = ''.obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart index f153f5f5..a84186e9 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart @@ -1,9 +1,5 @@ class CheckingInAddStaffSelectKeyEntity { - int? errorCode; - String? description; - String? errorMsg; - List? data; CheckingInAddStaffSelectKeyEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -19,6 +15,10 @@ class CheckingInAddStaffSelectKeyEntity { }); } } + int? errorCode; + String? description; + String? errorMsg; + List? data; Map toJson() { final Map data = {}; @@ -33,8 +33,6 @@ class CheckingInAddStaffSelectKeyEntity { } class CheckingInAddStaffKeyEntity { - String? attendanceWay; - String? staffName; CheckingInAddStaffKeyEntity({this.attendanceWay, this.staffName}); @@ -42,6 +40,8 @@ class CheckingInAddStaffKeyEntity { attendanceWay = json['attendanceWay']; staffName = json['staffName']; } + String? attendanceWay; + String? staffName; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart index bc729d3f..5646051e 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -1,3 +1,4 @@ + import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index d36f4ecf..5bf58a1a 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart index 23954119..e87eb0cf 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart @@ -1,8 +1,4 @@ class CheckingInAddStaffListEntity { - int? errorCode; - String? description; - String? errorMsg; - List? data; CheckingInAddStaffListEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -18,6 +14,10 @@ class CheckingInAddStaffListEntity { }); } } + int? errorCode; + String? description; + String? errorMsg; + List? data; Map toJson() { final Map data = {}; @@ -32,14 +32,6 @@ class CheckingInAddStaffListEntity { } class CheckingInAddStaffListItemEntity { - String? headurl; - String? staffName; - int? staffId; - int? attendanceType; - int? countryCode; - int? cardStatus;//0正常 1打卡失败 - String? attendanceWay; - String? reason; CheckingInAddStaffListItemEntity( {this.headurl, @@ -61,6 +53,14 @@ class CheckingInAddStaffListItemEntity { attendanceWay = json['attendanceWay']; reason = json['reason']; } + String? headurl; + String? staffName; + int? staffId; + int? attendanceType; + int? countryCode; + int? cardStatus;//0正常 1打卡失败 + String? attendanceWay; + String? reason; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart index 2eb50805..57988367 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/eventBusEventManage.dart'; @@ -10,8 +12,8 @@ class CheckingInStaffManageLogic extends BaseGetXController{ CheckingInStaffManageState state = CheckingInStaffManageState(); // 获取员工列表 - void getStaffList() async{ - var entity = await ApiRepository.to.getStaffListData( + Future getStaffList() async{ + final CheckingInAddStaffListEntity entity = await ApiRepository.to.getStaffListData( companyId: state.companyId.value, lockId:state.getKeyInfosData.value.lockId.toString(), ); @@ -21,8 +23,8 @@ class CheckingInStaffManageLogic extends BaseGetXController{ } // 删除员工 - void deletStaff(int staffId, int deleteKey) async{ - var entity = await ApiRepository.to.deletStaffData( + Future deletStaff(int staffId, int deleteKey) async{ + final LoginEntity entity = await ApiRepository.to.deletStaffData( lockId: state.getKeyInfosData.value.lockId!, staffId:staffId, deleteKey:deleteKey @@ -34,14 +36,13 @@ class CheckingInStaffManageLogic extends BaseGetXController{ late StreamSubscription _teamEvent; void _initLoadDataAction() { - _teamEvent = eventBus.on().listen((event) { + _teamEvent = eventBus.on().listen((RefreshCheckInStaffListDataEvent event) { getStaffList(); }); } @override void onReady() { - // TODO: implement onReady super.onReady(); getStaffList(); @@ -51,14 +52,12 @@ class CheckingInStaffManageLogic extends BaseGetXController{ @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose _teamEvent.cancel(); } } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index b9d88109..49d7c06f 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -1,3 +1,4 @@ + import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -8,9 +9,7 @@ import 'package:star_lock/tools/showTipView.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/customNetworkImage.dart'; import '../../../../../tools/noData.dart'; -import '../../../../../tools/showIosTipView.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; import 'checkingInStaffList_entity.dart'; @@ -238,22 +237,4 @@ class _CheckingInStaffListPageState extends State { return title; } -// void showIosTipViewDialog(int staffId, BuildContext context) { -// showDialog( -// context: context, -// builder: (BuildContext context) { -// return ShowIosTipView( -// title: "提示", -// tipTitle: "确定要删除员工吗?", -// sureClick: () async { -// Get.back(); -// logic.deletStaff(staffId, 0); -// }, -// cancelClick: () { -// Get.back(); -// }, -// ); -// }, -// ); -// } } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart index a0d76bc5..c240a0ca 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart @@ -5,15 +5,13 @@ import '../../../../lockMian/entity/lockListInfo_entity.dart'; import 'checkingInStaffList_entity.dart'; class CheckingInStaffManageState{ - final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; - - final staffListData = [].obs; - CheckingInStaffManageState() { Map map = Get.arguments; - getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; + getKeyInfosData.value = map['getKeyInfosData']; + companyId.value = map['companyId']; } + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + final RxList staffListData = [].obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart index 87edc79b..6addfe99 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_state.dart @@ -5,32 +5,32 @@ import '../../../../lockMian/entity/lockListInfo_entity.dart'; import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; class CheckingInStaffDetailState{ - final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; - - final staffListItemData = CheckingInAddStaffListItemEntity().obs; - - var attendanceType = "".obs; CheckingInStaffDetailState() { Map map = Get.arguments; - staffListItemData.value = map["staffListItem"]; - getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; + staffListItemData.value = map['staffListItem']; + getKeyInfosData.value = map['getKeyInfosData']; + companyId.value = map['companyId']; switch(staffListItemData.value.attendanceType){ case 1: - attendanceType.value = "APP"; + attendanceType.value = 'APP'; break; case 2: - attendanceType.value = "密码".tr; + attendanceType.value = '密码'.tr; break; case 3: - attendanceType.value = "卡".tr; + attendanceType.value = '卡'.tr; break; case 4: - attendanceType.value = "指纹".tr; + attendanceType.value = '指纹'.tr; break; } } + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + + final Rx staffListItemData = CheckingInAddStaffListItemEntity().obs; + + RxString attendanceType = ''.obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 97985703..cd588530 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -348,17 +348,20 @@ class LockDetailLogic extends BaseGetXController { // 从服务器获取锁的时间 开锁时传入 Future getServerDatetime() async { final GetServerDatetimeEntity entity = - await ApiRepository.to.getServerDatetimeData(); + await ApiRepository.to.getServerDatetimeData(isUnShowLoading:true); if (entity.errorCode!.codeIsSuccessful) { - state.differentialTime = entity.data!.date! ~/ 1000 - - DateTime.now().millisecondsSinceEpoch ~/ 1000; - // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); + state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; + }else{ + state.isHaveNetwork = false; } } int getUTCNetTime() { - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + - state.differentialTime; + if(state.isHaveNetwork){ + return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; + }else{ + return 0; + } } // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 diff --git a/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/lib/main/lockDetail/lockDetail/lockDetail_state.dart index 80245575..df604a3a 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -15,7 +15,8 @@ class LockDetailState { StreamSubscription? LockSetChangeSetRefreshLockDetailWithTypeSubscription; String lockNetToken = '0'; - int differentialTime = 0; + int differentialTime = 0;// 服务器时间与本地时间差值 + bool isHaveNetwork = true; int lockUserNo = 0; int senderUserId = 0; bool isOnlyOneData = false; @@ -51,6 +52,7 @@ class LockDetailState { int operateDate = 0; // 按日期查询消息记录的时间戳 int logCountPage = 10; // 蓝牙记录一页多少个 RxInt nextAuthTime = 0.obs; // 下次认证时间 + // LockDetailState() { // Map map = Get.arguments; // lockCount = map["lockCount"]; diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index abf06090..ea72be85 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -56,18 +56,15 @@ class UploadElectricQuantityLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().blueSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { dismissEasyLoading(); - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCTime(), + utcTimeStamp: state.serverTime, unixTimeStamp: getLocalTime(), isBeforeAddUser: false, privateKey: getPrivateKeyList, @@ -133,7 +130,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCTime(), + utcTimeStamp: state.serverTime, unixTimeStamp: getLocalTime(), isBeforeAddUser: false, privateKey: getPrivateKeyList, @@ -148,29 +145,18 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 从服务器获取锁的时间 开锁时传入 Future getServerDatetime() async { - final GetServerDatetimeEntity entity = - await ApiRepository.to.getServerDatetimeData(); + final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false); if (entity.errorCode!.codeIsSuccessful) { - state.differentialTime = entity.data!.date! ~/ 1000 - - DateTime.now().millisecondsSinceEpoch ~/ 1000; - // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); + state.serverTime = entity.data!.date! ~/ 1000; + getStarLockStatus(); } } - int getLocalTime() { - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + - state.differentialTime; - } - - int getUTCTime() { - final DateTime utcTime = - DateTime.fromMillisecondsSinceEpoch(getLocalTime() * 1000, isUtc: true); - - final String appointmentDate = - DateTool().getYMDHNDateStringWithDateTime(utcTime, 1); - final int utcTimeValue = DateTool().dateToTimestamp(appointmentDate, 1); - AppLog.log('appointmentDate: $appointmentDate utcTimeValue:$utcTimeValue'); - return utcTimeValue ~/ 1000; + int getLocalTime(){ + final DateTime now = DateTime.now(); + final Duration timeZoneOffset = now.timeZoneOffset; + AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds'); + return state.serverTime + timeZoneOffset.inSeconds; } @override @@ -178,7 +164,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { super.onReady(); _initReplySubscription(); - getServerDatetime(); + // getServerDatetime(); } @override diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart index 6d6fd4ff..f4328633 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart @@ -94,7 +94,7 @@ class _UploadElectricQuantityPageState extends State // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { - logic.getStarLockStatus(); + logic.getServerDatetime(); }), ], ), diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart index 8d5e5eec..fbc3a9b6 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart @@ -23,4 +23,5 @@ class UploadElectricQuantityState {// 0普通状态可用 1不可用 RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 RxInt sureBtnState = 0.obs; + int serverTime = 0;// 服务器时间即UTC+0时间 } \ No newline at end of file diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index f3893ea9..c38607c6 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -82,7 +82,7 @@ class LockTimeLogic extends BaseGetXController{ switch(status){ case 0x00: //成功 - final String dataEime = DateTool().dateToYMDHNString('${getLocalTime()}'); + final String dataEime = DateTool().dateToYMDHNString('${state.differentialTime}'); state.dateTime.value = dataEime; state.sureBtnState.value = 0; @@ -124,7 +124,7 @@ class LockTimeLogic extends BaseGetXController{ IoSenderManage.senderTimingCommand( lockID:BlueManage().connectDeviceName, userID:await Storage.getUid(), - nowTime: getLocalTime(), + nowTime: state.differentialTime, token:getTokenList, needAuthor:1, signKey:getSignKeyList, @@ -183,27 +183,14 @@ class LockTimeLogic extends BaseGetXController{ // 从服务器获取锁的时间 开锁时传入 Future getServerDatetime() async{ - final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(); + final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false); if(entity.errorCode!.codeIsSuccessful){ - state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; + state.differentialTime = entity.data!.date! ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); - getStarLockStatus(); + sendTiming(); } } - int getLocalTime(){ - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; - } - - int getUTCTime(){ - final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000, isUtc: true); - - final String appointmentDate = DateTool().getYMDHNDateStringWithDateTime(utcTime, 1); - final int utcTimeValue = DateTool().dateToTimestamp(appointmentDate, 1); - AppLog.log('appointmentDate: $appointmentDate utcTimeValue:$utcTimeValue'); - return utcTimeValue ~/ 1000; - } - @override void onReady() { super.onReady(); @@ -211,7 +198,8 @@ class LockTimeLogic extends BaseGetXController{ _initReplySubscription(); // getLockTimeFromGateway(); - getServerDatetime(); + + getStarLockStatus(); } @override diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart index 69643e8b..b2ab732d 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart @@ -56,8 +56,8 @@ class _LockTimePageState extends State with RouteAware{ padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { // logic.sendTiming(); - // logic.getServerDatetime(); - logic.sendTiming(); + logic.getServerDatetime(); + // logic.sendTiming(); }), SizedBox( height: 40.h, diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart index 2ec98723..5d012cdf 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart @@ -14,4 +14,6 @@ class LockTimeState{// 0普通状态(可用) 1连接中(不可用) RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 RxInt sureBtnState = 0.obs; + + int serverTime = 0;// 服务器时间即UTC+0时间 } \ No newline at end of file diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 8411c676..a1c8f50a 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -1,14 +1,14 @@ + import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:typed_data'; import 'package:crypto/crypto.dart'; +import 'package:date_format/date_format.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart'; import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart'; import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart'; @@ -27,7 +27,6 @@ import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; -import '../../../tools/dateTool.dart'; import '../../../tools/storage.dart'; import 'nearbyLock_state.dart'; @@ -123,7 +122,7 @@ class NearbyLockLogic extends BaseGetXController { lockId: BlueManage().connectDeviceName, keyID: '1', authUserID: await Storage.getUid(), - nowTime: getUTCTime(), + nowTime: state.serverTime, publicKeyData: publicKey, needAuthor: 1); break; @@ -353,7 +352,7 @@ class NearbyLockLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCTime(), + utcTimeStamp: state.serverTime, unixTimeStamp: getLocalTime(), isBeforeAddUser: true, privateKey: getPrivateKeyList, @@ -377,10 +376,17 @@ class NearbyLockLogic extends BaseGetXController { final List? privateKey = await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final String getUTCDate = formatDate(DateTime.fromMillisecondsSinceEpoch(state.serverTime*1000), [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss]); + final String getLocalDate = formatDate(DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000), [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss]); + + AppLog.log('state.serverTime:${state.serverTime} getUTCDate:$getUTCDate ' + 'getLocalTime:${getLocalTime()} getLocalDate:$getLocalDate ' + '差值:${getLocalTime() - state.serverTime}'); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCTime(), + utcTimeStamp: state.serverTime, unixTimeStamp: getLocalTime(), isBeforeAddUser: true, privateKey: getPrivateKeyList, @@ -494,10 +500,10 @@ class NearbyLockLogic extends BaseGetXController { //首次 final int difference = length % 240; otaCount = length ~/ 240 + (difference > 0 ? 1 : 0); - startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000; + startSecond = DateTime.now().millisecondsSinceEpoch; } if (otaCount <= otaIndex) { - final int now = DateTime.now().millisecondsSinceEpoch ~/ 1000; + final int now = DateTime.now().millisecondsSinceEpoch; final String msg = '传输完成 时间:${now - startSecond}秒 otaCount:$otaCount otaIndex:$otaIndex '; closeOTADAta(); @@ -624,24 +630,25 @@ class NearbyLockLogic extends BaseGetXController { // 从服务器获取锁的时间 开锁时传入 Future getServerDatetime() async{ - final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(); + final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false); if(entity.errorCode!.codeIsSuccessful){ - state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; + state.serverTime = entity.data!.date! ~/ 1000; + + if (state.otaState.value) { + oTAUpgrade(state.selectLockName.value); + } else { + connect(state.selectLockName.value); + } + // state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } int getLocalTime(){ - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; - } - - int getUTCTime(){ - final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000, isUtc: true); - - final String appointmentDate = DateTool().getYMDHNDateStringWithDateTime(utcTime, 1); - final int utcTimeValue = DateTool().dateToTimestamp(appointmentDate, 1); - AppLog.log('appointmentDate: $appointmentDate utcTimeValue:$utcTimeValue'); - return utcTimeValue ~/ 1000; + final DateTime now = DateTime.now(); + final Duration timeZoneOffset = now.timeZoneOffset; + AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds'); + return state.serverTime + timeZoneOffset.inSeconds; } @override @@ -649,7 +656,6 @@ class NearbyLockLogic extends BaseGetXController { super.onReady(); _initReplySubscription(); state.ifCurrentScreen.value = true; - getServerDatetime(); startScanBlueList(); } diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_page.dart b/lib/mine/addLock/nearbyLock/nearbyLock_page.dart index 08000e35..d891b53a 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_page.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_page.dart @@ -71,11 +71,7 @@ class _NearbyLockPageState extends State with RouteAware { 'images/icon_lockGroup_item.png', state.devices[index], () { String advName = state.devices[index].advertisementData.advName; state.selectLockName.value = advName; - if (state.otaState.value) { - logic.oTAUpgrade(advName); - } else { - logic.connect(advName); - } + logic.getServerDatetime(); }); }, separatorBuilder: (BuildContext context, int index) { diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_state.dart b/lib/mine/addLock/nearbyLock/nearbyLock_state.dart index 798a25bc..b0a5ae87 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_state.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_state.dart @@ -3,20 +3,21 @@ import 'package:get/get.dart'; class NearbyLockState { RxList devices = [].obs; - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 // var sureBtnState = 0.obs;// 0可点击 1 不可点击 - int differentialTime = 0; + // int differentialTime = 0; + int serverTime = 0;// 服务器时间即UTC+0时间 - var selectLockName = "".obs; + RxString selectLockName = ''.obs; - var timestampValue = 0; - var lockInfo = {}; - var featureValue = ''; - var featureSettingValue = ''; - var featureSettingParams = []; + int timestampValue = 0; + Map lockInfo = {}; + String featureValue = ''; + String featureSettingValue = ''; + List featureSettingParams = []; - var otaState = false.obs; //ota 升级 - var otaUpdateIng = false.obs; - var otaProgress = 0.00.obs; + RxBool otaState = false.obs; //ota 升级 + RxBool otaUpdateIng = false.obs; + RxDouble otaProgress = 0.00.obs; bool oTAProgressDialog = false; } diff --git a/lib/mine/addLock/selectLockType/selectLockType_logic.dart b/lib/mine/addLock/selectLockType/selectLockType_logic.dart index 0ec49cfa..2e5d8186 100755 --- a/lib/mine/addLock/selectLockType/selectLockType_logic.dart +++ b/lib/mine/addLock/selectLockType/selectLockType_logic.dart @@ -8,7 +8,7 @@ class SelectLockTypeLogic extends BaseGetXController { SelectLockTypeState state = SelectLockTypeState(); void getServerDatetime() async{ - var entity = await ApiRepository.to.getServerDatetimeData(); + var entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:true); if(entity.errorCode!.codeIsSuccessful){ } } diff --git a/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart b/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart index 83eb78ce..df7fb1af 100755 --- a/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart +++ b/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart @@ -182,7 +182,7 @@ class _LockGroupListPageState extends State { logic.showToast( TranslationLoader.lanKeys!.pleaseEnterAGroupName!.tr); } - }); + }, isShowSuffixIcon: true); }, child: Container( width: 100.w, diff --git a/lib/network/api.dart b/lib/network/api.dart index 1764a28e..0666954d 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -252,4 +252,6 @@ abstract class Api { final String keydetail = ' /key/detail'; //获取钥匙详情 final String updateTemplateInfoURL = '/v2/service/update'; //更新模板信息 final String deleteTemplateURL = '/v2/service/delete'; //删除模板 + + final String checkIpURL = '/checkIp/ip'; } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 71952895..fd37a06e 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -840,8 +840,8 @@ class ApiProvider extends BaseProvider { })); // 获取服务器当前时间 - Future getServerDatetimeLoadData() => - post(getServerDatetimeUrl.toUrl, jsonEncode({}), isUnShowLoading: true); + Future getServerDatetimeLoadData(bool isUnShowLoading) => + post(getServerDatetimeUrl.toUrl, jsonEncode({}), isUnShowLoading: isUnShowLoading); // 锁诊断 Future setLockDiagnoseData( @@ -2225,6 +2225,12 @@ class ApiProvider extends BaseProvider { jsonEncode({'id': id}), isUnShowLoading: true, ); + + Future> checkIpAction(String ip) => post( + checkIpURL.toUrl, + jsonEncode({'ip': ip}), + isUnShowLoading: true, + ); } extension ExtensionString on String { diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 770372db..43dce014 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -46,6 +46,7 @@ import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; import '../login/register/entity/SendValidationCodeEntity.dart'; +import '../login/register/entity/checkIP_entity.dart'; import '../main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart'; import '../main/lockDetail/card/addICCard/addICCard_entity.dart'; import '../main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart'; @@ -890,8 +891,8 @@ class ApiRepository { } // 获取服务器当前时间 - Future getServerDatetimeData() async { - final res = await apiProvider.getServerDatetimeLoadData(); + Future getServerDatetimeData({bool? isUnShowLoading}) async { + final res = await apiProvider.getServerDatetimeLoadData(isUnShowLoading ?? true); return GetServerDatetimeEntity.fromJson(res.body); } @@ -2237,4 +2238,10 @@ class ApiRepository { final Response res = await apiProvider.deleteTemplateInfo(id); return LoginEntity.fromJson(res.body); } + + // 查看ip是否是国外还是国内 + Future checkIpAction({required String ip}) async { + final Response res = await apiProvider.checkIpAction(ip); + return CheckIPEntity.fromJson(res.body); + } } diff --git a/lib/tools/showTFView.dart b/lib/tools/showTFView.dart index a3b05179..fd40eb1e 100755 --- a/lib/tools/showTFView.dart +++ b/lib/tools/showTFView.dart @@ -12,6 +12,7 @@ class ShowTFView extends StatelessWidget { String? tipTitle; String? leftBtnTitle; String? rightBtnTitle; + bool? isShowSuffixIcon; TextEditingController? controller; List? inputFormatters; TextInputType? keyboardType; @@ -24,6 +25,7 @@ class ShowTFView extends StatelessWidget { this.tipTitle, this.leftBtnTitle, this.rightBtnTitle, + this.isShowSuffixIcon, this.controller, this.inputFormatters, this.keyboardType, @@ -58,14 +60,16 @@ class ShowTFView extends StatelessWidget { inputFormatters: inputFormatters, keyboardType: keyboardType, decoration: InputDecoration( - contentPadding: - const EdgeInsets.only(left: 5, top: -8, bottom: 6), + contentPadding: EdgeInsets.only(left: 5, top: isShowSuffixIcon! ? 0 : -8, bottom: 6), hintText: tipTitle??TranslationLoader.lanKeys!.pleaseEnter!.tr, hintStyle: TextStyle(fontSize: 22.sp, height: 1.0), //不需要输入框下划线 border: InputBorder.none, + suffixIcon: isShowSuffixIcon! ? IconButton( + onPressed: () => controller?.clear(), + icon: const Icon(Icons.clear), + ) : null, ), - ), ) ], diff --git a/lib/tools/showTipView.dart b/lib/tools/showTipView.dart index 1386d50c..011e1806 100755 --- a/lib/tools/showTipView.dart +++ b/lib/tools/showTipView.dart @@ -13,18 +13,17 @@ typedef BlockIsHaveAllDataCallback = void Function(bool isAllData); class ShowTipView { // 只有一个确定按钮 - void showSureAlertDialog(String contentStr) { + void showSureAlertDialog(String contentStr, {String? tipTitle, String? sureStr}) { showCupertinoDialog( context: Get.context!, builder: (BuildContext context) { return CupertinoAlertDialog( + title: Text(tipTitle ?? ''), content: Text(contentStr), actions: [ CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.sure!.tr), - onPressed: () { - Get.back(); - }, + child: Text(sureStr ?? TranslationLoader.lanKeys!.sure!.tr), + onPressed: Get.back, ), ], ); @@ -40,7 +39,7 @@ class ShowTipView { context: Get.context!, builder: (BuildContext context) { return CupertinoAlertDialog( - title: Text("提示".tr), + title: Text('提示'.tr), content: SizedBox( // height: 100.h, child: ShowDeleteAdministratorIsHaveAllDataWidget( @@ -53,9 +52,7 @@ class ShowTipView { actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), - onPressed: () { - Get.back(); - }, + onPressed: Get.back, ), CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), @@ -97,7 +94,7 @@ class ShowTipView { void showTFViewAlertDialog(TextEditingController controller, String title, String tipTitle, Function sureClick, - {List? inputFormatters}) { + {List? inputFormatters, bool? isShowSuffixIcon}) { // 点击删除 开始扫描 showDialog( context: Get.context!, @@ -107,6 +104,7 @@ class ShowTipView { tipTitle: tipTitle, inputFormatters: inputFormatters, controller: controller, + isShowSuffixIcon: isShowSuffixIcon ?? false, sureClick: () { //发送删除锁请求 if (controller.text.isEmpty) { From 87bbce3d9fb63456c10f139f925a8cb99a98cb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 7 Jun 2024 10:53:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/login/register/entity/Data.dart | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100755 lib/login/register/entity/Data.dart diff --git a/lib/login/register/entity/Data.dart b/lib/login/register/entity/Data.dart deleted file mode 100755 index 19efdbfc..00000000 --- a/lib/login/register/entity/Data.dart +++ /dev/null @@ -1,28 +0,0 @@ -class Data { - Data({ - this.originalImageBase64, - this.jigsawImageBase64, - this.secretKey, - this.token}); - - Data.fromJson(dynamic json) { - originalImageBase64 = json['originalImageBase64']; - jigsawImageBase64 = json['jigsawImageBase64']; - secretKey = json['secretKey']; - token = json['token']; - } - int? originalImageBase64; - String? jigsawImageBase64; - String? secretKey; - String? token; - - Map toJson() { - final map = {}; - map['originalImageBase64'] = originalImageBase64; - map['jigsawImageBase64'] = jigsawImageBase64; - map['secretKey'] = secretKey; - map['token'] = token; - return map; - } - -} \ No newline at end of file From ed12b39f5b211fac44f2ff81d85ec93d380e3873 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Fri, 7 Jun 2024 11:12:45 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=E8=B0=83=E9=80=9A=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 6 +- lib/login/login/app_get_version.dart | 3 + lib/main/lockMian/lockMain/lockMain_page.dart | 6 +- .../lockMain/xhj/lockMain_xhj_page.dart | 142 +++++++----------- lib/mine/mall/lockMall_logic.dart | 24 ++- lib/mine/mall/lockMall_page.dart | 13 +- .../messageList/messageList_xhj_page.dart | 5 +- lib/mine/mineSet/mineSet/mineSet_page.dart | 6 +- lib/tools/pay/wx_pay_tool.dart | 8 +- 9 files changed, 97 insertions(+), 116 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index dc825bcd..0af65278 100755 --- a/lib/app.dart +++ b/lib/app.dart @@ -14,6 +14,7 @@ import 'package:star_lock/tools/appFirstEnterHandle.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; import 'package:star_lock/tools/customer_tool.dart'; +import 'package:star_lock/tools/pay/wx_pay_tool.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/translations/app_dept.dart'; @@ -117,7 +118,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { getPages: AppRouters.routePages, builder: EasyLoading.init(), initialBinding: AppBindings(), - initialRoute: initialRoute ); + initialRoute: initialRoute); } @override @@ -178,4 +179,5 @@ Future getAgreePrivacyShowUpdate() async { Future getAppInfo() async { final GetAppInfo entity = await ApiRepository.to.getAppInfo(); CustomerTool.init(entity.data?.wechatServiceUrl ?? ''); -} \ No newline at end of file + WxPayTool.associationUrl = entity.data?.appSiteUrl ?? ''; +} diff --git a/lib/login/login/app_get_version.dart b/lib/login/login/app_get_version.dart index f224088b..fb738b60 100644 --- a/lib/login/login/app_get_version.dart +++ b/lib/login/login/app_get_version.dart @@ -28,13 +28,16 @@ class GetAppInfo { class Data { Data.fromJson(Map json) { wechatServiceUrl = json['wechat_service_url']; + appSiteUrl = json['app_site_url']; } String? wechatServiceUrl; + String? appSiteUrl; Map toJson() { final Map data = {}; data['wechat_service_url'] = wechatServiceUrl; + data['app_site_url'] = appSiteUrl; return data; } } diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index b23b80c4..ffa55bf2 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -33,7 +33,7 @@ class StarLockMainPage extends StatefulWidget { State createState() => _StarLockMainPageState(); } -class _StarLockMainPageState extends State with BaseWidget { +class _StarLockMainPageState extends State with BaseWidget ,AutomaticKeepAliveClientMixin { final logic = Get.put(LockMainLogic()); final state = Get.find().state; @@ -265,8 +265,10 @@ class _StarLockMainPageState extends State with BaseWidget { @override void dispose() { - // TODO: implement dispose super.dispose(); _teamEvent.cancel(); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart index c9c5a493..55aefff1 100755 --- a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart +++ b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart @@ -26,6 +26,7 @@ class StarLockMainXHJPage extends StatefulWidget { class _StarLockMainXHJPageState extends State with BaseWidget { + PageController _pageController = PageController(); @override void initState() { @@ -44,109 +45,70 @@ class _StarLockMainXHJPageState extends State builder: (LockMainXHJLogic logic) { return Scaffold( backgroundColor: Colors.white, - body: Stack( + body: PageView( + controller: _pageController, + physics: const NeverScrollableScrollPhysics(), // 禁止滑动 children: [ - pageView( - widget: StarLockMainPage( + StarLockMainPage( + showAppBar: false, + showDrawer: false, + ), + SafeArea( + bottom: false, + child: LockMallPage( + allowReturn: false, + ), + ), + SafeArea( + bottom: false, + child: MessageListXHJPage( showAppBar: false, - showDrawer: false, ), - logic: logic, - index: 0, ), - pageView( - widget: SafeArea( - bottom: false, - child: LockMallPage( - allowReturn: false, - ), + SafeArea( + bottom: false, + child: MineSetPage( + showAppBar: false, + showAbout: true, ), - logic: logic, - index: 1, - ), - pageView( - widget: SafeArea( - bottom: false, - child: MessageListXHJPage( - showAppBar: false, - ), - ), - logic: logic, - index: 2, - ), - pageView( - widget: SafeArea( - bottom: false, - child: MineSetPage( - showAppBar: false, - showAbout: true, - ), - ), - logic: logic, - index: 3, ), ], ), - bottomNavigationBar: Container( - padding: EdgeInsets.only( - top: 20.h, bottom: GetPlatform.isAndroid ? 20.h : 0), - decoration: const BoxDecoration( - color: Colors.transparent, - border: Border( - top: BorderSide( - color: Colors.black, // 设置边框颜色 - width: 0.3, // 设置边框宽度 - ), - ), - ), - child: SafeArea( - top: false, - child: Row( - children: [ - navigationBarItem(Icons.key, - TranslationLoader.lanKeys!.device!.tr, logic, 0, () { - logic.setIndex(0); - }), - navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 1, - () { - logic.setIndex(1); - }), - navigationBarItem(Icons.message, - TranslationLoader.lanKeys!.message!.tr, logic, 2, () { - logic.setIndex(2); - }), - navigationBarItem(Icons.account_circle, '我的'.tr, logic, 3, - () { - logic.setIndex(3); - }), - ], - ), - ), - ), + bottomNavigationBar: buildBottomNavigationBar(logic), ); }); } - //布局 - Widget pageView( - {required Widget widget, - required LockMainXHJLogic logic, - required int index}) { - return Positioned.fill( - child: Offstage( - offstage: logic.state.index != index, - child: widget, + Widget buildBottomNavigationBar(LockMainXHJLogic logic) { + return Container( + padding: + EdgeInsets.only(top: 20.h, bottom: GetPlatform.isAndroid ? 20.h : 0), + decoration: const BoxDecoration( + color: Colors.transparent, + border: Border(top: BorderSide(color: Colors.black, width: 0.3)), + ), + child: SafeArea( + top: false, + child: Row( + children: [ + navigationBarItem(logic, Icons.key, '设备'.tr, 0), + navigationBarItem(logic, Icons.shopping_cart, '商城'.tr, 1), + navigationBarItem(logic, Icons.message, '消息'.tr, 2), + navigationBarItem(logic, Icons.account_circle, '我的'.tr, 3), + ], + ), ), ); } - //底部按钮 - Widget navigationBarItem(IconData icon, String text, LockMainXHJLogic logic, - int index, GestureTapCallback? onTop) { - final bool check = logic.state.index == index; + Widget navigationBarItem( + LockMainXHJLogic logic, IconData icon, String text, int index) { return Expanded( child: GestureDetector( - onTap: onTop, + onTap: () { + _pageController.jumpToPage(index); + logic.setIndex(index); + }, child: Container( color: Colors.transparent, child: Column( @@ -157,16 +119,18 @@ class _StarLockMainXHJPageState extends State child: Icon( icon, size: 32.r, - color: - check ? AppColors.mainColor : AppColors.darkGrayTextColor, + color: logic.state.index == index + ? AppColors.mainColor + : AppColors.darkGrayTextColor, ), ), Text( text, style: TextStyle( fontSize: 16.sp, - color: - check ? AppColors.mainColor : AppColors.darkGrayTextColor, + color: logic.state.index == index + ? AppColors.mainColor + : AppColors.darkGrayTextColor, ), ), ], diff --git a/lib/mine/mall/lockMall_logic.dart b/lib/mine/mall/lockMall_logic.dart index e9daa4e9..fc41e91d 100755 --- a/lib/mine/mall/lockMall_logic.dart +++ b/lib/mine/mall/lockMall_logic.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fluwx/fluwx.dart'; import 'package:get/get.dart'; @@ -25,13 +26,12 @@ class LockMallLogic extends BaseGetXController { //获取商城跳转地址 Future getMallURLRequest() async { - LockMallDataEntity entity = await ApiRepository.to.getMallURLData(); + final LockMallDataEntity entity = await ApiRepository.to.getMallURLData(); if (entity.errorCode!.codeIsSuccessful) { state.lockMallUrl.value = entity.data!.url!; state.mallWebView.setNavigationDelegate( NavigationDelegate( onProgress: (int progress) { - // Update loading bar. state.webProgress.value = progress / 100; }, onPageStarted: (String url) { @@ -40,6 +40,7 @@ class LockMallLogic extends BaseGetXController { onPageFinished: (String url) { state.webProgress.value = 1.0; refreshGoBack(); + update(); }, onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest request) async { @@ -53,27 +54,24 @@ class LockMallLogic extends BaseGetXController { ), ); state.mallWebView.loadRequest(Uri.parse(state.lockMallUrl.value)); - // FlutterBridge.postMessage({action:'',data:'{}',callFun:'回调给js的方法'}) state.mallWebView.addJavaScriptChannel( - "FlutterBridge", + 'FlutterBridge', onMessageReceived: (JavaScriptMessage message) async { flutterBridge(message); }, ); - // onMessageReceived } } //监听webview的调用 Future flutterBridge(JavaScriptMessage message) async { final dynamic obj = json.decode(message.message); - AppLog.log(obj.toString()); if (obj is! Map && obj['action'] is String) { return; } - String action = obj['action']; - dynamic data = obj['data']; - String? callFun = obj['callFun']; + final String action = obj['action']; + final dynamic data = obj['data']; + final String? callFun = obj['callFun']; switch (action) { case 'WechatPayParams': //微信支付 @@ -84,9 +82,9 @@ class LockMallLogic extends BaseGetXController { //微信支付 Future wxPay(dynamic data, String? callFun) async { - WxPayTool.pay(WxPayTool.mapToPayment(data), (response) { + WxPayTool.pay(WxPayTool.mapToPayment(data), (WeChatResponse response) { if (response is WeChatPaymentResponse) { - Map data = { + final Map data = { 'type': response.type, 'extData': response.extData, 'errCode': response.errCode, @@ -101,7 +99,7 @@ class LockMallLogic extends BaseGetXController { //判断webview 是否可以有路由可以回退,无则退出当前页面 Future canGoBack(bool didPop) async { - bool canGoBack = await state.mallWebView.canGoBack(); + final bool canGoBack = await state.mallWebView.canGoBack(); bool isMall = true; if (Get.isRegistered() && F.isXHJ) { isMall = Get.find().isMall; @@ -131,7 +129,7 @@ class LockMallLogic extends BaseGetXController { if (state.allowReturn) { return; } - state.mallWebView.canGoBack().then((value) { + state.mallWebView.canGoBack().then((bool value) { state.canGoBack = value; update(); }); diff --git a/lib/mine/mall/lockMall_page.dart b/lib/mine/mall/lockMall_page.dart index ef7614c6..1bd6b0b1 100755 --- a/lib/mine/mall/lockMall_page.dart +++ b/lib/mine/mall/lockMall_page.dart @@ -17,7 +17,7 @@ class LockMallPage extends StatefulWidget { State createState() => _LockMallPageState(); } -class _LockMallPageState extends State { +class _LockMallPageState extends State with AutomaticKeepAliveClientMixin { @override void initState() { super.initState(); @@ -25,8 +25,8 @@ class _LockMallPageState extends State { @override Widget build(BuildContext context) { - // FIXME 如果未登录状态,应先跳转登录页 - // FIXME url应该使用接口获取,接口名称 “获取商城跳转地址:/mall/getUrl“ POST请求,无参数,需要登录 + // 如果未登录状态,应先跳转登录页 + // url应该使用接口获取,接口名称 “获取商城跳转地址:/mall/getUrl“ POST请求,无参数,需要登录 // String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e'; return GetBuilder( init: LockMallLogic(allowReturn: widget.allowReturn), @@ -55,7 +55,7 @@ class _LockMallPageState extends State { PopScope( onPopInvoked: logic.canGoBack, canPop: false, - child: SizedBox(), + child: const SizedBox(), ), Container( padding: EdgeInsets.only(bottom: 10.w), @@ -76,10 +76,13 @@ class _LockMallPageState extends State { } String getWebTitle(LockMallLogic logic) { - String webTitleStr = "配件商城".tr; + String webTitleStr = '配件商城'.tr; logic.state.mallWebView.getTitle().then((result) { webTitleStr = result!; }); return webTitleStr; } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/mine/message/messageList/messageList_xhj_page.dart b/lib/mine/message/messageList/messageList_xhj_page.dart index b0837627..ecd5d31f 100755 --- a/lib/mine/message/messageList/messageList_xhj_page.dart +++ b/lib/mine/message/messageList/messageList_xhj_page.dart @@ -25,7 +25,7 @@ class MessageListXHJPage extends StatefulWidget { } class _MessageListXHJPageState extends State - with TickerProviderStateMixin { + with TickerProviderStateMixin ,AutomaticKeepAliveClientMixin { final MessageListLogic logic = Get.put(MessageListLogic()); final MessageListState state = Get.find().state; @@ -257,4 +257,7 @@ class _MessageListXHJPageState extends State ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/mine/mineSet/mineSet/mineSet_page.dart b/lib/mine/mineSet/mineSet/mineSet_page.dart index 55718339..51cd8e96 100755 --- a/lib/mine/mineSet/mineSet/mineSet_page.dart +++ b/lib/mine/mineSet/mineSet/mineSet_page.dart @@ -29,7 +29,8 @@ class MineSetPage extends StatefulWidget { State createState() => _MineSetPageState(); } -class _MineSetPageState extends State with WidgetsBindingObserver { +class _MineSetPageState extends State + with WidgetsBindingObserver, AutomaticKeepAliveClientMixin { final MineSetLogic logic = Get.put(MineSetLogic()); final MineSetState state = Get.find().state; @@ -590,4 +591,7 @@ class _MineSetPageState extends State with WidgetsBindingObserver { WidgetsBinding.instance.removeObserver(this); super.dispose(); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/tools/pay/wx_pay_tool.dart b/lib/tools/pay/wx_pay_tool.dart index d5231c51..20e025a5 100755 --- a/lib/tools/pay/wx_pay_tool.dart +++ b/lib/tools/pay/wx_pay_tool.dart @@ -5,8 +5,10 @@ import 'package:fluwx/fluwx.dart'; /// /// class WxPayTool { - static bool isInit = false; static Fluwx fluwx = Fluwx(); + static bool isInit = false; + static String associationUrl = ''; + static init(String appId, String universalLink) { fluwx.registerApi(appId: appId, universalLink: universalLink); @@ -15,7 +17,7 @@ class WxPayTool { static Future pay(Payment payment, WeChatResponseSubscriber listener) async { if (!isInit) { isInit = true; - await init(payment.appId, 'https://lock.skychip.top/apple-app-site-association.json'); + await init(payment.appId, associationUrl); //回调 responseListener(WeChatResponse response) { if (response is WeChatPaymentResponse) { @@ -30,7 +32,7 @@ class WxPayTool { } static Payment mapToPayment(dynamic data) { - Payment payment = Payment( + final Payment payment = Payment( appId: data['appId'], partnerId: data['partnerId'], prepayId: data['prepayId'],