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

// 赴港

parent dfc6263b
......@@ -334,16 +334,14 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa
if item.type == .goHKMakeCertificate {
// 赴港办证
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
var isGoHK: Bool? = nil
if self.isNeedGoHK == 0 {
isGoHK = false
} else if self.isNeedGoHK == 1 {
isGoHK = true
}
cell.selectIndex = btnIndex
cell.isSelectGoHK = isGoHK
cell.selectBlock = {
[weak self] index in
guard let self = self else { return }
......@@ -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 { // 已经预约过
// 是否赴港办证不能点击否 index 0是是按钮 1是否按钮
cell.disableBtn(index: 1)
} else {
// 否按钮不可点击且未选中 标题置灰
cell.optionsView.setOptionBtnDisabledAndUnselected(1)
cell.optionsView.setOptionBtnDisabled(index: 0, disabled: true)
}
return cell
}
......
......@@ -13,17 +13,17 @@ class YHCertificateAppointOptionCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateAppointOptionCell"
// 此处index 是按钮从左到右由0开始
var selectIndex = -1 {
// 选择是否赴港
var isSelectGoHK:Bool? {
didSet {
var selectIndex = -1 // 是否都未选择
if let isGoHK = isSelectGoHK {
selectIndex = isGoHK ? 0 : 1
}
optionsView.selectIndex = selectIndex
}
}
func disableBtn(index: Int) {
optionsView.setOptionBtnDisabled(index)
}
var selectBlock:((Int)->())?
lazy var whiteContentView: UIView = {
......
......@@ -111,7 +111,8 @@ class YHInfoItemOptionView: UIView {
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 {
setOptionBtnSelected(btn: btn, isSelect:false)
btn.isEnabled = false
......@@ -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) {
super.init(frame: frame)
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