Commit c9c142f8 authored by Steven杜宇's avatar Steven杜宇

// 配偶信息填写

parent fda3d7de
......@@ -97,6 +97,7 @@ class YHSpouseFormVC: YHBaseViewController {
// 港澳通信证
let title3 = YHFormTitleItem(type: .getHKPassport)
let item30 = YHFormDetailItem(type: .hkPassport)
item30.isHandleHkPassport = true
let arr3:[YHFormItemProtocol] = [title3, item30]
items.append(contentsOf:[arr1, arr2, arr3])
......@@ -180,37 +181,53 @@ extension YHSpouseFormVC : UITableViewDelegate, UITableViewDataSource {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .accompany || detailItem.type == .hkPassport {
if detailItem.type == .accompany || detailItem.type == .hkPassport || detailItem.type == .isLiveTother {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemDoubleChoiceCell.cellReuseIdentifier, for: indexPath) as! YHFormItemDoubleChoiceCell
cell.title = detailItem.getTitle()
let answers = [YHFormChoiceItem(title: "是".local, isSelect: true),YHFormChoiceItem(title: "否".local, isSelect: false)]
cell.answerArr = answers
if detailItem.type == .accompany {
cell.response = detailItem.isAccompany
} else if detailItem.type == .hkPassport {
let answers =
[YHFormChoiceItem(title: "是".local, isSelect: detailItem.isAccompany),
YHFormChoiceItem(title: "否".local, isSelect: !detailItem.isAccompany)]
cell.answerArr = answers
} else if detailItem.type == .hkPassport {
let answers =
[YHFormChoiceItem(title: "是".local, isSelect: detailItem.isHandleHkPassport),
YHFormChoiceItem(title: "否".local, isSelect: !detailItem.isHandleHkPassport)]
cell.answerArr = answers
} else if detailItem.type == .isLiveTother {
let answers =
[YHFormChoiceItem(title: "是".local, isSelect: detailItem.isLiveTogether),
YHFormChoiceItem(title: "否".local, isSelect: !detailItem.isLiveTogether)]
cell.answerArr = answers
}
cell.responseBlock = {
cell.answerBlock = {
[weak self] (arr, selectIndex) in
[weak self] choice in
let selectItem:YHFormChoiceItem = arr[selectIndex]
if detailItem.type == .accompany {
self?.spouse?.follow = (choice ? 1 : 0)
if detailItem.type == .accompany { // 是否随行
let follow = (selectItem.title == "是".local ? 1 : 0)
self?.spouse?.follow = follow
self?.loadSponseInfo()
} else if detailItem.type == .hkPassport {
} else if detailItem.type == .hkPassport { // 是否办理港澳通行证
let handlePassport = (selectItem.title == "是".local ? 1 : 0)
self?.spouse?.isHandled = handlePassport
self?.loadSponseInfo()
} else if detailItem.type == .isLiveTother { // 是否与主申请人同住
let isLiveTother = (selectItem.title == "是".local ? 1 : 0)
}
}
return cell
} else if detailItem.type == .isLiveTother || detailItem.isHongKongMacouPassport {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemDoubleChoiceCell.cellReuseIdentifier, for: indexPath) as! YHFormItemDoubleChoiceCell
cell.title = detailItem.getTitle()
return cell
} else if detailItem.type == .country || detailItem.type == .liveContry || detailItem.type == .liveCity || detailItem.type == .detailAddress {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
......
......@@ -161,8 +161,8 @@ class YHFormDetailItem : YHFormItemProtocol {
// 是否随行
var isAccompany:Bool = false
// 港澳通信证
var isHongKongMacouPassport:Bool = false
// 是否办理港澳通信证
var isHandleHkPassport:Bool = false
// 国籍
var country:String? = ""
......
......@@ -8,6 +8,19 @@
import UIKit
// 选择项
class YHFormChoiceItem {
var title:String
// 是否被选中
var isSelect:Bool
init(title: String, isSelect: Bool) {
self.title = title
self.isSelect = isSelect
}
}
class YHFormItemDoubleChoiceCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemDoubleChoiceCell"
......@@ -15,11 +28,11 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
let btnHeight = 32.0
let btnTitleSelectColor = UIColor(hex: 0x4487F9)
let btnTitleDefaultColor = UIColor(hex:0x222222)
let btnBgColor = UIColor(hex:0xF8F9FB)
let negativeTag = 9527
let confirmTag = 9528
let btnBgDefaultColor = UIColor(hex:0xF8F9FB)
let btnBgSelectColor = UIColor(hex:0x4487F9, alpha: 0.08)
let answerBaseTag = 9527
var responseBlock:((Bool)->Void)?
var answerBlock:(([YHFormChoiceItem], Int)->Void)?
var title:String? {
didSet {
......@@ -35,16 +48,40 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(hex:0xFF3A3A), range: starRange)
titleLabel.attributedText = questionAttrStr
}
}
}
var response:Bool = false {
// 必须传2个item的arr
var answerArr:[YHFormChoiceItem]? {
didSet {
showResponse(response)
if let answerArr = answerArr, answerArr.count == 2 {
for i in 0...1 {
let answerBtn = self.viewWithTag(answerBaseTag+i) as! UIButton
let item = answerArr[i]
answerBtn.setTitle(item.title, for: .normal)
updateAnswerButton(answerBtn, item.isSelect)
}
} else {
// 重置所有答案状态
for i in 0...1 {
let answerBtn = self.viewWithTag(answerBaseTag+i) as! UIButton
answerBtn.setTitle("", for: .normal)
updateAnswerButton(answerBtn, false)
}
}
}
}
// 更新答案按钮选中状态
func updateAnswerButton(_ btn:UIButton, _ isSelect:Bool) {
btn.layer.borderColor = (isSelect ? btnTitleSelectColor : .clear).cgColor
btn.setTitleColor((isSelect ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal)
btn.backgroundColor = (isSelect ? btnBgSelectColor : btnBgDefaultColor)
}
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hexString:"#333333")
......@@ -54,24 +91,26 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
return label
}()
lazy var confirmBtn: UIButton = {
let btn = UIButton.bs_button(title: "是".local, font: UIFont.PFSCR(ofSize: 14), normalColor: btnTitleDefaultColor)
btn.backgroundColor = btnBgColor
lazy var answer1Btn: UIButton = {
let btn = UIButton.bs_button(title: "", font: UIFont.PFSCR(ofSize: 14), normalColor: btnTitleDefaultColor)
btn.backgroundColor = btnBgDefaultColor
btn.layer.cornerRadius = btnHeight/2.0
btn.layer.masksToBounds = true
btn.layer.borderWidth = 1
btn.tag = confirmTag
btn.layer.borderColor = UIColor.clear.cgColor
btn.tag = answerBaseTag
btn.addTarget(self, action: #selector(didClickResponseBtn(btn:)), for: .touchUpInside)
return btn
}()
lazy var negativeBtn: UIButton = {
let btn = UIButton.bs_button(title: "否".local, font: UIFont.PFSCR(ofSize: 14), normalColor: btnTitleDefaultColor)
btn.backgroundColor = btnBgColor
lazy var answer2Btn: UIButton = {
let btn = UIButton.bs_button(title: "", font: UIFont.PFSCR(ofSize: 14), normalColor: btnTitleDefaultColor)
btn.backgroundColor = btnBgDefaultColor
btn.layer.cornerRadius = btnHeight/2.0
btn.layer.masksToBounds = true
btn.layer.borderWidth = 1
btn.tag = negativeTag
btn.layer.borderColor = UIColor.clear.cgColor
btn.tag = answerBaseTag+1
btn.addTarget(self, action: #selector(didClickResponseBtn(btn:)), for: .touchUpInside)
return btn
}()
......@@ -93,42 +132,42 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
title = " 1、是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪? "
contentView.addSubview(titleLabel)
contentView.addSubview(negativeBtn)
contentView.addSubview(confirmBtn)
// 默认选择否按钮
response = false
contentView.addSubview(answer2Btn)
contentView.addSubview(answer1Btn)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(contentView.snp.top).offset(22)
make.left.equalToSuperview().offset(16)
make.right.equalTo(confirmBtn.snp.left).offset(-8)
make.right.equalTo(answer1Btn.snp.left).offset(-8)
make.bottom.equalTo(contentView.snp.bottom).offset(-22)
}
negativeBtn.snp.makeConstraints { make in
answer2Btn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.right.equalToSuperview().offset(-16)
make.top.equalToSuperview().offset(16)
}
confirmBtn.snp.makeConstraints { make in
answer1Btn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.right.equalTo(negativeBtn.snp.left).offset(-8)
make.top.equalTo(negativeBtn)
make.right.equalTo(answer2Btn.snp.left).offset(-8)
make.top.equalTo(answer2Btn)
}
}
@objc func didClickResponseBtn(btn: UIButton) {
response = (btn.tag == confirmTag)
if let responseBlock = responseBlock {
responseBlock(btn.tag==confirmTag)
let selectIndex = btn.tag-answerBaseTag
if let resultArr = answerArr, resultArr.count == 2 {
for i in 0...1 {
let item = resultArr[i]
item.isSelect = (i == selectIndex)
}
answerArr = resultArr
if let answerBlock = answerBlock {
answerBlock(resultArr, selectIndex)
}
}
}
func showResponse(_ isConfirm: Bool) {
confirmBtn.layer.borderColor = (isConfirm ? btnTitleSelectColor : .clear).cgColor
confirmBtn.setTitleColor((isConfirm ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal)
negativeBtn.layer.borderColor = (isConfirm ? .clear : btnTitleSelectColor).cgColor
negativeBtn.setTitleColor((isConfirm ? btnTitleDefaultColor: btnTitleSelectColor), for: .normal)
}
}
......@@ -44,6 +44,7 @@ class YHFormItemEnterDetailCell: UITableViewCell {
lazy var titleLabel: UILabel = {
let label = UILabel()
label.text = "XXXXXXX"
label.textColor = UIColor(hexString:"#333333")
label.textAlignment = .left
label.numberOfLines = 0
......@@ -53,6 +54,7 @@ class YHFormItemEnterDetailCell: UITableViewCell {
lazy var detailLabel: UILabel = {
let label = UILabel()
label.text = "XXXXXXX"
label.textColor = UIColor(hexString: "#888F98")
label.textAlignment = .right
label.numberOfLines = 0
......
......@@ -9,6 +9,8 @@
import UIKit
class YHFormItemQuestionCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemQuestionCell"
......
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