Commit bc2980f9 authored by pete谢兆麟's avatar pete谢兆麟

新增受养人部分接口调试

parent 969d4aeb
......@@ -123,6 +123,8 @@
0430E6862C76DF6A000511E2 /* YHAdopterMainModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E6852C76DF6A000511E2 /* YHAdopterMainModel.swift */; };
0430E6882C771B06000511E2 /* YHAdopterItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E6872C771B06000511E2 /* YHAdopterItemView.swift */; };
0430E68A2C77415D000511E2 /* YHAdopterAddModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E6892C77415D000511E2 /* YHAdopterAddModel.swift */; };
0430E68C2C786257000511E2 /* YHAdopterIncomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E68B2C786257000511E2 /* YHAdopterIncomeViewModel.swift */; };
0430E68E2C7875F4000511E2 /* YHAdopterDependentDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E68D2C7875F4000511E2 /* YHAdopterDependentDataModel.swift */; };
04358E042C77322700811928 /* YHHaveGrabbedNumberListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */; };
04358E062C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */; };
04358E082C77657000811928 /* YHReAppointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E072C77657000811928 /* YHReAppointViewController.swift */; };
......@@ -870,6 +872,8 @@
0430E6852C76DF6A000511E2 /* YHAdopterMainModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAdopterMainModel.swift; sourceTree = "<group>"; };
0430E6872C771B06000511E2 /* YHAdopterItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAdopterItemView.swift; sourceTree = "<group>"; };
0430E6892C77415D000511E2 /* YHAdopterAddModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAdopterAddModel.swift; sourceTree = "<group>"; };
0430E68B2C786257000511E2 /* YHAdopterIncomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAdopterIncomeViewModel.swift; sourceTree = "<group>"; };
0430E68D2C7875F4000511E2 /* YHAdopterDependentDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAdopterDependentDataModel.swift; sourceTree = "<group>"; };
04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberListCell.swift; sourceTree = "<group>"; };
04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberInfoView.swift; sourceTree = "<group>"; };
04358E072C77657000811928 /* YHReAppointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHReAppointViewController.swift; sourceTree = "<group>"; };
......@@ -1770,6 +1774,7 @@
0430E65B2C744187000511E2 /* YHAdopterCardModel.swift */,
0430E6852C76DF6A000511E2 /* YHAdopterMainModel.swift */,
0430E6892C77415D000511E2 /* YHAdopterAddModel.swift */,
0430E68D2C7875F4000511E2 /* YHAdopterDependentDataModel.swift */,
);
path = M;
sourceTree = "<group>";
......@@ -1825,6 +1830,7 @@
0430E6592C7436CD000511E2 /* YHAdopterNewPeopleViewModel.swift */,
0430E6632C7482DD000511E2 /* YHYHAdopterTravelViewModel.swift */,
0430E6832C76D702000511E2 /* YHAddpterViewModel.swift */,
0430E68B2C786257000511E2 /* YHAdopterIncomeViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
......@@ -4165,6 +4171,7 @@
A5ACE9362B4564F7002C94D2 /* YHNetworkStatusManager.swift in Sources */,
048787D52BCE880B0036E221 /* YHServiceOrderListViewController.swift in Sources */,
A5D0012A2BABC84A001F003C /* YHFileListHeaerView.swift in Sources */,
0430E68C2C786257000511E2 /* YHAdopterIncomeViewModel.swift in Sources */,
044414052BC3B9DE00784A14 /* YHServiceTableFootView.swift in Sources */,
045EEEEF2B9F171A0022A143 /* YHCertificateInfoController.swift in Sources */,
045EEEDA2B9F171A0022A143 /* YHEducationInfoListVC.swift in Sources */,
......@@ -4666,6 +4673,7 @@
0430E6422C72E120000511E2 /* YHAddAdoptersViewController.swift in Sources */,
A5CA3F5C2C74C4C200EB22F5 /* YHHKCardTemplateView.swift in Sources */,
044D0C022C216AAF00C5CF5E /* YHInformationAuthorizeViewModel.swift in Sources */,
0430E68E2C7875F4000511E2 /* YHAdopterDependentDataModel.swift in Sources */,
A5ACE9572B4564F7002C94D2 /* YHBasicContentView.swift in Sources */,
A51D14EB2C75E98500E2820C /* UINavigationController+Extension.swift in Sources */,
A59B43CB2C4A151200B28379 /* YHStatusAdvantageVC.swift in Sources */,
......
......@@ -24,6 +24,11 @@ class YHAddAdoptersViewController: YHBaseViewController {
getData()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
getData()
}
func getData() {
viewModel.getAddpterMainData(orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
......@@ -139,6 +144,7 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
self.viewModel.postManagementAdd(isSpouse: 1, orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
let vc = YHAdopterNewPeopleViewController()
vc.id = self.viewModel.addModel?.id ?? 0
self.navigationController?.pushViewController(vc)
}
}
......@@ -146,6 +152,7 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
self.viewModel.postManagementAdd(isSpouse: 0, orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
let vc = YHAdopterNewPeopleViewController()
vc.id = self.viewModel.addModel?.id ?? 0
self.navigationController?.pushViewController(vc)
}
}
......@@ -163,7 +170,9 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
}
cell.clickBlock = { [weak self] model in
guard let self = self else { return }
let vc = YHAdopterNewPeopleViewController()
vc.id = model.id
self.navigationController?.pushViewController(vc)
}
return cell
} else {
......@@ -172,6 +181,8 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
cell.clickBlock = { [weak self] index in
guard let self = self else { return }
let vc = YHAdopterIncomeDetailViewController()
vc.data = self.viewModel.model?.deposit ?? YHAdopterDepositModel()
vc.orderId = orderId
self.navigationController?.pushViewController(vc)
}
return cell
......
......@@ -7,6 +7,7 @@
//
import UIKit
import IQKeyboardManagerSwift
class YHAdopterIncomeDetailViewController: YHBaseViewController {
......@@ -14,7 +15,15 @@ class YHAdopterIncomeDetailViewController: YHBaseViewController {
var nextButton: UIButton!
var clickIndex = -1
var file: [YHWorkExperienceFileModel] = []
var viewModel = YHBaseViewModel()
var data: YHAdopterDepositModel = YHAdopterDepositModel()
var viewModel: YHAdopterIncomeViewModel = YHAdopterIncomeViewModel()
var orderId: Int = 0
lazy var previewFileTool:YHFilePreviewTool = {
let tool = YHFilePreviewTool(targetVC: self)
return tool
}()
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "上传存款证明"
......@@ -23,6 +32,16 @@ class YHAdopterIncomeDetailViewController: YHBaseViewController {
}
func getData() {
guard let resultModels = [YHAdopterFileModel].deserialize(json: data.urls) else {
return
}
for item in resultModels {
var tempFile = YHWorkExperienceFileModel()
tempFile.fileName = item?.name ?? ""
tempFile.fileUrl = item?.url ?? ""
tempFile.uploadedAt = item?.upload_date ?? ""
file.append(tempFile)
}
tableView.reloadData()
}
......@@ -65,14 +84,30 @@ class YHAdopterIncomeDetailViewController: YHBaseViewController {
make.height.equalTo(48)
}
if data.status == 0 || data.status == 1 {
nextButton.isHidden = true
}
}
@objc func nextStep() {
viewModel.postDepositUpload(file: file, orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
}
}
@objc func submit() {
func getFileNameWithoutSuffix(_ string: String) -> String {
if string.isEmpty {
return string
}
if !string.contains(".") {
return string
}
if !string.pathExtension.isEmpty {
let fileName = (string as NSString).deletingPathExtension
return fileName
}
return ""
}
func uploadImage(_ img: UIImage, imageName:String, callBack:((Bool, String)->())?) {
......@@ -137,17 +172,76 @@ class YHAdopterIncomeDetailViewController: YHBaseViewController {
extension YHAdopterIncomeDetailViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if data.status == 0 || data.status == 1 {
return 2
}
return 4
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withClass: YHAdopterIncomeTitleTableViewCell.self)
cell.dataSource = data
return cell
}
if indexPath.row == 1 {
let cell = tableView.dequeueReusableCell(withClass: YHAdopterIncomeFileTableViewCell.self)
cell.dataSource = self.file
cell.experienceListBlock = {[weak self] model, type in
guard let self = self else { return }
if type == .click {
self.viewModel.getPublicImageUrl(model.fileUrl) { success, error in
YHHUD.hide()
if let success = success {
self.previewFileTool.openXLSXRemoteFile(urlString: success, fileName: "")
}
}
}
if type == .delete {
var items = [YHCertificateEditItem(type:.preview, title:"预览"),
YHCertificateEditItem(type:.rename, title:"重命名"),
YHCertificateEditItem(type:.delete, title:"删除"),
YHCertificateEditItem(type:.cancel, title:"取消")]
if data.status == 0 || data.status == 1 {
items = [YHCertificateEditItem(type:.preview, title:"预览"),
YHCertificateEditItem(type:.cancel, title:"取消")]
}
YHCertificateEditSheetView.sheetView(items:items) {
[weak self] editType in
guard let self = self else { return }
if editType == .rename {
IQKeyboardManager.shared.enable = false
var name = getFileNameWithoutSuffix(model.fileName)
if name.count > 30 {
name = name[safe: ..<30]!
}
let view = YHPrincipleFileRenameView.renameView(name: name)
view.confirmBlock = {
[weak self] text in
guard let self = self else { return }
model.fileName = text
self.tableView.reloadData()
}
view.show()
} else if editType == .delete { // 删除
for (index, item) in file.enumerated() {
if item.fileUrl == model.fileUrl {
file.remove(at: index)
}
}
self.tableView.reloadData()
} else if editType == .preview { // 预览
self.viewModel.getPublicImageUrl(model.fileUrl) { success, error in
YHHUD.hide()
if let success = success {
self.previewFileTool.openXLSXRemoteFile(urlString: success, fileName: "")
}
}
}
}.show()
}
}
return cell
}
if indexPath.row == 2 {
......@@ -225,6 +319,7 @@ extension YHAdopterIncomeDetailViewController: UITableViewDelegate, UITableViewD
}
if indexPath.row == 3 {
let cell = tableView.dequeueReusableCell(withClass: YHAdopterIncomeFileCountTableViewCell.self)
cell.setContentData(self.file.count)
return cell
}
......@@ -233,7 +328,11 @@ extension YHAdopterIncomeDetailViewController: UITableViewDelegate, UITableViewD
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0 {
return 119
if self.data.status == 2 {
return 119
} else {
return 66
}
}
if indexPath.row == 1 {
let count = self.file.count
......
......@@ -16,7 +16,7 @@ class YHAdopterNewPeopleViewController: YHBaseViewController {
var dataSource: [YHSectionItemModel] = []
var cardDataSource: [YHAdopterCardModel] = []
var isShowPrompt: Bool = false
var orderId: Int = 0
var id: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
......@@ -31,17 +31,10 @@ class YHAdopterNewPeopleViewController: YHBaseViewController {
func getData() {
self.updateDataSource()
// viewModel.requestMainInformation("\(orderId)") {[weak self] success, error in
// guard let self = self else { return }
// self.stepView.maxIndex = self.viewModel.mainModel.step
// self.stepView.currentIndex = self.viewModel.mainModel.step
// self.updateDataSource()
// if self.stepView.currentIndex == 3 {
// self.bottomView.nextButton.setTitle("提交", for: .normal)
// } else {
// self.bottomView.nextButton.setTitle("下一步", for: .normal)
// }
// }
viewModel.getDependentsData(id: id) {[weak self] success, error in
guard let self = self else { return }
self.updateDataSource()
}
}
func updateDataSource() {
......@@ -96,25 +89,80 @@ class YHAdopterNewPeopleViewController: YHBaseViewController {
bottomView = {
let bottom = YHBottomNextView()
bottom.saveButton.setTitle("上一步", for: .normal)
bottom.saveButton.isHidden = true
bottom.nextButton.snp.remakeConstraints { make in
make.right.equalTo(-16)
make.top.equalTo(10)
make.height.equalTo(44)
make.left.equalTo(16)
}
bottom.nextblock = { [weak self] in
// bottom.nextButton.isEnabled = false
bottom.nextButton.isEnabled = false
guard let self = self else { return }
self.stepView.currentIndex = self.stepView.currentIndex + 1
self.updateDataSource()
// if self.viewModel.isCanNext(self.stepView.currentIndex) {
if self.viewModel.isCanNext(self.stepView.currentIndex) {
self.viewModel.postDependentsAdd(id: id) {[weak self] success, error in
guard let self = self else { return }
bottom.nextButton.isEnabled = true
bottom.saveButton.isHidden = false
bottom.nextButton.setTitle("确认,保存", for: .normal)
bottom.nextButton.snp.remakeConstraints { make in
make.right.equalTo(-16)
make.top.equalTo(10)
make.height.equalTo(44)
make.left.equalTo(bottom.saveButton.snp.right).offset(10)
}
self.stepView.currentIndex = self.stepView.currentIndex + 1
let view = YHAdopterCardOtherGuideView.sheetView()
view.ischeckBeforeFlag = false
view.block = {
}
view.show()
}
// self.viewModel.mainModel.step = self.stepView.currentIndex
// } else {
//
// }
let view = YHAdopterCardOtherGuideView.sheetView()
view.ischeckBeforeFlag = false
view.block = {
// self.viewModel.updateMainInformation(.submit, self.orderId, self.stepView.currentIndex) {[weak self] success, error in
// guard let self = self else { return }
// if let error = error {
// YHHUD.flash(message: error.errorMsg )
// } else {
// YHHUD.hideFlashMessage()
// self.stepView.currentIndex = self.stepView.currentIndex + 1
// self.isShowPrompt = false
// self.stepView.currentIndex = self.stepView.currentIndex
// if self.stepView.currentIndex == 3 {
// self.bottomView.nextButton.setTitle("提交", for: .normal)
// } else {
// self.bottomView.nextButton.setTitle("下一步", for: .normal)
// }
// if self.stepView.currentIndex == self.stepView.dataSource?.count {
// YHHUD.flash(message: "提交成功")
// self.navigationController?.popViewController()
// } else {
// self.updateDataSource()
// }
// }
// }
} else {
bottom.nextButton.isEnabled = true
self.isShowPrompt = true
self.updateDataSource()
YHHUD.flash(message: "您还有信息未填写")
}
view.show()
}
bottom.saveBlock = { [weak self] in
guard let self = self else { return }
self.stepView.currentIndex = 0
self.getData()
bottom.saveButton.setTitle("上一步", for: .normal)
bottom.saveButton.isHidden = true
bottom.nextButton.snp.remakeConstraints { make in
make.right.equalTo(-16)
make.top.equalTo(10)
make.height.equalTo(44)
make.left.equalTo(16)
}
}
return bottom
}()
......@@ -143,15 +191,10 @@ extension YHAdopterNewPeopleViewController: UITableViewDelegate, UITableViewData
return cell
} else {
let cell = tableView.dequeueReusableCell(withClass: YHMainInformationTableViewCell.self)
cell.country = self.viewModel.mainModel.address.country
cell.dataSource = dataSource[indexPath.row]
cell.informationBlock = {[weak self] model in
guard let self = self else { return }
// self.viewModel.updateModel(model)
// let id = model.id
// if id != .id32 && id != .id4 && id != .id8 && id != .id9 && id != .id12 && id != .id13 && id != .id17 && id != .id18 && id != .id21 && id != .id22 && id != .id23 && id != .id34 && id != .id29 && id != .id30 && id != .id35 {
// self.updateDataSource()
// }
self.viewModel.updateModel(model)
}
return cell
}
......
//
// YHAdopterDependentModel.swift
// galaxy
//
// Created by EDY on 2024/8/23.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHAdopterDependentDataModel: SmartCodable {
var info : YHAdopterDependentDataInfoModel = YHAdopterDependentDataInfoModel()
var docList : [YHAdopterDependentDataDocModel] = []
required init() {
}
}
class YHAdopterDependentDataInfoModel: SmartCodable {
var id : Int = 0
var order_sn : String = ""
var applicant_name : String = ""
var order_id : Int = 0
var dep_name : String = ""
var dep_nationality : Int = 5 //随迁人国籍0大陆1台湾2澳门3海外
var status : Int = 0 //状态0待完善,1审核中,2已驳回,3已完成
var sync_status : Int = 0 //状态0待完善, 0未同步 1已同步
var created_at : String = ""
var updated_at : String = ""
var deleted_at : String = ""
var is_spouse : Int = 0
var sync_subset_id : Int = 0
required init() {
}
}
class YHAdopterDependentDataDocModel: SmartCodable {
var id : Int = 0
var dep_name : String = ""
var dep_type : Int = 0
var dep_id : Int = 0
var order_id : Int = 0
var dep_nationality : Int = 0
var is_spouse : Int = 0
var status : Int = 0
var created_at : String = ""
var updated_at : String = ""
var deleted_at : String = ""
var reject_reason : String = ""
var require : String = ""
var certificates_info : String = ""
var url : [String] = []
required init() {
}
}
......@@ -69,3 +69,12 @@ class YHAdopterDepositModel: SmartCodable {
required init() {
}
}
class YHAdopterFileModel: SmartCodable {
var upload_date : String = ""
var name : String = ""
var url: String = ""
required init() {
}
}
......@@ -11,7 +11,7 @@ import AttributedString
class YHAdopterIncomeFileCountTableViewCell: UITableViewCell {
var alertLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......@@ -55,4 +55,11 @@ class YHAdopterIncomeFileCountTableViewCell: UITableViewCell {
make.right.equalTo(-18)
}
}
func setContentData(_ count: Int) {
let a: ASAttributedString = .init("已上传 ", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor.labelTextColor2))
let b: ASAttributedString = .init(" \(count)/10", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0x222222)))
let c: ASAttributedString = .init(" 张图片或文件", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor.labelTextColor2))
alertLabel.attributed.text = a + b + c
}
}
......@@ -11,9 +11,7 @@ import UIKit
class YHAdopterIncomeFileTableViewCell: UITableViewCell {
typealias ExperienceListBlock = (_ model: YHWorkExperienceFileModel, _ type: YHWorkFileClickType) -> ()
typealias AddIntroductionBlock = () -> ()
var experienceListBlock: ExperienceListBlock?
var selectIntroductionBlock: AddIntroductionBlock?
var mainItemView: UIView!
var dataSource: [YHWorkExperienceFileModel]?{
didSet {
......
......@@ -14,7 +14,12 @@ class YHAdopterIncomeTitleTableViewCell: UITableViewCell {
var alertLabel: UILabel!
var failLabel: UILabel!
var failImageView: UIImageView!
var dataSource: YHAdopterDepositModel? {
didSet {
updateContent()
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......@@ -110,7 +115,7 @@ class YHAdopterIncomeTitleTableViewCell: UITableViewCell {
failImageView = {
let view = UIImageView()
view.image = UIImage(named: "service_adopter_income_fail")
view.image = UIImage(named: "service_adopter_income_fail_alert")
return view
}()
contentView.addSubview(failImageView)
......@@ -122,4 +127,36 @@ class YHAdopterIncomeTitleTableViewCell: UITableViewCell {
}
func updateContent() {
guard let data = dataSource else { return }
if data.status == 4 {
subTitleLabel.textColor = UIColor.brandMainColor
subTitleLabel.backgroundColor = UIColor(hex: 0xf0f4fb)
failImageView.isHidden = true
failLabel.isHidden = true
subTitleLabel.text = "待上传"
}
if data.status == 0 {
subTitleLabel.textColor = UIColor(hex: 0xff8000)
subTitleLabel.backgroundColor = UIColor(hex: 0xfff5eb)
failImageView.isHidden = true
failLabel.isHidden = true
subTitleLabel.text = "审核中"
}
if data.status == 1 {
subTitleLabel.textColor = UIColor(hex: 0x3cc694)
subTitleLabel.backgroundColor = UIColor(hex: 0xf0fbf7)
failImageView.isHidden = true
failLabel.isHidden = true
subTitleLabel.text = "已完成"
}
if data.status == 2 {
subTitleLabel.textColor = UIColor(hex: 0xf81d22)
subTitleLabel.backgroundColor = UIColor(hex: 0xfff2f2)
failImageView.isHidden = false
failLabel.isHidden = false
subTitleLabel.text = "已驳回"
}
failLabel.text = data.remark
}
}
......@@ -110,7 +110,11 @@ class YHAdopterItemView: UIView {
func updateAllViews() {
guard let dataSource = dataSource else { return }
titleLabel.text = dataSource.applicant_name
var spouse = "子女"
if dataSource.has_spouse {
spouse = "配偶"
}
titleLabel.text = spouse + "(\(dataSource.dep_name))"
if dataSource.status == 0 {
explainLabel.text = "待上传"
explainLabel.textColor = UIColor.brandMainColor
......
//
// YHAdopterIncomeViewModel.swift
// galaxy
//
// Created by EDY on 2024/8/23.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAdopterIncomeViewModel: YHBaseViewModel {
func postDepositUpload(file: [YHWorkExperienceFileModel], orderId: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var urls: [Any] = []
for item in file {
let file = ["name": item.fileName, "url": item.fileUrl, "upload_date": item.uploadedAt]
urls.append(file)
}
let params: [String: Any] = ["urls": urls,
"order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Adopter.depositUpload
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
callBackBlock(true,nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(false,err)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -9,15 +9,25 @@
import UIKit
class YHAdopterNewPeopleViewModel: YHBaseViewModel {
var mainModel: YHMainInformationModel = YHMainInformationModel()
var mainModel: YHAdopterDependentDataModel = YHAdopterDependentDataModel()
override init() {
super.init()
}
func getBaseDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
let item = YHItemModel(id: .id1, isNeed: true, title: "姓名", isUserKeyBoard: true, prompts: "请输入", message: "", isShowPrompts: isShowPrompt, alertMessage:"请选择国家/地区")
let item1 = YHItemModel(id: .id1, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: "", type: .selectAddress, isShowPrompts: isShowPrompt, alertMessage:"请选择国家/地区")
let item = YHItemModel(id: .id1, isNeed: true, title: "姓名", isUserKeyBoard: true, prompts: "请输入", message: mainModel.info.dep_name, isShowPrompts: isShowPrompt, alertMessage:"请输入姓名")
var string = ""
if mainModel.info.dep_nationality == 0 {
string = "中国大陆"
} else if mainModel.info.dep_nationality == 1 {
string = "中国澳门"
} else if mainModel.info.dep_nationality == 2 {
string = "中国台湾"
} else if mainModel.info.dep_nationality == 3 {
string = "海外地区"
}
let item1 = YHItemModel(id: .id2, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: string, type: .selectAddress, isShowPrompts: isShowPrompt, alertMessage:"请选择国家/地区")
let section = YHSectionItemModel(title: "配偶信息", models: [item, item1])
return [section]
}
......@@ -35,4 +45,89 @@ class YHAdopterNewPeopleViewModel: YHBaseViewModel {
return [item, item1, item2, item3, item4, item5, item6, item7, item8]
}
func updateModel(_ item: YHItemModel) {
guard let type = item.id else { return }
switch type {
case .id1:
mainModel.info.dep_name = item.message ?? ""
case .id2:
mainModel.info.dep_nationality = item.value?.first?.int ?? 0
default:
break
}
}
func isCanNext(_ step: Int) -> Bool {
let depname = mainModel.info.dep_name
let depnationality = mainModel.info.dep_nationality
guard depname.count > 0 else { return false }
guard depnationality < 4 else { return false }
return true
}
func getDependentsData(id: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String: Any] = ["id": id]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Adopter.dependents
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let resultModel = YHAdopterDependentDataModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false,err)
return
}
self.mainModel = resultModel
callBackBlock(true,nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(false,err)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func postDependentsAdd(id: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String: Any] = ["id": id,
"is_spouse": mainModel.info.is_spouse,
"order_id": mainModel.info.order_id,
"dep_nationality": mainModel.info.dep_nationality,
"dep_name": mainModel.info.dep_name]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Adopter.dependentsAdd
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let resultModel = YHAdopterDependentDataModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false,err)
return
}
self.mainModel = resultModel
callBackBlock(true,nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(false,err)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -425,20 +425,20 @@ class YHConstantArrayData {
static let arrSelectAddress = [
[
"id":"中国大陆",
"id": "0",
"title" : "中国大陆",
],
[
"id" : "中国澳门",
"id" : "1",
"title" : "中国澳门",
],
[
"id" : "中国台湾",
"id" : "2",
"title" : "中国台湾",
],
[
"id":"外国地区",
"title" : "外国地区",
"id": "3",
"title" : "海外地区",
]
]
//通过 id 获取 title
......
......@@ -458,6 +458,12 @@ class YHAllApiName {
static let managementAdd = "super-app/order/information/management/add"
static let del = "super-app/order/information/dependents/del"
static let depositUpload = "super-app/order/information/deposit/upload"
static let dependents = "super-app/order/information/dependents/get"
static let dependentsAdd = "super-app/order/information/dependents/add"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment