From c9e6d8f1e655a010dee1417bf68cf0bb5ee80931 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 5 Mar 2024 09:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=A1=B5=E9=9D=A2=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/mine/mine/starLockMine_page.dart | 22 ++-- .../lib/mine/mine/starLockMine_state.dart | 6 - .../MinePersonInfoEditName_logic.dart | 2 +- ...dart => minePersonInfoEditName_state.dart} | 0 .../minePersonInfo_logic.dart | 39 +++--- .../minePersonInfo_page.dart | 114 ++++++++++-------- .../minePersonInfo_state.dart | 6 - .../minePersonInfoSetSafetyProblem_logic.dart | 2 +- .../minePersonInfoSetSafetyProblem_page.dart | 8 +- star_lock/lib/network/api_repository.dart | 11 +- star_lock/lib/tools/commonItem.dart | 11 +- 11 files changed, 106 insertions(+), 115 deletions(-) rename star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/{MinePersonInfoEditNamePage_state.dart => minePersonInfoEditName_state.dart} (100%) diff --git a/star_lock/lib/mine/mine/starLockMine_page.dart b/star_lock/lib/mine/mine/starLockMine_page.dart index 0cdb41fe..a71aeb41 100644 --- a/star_lock/lib/mine/mine/starLockMine_page.dart +++ b/star_lock/lib/mine/mine/starLockMine_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -32,7 +31,9 @@ class _StarLockMinePageState extends State with BaseWidget { children: [ topWidget(), bottomListWidget(), - SizedBox(height: 40.h,), + SizedBox( + height: 40.h, + ), // keyBottomWidget() ], ), @@ -92,7 +93,8 @@ class _StarLockMinePageState extends State with BaseWidget { SizedBox( height: 10.h, ), - Text("${TranslationLoader.lanKeys!.accountNumber!.tr}:${state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value}", + Text( + "${TranslationLoader.lanKeys!.accountNumber!.tr}:${state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value}", style: TextStyle( fontSize: 18.sp, color: Colors.white, @@ -147,15 +149,15 @@ class _StarLockMinePageState extends State with BaseWidget { Get.back(); Get.toNamed(Routers.valueAddedServicesPage); }), - mineItem('images/mine/icon_mine_main_shoppingcart.png', - "配件商城".tr, () { - Get.back(); - Get.toNamed(Routers.LockMallPage); - }), + mineItem('images/mine/icon_mine_main_shoppingcart.png', "配件商城".tr, + () { + Get.back(); + Get.toNamed(Routers.LockMallPage); + }), mineItem('images/mine/icon_mine_main_about.png', TranslationLoader.lanKeys!.about!.tr, () { - Get.back(); - Get.toNamed(Routers.aboutPage); + Get.back(); + Get.toNamed(Routers.aboutPage); }), ], ), diff --git a/star_lock/lib/mine/mine/starLockMine_state.dart b/star_lock/lib/mine/mine/starLockMine_state.dart index b9c346da..3acfa16c 100644 --- a/star_lock/lib/mine/mine/starLockMine_state.dart +++ b/star_lock/lib/mine/mine/starLockMine_state.dart @@ -1,11 +1,5 @@ -import 'dart:convert'; - import 'package:get/get.dart'; -import '../../login/login/entity/LoginData.dart'; -import '../../login/login/entity/LoginEntity.dart'; -import '../../tools/storage.dart'; - class StarLockMineState { // final loginData = LoginData().obs; diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditName_logic.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditName_logic.dart index 8f2921fa..933338ac 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditName_logic.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditName_logic.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; -import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditNamePage_state.dart'; +import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_state.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditNamePage_state.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_state.dart similarity index 100% rename from star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/MinePersonInfoEditNamePage_state.dart rename to star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_state.dart diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart index 9ba92ced..48ac85f3 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart @@ -1,23 +1,20 @@ import 'dart:async'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; +import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; import 'minePersonGetUploadFileInfo_entity.dart'; -class MinePersonInfoLogic extends GetConnect{ +class MinePersonInfoLogic extends GetConnect { final MinePersonInfoState state = MinePersonInfoState(); //用户信息 Future getUserInfoRequest() async { - var entity = await ApiRepository.to.getUserInfo(""); + MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(""); if (entity.errorCode!.codeIsSuccessful) { + print('到了这里么'); state.mineInfoData.value = entity.data!; - state.nickname.value = entity.data!.nickname!; - state.mobileStr.value = entity.data!.mobile!; - state.emailStr.value = entity.data!.email!; - state.countryStr.value = entity.data!.countryName!; - state.haveSafeAnswer.value = entity.data!.haveSafeAnswer!; } } @@ -28,8 +25,7 @@ class MinePersonInfoLogic extends GetConnect{ typeKey: 'userId', type: state.mineInfoData.value.uid!.toString(), filename: filename, - size: size - ); + size: size); if (entity.errorCode!.codeIsSuccessful) { uploadFile(entity); // print("aaaaa:$loginEntity"); @@ -37,7 +33,9 @@ class MinePersonInfoLogic extends GetConnect{ } // 上传头像 - void uploadFile(MinePersonGetUploadFileInfoEntity minePersonGetUploadFileInfoEntity) async { + void uploadFile( + MinePersonGetUploadFileInfoEntity + minePersonGetUploadFileInfoEntity) async { // String json = JsonDecoder(minePersonGetUploadFileInfoEntity.data!.formData!); // var formData = FormData(); @@ -47,16 +45,14 @@ class MinePersonInfoLogic extends GetConnect{ // MultipartFile(state.image!.path, filename: 'b'), // )); - Map user = minePersonGetUploadFileInfoEntity.data!.formData!; - user[minePersonGetUploadFileInfoEntity.data!.fileField!] = state.image!.path; + Map user = + minePersonGetUploadFileInfoEntity.data!.formData!; + user[minePersonGetUploadFileInfoEntity.data!.fileField!] = + state.image!.path; final form = FormData(user); var entity = await ApiRepository.to.uploadFile( - url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, - body: form - ); - if (entity.errorCode!.codeIsSuccessful) { - - } + url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, body: form); + if (entity.errorCode!.codeIsSuccessful) {} // final formData = FormData.fromMap({ // 'file': await MultipartFile.fromFile(imageFile.path, contentType: MediaType.parse(mimeType)) @@ -72,12 +68,13 @@ class MinePersonInfoLogic extends GetConnect{ 'file': MultipartFile(image, filename: 'avatar.png'), 'otherFile': MultipartFile(image, filename: 'cover.png'), }); - Response response= await post('http://youapi/users/upload', form); + Response response = await post('http://youapi/users/upload', form); } //更新个人信息-头像 Future updateUserInfoRequest() async { - var entity = await ApiRepository.to.updateUserInfo(state.headUrl.value); + var entity = await ApiRepository.to + .updateUserInfo(state.mineInfoData.value.headUrl!); if (entity.errorCode!.codeIsSuccessful) { EasyLoading.showToast("操作成功", duration: 2000.milliseconds); } @@ -99,10 +96,8 @@ class MinePersonInfoLogic extends GetConnect{ getUserInfoRequest(); } - @override void onClose() { // TODO: implement onClose - } } diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart index af614314..ac26b9b7 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -23,12 +24,11 @@ class _MinePersonInfoPageState extends State { final logic = Get.put(MinePersonInfoLogic()); final state = Get.find().state; - // @override - // void initState() { - // super.initState(); - // - // logic.getUserInfoRequest(); - // } + @override + initState() { + super.initState(); + logic.getUserInfoRequest(); + } @override Widget build(BuildContext context) { @@ -40,88 +40,96 @@ class _MinePersonInfoPageState extends State { backgroundColor: AppColors.mainColor), body: Column( children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.avatar!.tr, - rightTitle: "", - allHeight: 100.h, - isHaveLine: true, - isHaveDirection: true, - isHaveRightWidget: true, - rightWidget: ClipOval( - child: state.image != null - ? Image.file( - File(state.image!.path), - width: 72.w, - height: 72.w, - fit: BoxFit.fill, - ) - : Image.asset( - 'images/controls_user.png', - width: 72.w, - height: 72.w, - fit: BoxFit.fill, - ), - ), - action: () { - _openModalBottomSheet(); - }, - ), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.avatar!.tr, + rightTitle: "", + allHeight: 100.h, + isHaveLine: true, + isHaveDirection: true, + isHaveRightWidget: true, + rightWidget: ClipOval( + child: state.mineInfoData.value.headUrl != null + ? CachedNetworkImage( + imageUrl: Uri.encodeFull( + state.mineInfoData.value.headUrl!), + width: 72.w, + height: 72.w, + fit: BoxFit.fill, + placeholder: (context, url) => Image.asset( + 'images/controls_user.png', + width: 72.w, + height: 72.w, + fit: BoxFit.fill, + )) + : Image.asset( + 'images/controls_user.png', + width: 72.w, + height: 72.w, + fit: BoxFit.fill, + ), + ), + action: () { + _openModalBottomSheet(); + }, + )), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.nickName!.tr, - rightTitle: state.nickname.value, + rightTitle: state.mineInfoData.value.nickname != null + ? state.mineInfoData.value.nickname! + : "", isHaveLine: true, isHaveDirection: true, action: () { Navigator.pushNamed( - context, Routers.minePersonInfoEditNamePage, - arguments: {'nickName': state.nickname.value}) - .then((value) => logic.getUserInfoRequest()); + context, Routers.minePersonInfoEditNamePage, arguments: { + 'nickName': state.mineInfoData.value.nickname + }).then((value) => logic.getUserInfoRequest()); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.mobileNumber!.tr, - rightTitle: state.mobileStr.value.isNotEmpty - ? state.mobileStr.value + rightTitle: state.mineInfoData.value.mobile != null + ? state.mineInfoData.value.mobile! : TranslationLoader.lanKeys!.goBind!.tr, isHaveLine: true, isHaveDirection: true, action: () { //有手机号 则去修改手机号 否则去绑定新的手机号 isFrom:1 短信,2 邮箱 - if (state.mobileStr.value.isNotEmpty) { + if (state.mineInfoData.value.mobile!.isNotEmpty) { Navigator.pushNamed( context, Routers.mineUnbindPhoneOrEmailPage, arguments: { - 'mobile': state.mobileStr.value, + 'mobile': state.mineInfoData.value.mobile!, 'isFrom': '1' }).then((value) => logic.getUserInfoRequest()); } else { Navigator.pushNamed( context, Routers.mineBindPhoneOrEmailPage, arguments: { - 'mobile': state.mobileStr.value, + 'mobile': state.mineInfoData.value.mobile!, 'isFrom': '1' }).then((value) => logic.getUserInfoRequest()); } })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.email!.tr, - rightTitle: state.emailStr.value.isNotEmpty - ? state.emailStr.value + rightTitle: state.mineInfoData.value.email != null + ? state.mineInfoData.value.email! : TranslationLoader.lanKeys!.goBind!.tr, isHaveLine: true, isHaveDirection: true, action: () { //有邮箱 则去修改邮箱 否则去绑定新的邮箱 isFrom:1 短信,2 邮箱 - if (state.emailStr.value.isNotEmpty) { + if (state.mineInfoData.value.email!.isNotEmpty) { Navigator.pushNamed( context, Routers.mineUnbindPhoneOrEmailPage, arguments: { 'isFrom': '2', - 'email': state.emailStr.value + 'email': state.mineInfoData.value.email! }).then((value) => logic.getUserInfoRequest()); } else { Navigator.pushNamed( context, Routers.mineBindPhoneOrEmailPage, arguments: { 'isFrom': '2', - 'email': state.emailStr.value + 'email': state.mineInfoData.value.email! }).then((value) => logic.getUserInfoRequest()); } })), @@ -136,11 +144,12 @@ class _MinePersonInfoPageState extends State { }), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.safetyProblem!.tr, - rightTitle: state.haveSafeAnswer.value == 0 ? "去设置" : "", + rightTitle: + state.mineInfoData.value.haveSafeAnswer == 0 ? "去设置" : "", isHaveLine: true, isHaveDirection: true, action: () { - if (state.haveSafeAnswer.value == 0) { + if (state.mineInfoData.value.haveSafeAnswer == 0) { Navigator.pushNamed( context, Routers.minePersonInfoSetSafetyProblemPage) .then((value) => logic.getUserInfoRequest()); @@ -151,7 +160,9 @@ class _MinePersonInfoPageState extends State { })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: state.countryStr.value, + rightTitle: state.mineInfoData.value.countryName != null + ? state.mineInfoData.value.countryName! + : "", isHaveLine: false, isHaveDirection: false)), ], @@ -203,9 +214,10 @@ class _MinePersonInfoPageState extends State { var bytes = File(state.image!.path); var enc = await bytes.readAsBytes(); print(enc.length); - print("state.image!.path:${state.image!.path} state.image!.name:${state.image!.name} state.image!.length():${state.image!.length()}"); + print( + "state.image!.path:${state.image!.path} state.image!.name:${state.image!.name} state.image!.length():${state.image!.length()}"); logic.getUpTokenRequest(state.image!.name, enc.length); - setState((){}); + setState(() {}); } } } diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart index 55825f50..4f4ac5b1 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart @@ -5,13 +5,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_ class MinePersonInfoState { final mineInfoData = MinePersonInfoData().obs; - var nickname = ''.obs; //昵称 - var mobileStr = ''.obs; //手机号 - var emailStr = ''.obs; //邮箱 - var countryStr = ''.obs; //国家/地区 - var haveSafeAnswer = 0.obs; //是否已设置安全问题 var typeStr = '2'.obs; //2:上传头像 - var headUrl = ''.obs; //头像url // ImagePicker获取内容后返回的对象是XFile XFile? image; diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_logic.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_logic.dart index e41f7f6f..6ed7a709 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_logic.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_logic.dart @@ -23,7 +23,7 @@ class MineSetSafetyProblemLogic extends BaseGetXController { //设置安全信息 Future setSafeAnswerRequest() async { var entity = - await ApiRepository.to.setSafeAnswer(state.questionAndAnswerList); + await ApiRepository.to.setSafeAnswer(state.questionAndAnswerList.value); if (entity.errorCode!.codeIsSuccessful) { showToast("操作成功"); Get.until((route) => route.settings.name == Routers.minePersonInfoPage); diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_page.dart index 36257526..a66267a8 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_page.dart @@ -78,26 +78,26 @@ class _MinePersonInfoSetSafetyProblemPageState btnName: TranslationLoader.lanKeys!.sure!.tr, isDisabled: state.canSub.value, onClick: () { - //state.questionAndAnswerList + state.questionAndAnswerList.value.clear(); for (int i = 0; i < 3; i++) { if (i == 0) { SafetyProblemData data = SafetyProblemData(); data.question = state.firstProblemStr.value; data.answer = state.firstAnswerStr.value; data.questionId = state.firstQuestionId.value; - state.questionAndAnswerList.add(data); + state.questionAndAnswerList.value.add(data); } else if (i == 1) { SafetyProblemData data = SafetyProblemData(); data.question = state.secondProblemStr.value; data.answer = state.secondAnswerStr.value; data.questionId = state.secondQuestionId.value; - state.questionAndAnswerList.add(data); + state.questionAndAnswerList.value.add(data); } else if (i == 2) { SafetyProblemData data = SafetyProblemData(); data.question = state.thirdProblemStr.value; data.answer = state.thirdAnswerStr.value; data.questionId = state.thirdQuestionId.value; - state.questionAndAnswerList.add(data); + state.questionAndAnswerList.value.add(data); } } //设置安全信息接口 diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 9ad01031..eba142d8 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -403,15 +403,8 @@ class ApiRepository { required int startHours, required int endHours, required int isCoerced}) async { - final res = await apiProvider.getKeyboardPwd( - endDate, - keyboardPwdName, - keyboardPwdType, - lockId, - startDate, - startHours, - endHours, - isCoerced); + final res = await apiProvider.getKeyboardPwd(endDate, keyboardPwdName, + keyboardPwdType, lockId, startDate, startHours, endHours, isCoerced); return PasswordKeyEntity.fromJson(res.body); } diff --git a/star_lock/lib/tools/commonItem.dart b/star_lock/lib/tools/commonItem.dart index 6c672787..4f325d65 100644 --- a/star_lock/lib/tools/commonItem.dart +++ b/star_lock/lib/tools/commonItem.dart @@ -43,8 +43,7 @@ class CommonItem extends StatelessWidget { SizedBox(width: 20.w), SizedBox( // width: isHaveRightWidget! ? 100.w : 300.w, - child: Text(leftTitel!, style: TextStyle(fontSize: 22.sp)) - ), + child: Text(leftTitel!, style: TextStyle(fontSize: 22.sp))), SizedBox(width: 6.w), isTipsImg == true ? Image.asset( @@ -60,15 +59,17 @@ class CommonItem extends StatelessWidget { isHaveRightWidget! ? rightWidget! : SizedBox( - width: rightTitle!.isNotEmpty ? 250.w : 0.1.w, + width: rightTitle!.isNotEmpty ? 260.w : 0.1.w, child: Text( rightTitle ?? "", textAlign: TextAlign.right, overflow: TextOverflow.ellipsis, maxLines: 2, - style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + style: TextStyle( + fontSize: 22.sp, + color: AppColors.darkGrayTextColor), ), - ), + ), ], ), isHaveDirection! ? SizedBox(width: 3.w) : Container(),