diff --git a/lib/controller/mine/edit_info_controller.dart b/lib/controller/mine/edit_info_controller.dart index 9caabd9..b36ee3d 100644 --- a/lib/controller/mine/edit_info_controller.dart +++ b/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? 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 : "", diff --git a/lib/pages/home/user_information_page.dart b/lib/pages/home/user_information_page.dart index 9217d54..6f4d625 100644 --- a/lib/pages/home/user_information_page.dart +++ b/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) diff --git a/lib/pages/mine/edit_info_page.dart b/lib/pages/mine/edit_info_page.dart index 70916e7..20867f4 100644 --- a/lib/pages/mine/edit_info_page.dart +++ b/lib/pages/mine/edit_info_page.dart @@ -497,13 +497,37 @@ class _EditInfoPageState extends State { ], ), 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 { ], ), ), + + 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( diff --git a/lib/pages/mine/signature_page.dart b/lib/pages/mine/signature_page.dart index ca0aaac..d7b9a22 100644 --- a/lib/pages/mine/signature_page.dart +++ b/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 createState() => _SignaturePageState(); -} - -class _SignaturePageState extends State { - - - 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( + 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; - }, - ), - ), + ); + }, ); } } + + +