Browse Source

增加控制器重置,优化修改资料

master
王子贤 3 months ago
parent
commit
5602aa1794
3 changed files with 61 additions and 40 deletions
  1. 2
      lib/controller/global.dart
  2. 48
      lib/controller/mine/edit_info_controller.dart
  3. 51
      lib/pages/mine/edit_info_page.dart

2
lib/controller/global.dart

@ -2,6 +2,7 @@
import 'dart:io';
import 'package:dating_touchme_app/controller/discover/discover_controller.dart';
import 'package:dating_touchme_app/controller/discover/room_controller.dart';
import 'package:dating_touchme_app/controller/home/home_controller.dart';
import 'package:dating_touchme_app/controller/message/conversation_controller.dart';
import 'package:get/get.dart';
@ -27,6 +28,7 @@ class GlobalData {
Get.delete<HomeController>(force: true);
Get.delete<DiscoverController>(force: true);
Get.delete<RoomController>(force: true);
Get.delete<ConversationController>(force: true);
Get.delete<MineController>(force: true);
}

48
lib/controller/mine/edit_info_controller.dart

@ -107,7 +107,6 @@ class EditInfoController extends GetxController {
@override
void onInit() {
super.onInit();
userData.value = GlobalData().userData;
final ImagePickerPlatform imagePickerImplementation =
ImagePickerPlatform.instance;
if (imagePickerImplementation is ImagePickerAndroid) {
@ -116,6 +115,13 @@ class EditInfoController extends GetxController {
_userApi = Get.find<UserApi>();
getBaseData();
}
getBaseData() async {
await getInfo();
getEducationList();
getIncomeList();
getMaritalList();
@ -544,27 +550,21 @@ class EditInfoController extends GetxController {
savaImgList() async {
try{
final imgPayload = {
final originImg = userData.value!.photoList!.map((e) => e.photoUrl).toSet();
final result = imgList
.where((e) => !originImg.contains(e))
.toList();
final imgPayload = {
'miId': userData.value?.id ?? 0,
'authenticationCode': '6',
'value': '0',
'imgUrl': imgList.isNotEmpty ? imgList : ['0'],
'imgUrl': result.isNotEmpty ? result : ['0'],
};
final imgAuditResp = await _userApi.saveCertificationAudit(imgPayload);
if (imgAuditResp.data.isSuccess) {
final result = await _userApi.getMarriageInformationDetail();
// print(result.data);
if (result.data.isSuccess) {
final information = result.data.data!;
information.matchmakerFlag = userData.value?.matchmakerFlag ?? false;
information.realName = userData.value?.realName;
information.phone = userData.value?.phone;
GlobalData().userData = information;
await storage.write('userId', GlobalData().userId);
}
getInfo();
} else{
SmartDialog.showToast(imgAuditResp.data.message);
@ -579,6 +579,24 @@ class EditInfoController extends GetxController {
}
}
getInfo() async {
final result = await _userApi.getMarriageInformationDetail();
// print(result.data);
if (result.data.isSuccess) {
final information = result.data.data!;
information.matchmakerFlag = userData.value?.matchmakerFlag ?? false;
information.realName = userData.value?.realName;
information.phone = userData.value?.phone;
GlobalData().userData = information;
userData.value = GlobalData().userData;
await storage.write('userId', GlobalData().userId);
setData();
}
}
deleteImgList(int index) async {
if(userData.value!.photoList!.length > index){

51
lib/pages/mine/edit_info_page.dart

@ -398,34 +398,15 @@ class _EditInfoPageState extends State<EditInfoPage> {
fit: BoxFit.cover,
),
),
if(controller.userData.value!.photoList!.isNotEmpty && controller.userData.value!.photoList!.length > entry.key)Positioned(
left: 5.w,
top: 5.w,
child: Container(
width: 20.w,
height: 20.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.w)),
color: const Color.fromRGBO(0, 0, 0, .3)
),
child: Icon(
Icons.close,
size: 20.w,
),
).onTap((){
controller.deleteImgList(entry.key);
}),
),
if(controller.userData.value!.photoList!.isNotEmpty && controller.userData.value!.photoList!.length > entry.key && controller.userData.value!.photoList![entry.key].auditStatus == 0)Positioned(
top: 0,
right: 0,
child: Container(
width: 33.w,
height: 17.w,
width: 70.w,
height: 70.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(9.w),
bottomLeft: Radius.circular(9.w)
borderRadius: BorderRadius.all(
Radius.circular(9.w)
),
color: const Color.fromRGBO(0, 0, 0, .4)
),
@ -433,14 +414,34 @@ class _EditInfoPageState extends State<EditInfoPage> {
child: Text(
"审核中",
style: TextStyle(
fontSize: 8.w,
fontSize: 10.w,
color: Colors.white,
fontWeight: FontWeight.w500
),
),
),
),
)
),
if(controller.userData.value!.photoList!.isNotEmpty && controller.userData.value!.photoList!.length > entry.key)Positioned(
right: 5.w,
top: 5.w,
child: Container(
width: 20.w,
height: 20.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.w)),
color: const Color.fromRGBO(0, 0, 0, .3)
),
child: Icon(
Icons.close,
size: 20.w,
color: Colors.white,
),
).onTap((){
controller.deleteImgList(entry.key);
}),
),
],
);
}),

Loading…
Cancel
Save