Browse Source

优化上传相册,增加简介信息,昵称可修改

master
王子贤 2 months ago
parent
commit
0c0c6ee1f2
4 changed files with 193 additions and 64 deletions
  1. 71
      lib/controller/mine/edit_info_controller.dart
  2. 2
      lib/pages/home/user_information_page.dart
  3. 80
      lib/pages/mine/edit_info_page.dart
  4. 104
      lib/pages/mine/signature_page.dart

71
lib/controller/mine/edit_info_controller.dart

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:dating_touchme_app/controller/global.dart';
@ -34,6 +35,13 @@ class EditInfoController extends GetxController {
final birthday = ''.obs;
final message = ''.obs;
final messageController = TextEditingController().obs;
final name = ''.obs;
final nameController = TextEditingController().obs;
//
void selectBirthday(String selectedDate) {
birthday.value = selectedDate;
@ -292,6 +300,20 @@ class EditInfoController extends GetxController {
}
birthday.value = userData.value?.birthDate ?? "";
message.value = userData.value?.describeInfo ?? "";
messageController.value.value = TextEditingValue(
text: message.value,
selection: TextSelection.fromPosition(TextPosition(offset: message.value.length)),
);
name.value = userData.value?.nickName ?? "";
nameController.value.value = TextEditingValue(
text: name.value,
selection: TextSelection.fromPosition(TextPosition(offset: name.value.length)),
);
}
goPreview() {
@ -398,7 +420,9 @@ class EditInfoController extends GetxController {
final ImagePicker picker = ImagePicker();
final List<XFile>? image = await picker.pickMultiImage(limit: 9 - imgList.length);
if (image != null) {
print(image);
if (image != null && image.isNotEmpty) {
final futures = image.map((e){
return processSelectedMoreImage(File(e.path), type);;
});
@ -579,6 +603,37 @@ class EditInfoController extends GetxController {
}
}
savaDescribeInfo() async {
try{
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': '7',
'value': message.value,
'imgUrl': ['0'],
};
final imgAuditResp = await _userApi.saveCertificationAudit(imgPayload);
if (imgAuditResp.data.isSuccess) {
getInfo();
SmartDialog.showToast("交友心声已提交审核");
} else{
SmartDialog.showToast(imgAuditResp.data.message);
return;
}
} catch(e){
print('相册提交审核失败: $e');
SmartDialog.showToast('交友心声提交审核失败,请重试');
return;
}
}
getInfo() async {
final result = await _userApi.getMarriageInformationDetail();
// print(result.data);
@ -643,6 +698,18 @@ class EditInfoController extends GetxController {
}
}
Timer? _debounce;
void onTextChanged(String text) {
//
_debounce?.cancel();
_debounce = Timer(const Duration(milliseconds: 500), () {
name.value = text;
saveData();
});
}
saveData() async {
@ -664,7 +731,7 @@ class EditInfoController extends GetxController {
'hometownCityName': homeLocation.value != "" ? homeLocation.value.split("-")[1] : "",
"incomeCode": incomeSelect.value != -1 ? incomeList[incomeSelect.value].value : "",
"maritalStatusCode": maritalSelect.value != -1 ? maritalList[maritalSelect.value].value : "",
"nickName": userData.value?.nickName ?? "",
"nickName": name.value,
'occupation': occupation.value != "" ? occupation.value.split("-")[1] : "",
'occupationCode': occupationValue.length >= 2 ? occupationValue[1] : "",
"propertyPermitsCode": propertySelect.value != -1 ? propertyList[propertySelect.value].value : "",

2
lib/pages/home/user_information_page.dart

@ -273,7 +273,7 @@ class UserInformationPage extends StatelessWidget {
),
SizedBox(height: 8.w,),
Text(
"父母催婚找个结婚的",
controller.userData.value.describeInfo ?? "我想找一个有缘的异性,快来联系我吧。",
style: TextStyle(
fontSize: 14.w,
color: const Color.fromRGBO(144, 144, 144, 1)

80
lib/pages/mine/edit_info_page.dart

@ -497,13 +497,37 @@ class _EditInfoPageState extends State<EditInfoPage> {
],
),
SizedBox(height: 2.w,),
SetItem(label: "昵称", child: Text(
controller.userData.value?.nickName ?? "",
SetItem(label: "昵称", child: Expanded(child: TextField(
controller: controller.nameController.value,
textAlign: TextAlign.right,
textAlignVertical: TextAlignVertical.center,
style: TextStyle(
fontSize: 13.w,
fontWeight: FontWeight.w500
fontSize: ScreenUtil().setWidth(13),
height: 1
),
), hideArrow: true,),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.only(
left: 0,
right: -8
),
hintText: "请输入昵称",
border: const OutlineInputBorder(
borderSide: BorderSide.none, // //
),
// focusedBorder enabledBorder
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
onChanged: controller.onTextChanged,
))),
SetItem(label: "性别", child: Text(
"${controller.userData.value?.genderCode == 0 ? "" : ""}",
style: TextStyle(
@ -801,6 +825,52 @@ class _EditInfoPageState extends State<EditInfoPage> {
],
),
),
Container(
width: 375.w,
padding: EdgeInsets.only(
left: 14.w,
right: 20.w,
top: 14.w,
bottom: 14.w
),
margin: EdgeInsets.only(top: 10.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(9.w))
),
child: Column(
children: [
Row(
children: [
Text(
"交友心声",
style: TextStyle(
fontSize: 15.w,
fontWeight: FontWeight.w500
),
)
],
),
SizedBox(height: 2.w,),
Container(
alignment: Alignment.centerLeft,
child: Text(
controller.message.value,
style: TextStyle(
fontSize: 13.w,
fontWeight: FontWeight.w500
),
),
)
],
),
).onTap((){
Get.to(() => SignaturePage())?.then((e){
controller.savaDescribeInfo();
});
}),
],
if(false && controller.menuActive.value == 2) ...[
Stack(

104
lib/pages/mine/signature_page.dart

@ -1,70 +1,62 @@
import 'package:dating_touchme_app/components/page_appbar.dart';
import 'package:dating_touchme_app/controller/mine/edit_info_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class SignaturePage extends StatefulWidget {
class SignaturePage extends StatelessWidget {
const SignaturePage({super.key});
@override
State<SignaturePage> createState() => _SignaturePageState();
}
class _SignaturePageState extends State<SignaturePage> {
String message = '拒绝内耗,向阳而生,用热爱抵御岁月漫长,用真诚对待每一次相遇拒绝内耗,向阳而生,用热爱抵御岁月漫长,用真诚对待每一次相遇';
final TextEditingController _messageController = TextEditingController();
@override
void initState() {
super.initState();
_messageController.value = TextEditingValue(
text: message,
selection: TextSelection.fromPosition(TextPosition(offset: message.length)),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PageAppbar(title: "交友心声",),
body: Container(
padding: EdgeInsets.all(17.w),
child: TextField(
controller: _messageController,
maxLength: 50, //
minLines: 5, //
maxLines: 5, //
style: TextStyle(
fontSize: ScreenUtil().setWidth(13),
height: 1
),
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: 0,
horizontal: 0
),
hintText: "请输入交友心声",
border: const OutlineInputBorder(
borderSide: BorderSide.none, // //
),
// focusedBorder enabledBorder
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(8.0)),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(8.0)),
return GetX<EditInfoController>(
init: EditInfoController(),
builder: (controller) {
return Scaffold(
appBar: PageAppbar(title: "交友心声",),
body: Container(
padding: EdgeInsets.all(17.w),
child: TextField(
controller: controller.messageController.value,
maxLength: 50, //
minLines: 5, //
maxLines: 5, //
style: TextStyle(
fontSize: ScreenUtil().setWidth(13),
height: 1
),
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: 0,
horizontal: 0
),
hintText: "请输入交友心声",
border: const OutlineInputBorder(
borderSide: BorderSide.none, // //
),
// focusedBorder enabledBorder
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(8.0)),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(8.0)),
),
),
onChanged: (value){
controller.message.value = value;
print(value);
},
),
),
onChanged: (value){
message = value;
},
),
),
);
},
);
}
}
Loading…
Cancel
Save