Commit 3a9cc3dc authored by Steven杜宇's avatar Steven杜宇

// 赴港

parent dfc6263b
...@@ -334,16 +334,14 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa ...@@ -334,16 +334,14 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa
if item.type == .goHKMakeCertificate { if item.type == .goHKMakeCertificate {
// 赴港办证 // 赴港办证
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 var isGoHK: Bool? = nil
if self.isNeedGoHK == 0 {
isGoHK = false
} else if self.isNeedGoHK == 1 {
isGoHK = true
}
cell.isSelectGoHK = isGoHK
cell.selectBlock = { cell.selectBlock = {
[weak self] index in [weak self] index in
guard let self = self else { return } guard let self = self else { return }
...@@ -360,11 +358,15 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa ...@@ -360,11 +358,15 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa
} }
} }
// 默认设置两个按钮可点击
cell.optionsView.setOptionBtnDisabled(index: 0, disabled: false)
cell.optionsView.setOptionBtnDisabled(index: 1, disabled: false)
if self.reservationToHK == 1 { // 已经预约过 if self.reservationToHK == 1 { // 已经预约过
// 是否赴港办证不能点击否 index 0是是按钮 1是否按钮 // 是否赴港办证不能点击否 index 0是是按钮 1是否按钮
cell.disableBtn(index: 1) // 否按钮不可点击且未选中 标题置灰
} else { cell.optionsView.setOptionBtnDisabledAndUnselected(1)
cell.optionsView.setOptionBtnDisabled(index: 0, disabled: true)
} }
return cell return cell
} }
......
...@@ -13,15 +13,15 @@ class YHCertificateAppointOptionCell: UITableViewCell { ...@@ -13,15 +13,15 @@ class YHCertificateAppointOptionCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateAppointOptionCell" static let cellReuseIdentifier = "YHCertificateAppointOptionCell"
// 此处index 是按钮从左到右由0开始 // 选择是否赴港
var selectIndex = -1 { var isSelectGoHK:Bool? {
didSet { didSet {
optionsView.selectIndex = selectIndex var selectIndex = -1 // 是否都未选择
if let isGoHK = isSelectGoHK {
selectIndex = isGoHK ? 0 : 1
} }
optionsView.selectIndex = selectIndex
} }
func disableBtn(index: Int) {
optionsView.setOptionBtnDisabled(index)
} }
var selectBlock:((Int)->())? var selectBlock:((Int)->())?
......
...@@ -111,7 +111,8 @@ class YHInfoItemOptionView: UIView { ...@@ -111,7 +111,8 @@ class YHInfoItemOptionView: UIView {
btn.setTitleColor(isSelect ? UIColor.brandMainColor : UIColor.init(hex: 0x222222), for: .normal) btn.setTitleColor(isSelect ? UIColor.brandMainColor : UIColor.init(hex: 0x222222), for: .normal)
} }
func setOptionBtnDisabled(_ index: Int) { // 禁用按钮且更新为未选择状态并将标题置灰
func setOptionBtnDisabledAndUnselected(_ index: Int) {
if let btn = self.viewWithTag(baseBtnTag + index) as? UIButton { if let btn = self.viewWithTag(baseBtnTag + index) as? UIButton {
setOptionBtnSelected(btn: btn, isSelect:false) setOptionBtnSelected(btn: btn, isSelect:false)
btn.isEnabled = false btn.isEnabled = false
...@@ -119,6 +120,13 @@ class YHInfoItemOptionView: UIView { ...@@ -119,6 +120,13 @@ class YHInfoItemOptionView: UIView {
} }
} }
// 是否禁用按钮点击
func setOptionBtnDisabled(index: Int, disabled: Bool) {
if let btn = self.viewWithTag(baseBtnTag + index) as? UIButton {
btn.isEnabled = !disabled
}
}
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
createUI() createUI()
......
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