Commit f0cd29c5 authored by Alex朱枝文's avatar Alex朱枝文

申请类别接口调试

parent 73c64783
......@@ -606,6 +606,8 @@
04B4019B2CE306DC005C61A9 /* YHGCBasicInfoFillViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4019A2CE306DC005C61A9 /* YHGCBasicInfoFillViewController.swift */; };
04B4019F2CE32175005C61A9 /* YHGCMineSchemeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4019E2CE32175005C61A9 /* YHGCMineSchemeViewController.swift */; };
04B401A22CE331F5005C61A9 /* YHGCSchemeTableHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B401A12CE331F5005C61A9 /* YHGCSchemeTableHeadView.swift */; };
04B401A52CE38336005C61A9 /* YHGCApplicationTypeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B401A42CE38336005C61A9 /* YHGCApplicationTypeViewModel.swift */; };
04B401A72CE384D5005C61A9 /* YHGCApplicationTypeResponseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B401A62CE384D5005C61A9 /* YHGCApplicationTypeResponseModel.swift */; };
04B4B8D52C89CE5E00ED82BC /* YHButlerServiceMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4B8D42C89CE5E00ED82BC /* YHButlerServiceMessage.swift */; };
04B4B8D72C8AE77C00ED82BC /* YHButlerServiceMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4B8D62C8AE77C00ED82BC /* YHButlerServiceMessageHandler.swift */; };
04B4B8DC2C90696E00ED82BC /* YHResignDocumentManagementVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4B8DB2C90696E00ED82BC /* YHResignDocumentManagementVC.swift */; };
......@@ -1597,6 +1599,8 @@
04B4019A2CE306DC005C61A9 /* YHGCBasicInfoFillViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCBasicInfoFillViewController.swift; sourceTree = "<group>"; };
04B4019E2CE32175005C61A9 /* YHGCMineSchemeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMineSchemeViewController.swift; sourceTree = "<group>"; };
04B401A12CE331F5005C61A9 /* YHGCSchemeTableHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCSchemeTableHeadView.swift; sourceTree = "<group>"; };
04B401A42CE38336005C61A9 /* YHGCApplicationTypeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCApplicationTypeViewModel.swift; sourceTree = "<group>"; };
04B401A62CE384D5005C61A9 /* YHGCApplicationTypeResponseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCApplicationTypeResponseModel.swift; sourceTree = "<group>"; };
04B4B8D42C89CE5E00ED82BC /* YHButlerServiceMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHButlerServiceMessage.swift; sourceTree = "<group>"; };
04B4B8D62C8AE77C00ED82BC /* YHButlerServiceMessageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHButlerServiceMessageHandler.swift; sourceTree = "<group>"; };
04B4B8DB2C90696E00ED82BC /* YHResignDocumentManagementVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignDocumentManagementVC.swift; sourceTree = "<group>"; };
......@@ -3990,6 +3994,7 @@
04B401862CE1D006005C61A9 /* ApplicationType(申请类别) */ = {
isa = PBXGroup;
children = (
04B401A32CE382E4005C61A9 /* VM */,
04B4018D2CE1E6BB005C61A9 /* M */,
04B401882CE1D036005C61A9 /* V */,
04B401872CE1D02F005C61A9 /* C */,
......@@ -4020,6 +4025,7 @@
children = (
04B4018E2CE1E6DB005C61A9 /* YHGCApplicationType.swift */,
04B401902CE20360005C61A9 /* YHGCApplicationModel.swift */,
04B401A62CE384D5005C61A9 /* YHGCApplicationTypeResponseModel.swift */,
);
path = M;
sourceTree = "<group>";
......@@ -4081,6 +4087,14 @@
path = V;
sourceTree = "<group>";
};
04B401A32CE382E4005C61A9 /* VM */ = {
isa = PBXGroup;
children = (
04B401A42CE38336005C61A9 /* YHGCApplicationTypeViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
};
04B4B8D32C89CCE400ED82BC /* M */ = {
isa = PBXGroup;
children = (
......@@ -5718,6 +5732,7 @@
048058352C7DC7AC00502CAA /* YHMyTestViewController.swift in Sources */,
045EEEA72B9F171A0022A143 /* YHWorkExperienceViewController.swift in Sources */,
A5FD63BD2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift in Sources */,
04B401A52CE38336005C61A9 /* YHGCApplicationTypeViewModel.swift in Sources */,
04CA2BEA2CB7708E00F36DE7 /* YHResignUploadTravelCardListheadView.swift in Sources */,
045EEE8D2B9F171A0022A143 /* YHPreviewInfoCell.swift in Sources */,
047AA3E22C4A66CE009C4554 /* YHLifeItemTableViewCell.swift in Sources */,
......@@ -6061,6 +6076,7 @@
04256E192C75BD2700A37BA4 /* YHVisaPaymentViewModel.swift in Sources */,
04754A952B96FF3D00F8ADCA /* UITextField+Extension.swift in Sources */,
04256DD02C7041C700A37BA4 /* YHInfoItemView.swift in Sources */,
04B401A72CE384D5005C61A9 /* YHGCApplicationTypeResponseModel.swift in Sources */,
04B401932CE22EF0005C61A9 /* YHGCVisaProgramPopVC.swift in Sources */,
A5ACE9312B4564F7002C94D2 /* YHPersonalCenterCell.swift in Sources */,
0430E6562C7342AB000511E2 /* YHAdopterIncomeFileCountTableViewCell.swift in Sources */,
......
......@@ -76,10 +76,34 @@ class YHGCApplicationTypeController: YHBaseViewController {
return view
}()
private lazy var viewModel = YHGCApplicationTypeViewModel()
private var didAppear: Bool = false
private let orderId: Int
init(orderId: Int) {
self.orderId = orderId
super.init(nibName: nil, bundle: nil)
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if !didAppear {
didAppear.toggle()
requestData(isNeedLoading: true)
} else {
requestData(isNeedLoading: false)
}
}
}
extension YHGCApplicationTypeController {
......@@ -94,8 +118,25 @@ extension YHGCApplicationTypeController {
YHCommonAlertView.show("", "确定是否提交申请类别?提交后将不能修改", "取消", "确认", fullGuestureEnable: false) {
//
} callBack: { [weak self] in
guard let self = self else {
return
}
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.submitApplyType(orderId, model.type.rawValue) { success, error in
YHHUD.hide()
if success {
YHHUD.flash(message: "提交成功")
//self.requestData(isNeedLoading: false)
let resultVC = YHGCApplicationTypeResultController(type: model.type)
self?.navigationController?.pushViewController(resultVC)
self.navigationController?.pushViewController(resultVC)
} else {
var errorMsg = "提交失败"
if let error = error, error.errorMsg.count > 0 {
errorMsg = error.errorMsg
}
YHHUD.flash(message: errorMsg)
}
}
}
}
......@@ -134,6 +175,35 @@ extension YHGCApplicationTypeController {
tableView.tableHeaderView = headerView
}
private func requestData(isNeedLoading: Bool = false) {
if isNeedLoading {
YHHUD.show(.progress(message: "加载中..."))
}
viewModel.getApplyType(orderId: orderId) { [weak self] model, error in
guard let self = self else {
return
}
if isNeedLoading {
YHHUD.hide()
}
guard let model = model else {
printLog("YHGCApplicationTypeController: 请求失败")
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
}
return
}
self.datas.flatMap { $0 }.forEach {
if $0.type.rawValue == model.apply_type {
$0.isSelected = true
} else {
$0.isSelected = false
}
}
self.tableView.reloadData()
}
}
private func showPopVC(type: YHGCApplicationType) {
let vc = YHGCVisaProgramPopVC(type: type)
let pc = YHBottomPresentationController(presentedViewController: vc, presenting: self)
......
......@@ -9,9 +9,9 @@
import Foundation
enum YHGCApplicationType: Int {
case typeA
case typeB
case typeC
case typeA = 1
case typeB = 2
case typeC = 3
var titleString: String {
switch self {
......
//
// YHGCApplicationTypeResponseModel.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHGCApplicationTypeResponseModel: SmartCodable {
var apply_type: Int = -1
required init() {
}
}
//
// YHGCApplicationTypeViewModel.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCApplicationTypeViewModel: YHBaseViewModel {
func getApplyType(orderId: Int, callback: @escaping (_ model: YHGCApplicationTypeResponseModel?, _ error: YHErrorModel?) -> ()) {
let params = ["order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.GCApplyType.getApplyType
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { json, code in
//1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let resultModel = YHGCApplicationTypeResponseModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callback(nil, err)
return
}
callback(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(nil, err)
}
} failBlock: { err in
callback(nil, err)
}
}
func submitApplyType(_ orderId: Int, _ applyType: Int, callBackBlock: @escaping (_ success: Bool, _ error:YHErrorModel?) -> () ) {
let params: [String : Any] = ["order_id": orderId, "apply_type": applyType]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.GCApplyType.submitApplyType
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { json, code in
//1. json字符串 转 对象
printLog("model 是 ==> \(json)")
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)
}
}
}
......@@ -627,4 +627,10 @@ class YHAllApiName {
static let result = "super-app/renewal/renewal-result"
}
// 高才申请类型
struct GCApplyType {
static let getApplyType = "infoflow/apply/get-apply-type"
static let submitApplyType = "infoflow/apply/submit-apply-type"
}
}
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