diff --git a/lib/models/house/lease_echo_model.dart b/lib/models/house/lease_echo_model.dart new file mode 100644 index 00000000..8897dfba --- /dev/null +++ b/lib/models/house/lease_echo_model.dart @@ -0,0 +1,25 @@ +import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'lease_echo_model.g.dart'; + +@JsonSerializable() +class LeaseEchoModel extends Equatable { + final String? name; + final num? sex; + final String tel; + final String? idNumber; + LeaseEchoModel({ + required this.name, + required this.sex, + required this.tel, + required this.idNumber, + }); + factory LeaseEchoModel.fromJson(Map json) => + _$LeaseEchoModelFromJson(json); + + factory LeaseEchoModel.fail() => + LeaseEchoModel(name: '', sex: 0, tel: '', idNumber: ''); + + @override + List get props => [name, sex, tel, idNumber]; +} diff --git a/lib/models/house/lease_echo_model.g.dart b/lib/models/house/lease_echo_model.g.dart new file mode 100644 index 00000000..0e8d31f9 --- /dev/null +++ b/lib/models/house/lease_echo_model.g.dart @@ -0,0 +1,16 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'lease_echo_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +LeaseEchoModel _$LeaseEchoModelFromJson(Map json) { + return LeaseEchoModel( + name: json['name'] as String?, + sex: json['sex'] as num?, + tel: json['tel'] as String, + idNumber: json['idNumber'] as String?, + ); +} diff --git a/lib/ui/profile/house/house_func.dart b/lib/ui/profile/house/house_func.dart index 01c035e7..d3828dc5 100644 --- a/lib/ui/profile/house/house_func.dart +++ b/lib/ui/profile/house/house_func.dart @@ -1,5 +1,6 @@ import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/user/house_model.dart'; +import 'package:aku_community/models/house/lease_echo_model.dart'; import 'package:aku_community/models/user/passed_house_list_model.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; @@ -23,7 +24,7 @@ class HouseFunc { } ///我的房屋 租赁认证 - Future leaseCertification( + Future leaseCertification( String name, String sex, String tel, @@ -43,6 +44,16 @@ class HouseFunc { return false; } + ///租赁认证信息回显 + static Future leaseEcho() async { + BaseModel baseModel = await NetUtil().get(API.house.leaseEcho); + if (baseModel.status ?? false) { + return LeaseEchoModel.fromJson(baseModel.data); + } else { + return LeaseEchoModel.fail(); + } + } + Map getSex = { '男': 1, '女': 2, diff --git a/lib/ui/profile/house/user_identify_page.dart b/lib/ui/profile/house/user_identify_page.dart index 8a03fd51..75610948 100644 --- a/lib/ui/profile/house/user_identify_page.dart +++ b/lib/ui/profile/house/user_identify_page.dart @@ -1,4 +1,5 @@ import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/models/house/lease_echo_model.dart'; import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/ui/profile/house/tenant_house_list_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; @@ -22,15 +23,43 @@ class UserIdentifyPage extends StatefulWidget { class _UserIdentifyPageState extends State { TextEditingController _nameController = TextEditingController(); - TextEditingController _phoneController = TextEditingController(); TextEditingController _indentifyCodeController = TextEditingController(); String _sex = '请选择性别'; String _identify = '请选择身份'; + String _tel = ''; + @override + void initState() { + super.initState(); + Future.delayed(Duration(milliseconds: 300), () async { + LeaseEchoModel _model = await HouseFunc.leaseEcho(); + if (!_model.name.isEmptyOrNull) { + _nameController.text = _model.name!; + } + if (_model.sex != null) { + switch (_model.sex) { + case 1: + _sex = '男'; + break; + case 2: + _sex = '女'; + break; + default: + break; + } + } + if (_model.tel.isNotEmpty) { + _tel = _model.tel; + } + if (!_model.idNumber.isEmptyOrNull) { + _indentifyCodeController.text = _model.idNumber!; + } + setState(() {}); + }); + } @override void dispose() { _nameController.dispose(); - _phoneController.dispose(); _indentifyCodeController.dispose(); super.dispose(); } @@ -58,12 +87,11 @@ class _UserIdentifyPageState extends State { setState(() {}); }, ), - BeeInputRow( + BeeInputRow.button( title: '手机号码', - controller: _phoneController, - formatters: [FilteringTextInputFormatter.digitsOnly], - hintText: '请输入手机号', + onPressed: () {}, isRequire: true, + hintText: _tel, ), BeeInputRow( title: '身份证号码', @@ -89,7 +117,7 @@ class _UserIdentifyPageState extends State { bool result = await HouseFunc().leaseCertification( _nameController.text, _sex, - _phoneController.text, + _tel, _indentifyCodeController.text); if (result) { Get.off(() => TenantHouseListPage()); @@ -107,10 +135,6 @@ class _UserIdentifyPageState extends State { BotToast.showText(text: '姓名不能为空!'); return false; } - if (_phoneController.text.isEmpty) { - BotToast.showText(text: '手机号码不能为空!'); - return false; - } if (_indentifyCodeController.text.isEmpty) { BotToast.showText(text: '身份证号码不能为空!'); return false; @@ -179,15 +203,27 @@ class _UserIdentifyPageState extends State { return CupertinoAlertDialog( title: '账户不存在'.text.size(34.sp).color(ktextPrimary).bold.isIntrinsic.make(), - content: '''原因: - 1.用户未具备相关资格 - 2.用户填写的姓名及身份证号与登记在册的姓名及身份证号并不一致''' - .text - .size(26.sp) - .color(ktextPrimary) - .bold - .isIntrinsic - .make(), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '原因:'.text.size(26.sp).color(ktextPrimary).bold.isIntrinsic.make(), + '1.用户未具备相关资格' + .text + .size(26.sp) + .color(ktextPrimary) + .bold + .isIntrinsic + .make(), + '2.用户填写的姓名及身份证号与登记在册的姓名及身份证号并不一致' + .text + .size(26.sp) + .color(ktextPrimary) + .align(TextAlign.left) + .bold + .isIntrinsic + .make(), + ], + ), actions: [ CupertinoDialogAction( onPressed: () {