Commit 9bce29d0 authored by David黄金龙's avatar David黄金龙

Merge commit 'e99d7f85' into davidhuang

* commit 'e99d7f85':
  主申请人上传身份证逻辑
  // 家庭成员
  上传接口
parents 113055e0 e99d7f85
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
04010B952B6A1DE90093F3BB /* YHSaveAndSubmitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */; }; 04010B952B6A1DE90093F3BB /* YHSaveAndSubmitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */; };
040ED45F2B91711A005CA3F8 /* YHCNIDCardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 040ED45E2B91711A005CA3F8 /* YHCNIDCardModel.swift */; };
040ED4612B9173DE005CA3F8 /* YHHKIDCardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 040ED4602B9173DE005CA3F8 /* YHHKIDCardModel.swift */; };
0413A6D82B8C76290006D154 /* YHCertificateUploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0413A6D72B8C76290006D154 /* YHCertificateUploadVC.swift */; }; 0413A6D82B8C76290006D154 /* YHCertificateUploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0413A6D72B8C76290006D154 /* YHCertificateUploadVC.swift */; };
041B52872B5657B3007EBCEB /* IMAppKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B52862B5657B3007EBCEB /* IMAppKey.swift */; }; 041B52872B5657B3007EBCEB /* IMAppKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B52862B5657B3007EBCEB /* IMAppKey.swift */; };
041B528D2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */; }; 041B528D2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */; };
...@@ -305,6 +307,8 @@ ...@@ -305,6 +307,8 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSaveAndSubmitView.swift; sourceTree = "<group>"; }; 04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSaveAndSubmitView.swift; sourceTree = "<group>"; };
040ED45E2B91711A005CA3F8 /* YHCNIDCardModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCNIDCardModel.swift; sourceTree = "<group>"; };
040ED4602B9173DE005CA3F8 /* YHHKIDCardModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKIDCardModel.swift; sourceTree = "<group>"; };
0413A6D72B8C76290006D154 /* YHCertificateUploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadVC.swift; sourceTree = "<group>"; }; 0413A6D72B8C76290006D154 /* YHCertificateUploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadVC.swift; sourceTree = "<group>"; };
041B52862B5657B3007EBCEB /* IMAppKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMAppKey.swift; sourceTree = "<group>"; }; 041B52862B5657B3007EBCEB /* IMAppKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMAppKey.swift; sourceTree = "<group>"; };
041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemDoubleChoiceCell.swift; sourceTree = "<group>"; }; 041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemDoubleChoiceCell.swift; sourceTree = "<group>"; };
...@@ -938,6 +942,8 @@ ...@@ -938,6 +942,8 @@
04E86E402B8357EC00A35F4B /* YHMainInformationModel.swift */, 04E86E402B8357EC00A35F4B /* YHMainInformationModel.swift */,
04E86E412B8357EC00A35F4B /* YHCountryMessage.swift */, 04E86E412B8357EC00A35F4B /* YHCountryMessage.swift */,
04E86E422B8357EC00A35F4B /* YHItemModel.swift */, 04E86E422B8357EC00A35F4B /* YHItemModel.swift */,
040ED45E2B91711A005CA3F8 /* YHCNIDCardModel.swift */,
040ED4602B9173DE005CA3F8 /* YHHKIDCardModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1912,6 +1918,7 @@ ...@@ -1912,6 +1918,7 @@
04E86E312B81EA1000A35F4B /* YHWorkItemView.swift in Sources */, 04E86E312B81EA1000A35F4B /* YHWorkItemView.swift in Sources */,
A5191F642B89E926001069F7 /* YHPreviewOtherInformationViewController.swift in Sources */, A5191F642B89E926001069F7 /* YHPreviewOtherInformationViewController.swift in Sources */,
A5191F6A2B8B1888001069F7 /* YHPreviewInfoCertificateInformationItemsView.swift in Sources */, A5191F6A2B8B1888001069F7 /* YHPreviewInfoCertificateInformationItemsView.swift in Sources */,
040ED45F2B91711A005CA3F8 /* YHCNIDCardModel.swift in Sources */,
0468D4492B6258A900CFB916 /* YHItemView.swift in Sources */, 0468D4492B6258A900CFB916 /* YHItemView.swift in Sources */,
041B528F2B5E620E007EBCEB /* YHFormItemInputTextCell.swift in Sources */, 041B528F2B5E620E007EBCEB /* YHFormItemInputTextCell.swift in Sources */,
04E86E612B85CAEA00A35F4B /* YHWorkExampleModel.swift in Sources */, 04E86E612B85CAEA00A35F4B /* YHWorkExampleModel.swift in Sources */,
...@@ -1940,6 +1947,7 @@ ...@@ -1940,6 +1947,7 @@
0468D42B2B55019900CFB916 /* YHAnalytics.swift in Sources */, 0468D42B2B55019900CFB916 /* YHAnalytics.swift in Sources */,
A5ACE93C2B4564F7002C94D2 /* UIColor+Extension.swift in Sources */, A5ACE93C2B4564F7002C94D2 /* UIColor+Extension.swift in Sources */,
04E86E4F2B8479B700A35F4B /* YHWorkIntroductionItemView.swift in Sources */, 04E86E4F2B8479B700A35F4B /* YHWorkIntroductionItemView.swift in Sources */,
040ED4612B9173DE005CA3F8 /* YHHKIDCardModel.swift in Sources */,
044CC62D2B876C980083FF76 /* YHSheetPickerViewType.swift in Sources */, 044CC62D2B876C980083FF76 /* YHSheetPickerViewType.swift in Sources */,
04E86E5B2B84BF2000A35F4B /* YHWorkExampleTypeView.swift in Sources */, 04E86E5B2B84BF2000A35F4B /* YHWorkExampleTypeView.swift in Sources */,
042FBBBD2B63519C00F9DE23 /* YHFormItemSelectSheetCell.swift in Sources */, 042FBBBD2B63519C00F9DE23 /* YHFormItemSelectSheetCell.swift in Sources */,
......
...@@ -161,6 +161,7 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol { ...@@ -161,6 +161,7 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
guard let self = self else { return } guard let self = self else { return }
if let targetStep = getStepForArrayIndex(index) { if let targetStep = getStepForArrayIndex(index) {
currentStep = targetStep currentStep = targetStep
spouse.step = targetStep
} }
print("index:\(index)") print("index:\(index)")
} }
......
...@@ -336,6 +336,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -336,6 +336,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
if formItem.type == .child { if formItem.type == .child {
if self.isChildsEditMode == .canCancel { if self.isChildsEditMode == .canCancel {
self.isChildsEditMode = .canEdit self.isChildsEditMode = .canEdit
} else if self.isChildsEditMode == .canEdit { } else if self.isChildsEditMode == .canEdit {
self.isChildsEditMode = .canCancel self.isChildsEditMode = .canCancel
} }
...@@ -343,6 +344,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -343,6 +344,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
if formItem.type == .brother { if formItem.type == .brother {
if self.isBrothersEditMode == .canCancel { if self.isBrothersEditMode == .canCancel {
self.isBrothersEditMode = .canEdit self.isBrothersEditMode = .canEdit
} else if self.isBrothersEditMode == .canEdit { } else if self.isBrothersEditMode == .canEdit {
self.isBrothersEditMode = .canCancel self.isBrothersEditMode = .canCancel
} }
...@@ -358,7 +360,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -358,7 +360,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
let detailItem = item as! YHFamilyMember let detailItem = item as! YHFamilyMember
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
cell.detailLabel.textColor = (isNeedShowError && detailItem.notFillNumber > 0 ? .failColor : .labelTextColor2) cell.detailLabel.textColor = (isNeedShowError && detailItem.notFillNumber != 0 ? .failColor : .labelTextColor2)
if detailItem.notFillNumber > 0 { if detailItem.notFillNumber > 0 {
cell.detailLabel.text = String(format: "有%d项未填写".local, detailItem.notFillNumber) cell.detailLabel.text = String(format: "有%d项未填写".local, detailItem.notFillNumber)
......
...@@ -911,7 +911,7 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol { ...@@ -911,7 +911,7 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol {
var finishFollow: Int = 0 var finishFollow: Int = 0
var step: Int = 0 var step: Int = 0
var isHandled: Int = 0 var isHandled: Int = 0
var notFillNumber: Int = 0 var notFillNumber: Int = -1
var certificates: YHCertificates? var certificates: YHCertificates?
var usedName: String = "" var usedName: String = ""
var hkIdentityOther: String = "" var hkIdentityOther: String = ""
......
...@@ -45,7 +45,7 @@ class YHFamilyRequestViewModel { ...@@ -45,7 +45,7 @@ class YHFamilyRequestViewModel {
YHHUD.show(.progress(message: "数据加载中...")) YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Family.familyInfoApi let strUrl = "http://192.168.34.187:8808/" + YHAllApiName.Family.familyInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:params) {[weak self] json, code in let _ = YHNetRequest.postRequest(url: strUrl, params:params) {[weak self] json, code in
......
...@@ -464,7 +464,14 @@ extension YHFormPickerView { ...@@ -464,7 +464,14 @@ extension YHFormPickerView {
func getSubType(_ title: String?) -> YHFormPickerViewSubType { func getSubType(_ title: String?) -> YHFormPickerViewSubType {
guard let title = title else { return .none } guard let title = title, !title.isEmpty else {
if let arr = dataDict[type], arr.count > 0 {
let item0:YHFormPickerViewItem = arr[0]
return item0.type
}
return .none
}
switch type { switch type {
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
import UIKit import UIKit
class YHMainApplicantInformationViewController: YHBaseViewController { class YHMainApplicantInformationViewController: YHBaseViewController {
var stepView: YHStepView! var stepView: YHStepView!
var bottomView: YHBottomNextView! var bottomView: YHBottomNextView!
var tableView: UITableView! var tableView: UITableView!
...@@ -135,8 +134,12 @@ extension YHMainApplicantInformationViewController: UITableViewDelegate, UITable ...@@ -135,8 +134,12 @@ extension YHMainApplicantInformationViewController: UITableViewDelegate, UITable
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if stepView.currentIndex == 1 { if stepView.currentIndex == 1 {
let cell = tableView.dequeueReusableCell(withClass: YHMainInformationCardTableViewCell.self) let cell = tableView.dequeueReusableCell(withClass: YHMainInformationCardTableViewCell.self)
cell.dataSource = dataSource?[indexPath.row] cell.type = YHCardType(rawValue: indexPath.row) ?? .identity
cell.type = YHCardType(rawValue: indexPath.row) cell.viewModel = viewModel
cell.informationBlock = {[weak self] type, image, isLeft in
guard let self = self else { return }
}
return cell return cell
} else { } else {
let cell = tableView.dequeueReusableCell(withClass: YHMainInformationTableViewCell.self) let cell = tableView.dequeueReusableCell(withClass: YHMainInformationTableViewCell.self)
......
//
// YHCNIDCardModel.swift
// galaxy
//
// Created by EDY on 2024/3/1.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHCNIDCardModel: YHBaseModel {
var gender: String = ""
var address: String = ""
var card_num: String = ""
var issuing_authority: String = ""
var birth: String = ""
var term_begins: String = ""
var end_of_term: String = ""
var nationality: String = ""
var name: String = ""
}
//
// YHHKIDCardModel.swift
// galaxy
//
// Created by EDY on 2024/3/1.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHKIDCardModel: YHBaseModel {
var name: String = ""
var pingyin: String = ""
var birth: String = ""
var gender: String = ""
var term_begins: String = ""
var end_of_term: String = ""
var issuing_authority: String = ""
var card_num: String = ""
}
...@@ -207,7 +207,10 @@ extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerContro ...@@ -207,7 +207,10 @@ extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerContro
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
uploadImage(image: image) uploadImage(image: image)
self.dismiss() if let block = backImage {
block(image)
self.dismiss()
}
} else { } else {
printLog("pick image wrong") printLog("pick image wrong")
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import Alamofire import Alamofire
import Kingfisher
enum YHCardType: Int { enum YHCardType: Int {
case identity = 0 case identity = 0
...@@ -15,7 +16,8 @@ enum YHCardType: Int { ...@@ -15,7 +16,8 @@ enum YHCardType: Int {
} }
class YHMainInformationCardTableViewCell: UITableViewCell { class YHMainInformationCardTableViewCell: UITableViewCell {
typealias InformationBlock = (_ type: YHCardType, _ image: UIImage, _ isleft: Bool) -> ()
var informationBlock: InformationBlock?
var centerView: UIView! var centerView: UIView!
var titleLabel: UILabel! var titleLabel: UILabel!
var exampleButton: UIButton! var exampleButton: UIButton!
...@@ -23,9 +25,50 @@ class YHMainInformationCardTableViewCell: UITableViewCell { ...@@ -23,9 +25,50 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
var backSurfaceLabel: UILabel! var backSurfaceLabel: UILabel!
var frontImageButton: UIButton! var frontImageButton: UIButton!
var backSurfaceImageButton: UIButton! var backSurfaceImageButton: UIButton!
var type: YHCardType? { var frontDeleteButton: UIButton!
var backSurfaceDeleteButton: UIButton!
var activityIndicator: UIActivityIndicatorView!
var viewModel: YHMainApplicantInformationViewModel! {
didSet {
if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_front.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.cn_identity_card.img_front) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.frontImageButton.kf.setBackgroundImage(with: URL(string: success), for: .normal)
self.frontDeleteButton.isHidden = false
}
}
if viewModel.mainModel.certificates.cn_identity_card.img_back.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.cn_identity_card.img_back) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.backSurfaceImageButton.kf.setBackgroundImage(with: URL(string: success), for: .normal)
self.backSurfaceDeleteButton.isHidden = false
}
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_front.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.hk_macao_pass.img_front) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.frontImageButton.kf.setBackgroundImage(with: URL(string: success), for: .normal)
self.frontDeleteButton.isHidden = false
}
}
if viewModel.mainModel.certificates.hk_macao_pass.img_back.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.hk_macao_pass.img_back) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.backSurfaceImageButton.kf.setBackgroundImage(with: URL(string: success), for: .normal)
self.backSurfaceDeleteButton.isHidden = false
}
}
}
}
}
var type: YHCardType = .identity {
didSet { didSet {
guard let type = type else { return }
switch type { switch type {
case .identity: case .identity:
titleLabel.text = "中国身份证(选填)" titleLabel.text = "中国身份证(选填)"
...@@ -39,12 +82,7 @@ class YHMainInformationCardTableViewCell: UITableViewCell { ...@@ -39,12 +82,7 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
} }
} }
} }
var dataSource: YHSectionItemModel?{
didSet {
updataData()
}
}
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
// Initialization code // Initialization code
...@@ -174,6 +212,21 @@ class YHMainInformationCardTableViewCell: UITableViewCell { ...@@ -174,6 +212,21 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
make.width.equalTo(147) make.width.equalTo(147)
} }
frontDeleteButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_delete"), for: .normal)
button.addTarget(self, action: #selector(frontDeleteClick), for: .touchUpInside)
button.isHidden = true
return button
}()
centerView.addSubview(frontDeleteButton)
frontDeleteButton.snp.makeConstraints { make in
make.centerX.equalTo(frontImageButton.snp.right)
make.centerY.equalTo(frontImageButton.snp.top)
make.height.equalTo(21)
make.width.equalTo(21)
}
backSurfaceImageButton = { backSurfaceImageButton = {
let button = UIButton(type: .custom) let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_back"), for: .normal) button.setBackgroundImage(UIImage(named: "service_card_back"), for: .normal)
...@@ -187,6 +240,33 @@ class YHMainInformationCardTableViewCell: UITableViewCell { ...@@ -187,6 +240,33 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
make.height.equalTo(91) make.height.equalTo(91)
make.width.equalTo(147) make.width.equalTo(147)
} }
backSurfaceDeleteButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_delete"), for: .normal)
button.addTarget(self, action: #selector(backSurfaceDeleteClick), for: .touchUpInside)
button.isHidden = true
return button
}()
centerView.addSubview(backSurfaceDeleteButton)
backSurfaceDeleteButton.snp.makeConstraints { make in
make.centerX.equalTo(backSurfaceImageButton.snp.right)
make.centerY.equalTo(backSurfaceImageButton.snp.top)
make.height.equalTo(21)
make.width.equalTo(21)
}
activityIndicator = {
let view = UIActivityIndicatorView()
view.style = .medium
return view
}()
centerView.addSubview(activityIndicator)
activityIndicator.snp.makeConstraints { make in
make.center.equalTo(backSurfaceImageButton.snp.center)
make.height.equalTo(25)
make.width.equalTo(25)
}
} }
@objc func exampleClick() { @objc func exampleClick() {
...@@ -197,14 +277,113 @@ class YHMainInformationCardTableViewCell: UITableViewCell { ...@@ -197,14 +277,113 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
} }
@objc func frontImageClick() { @objc func frontImageClick() {
YHImagePickerView.show() { image in if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_front.count != 0 {
return
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_front.count != 0 {
return
}
}
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
self.activityIndicator.snp.remakeConstraints { make in
make.center.equalTo(self.frontImageButton.snp.center)
make.height.equalTo(25)
make.width.equalTo(25)
}
self.activityIndicator.startAnimating()
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.updateModel(self.type, isFront: true, url: url)
self.frontImageButton.setBackgroundImage(image, for: .normal)
self.frontDeleteButton.isHidden = false
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
if self.type == .identity {
self.viewModel.requestCnIDCardMessage(url) {[weak self] success, error in
guard let self = self else { return }
self.activityIndicator.stopAnimating()
if success {
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
} else {
self.viewModel.requestHkIDCardMessage(url) {[weak self] success, error in
guard let self = self else { return }
self.activityIndicator.stopAnimating()
if success {
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
}
// if let block = self.informationBlock {
// block(self.type, image, false)
// }
} }
} }
@objc func backSurfaceImageClick() { @objc func backSurfaceImageClick() {
YHImagePickerView.show() { image in if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_back.count != 0 {
return
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_back.count != 0 {
return
}
}
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
self.activityIndicator.snp.remakeConstraints { make in
make.center.equalTo(self.backSurfaceImageButton.snp.center)
make.height.equalTo(25)
make.width.equalTo(25)
}
self.activityIndicator.startAnimating()
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.backSurfaceImageButton.setBackgroundImage(image, for: .normal)
self.viewModel.updateModel(self.type, isFront: false, url: url)
self.backSurfaceDeleteButton.isHidden = false
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
if self.type == .identity {
self.viewModel.requestCnIDCardMessage(url) {[weak self] success, error in
guard let self = self else { return }
self.activityIndicator.stopAnimating()
if success {
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
} else {
self.viewModel.requestHkIDCardMessage(url) {[weak self] success, error in
guard let self = self else { return }
self.activityIndicator.stopAnimating()
if success {
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
}
// if let block = self.informationBlock {
// block(self.type, image, true)
// }
} }
} }
...@@ -214,5 +393,15 @@ class YHMainInformationCardTableViewCell: UITableViewCell { ...@@ -214,5 +393,15 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
backSurfaceLabel.text = "身份证国徽面" backSurfaceLabel.text = "身份证国徽面"
} }
@objc func frontDeleteClick() {
viewModel.updateModel(self.type, isFront: true, url: "")
frontDeleteButton.isHidden = true
frontImageButton.setBackgroundImage(UIImage(named: "service_card_front"), for: .normal)
}
@objc func backSurfaceDeleteClick() {
viewModel.updateModel(self.type, isFront: false, url: "")
backSurfaceDeleteButton.isHidden = true
backSurfaceImageButton.setBackgroundImage(UIImage(named: "service_card_back"), for: .normal)
}
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import SmartCodable import SmartCodable
import Alamofire
enum YHSaveType: Int { enum YHSaveType: Int {
case save = 0 case save = 0
...@@ -205,9 +206,80 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -205,9 +206,80 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
} }
} }
func updateModel(_ type: YHCardType, isFront: Bool, url: String) {
switch type {
case .identity:
if isFront {
mainModel.certificates.cn_identity_card.img_front = url
} else {
mainModel.certificates.cn_identity_card.img_back = url
}
case .passport:
if isFront {
mainModel.certificates.hk_macao_pass.img_front = url
} else {
mainModel.certificates.hk_macao_pass.img_back = url
}
}
}
func updateModel(_ model: YHHKIDCardModel) {
if model.name.count != 0 {
mainModel.username = model.name
}
if model.birth.count != 0 {
mainModel.birthday = model.birth.toTimeString()
}
if model.gender.count != 0 {
if model.gender == "女" {
mainModel.sex = 2
} else {
mainModel.sex = 1
}
}
if model.term_begins.count != 0 {
mainModel.certificates.hk_macao_pass.issue_date_start_at = model.term_begins.toTimeString()
}
if model.end_of_term.count != 0 {
mainModel.certificates.hk_macao_pass.issue_date_end_at = model.end_of_term.toTimeString()
}
if model.issuing_authority.count != 0 {
mainModel.certificates.hk_macao_pass.issue_at = model.issuing_authority
}
if model.card_num.count != 0 {
mainModel.certificates.hk_macao_pass.number = model.card_num
}
}
func updateModel(_ model: YHCNIDCardModel) {
if model.name.count != 0 {
mainModel.username = model.name
}
if model.birth.count != 0 {
mainModel.birthday = model.birth.toTimeString()
}
if model.gender.count != 0 {
if model.gender == "女" {
mainModel.sex = 2
} else {
mainModel.sex = 1
}
}
if model.term_begins.count != 0 {
mainModel.certificates.hk_macao_pass.issue_date_start_at = model.term_begins.toTimeString()
}
if model.end_of_term.count != 0 {
mainModel.certificates.hk_macao_pass.issue_date_end_at = model.end_of_term.toTimeString()
}
if model.issuing_authority.count != 0 {
mainModel.certificates.hk_macao_pass.issue_at = model.issuing_authority
}
if model.card_num.count != 0 {
mainModel.certificates.hk_macao_pass.number = model.card_num
}
}
func requestMainInformation(_ orderID: String, callBackBlock:@escaping (_ success: YHMainInformationModel?, _ error:YHErrorModel?)->()) { func requestMainInformation(_ orderID: String, callBackBlock:@escaping (_ success: YHMainInformationModel?, _ error:YHErrorModel?)->()) {
// /infoflow/order-information/get_information?order_id=9402
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.getInformation + "?order_id=\(orderID)" let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.getInformation + "?order_id=\(orderID)"
// let strUrl = "http://192.168.25.48:18088/" + YHAllApiName.OrderInformation.getInformation + "?order_id=\(orderID)" // let strUrl = "http://192.168.25.48:18088/" + YHAllApiName.OrderInformation.getInformation + "?order_id=\(orderID)"
// let params: [String : Any] = ["order_id": orderID] // let params: [String : Any] = ["order_id": orderID]
...@@ -301,6 +373,90 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -301,6 +373,90 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
} }
} }
// 上传方法
func uploadImage(_ image: UIImage, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/upload/storage"
let boundary = UUID().uuidString
let headers: HTTPHeaders = [
"Content-type": "multipart/form-data; boundary=\(boundary)",
"businessCode": "4001001"
]
let _ = YHNetRequest.uplaodRequest(url: strUrl, headers: headers, image: image) { [weak self] json, code in
guard let self = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil, err)
}
}
func getPublicImageUrl(_ url: String, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/storage/convertToPublicURL" + "?fileUrl=\(url)"
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil,err)
}
}
func requestCnIDCardMessage(_ url: String, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.cnIdCard
let params: [String : Any] = ["url": url]
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 result = YHCNIDCardModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(false, nil)
return
}
self.updateModel(result)
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func requestHkIDCardMessage(_ url: String, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.hkIdCard
let params: [String : Any] = ["url": url]
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 result = YHHKIDCardModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(false, nil)
return
}
self.updateModel(result)
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func isCanNext(_ step: Int) -> Bool { func isCanNext(_ step: Int) -> Bool {
if step == 0 { if step == 0 {
let nationality = mainModel.nationality let nationality = mainModel.nationality
......
...@@ -144,6 +144,19 @@ extension String { ...@@ -144,6 +144,19 @@ extension String {
dateformatter.dateFormat="yyyy-MM-dd HH:mm:ss" dateformatter.dateFormat="yyyy-MM-dd HH:mm:ss"
return dateformatter.string(from: date as Date) return dateformatter.string(from: date as Date)
} }
func toTimeString() -> String {
let formatter = DateFormatter()
formatter.dateFormat = "yyyyMMdd" // 设置输入的日期格式
if let date = formatter.date(from: self) {
let newformatter = DateFormatter()
newformatter.dateFormat = "yyyy-MM-dd" // 设置输出的日期格式
let formatterDateString = newformatter.string(from: date)
return formatterDateString
} else {
return ""
}
}
} }
// MARK: - 正则获取http // MARK: - 正则获取http
......
...@@ -116,6 +116,10 @@ class YHAllApiName { ...@@ -116,6 +116,10 @@ class YHAllApiName {
static let updateInformation = "infoflow/order-information/update_information" static let updateInformation = "infoflow/order-information/update_information"
// 主申请人国家信息 // 主申请人国家信息
static let countryInformation = "infoflow/country" static let countryInformation = "infoflow/country"
// 主申请人中国
static let cnIdCard = "infoflow/order-information/get_id_card"
// 主申请人港澳通行证
static let hkIdCard = "infoflow/order-information/get_hk_macao_pass"
} }
struct WorkExperience { struct WorkExperience {
......
...@@ -174,13 +174,13 @@ class YHNetRequest: NSObject { ...@@ -174,13 +174,13 @@ class YHNetRequest: NSObject {
return httpRequest return httpRequest
} }
guard let imageData = image.jpegData(compressionQuality: 1) else { return httpRequest } guard let imageData = image.jpegData(compressionQuality: 1) else { return httpRequest }
var multipartFormData = MultipartFormData() let multipartFormData = MultipartFormData()
// 将图片添加到multipartFormData中 // 将图片添加到multipartFormData中
multipartFormData.append(imageData, withName: "file", fileName: "image.jpg", mimeType: "image/jpeg") multipartFormData.append(imageData, withName: "file", fileName: "image.jpg", mimeType: "image/jpeg")
// 发送POST请求 // 发送POST请求
let uploadRequest = AF.upload(multipartFormData: multipartFormData, to: "https://test-comserver.galaxy-immi.com/oss/upload/storage", headers: headers) let uploadRequest = AF.upload(multipartFormData: multipartFormData, to: self.url!, headers: headers)
uploadRequest.responseString(completionHandler: { string in uploadRequest.responseString(completionHandler: { string in
#if DEBUG #if DEBUG
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "service_card_delete@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "service_card_delete@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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