Commit 9f1109f5 authored by Steven杜宇's avatar Steven杜宇

// 办证

parent 5077d390
...@@ -14,7 +14,7 @@ class YHCertificateAppointViewController: YHBaseViewController { ...@@ -14,7 +14,7 @@ class YHCertificateAppointViewController: YHBaseViewController {
var items = ["", "", ""] var items = ["", "", ""]
let viewModel = YHCerAppointViewModel() let viewModel = YHCerAppointViewModel()
var isNeedGoHK: Int = 3 // 0不需要 1需要赴港 2没有选择 var isNeedGoHK: Int = 2 // 0不需要 1需要赴港 2没有选择
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped) let tableView = UITableView(frame:.zero, style:.grouped)
tableView.estimatedSectionHeaderHeight = 16.0 tableView.estimatedSectionHeaderHeight = 16.0
...@@ -50,12 +50,8 @@ class YHCertificateAppointViewController: YHBaseViewController { ...@@ -50,12 +50,8 @@ class YHCertificateAppointViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
} }
}
self.requetIsGoToHK()
func requetIsGoToHK() {
viewModel.getIsNeedGoToHK(orderId: orderId) { needGoHK in
}
} }
} }
...@@ -69,6 +65,33 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa ...@@ -69,6 +65,33 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa
if indexPath.row == 0 { if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHCertificateAppointOptionCell let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHCertificateAppointOptionCell
// 此处btnIndex 是从左到右按钮的index从0算起
// 按钮排序如下 [是0,否1]
var btnIndex = 1000
if self.isNeedGoHK == 0 { // 服务端0代表不需要,否
btnIndex = 1 // 选中第2个btn
} else if self.isNeedGoHK == 1 { // 服务端1代表需要,是
btnIndex = 0 // 选中第1个btn
}
cell.selectIndex = btnIndex
cell.selectBlock = {
[weak self] index in
guard let self = self else { return }
// 此处index表示第index个按钮
let isNeedHK = (index == 0)
YHHUD.show(.progress(message: "加载中..."))
self.saveNeedGoToHK(isNeed: isNeedHK) {
[weak self] success in
YHHUD.hide()
guard let self = self else { return }
if success {
self.isNeedGoHK = isNeedHK ? 1 : 0
}
self.tableView.reloadData()
}
}
return cell return cell
} }
...@@ -124,3 +147,23 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa ...@@ -124,3 +147,23 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa
} }
} }
extension YHCertificateAppointViewController {
func requetIsGoToHK() {
viewModel.getIsNeedGoToHK(orderId: orderId) {
[weak self] needGoHK in
guard let self = self else { return }
self.isNeedGoHK = needGoHK
self.tableView.reloadData()
}
}
func saveNeedGoToHK(isNeed:Bool, callback:((Bool)->())?) {
YHHUD.show(.progress(message: "加载中..."))
viewModel.saveNeedGoHK(orderId: orderId, need: isNeed) {
success in
callback?(success)
}
}
}
...@@ -13,6 +13,15 @@ class YHCertificateAppointOptionCell: UITableViewCell { ...@@ -13,6 +13,15 @@ class YHCertificateAppointOptionCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateAppointOptionCell" static let cellReuseIdentifier = "YHCertificateAppointOptionCell"
// 此处index 是按钮从左到右由0开始
var selectIndex = -1 {
didSet {
optionsView.selectIndex = selectIndex
}
}
var selectBlock:((Int)->())?
lazy var whiteContentView: UIView = { lazy var whiteContentView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .white view.backgroundColor = .white
...@@ -48,9 +57,11 @@ class YHCertificateAppointOptionCell: UITableViewCell { ...@@ -48,9 +57,11 @@ class YHCertificateAppointOptionCell: UITableViewCell {
let view = YHInfoItemOptionView(frame: .zero) let view = YHInfoItemOptionView(frame: .zero)
view.title = "是否赴港办证" view.title = "是否赴港办证"
view.setOptions(["是", "否"]) view.setOptions(["是", "否"])
view.selectIndex = 0 view.selectIndex = -1
view.selectBlock = { view.selectBlock = {
index in [weak self] index in
guard let self = self else { return }
self.selectBlock?(index)
} }
return view return view
}() }()
......
...@@ -180,6 +180,8 @@ class YHInfoItemOptionView: UIView { ...@@ -180,6 +180,8 @@ class YHInfoItemOptionView: UIView {
if let btn2 = self.viewWithTag(baseBtnTag + 1) as? UIButton { if let btn2 = self.viewWithTag(baseBtnTag + 1) as? UIButton {
setOptionBtnSelected(btn: btn2, isSelect: sender.tag == baseBtnTag + 1) setOptionBtnSelected(btn: btn2, isSelect: sender.tag == baseBtnTag + 1)
} }
selectBlock?(sender.tag-baseBtnTag)
} }
func getHeight(text:String, font:UIFont, width:CGFloat)->CGFloat { func getHeight(text:String, font:UIFont, width:CGFloat)->CGFloat {
......
...@@ -135,8 +135,13 @@ class YHCerAppointViewModel: NSObject { ...@@ -135,8 +135,13 @@ class YHCerAppointViewModel: NSObject {
printLog("model 是 ==> \(json)") printLog("model 是 ==> \(json)")
if json.code == 200 { if json.code == 200 {
//
if let dic = json.data as? [String:Any], let needGoHK = dic["is_need_to_hk"] as? Int {
callback?(needGoHK)
} else {
callback?(2)
}
} else { } else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg) let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHFamilyInfoConfirmViewController: YHBaseViewController { class YHFamilyInfoConfirmViewController: YHBaseViewController {
var orderId: Int = 151086 var orderId: Int = 0
var sectionItems:[String] = ["", "", "", ""] var sectionItems:[String] = ["", "", "", ""]
var familyArr: [YHApplicantInfoModel] = [] var familyArr: [YHApplicantInfoModel] = []
let viewModel = YHFamilyInfoConfirmViewModel() let viewModel = YHFamilyInfoConfirmViewModel()
......
...@@ -173,7 +173,7 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController { ...@@ -173,7 +173,7 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController {
items.append(arr1) items.append(arr1)
// arr2 递交证件信息 // arr2 递交证件信息
if let cer = self.detailMember.info.identity { if let _ = self.detailMember.info.identity {
let arr2 = viewModel.getCertificateInfo(self.detailMember) let arr2 = viewModel.getCertificateInfo(self.detailMember)
items.append(arr2) items.append(arr2)
} }
......
...@@ -355,16 +355,23 @@ extension YHInfoItemView: UITextFieldDelegate { ...@@ -355,16 +355,23 @@ extension YHInfoItemView: UITextFieldDelegate {
func updateNamePinYin() { func updateNamePinYin() {
// 编辑姓名 // 编辑姓名
if self.item.id == .mainApplicantName || self.item.id == .spouseName || self.item.id == .childName { if self.item.id == .mainApplicantName || self.item.id == .spouseName || self.item.id == .childName {
if let text = textField.text, !text.isEmpty {
YHHUD.show(.progress(message: "加载中...")) let text = textField.text ?? ""
self.viewModel.getPinYinFromName(text) { if text.isEmpty {
[weak self] firstNamePinYin, lastNamePinYin in self.faimilyInfo.familyName = ""
YHHUD.hide() self.faimilyInfo.givenName = ""
guard let self = self else { return } updateName?("")
self.faimilyInfo.familyName = firstNamePinYin return
self.faimilyInfo.givenName = lastNamePinYin }
updateName?(text)
} YHHUD.show(.progress(message: "加载中..."))
self.viewModel.getPinYinFromName(text) {
[weak self] firstNamePinYin, lastNamePinYin in
YHHUD.hide()
guard let self = self else { return }
self.faimilyInfo.familyName = firstNamePinYin
self.faimilyInfo.givenName = lastNamePinYin
updateName?(text)
} }
} }
} }
......
...@@ -345,11 +345,15 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -345,11 +345,15 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
if true { if true {
// test dy // test dy
if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") as? Int { // if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") as? Int {
let vc = YHFamilyInfoConfirmViewController() // let vc = YHFamilyInfoConfirmViewController()
vc.orderId = orderID // vc.orderId = orderID
self.navigationController?.pushViewController(vc) // self.navigationController?.pushViewController(vc)
} // }
let vc = YHCertificateAppointViewController()
vc.orderId = 151085
self.navigationController?.pushViewController(vc)
return return
} }
......
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