From 79f189ff60125907f4155b8605ea0b99c1093494 Mon Sep 17 00:00:00 2001 From: ante <448468458@qq.com> Date: Tue, 16 Apr 2024 09:58:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=A2=91=E7=8E=87=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_zh.json | 1 + .../face_authentication_entity.dart | 25 +++ .../valueAddedServicesRealName_page.dart | 198 ++++++++---------- .../value_added_services_real_name_logic.dart | 46 ++++ .../value_added_services_real_name_state.dart | 3 + star_lock/lib/network/api.dart | 9 +- star_lock/lib/network/api_provider.dart | 7 + star_lock/lib/network/api_repository.dart | 9 + 8 files changed, 183 insertions(+), 115 deletions(-) create mode 100644 star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart create mode 100644 star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_logic.dart create mode 100644 star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 374cf216..189822f3 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -687,6 +687,7 @@ "虹膜":"虹膜", "手掌":"手掌", + "商城":"商城", "我的":"我的" } diff --git a/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart new file mode 100644 index 00000000..a1c685f0 --- /dev/null +++ b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart @@ -0,0 +1,25 @@ +class FaceAuthenticationEntity { + FaceAuthenticationEntity({ + this.description, + this.errorCode, + this.errorMsg, + }); + + FaceAuthenticationEntity.fromJson(dynamic json) { + description = json['description']; + errorCode = json['errorCode']; + errorMsg = json['errorMsg']; + } + + String? description; + int? errorCode; + String? errorMsg; + + Map toJson() { + final map = {}; + map['description'] = description; + map['errorCode'] = errorCode; + map['errorMsg'] = errorMsg; + return map; + } +} diff --git a/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/valueAddedServicesRealName_page.dart b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/valueAddedServicesRealName_page.dart index 0b3a8dec..bafb4363 100644 --- a/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/valueAddedServicesRealName_page.dart +++ b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/valueAddedServicesRealName_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/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_logic.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/commonItem.dart'; import '../../../tools/titleAppBar.dart'; @@ -18,29 +19,33 @@ class _ValueAddedServicesRealNamePageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.realNameAuthentication!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - Container( - width: 1.sw, - // color: Colors.grey.shade300, - padding: EdgeInsets.only( - left: 25.h, right: 25.h, top: 25.h, bottom: 10.h), - child: Text( - TranslationLoader.lanKeys!.buyRealNameTip!.tr, - style: TextStyle( - color: AppColors.darkGrayTextColor, fontSize: 20.sp), - )), - middleWidget(), - bottomWidget() - ], - ), - ); + return GetBuilder( + init: ValueAddedServicesRealNameLogic(), + builder: (ValueAddedServicesRealNameLogic logic) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.realNameAuthentication!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + Container( + width: 1.sw, + // color: Colors.grey.shade300, + padding: EdgeInsets.only( + left: 25.h, right: 25.h, top: 25.h, bottom: 10.h), + child: Text( + TranslationLoader.lanKeys!.buyRealNameTip!.tr, + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 20.sp), + )), + middleWidget(), + bottomWidget() + ], + ), + ); + }); } Widget middleWidget() { @@ -112,98 +117,65 @@ class _ValueAddedServicesRealNamePageState } Widget bottomWidget() { - return Container( - width: 1.sw, - color: Colors.white, - margin: EdgeInsets.all(20.h), - child: Column( - children: [ - Column( + return GetBuilder( + builder: (ValueAddedServicesRealNameLogic logic) { + return Container( + width: 1.sw, + color: Colors.white, + margin: EdgeInsets.all(20.h), + child: Column( + children: [ + Column( + children: [ + Container( + padding: + EdgeInsets.only(top: 20.h, bottom: 20.h, left: 30.w), + child: Text( + TranslationLoader + .lanKeys!.buyRealNameSelectYouWantBuyTip!.tr, + style: TextStyle( + fontSize: 24.sp, fontWeight: FontWeight.w600), + )), + ], + ), + checkCommonItem( + logic, TranslationLoader.lanKeys!.forTheFirstTime!.tr, 0), + checkCommonItem(logic, TranslationLoader.lanKeys!.onceDay!.tr, 1), + checkCommonItem(logic, TranslationLoader.lanKeys!.weekOnce!.tr, 2), + checkCommonItem(logic, TranslationLoader.lanKeys!.monthOnce!.tr, 3, + isHaveLine: false, isHaveRightWidget: true), + ], + ), + ); + }); + } + + //选择组件 + Widget checkCommonItem( + ValueAddedServicesRealNameLogic logic, String text, int index, + {bool isHaveLine = true, bool isHaveRightWidget = true}) { + bool check = logic.state.index == index; + return CommonItem( + leftTitel: text, + rightTitle: "", + allHeight: 60.h, + isHaveLine: isHaveLine, + isHaveRightWidget: isHaveRightWidget, + rightWidget: GestureDetector( + onTap: () { + logic.check(index); + }, + child: Row( children: [ - Container( - padding: EdgeInsets.only(top: 20.h, bottom: 20.h, left: 30.w), - child: Text( - TranslationLoader - .lanKeys!.buyRealNameSelectYouWantBuyTip!.tr, - style: - TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), - )), + Image.asset( + check + ? 'images/icon_round_select.png' + : 'images/icon_round_unSelect.png', + width: 30.w, + height: 30.w, + ), ], ), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.forTheFirstTime!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelect.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.onceDay!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelect.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.weekOnce!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelect.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.monthOnce!.tr, - rightTitle: "", - allHeight: 60.h, - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelect.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - ], - ), - ); + )); } } diff --git a/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_logic.dart b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_logic.dart new file mode 100644 index 00000000..f6b6d2d3 --- /dev/null +++ b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_logic.dart @@ -0,0 +1,46 @@ +import 'dart:async'; + +import 'package:get/utils.dart'; +import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart'; +import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../network/api_repository.dart'; +import '../../../tools/eventBusEventManage.dart'; + +class ValueAddedServicesRealNameLogic extends BaseGetXController { + final ValueAddedServicesRealNameState state = + ValueAddedServicesRealNameState(); + + //请求消息列表 + Future setFaceAuthentication(int faceAuthFrequence) async { + FaceAuthenticationEntity entity = + await ApiRepository.to.setFaceAuthentication( + faceAuthFrequence: faceAuthFrequence, + ); + return entity.errorCode!.codeIsSuccessful; + } + + Future check(int index) async { + bool isSuccessful = await setFaceAuthentication(state.index + 1); + if (isSuccessful) { + showToast('修改成功'.tr); + state.index = index; + } + update(); + } + + @override + void onReady() { + super.onReady(); + } + + @override + void onInit() { + super.onInit(); + } + + @override + void onClose() { + super.onClose(); + } +} diff --git a/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart new file mode 100644 index 00000000..b9dff32e --- /dev/null +++ b/star_lock/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart @@ -0,0 +1,3 @@ +class ValueAddedServicesRealNameState { + int index = 0; +} diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 8f9cd047..b2759463 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -45,7 +45,8 @@ abstract class Api { final String passwordKeyGetURL = '/keyboardPwd/get'; //获取密码 final String passwordKeyAddURL = '/keyboardPwd/add'; //自定义密码 - final String passwordKeyCheckKeyboardpwdNameURL = '/keyboardPwd/checkKeyboardpwdName'; //自定义密码校验密码跟名字是否重复 + final String passwordKeyCheckKeyboardpwdNameURL = + '/keyboardPwd/checkKeyboardpwdName'; //自定义密码校验密码跟名字是否重复 final String updatePasswordKeyURL = '/keyboardPwd/update'; //修改密码详情 final String clearOperationRecordURL = '/lockRecords/clear'; //清空操作记录 final String addlockGroupURL = '/keyGroup/add'; //创建锁分组 @@ -175,7 +176,8 @@ abstract class Api { '/safeAnswer/getOwnQuestionList'; //获取已设置的安全信息 final String updateSafeAnswerURL = '/safeAnswer/update'; //修改安全信息 final String setSafeAnswerURL = '/safeAnswer/set'; //设置安全信息 - final String getUpTokenURL = '/file/getUploadParams'; //上传头像 先获取upToken 再调用updateUserInfo + final String getUpTokenURL = + '/file/getUploadParams'; //上传头像 先获取upToken 再调用updateUserInfo final String unbindPhoneTokenURL = '/user/unbindPhoneToken'; //获取解绑手机号Token final String unbindEmailTokenURL = '/user/unbindEmailToken'; //获取解绑邮箱Token final String pushBindAppIdURL = '/user/bindAppId'; //推送绑定APP设备 @@ -193,4 +195,7 @@ abstract class Api { final String getLockNoticeSettingURL = '/lockSetting/getLockNoticeSetting'; //获取锁消息设置 + + final String setFaceAuthenticationURL = + '/v2/service/setFaceAuthentication'; //设置实名认证频次 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index b4e0d1e2..a62bf25e 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -1779,6 +1779,13 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'lockId': lockId, })); + + // 设置实名认证频次 + Future setFaceAuthentication(int faceAuthFrequence) => post( + setFaceAuthenticationURL.toUrl, + jsonEncode({ + 'face_auth_frequence': faceAuthFrequence, + })); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 479de7f5..d0ac4acc 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -21,6 +21,7 @@ import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElect import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart'; import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart'; +import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart'; import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; @@ -1813,4 +1814,12 @@ class ApiRepository { final res = await apiProvider.getLockNoticeSetting(lockId); return VersionUndateEntity.fromJson(res.body); } + + + // 获取锁消息设置 + Future setFaceAuthentication( + {required int faceAuthFrequence}) async { + final res = await apiProvider.setFaceAuthentication(faceAuthFrequence); + return FaceAuthenticationEntity.fromJson(res.body); + } }