Commit 8fa3be52 authored by pete谢兆麟's avatar pete谢兆麟

新增受养人 首页接口逻辑

parent 30152107
......@@ -122,6 +122,7 @@
0430E6842C76D702000511E2 /* YHAddpterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E6832C76D702000511E2 /* YHAddpterViewModel.swift */; };
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 */; };
04358E042C77322700811928 /* YHHaveGrabbedNumberListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */; };
04358E062C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */; };
0435FA7F2BA178C100024EAE /* YHCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */; };
......@@ -867,6 +868,7 @@
0430E6832C76D702000511E2 /* YHAddpterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAddpterViewModel.swift; sourceTree = "<group>"; };
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>"; };
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>"; };
0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCommonAlertView.swift; sourceTree = "<group>"; };
......@@ -1764,6 +1766,7 @@
children = (
0430E65B2C744187000511E2 /* YHAdopterCardModel.swift */,
0430E6852C76DF6A000511E2 /* YHAdopterMainModel.swift */,
0430E6892C77415D000511E2 /* YHAdopterAddModel.swift */,
);
path = M;
sourceTree = "<group>";
......@@ -4421,6 +4424,7 @@
A5ACE93F2B4564F7002C94D2 /* UIViewController+Extension.swift in Sources */,
A53B61192BB3C9960010B573 /* YHMyDocListHeaderView.swift in Sources */,
A567E5B22BD7643D00D5D5A0 /* YHHomeBannerCollectionViewCell.swift in Sources */,
0430E68A2C77415D000511E2 /* YHAdopterAddModel.swift in Sources */,
045EEF082B9F171A0022A143 /* YHBasicInfoCellModel.swift in Sources */,
A59B43C92C491FB100B28379 /* YHH5WebViewVC.swift in Sources */,
0488518F2BF5FD1500C4E32D /* YHOSSManager.swift in Sources */,
......
......@@ -92,11 +92,11 @@ class YHAddAdoptersViewController: YHBaseViewController {
extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// if clickIndex == 1 {
if clickIndex == 1 {
return 4
// } else {
// return 1
// }
} else {
return 1
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -105,7 +105,7 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
cell.clickBlock = { [weak self] index in
guard let self = self else { return }
self.clickIndex = index
self.viewModel.postDependentAdd(dependent: index) {[weak self] success, error in
self.viewModel.postDependentAdd(dependent: index, orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
if self.clickIndex == 0 {
let view = YHNoAdopterAlertView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
......@@ -122,30 +122,50 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
return cell
} else if indexPath.row == 2 {
let cell = tableView.dequeueReusableCell(withClass: YHAdopterAddNewTableViewCell.self)
cell.dataSource = self.viewModel.model?.dependent
cell.newAdopterBlock = {[weak self] in
guard let self = self else { return }
let items = [YHCertificateEditItem(type:.rename, title:"新增配偶"),
YHCertificateEditItem(type:.preview, title:"新增子女"),
YHCertificateEditItem(type:.cancel, title:"取消")]
var items: [YHCertificateEditItem] = []
if self.viewModel.model?.has_spouse ?? false {
items.append(YHCertificateEditItem(type:.rename, title:"新增配偶"))
}
items.append(YHCertificateEditItem(type:.preview, title:"新增子女"))
items.append(YHCertificateEditItem(type:.cancel, title:"取消"))
YHCertificateEditSheetView.sheetView(items:items) {
[weak self] editType in
guard let self = self else { return }
if editType == .rename {
let vc = YHAdopterNewPeopleViewController()
self.navigationController?.pushViewController(vc)
self.viewModel.postManagementAdd(isSpouse: 1, orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
let vc = YHAdopterNewPeopleViewController()
self.navigationController?.pushViewController(vc)
}
}
if editType == .preview {
let vc = YHAdopterNewPeopleViewController()
self.navigationController?.pushViewController(vc)
self.viewModel.postManagementAdd(isSpouse: 0, orderId: orderId) {[weak self] success, error in
guard let self = self else { return }
let vc = YHAdopterNewPeopleViewController()
self.navigationController?.pushViewController(vc)
}
}
if editType == .delete {
}
}.show()
}
cell.deleteBlock = { [weak self] model in
guard let self = self else { return }
}
cell.clickBlock = { [weak self] model in
guard let self = self else { return }
}
return cell
} else {
let cell = tableView.dequeueReusableCell(withClass: YHAdopterIncomeTableViewCell.self)
cell.dataSource = self.viewModel.model?.deposit
cell.clickBlock = { [weak self] index in
guard let self = self else { return }
let vc = YHAdopterIncomeDetailViewController()
......@@ -164,8 +184,8 @@ extension YHAddAdoptersViewController: UITableViewDelegate, UITableViewDataSourc
return 136
}
if indexPath.row == 2 {
// count * 52
return 156
let count = self.viewModel.model?.dependent.count ?? 0
return CGFloat(156 + count * 52)
}
if indexPath.row == 3 {
return 199
......
//
// YHAdopterAddModel.swift
// galaxy
//
// Created by EDY on 2024/8/22.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHAdopterAddModel: SmartCodable {
var applicant_name : String = ""
var created_at : String = ""
var id : Int = 0
var is_spouse : Int = 0
var order_id : Int = 0
var order_sn : String = ""
var status : Int = 0
var updated_at : String = ""
required init() {
}
}
......@@ -54,7 +54,7 @@ class YHAdopterDepositModel: SmartCodable {
var img_front : String = ""
var img_back : String = ""
var other : String = ""
var status : Int = 0
var status : Int = 4
var collect_status : Int = 0
var checked_user_id : Int = 0
var checked_at : String = ""
......
......@@ -135,7 +135,7 @@ class YHAdopterAddNewTableViewCell: UITableViewCell {
mainItemView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalTo(-63)
make.top.equalTo(77)
make.top.equalTo(63)
}
bottomView = {
......@@ -207,7 +207,7 @@ class YHAdopterAddNewTableViewCell: UITableViewCell {
moreButton.isHidden = false
cannalButton.isHidden = true
for i in 0..<(dataSource?.count ?? 0) {
let view = mainItemView.viewWithTag(4000 + i) as! YHWorkItemView
let view = mainItemView.viewWithTag(4000 + i) as! YHAdopterItemView
view.isShowDelete(i, isShow: false)
}
if let block = isMoreBlock {
......@@ -219,7 +219,7 @@ class YHAdopterAddNewTableViewCell: UITableViewCell {
moreButton.isHidden = true
cannalButton.isHidden = false
for i in 0..<(dataSource?.count ?? 0) {
let view = mainItemView.viewWithTag(4000 + i) as! YHWorkItemView
let view = mainItemView.viewWithTag(4000 + i) as! YHAdopterItemView
view.isShowDelete(i, isShow: true)
}
if let block = isMoreBlock {
......
......@@ -18,6 +18,12 @@ class YHAdopterIncomeTableViewCell: UITableViewCell {
var selectLabel: UILabel!
var lineView: UIView!
var moreButton: UIButton!
var dataSource: YHAdopterDepositModel? {
didSet {
updateContent()
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......@@ -142,4 +148,28 @@ class YHAdopterIncomeTableViewCell: UITableViewCell {
block(0)
}
}
func updateContent() {
guard let data = dataSource else { return }
if data.status == 4 {
moreButton.setTitle("待上传", for: .normal)
moreButton.setImage(UIImage(named: "service_adopter_income_start"), for: .normal)
moreButton.setTitleColor(UIColor.brandMainColor, for: .normal)
}
if data.status == 0 {
moreButton.setTitle("审核中", for: .normal)
moreButton.setImage(UIImage(named: "service_adopter_income_wait"), for: .normal)
moreButton.setTitleColor(UIColor(hex: 0xff8000), for: .normal)
}
if data.status == 1 {
moreButton.setTitle("已完成", for: .normal)
moreButton.setImage(UIImage(named: "service_adopter_income_success"), for: .normal)
moreButton.setTitleColor(UIColor(hex: 0x3cc694), for: .normal)
}
if data.status == 2 {
moreButton.setTitle("已驳回", for: .normal)
moreButton.setImage(UIImage(named: "service_adopter_income_fail"), for: .normal)
moreButton.setTitleColor(UIColor.failColor, for: .normal)
}
}
}
......@@ -46,7 +46,7 @@ class YHAdopterItemView: UIView {
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.top.bottom.equalToSuperview()
make.width.equalTo(143)
make.width.equalTo(243)
}
explainLabel = {
......
......@@ -10,7 +10,7 @@ import UIKit
class YHAddpterViewModel: YHBaseViewModel {
var model: YHAdopterMainModel?
var addModel: YHAdopterAddModel?
func getAddpterMainData(orderId: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String: Any] = ["order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Adopter.main
......@@ -41,8 +41,9 @@ class YHAddpterViewModel: YHBaseViewModel {
}
}
func postDependentAdd(dependent: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String: Any] = ["has_dependent": dependent]
func postDependentAdd(dependent: Int, orderId: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String: Any] = ["has_dependent": dependent,
"order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Adopter.add
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
......@@ -60,4 +61,33 @@ class YHAddpterViewModel: YHBaseViewModel {
callBackBlock(false,err)
}
}
func postManagementAdd(isSpouse: Int, orderId: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String: Any] = ["is_spouse": isSpouse,
"order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Adopter.managementAdd
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 = YHAdopterAddModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false,err)
return
}
self.addModel = 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)
}
}
}
......@@ -452,6 +452,8 @@ class YHAllApiName {
static let main = "super-app/order/information/getDepList"
// 点击新增受养人
static let add = "super-app/order/information/dependent/add"
// 新增配偶子女
static let managementAdd = "super-app/order/information/management/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