修复个人信息页面部分bug

This commit is contained in:
Daisy 2024-03-05 09:29:49 +08:00
parent a6cabd25c9
commit c9e6d8f1e6
11 changed files with 106 additions and 115 deletions

View File

@ -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<StarLockMinePage> with BaseWidget {
children: [
topWidget(),
bottomListWidget(),
SizedBox(height: 40.h,),
SizedBox(
height: 40.h,
),
// keyBottomWidget()
],
),
@ -92,7 +93,8 @@ class _StarLockMinePageState extends State<StarLockMinePage> 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<StarLockMinePage> 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);
}),
],
),

View File

@ -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;

View File

@ -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';

View File

@ -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<void> 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<String, dynamic> user = minePersonGetUploadFileInfoEntity.data!.formData!;
user[minePersonGetUploadFileInfoEntity.data!.fileField!] = state.image!.path;
Map<String, dynamic> 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<void> 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
}
}

View File

@ -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<MinePersonInfoPage> {
final logic = Get.put(MinePersonInfoLogic());
final state = Get.find<MinePersonInfoLogic>().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<MinePersonInfoPage> {
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: () {
// isFrom1 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: () {
// isFrom1 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<MinePersonInfoPage> {
}),
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<MinePersonInfoPage> {
})),
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<MinePersonInfoPage> {
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(() {});
}
}
}

View File

@ -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;

View File

@ -23,7 +23,7 @@ class MineSetSafetyProblemLogic extends BaseGetXController {
//
Future<void> 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);

View File

@ -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);
}
}
//

View File

@ -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);
}

View File

@ -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(),