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

// 办证

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