diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 742fe57d..afd64b48 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -383,6 +383,9 @@ class _Upload { ///上传身份证背面照片 String get uploadCardBack => '/user/upload/uploadAppIdCardBack'; + + ///上传签名 + String get uploadSignName => '/user/upload/uploadLeaseContractSignaturePhoto'; } class _Message { diff --git a/lib/models/house/submit_model.dart b/lib/models/house/submit_model.dart new file mode 100644 index 00000000..9fd1f093 --- /dev/null +++ b/lib/models/house/submit_model.dart @@ -0,0 +1,44 @@ + + +import 'dart:io'; + +class SubmitModel { + int id; + String emergencyContact; + String emergencyContactNumber; + String correspondenceAddress; + String workUnits; + String payBank; + String bankAccountName; + String bankAccount; + List idCardFrontImgUrl; + List idCardBackImgUrl; + File? idCardFrontFile; + File? idCardBackFile; + SubmitModel({ + required this.id, + required this.emergencyContact, + required this.emergencyContactNumber, + required this.correspondenceAddress, + required this.workUnits, + required this.payBank, + required this.bankAccountName, + required this.bankAccount, + required this.idCardFrontImgUrl, + required this.idCardBackImgUrl, + required this.idCardFrontFile, + required this.idCardBackFile, + }); + + factory SubmitModel.init() => SubmitModel( + id: 0, + emergencyContact: '', + emergencyContactNumber: '', + correspondenceAddress: '', + workUnits: '', + payBank: '', + bankAccountName: '', + bankAccount: '', + idCardFrontImgUrl: [], + idCardBackImgUrl: [], idCardBackFile: null, idCardFrontFile: null); +} diff --git a/lib/ui/profile/house/contract_preview_page.dart b/lib/ui/profile/house/contract_preview_page.dart index fa99672f..870b99c3 100644 --- a/lib/ui/profile/house/contract_preview_page.dart +++ b/lib/ui/profile/house/contract_preview_page.dart @@ -3,10 +3,13 @@ import 'dart:typed_data'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; +import 'package:aku_community/constants/api.dart'; import 'package:aku_community/ui/profile/house/download_contract_page.dart'; +import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/buttons/bottom_button.dart'; import 'package:aku_community/widget/others/sign_name_board.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -14,7 +17,8 @@ import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; class ContractPreviewPage extends StatefulWidget { - ContractPreviewPage({Key? key}) : super(key: key); + final String url; + ContractPreviewPage({Key? key, required this.url}) : super(key: key); @override _ContractPreviewPageState createState() => _ContractPreviewPageState(); @@ -56,7 +60,7 @@ class _ContractPreviewPageState extends State { children: [ FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: 'image'), + image: API.image(widget.url)), Positioned( right: 70.w, bottom: 200.w, @@ -67,8 +71,17 @@ class _ContractPreviewPageState extends State { ], ), bottomNavi: BottomButton( - onPressed: () { - Get.off(() => DownLoadContractPage(firstRoute: true)); + onPressed: () async { + if (_signFile != null) { + Function cancel = BotToast.showLoading(); + String result = await HouseFunc().uploadSignName(_signFile!); + Get.off(() => DownLoadContractPage( + path: result, + )); + cancel(); + } else { + BotToast.showText(text: '请先签名!'); + } }, child: '生成合同'.text.size(32.sp).color(ktextPrimary).make()), ); diff --git a/lib/ui/profile/house/download_contract_page.dart b/lib/ui/profile/house/download_contract_page.dart index c3316ca2..b600fd2e 100644 --- a/lib/ui/profile/house/download_contract_page.dart +++ b/lib/ui/profile/house/download_contract_page.dart @@ -2,14 +2,19 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/ui/profile/house/upload_contracts_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/others/finish_result_image.dart'; +import 'package:aku_community/widget/views/%20bee_download_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:open_file/open_file.dart'; import 'package:velocity_x/velocity_x.dart'; class DownLoadContractPage extends StatefulWidget { - final bool firstRoute; - DownLoadContractPage({Key? key, required this.firstRoute}) : super(key: key); + final String path; + DownLoadContractPage({ + Key? key, + required this.path, + }) : super(key: key); @override _DownLoadContractPageState createState() => _DownLoadContractPageState(); @@ -26,11 +31,7 @@ class _DownLoadContractPageState extends State { 80.w.heightBox, FinishResultImage(status: true), 48.w.heightBox, - '${widget.firstRoute ? '生成成功' : '合同已生成'}' - .text - .size(36.sp) - .color(ktextPrimary) - .make(), + '${'生成成功'}'.text.size(36.sp).color(ktextPrimary).make(), 24.w.heightBox, '请下载合同'.text.size(26.sp).color(ktextSubColor).make(), '完善信息并盖章后再上传合同'.text.size(26.sp).color(ktextSubColor).make(), @@ -48,7 +49,12 @@ class _DownLoadContractPageState extends State { side: BorderSide(color: Color(0xFF666666), width: 1.w)), padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 78.w), - onPressed: () {}, + onPressed: () async { + String? result = await Get.dialog(BeeDownloadView( + file: widget.path, + )); + if (result != null) OpenFile.open(result); + }, child: '下载合同'.text.size(32.sp).bold.color(ktextPrimary).make(), ), diff --git a/lib/ui/profile/house/house_func.dart b/lib/ui/profile/house/house_func.dart index 5d6438a0..50568c86 100644 --- a/lib/ui/profile/house/house_func.dart +++ b/lib/ui/profile/house/house_func.dart @@ -1,8 +1,12 @@ +import 'dart:io'; + import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/user/house_model.dart'; import 'package:aku_community/models/house/lease_detail_model.dart'; import 'package:aku_community/models/house/lease_echo_model.dart'; +import 'package:aku_community/models/house/submit_model.dart'; import 'package:aku_community/models/user/passed_house_list_model.dart'; +import 'package:aku_community/utils/network/base_file_model.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; import 'package:bot_toast/bot_toast.dart'; @@ -67,13 +71,70 @@ class HouseFunc { } } - static Map getSex = { + ///上传身份证照片正面 + Future uploadIdCardFront(File file) async { + BaseFileModel baseFileModel = + await NetUtil().upload(API.upload.uploadCardFront, file); + if (baseFileModel.status ?? false) { + return baseFileModel.url!; + } else { + return ''; + } + } + + ///上传身份证照片背面 + Future uploadIdCardBack(File file) async { + BaseFileModel baseFileModel = + await NetUtil().upload(API.upload.uploadCardBack, file); + if (baseFileModel.status ?? false) { + return baseFileModel.url!; + } else { + return ''; + } + } + + ///提交个人租赁信息 + Future submitLeaseInfo(SubmitModel model) async { + BaseModel baseModel = + await NetUtil().get(API.house.submitLeaseInfo, params: { + "id": model.id, + "emergencyContact": model.emergencyContact, + "emergencyContactNumber": model.emergencyContactNumber, + "correspondenceAddress": model.correspondenceAddress, + "workUnits": model.workUnits, + "payBank": model.payBank, + "bankAccountName": model.bankAccountName, + "bankAccount": model.bankAccount, + "idCardFrontImgUrl": model.idCardFrontImgUrl, + "idCardBackImgUrl": model.idCardBackImgUrl, + }); + if (baseModel.status ?? false) { + return baseModel.data; + } else { + return ''; + } + } + + ///上传合同签名 + Future uploadSignName(File file) async { + BaseFileModel baseFileModel = + await NetUtil().upload(API.upload.uploadSignName, file); + if (baseFileModel.status ?? false) { + return baseFileModel.url!; + } else { + return ''; + } + } + + static Map getSex = { '男': 1, '女': 2, }; - static Map toSex = { + static Map toSex = { 1: '男', 2: '女', }; + + static Map toType = {1: '一类人才', 2: '二类人才', 3: '三类人才'}; } diff --git a/lib/ui/profile/house/house_information_check_page.dart b/lib/ui/profile/house/house_information_check_page.dart index 412d5074..d9f25310 100644 --- a/lib/ui/profile/house/house_information_check_page.dart +++ b/lib/ui/profile/house/house_information_check_page.dart @@ -1,17 +1,26 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; +import 'package:aku_community/models/house/lease_detail_model.dart'; +import 'package:aku_community/models/house/submit_model.dart'; import 'package:aku_community/ui/profile/house/contract_preview_page.dart'; +import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_divider.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/buttons/bottom_button.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:power_logger/power_logger.dart'; import 'package:velocity_x/velocity_x.dart'; class HouseInformationCheckPage extends StatefulWidget { - HouseInformationCheckPage({Key? key}) : super(key: key); + final SubmitModel submitModel; + final LeaseDetailModel detailModel; + HouseInformationCheckPage( + {Key? key, required this.submitModel, required this.detailModel}) + : super(key: key); @override _HouseInformationCheckPageState createState() => @@ -19,6 +28,13 @@ class HouseInformationCheckPage extends StatefulWidget { } class _HouseInformationCheckPageState extends State { + late SubmitModel _submitModel; + @override + void initState() { + super.initState(); + _submitModel = widget.submitModel; + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -28,18 +44,34 @@ class _HouseInformationCheckPageState extends State { padding: EdgeInsets.only(bottom: 24.w, left: 32.w, right: 32.w), children: [ _houseHead(), - _textTile('认定人才类型', '二类人才'), - _textTile('房屋户型', 'B座C1户型'), + _textTile('认定人才类型', HouseFunc.toType[widget.detailModel.type]!), + _textTile('房屋户型', widget.detailModel.estateType), _textTile('房屋结构', '两房两卫一厅'), _textTile('建筑面积', '90平米'), _textTile('使用面积', '78平米'), - _textTile('租赁期限', '2020-10-26 ———— 2023-10-25'), + _textTile('租赁期限', + '${widget.detailModel.leaseDateStart}————${widget.detailModel.leaseDateEnd}'), ].sepWidget(separate: 24.w.heightBox), ), bottomNavi: BottomButton( - onPressed: () { - Get.back(); - Get.off(() => ContractPreviewPage()); + onPressed: () async { + Function cancel = BotToast.showLoading(); + try { + _submitModel.idCardFrontImgUrl.add(await HouseFunc() + .uploadIdCardFront(_submitModel.idCardFrontFile!)); + _submitModel.idCardFrontImgUrl.add(await HouseFunc() + .uploadIdCardBack(_submitModel.idCardBackFile!)); + String result = await HouseFunc().submitLeaseInfo(_submitModel); + if (result.isNotEmpty) { + Get.back(); + Get.off(() => ContractPreviewPage( + url: result, + )); + } + } catch (e) { + LoggerData.addData(e); + } + cancel(); }, child: '确认'.text.size(32.sp).bold.color(ktextPrimary).make(), ), @@ -90,9 +122,7 @@ class _HouseInformationCheckPageState extends State { .bold .make(), 10.w.heightBox, - 'appProvider.selectedHouse!' - .text - .black + widget.detailModel.roomName.text.black .size(32.sp) .bold .make() diff --git a/lib/ui/profile/house/lease_house_card.dart b/lib/ui/profile/house/lease_house_card.dart index 67fee5ef..3ad69eec 100644 --- a/lib/ui/profile/house/lease_house_card.dart +++ b/lib/ui/profile/house/lease_house_card.dart @@ -2,9 +2,9 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/models/house/lease_list_model.dart'; import 'package:aku_community/ui/profile/house/contract_pay_page.dart'; -import 'package:aku_community/ui/profile/house/download_contract_page.dart'; import 'package:aku_community/ui/profile/house/supplement_information_page.dart'; import 'package:aku_community/ui/profile/house/upload_contracts_page.dart'; +import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/buttons/card_bottom_button.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -55,7 +55,7 @@ class LeaseHouseCard extends StatelessWidget { height: 40.w, ), 16.w.widthBox, - '南宁金融人才公寓'.text.size(32.sp).color(ktextPrimary).make().expand(), + S.of(context)!.tempPlotName.text.size(32.sp).color(ktextPrimary).make().expand(), model.statusString.text .size(32.sp) .color(ktextPrimary) @@ -108,8 +108,13 @@ class LeaseHouseCard extends StatelessWidget { }), CardBottomButton.white( text: '下载合同', - onPressed: () { - Get.to(() => DownLoadContractPage(firstRoute: false)); + onPressed: () async{ + //TODO:待接口中添加完合同路径字段后取消注释 + // String? result = await Get.dialog(BeeDownloadView( + // file: + // )); + // if (result != null) OpenFile.open(result); + }), ], ); diff --git a/lib/ui/profile/house/supplement_information_page.dart b/lib/ui/profile/house/supplement_information_page.dart index d8733a7f..3f9a3826 100644 --- a/lib/ui/profile/house/supplement_information_page.dart +++ b/lib/ui/profile/house/supplement_information_page.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/models/house/lease_detail_model.dart'; +import 'package:aku_community/models/house/submit_model.dart'; import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/ui/profile/house/house_information_check_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; @@ -58,16 +59,17 @@ class _SupplementInformationPageState extends State { ///身份证照片正面 File? _idCardFront; + ///身份证照片反面 File? _idCardBack; + SubmitModel _submitModel = SubmitModel.init(); + LeaseDetailModel? _model; @override void initState() { Future.delayed(Duration(milliseconds: 300), () async { - LeaseDetailModel? model = await HouseFunc().leaseDetail(widget.leaseId); - if (model != null) { - initModel(model); - setState(() {}); - } + _model = await HouseFunc().leaseDetail(widget.leaseId); + initHinText(_model); + setState(() {}); }); super.initState(); } @@ -153,17 +155,34 @@ class _SupplementInformationPageState extends State { bottomNavi: BottomButton( onPressed: () { if (canSubmit) { - - Get.to(() => HouseInformationCheckPage()); + updateSubmitModel(); + Get.to(() => HouseInformationCheckPage( + submitModel: _submitModel, + detailModel: _model!, + )); } }, child: '下一步'.text.size(32.sp).bold.color(ktextPrimary).make()), ); } + //更新要提交的model信息 + updateSubmitModel() { + _submitModel.bankAccountName = _nameController.text; + _submitModel.emergencyContact = _emergencyContactController.text; + _submitModel.emergencyContactNumber = _emergencyPhoneController.text; + _submitModel.correspondenceAddress = _addressController.text; + _submitModel.workUnits = _workUnitController.text; + _submitModel.payBank = _bankNameController.text; + _submitModel.bankAccount = _bankCodeController.text; + _submitModel.idCardFrontFile = _idCardFront; + _submitModel.idCardBackFile = _idCardBack; + } + //初始化model,基本信息回显 - initModel(LeaseDetailModel? model) { + initHinText(LeaseDetailModel? model) { if (model != null) { + _submitModel.id = model.id; _nameController.text = model.name; _sex = HouseFunc.toSex[model.sex]!; _codeController.text = model.idCard; @@ -188,8 +207,6 @@ class _SupplementInformationPageState extends State { } } - - Widget _sexBottomSheet() { return CupertinoActionSheet( title: diff --git a/lib/ui/profile/house/user_identify_page.dart b/lib/ui/profile/house/user_identify_page.dart index 5fab0a78..b65d9e58 100644 --- a/lib/ui/profile/house/user_identify_page.dart +++ b/lib/ui/profile/house/user_identify_page.dart @@ -226,6 +226,7 @@ class _UserIdentifyPageState extends State { onPressed: () { // Get.back(); // Get.back(); + //TODO: 开发用 ,模块开发完成后删掉 Get.to(() => TenantHouseListPage()); }, child: '回到首页'