Commit 25c67bb2 authored by Steven杜宇's avatar Steven杜宇

// 活动

parent e197756e
...@@ -145,7 +145,8 @@ extension YHActivityDetailViewController { ...@@ -145,7 +145,8 @@ extension YHActivityDetailViewController {
} }
func showApplyUI() { func showApplyUI() {
YHApplyActivityAlert.showApplyActivityAlertView(name: viewModel.activityDetailModel?.businessCardName ?? "") { tag, name, number, phone in var phone = YHLoginManager.shared.userModel?.mobile ?? ""
let view: YHApplyActivityAlert = YHApplyActivityAlert.showApplyActivityAlertView(name: viewModel.activityDetailModel?.businessCardName ?? "", phone_number: phone) { tag, name, number, phone in
if tag { if tag {
printLog(tag) printLog(tag)
printLog(name) printLog(name)
...@@ -160,6 +161,7 @@ extension YHActivityDetailViewController { ...@@ -160,6 +161,7 @@ extension YHActivityDetailViewController {
} }
} }
} }
view.phoneTextField.isUserInteractionEnabled = phone.isEmpty
} }
func setupUI() { func setupUI() {
......
...@@ -45,6 +45,138 @@ class YHActivityTravelViewController: YHBaseViewController { ...@@ -45,6 +45,138 @@ class YHActivityTravelViewController: YHBaseViewController {
return view return view
}() }()
lazy var bottomView: UIView = {
let v = UIView()
v.isHidden = true
v.backgroundColor = .white
v.addSubview(rightBtn)
v.addSubview(leftBtn)
leftBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(8)
make.height.equalTo(46)
}
rightBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(8)
make.height.equalTo(46)
}
return v
}()
lazy var leftBtn: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.white
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.contentHorizontalAlignment = .center
button.setTitleColor(.brandGrayColor8, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.layer.borderWidth = 0.5
button.layer.borderColor = UIColor.brandGrayColor8.cgColor
button.addTarget(self, action: #selector(clickleftButton), for: .touchUpInside)
button.clipsToBounds = true
return button
}()
lazy var rightBtn: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandGrayColor8
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.contentHorizontalAlignment = .center
button.setTitleColor(UIColor.white, for: .normal)
button.setTitle("扫码签到", for: .normal)
button.setImage(UIImage(named: "salon_scan"), for: .normal)
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 4, bottom: 0, right: 0)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 4)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(didRightBtnClicked), for: .touchUpInside)
button.clipsToBounds = true
return button
}()
@objc func didRightBtnClicked() {
func goToScanVC() {
let checkInVC = YHScanViewController.create(types: .checkIn) { [weak self] result in
guard let self = self else {
return
}
print("签到码: \(result.code)")
if let type = result.recognizedType, type == YHScanType.checkIn { // 活动扫码签到
if !type.prefixString.isEmpty, result.code.contains(type.prefixString) {
let signId = result.code.replacingOccurrences(of: type.prefixString, with: "")
let vc = YHActivitySignSuccessViewController()
vc.activityId = signId
self.navigationController?.pushViewController(vc)
return
}
}
}
navigationController?.pushViewController(checkInVC, animated: true)
}
}
func updateBottomView() {
guard let model = self.viewModel.activityTravelModel else {
return
}
var isHiddenBottomView = true
leftBtn.snp.remakeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(8)
make.height.equalTo(46)
}
rightBtn.snp.remakeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(8)
make.height.equalTo(46)
}
if model.status.int == YHActivityStatus.applied.rawValue {
// 已报名
leftBtn.setTitle("取消报名", for: .normal)
isHiddenBottomView = false
leftBtn.snp.remakeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(rightBtn.snp.left).offset(-10)
make.width.equalTo(rightBtn)
make.top.equalTo(8)
make.height.equalTo(46)
}
rightBtn.snp.remakeConstraints { make in
make.right.equalTo(-16)
make.top.equalTo(8)
make.height.equalTo(46)
}
} else if model.status.int == YHActivityStatus.notApply.rawValue || model.status.int == YHActivityStatus.canceled.rawValue {
// 立即报名或已取消报名
leftBtn.setTitle("重新报名", for: .normal)
isHiddenBottomView = false
} else if model.status.int == YHActivityStatus.end.rawValue {
// 活动已结束
isHiddenBottomView = true
} else if model.status.int == YHActivityStatus.soldout.rawValue {
// 活动已下架
isHiddenBottomView = false
} else {
isHiddenBottomView = true
}
self.bottomView.isHidden = isHiddenBottomView
self.bottomView.snp.updateConstraints { make in
make.height.equalTo(isHiddenBottomView ? 0 : 64+k_Height_safeAreaInsetsBottom())
}
}
// MARK: - 生命周期方法 // MARK: - 生命周期方法
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -141,6 +273,7 @@ extension YHActivityTravelViewController { ...@@ -141,6 +273,7 @@ extension YHActivityTravelViewController {
// 1. // 1.
view.addSubview(topBkgImageV) view.addSubview(topBkgImageV)
view.addSubview(tableView) view.addSubview(tableView)
view.addSubview(bottomView)
topBkgImageV.snp.makeConstraints { make in topBkgImageV.snp.makeConstraints { make in
make.top.left.right.equalToSuperview() make.top.left.right.equalToSuperview()
...@@ -153,7 +286,12 @@ extension YHActivityTravelViewController { ...@@ -153,7 +286,12 @@ extension YHActivityTravelViewController {
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.equalTo(20) make.left.equalTo(20)
make.right.equalTo(-20) make.right.equalTo(-20)
make.bottom.equalToSuperview() make.bottom.equalTo(bottomView.snp.top)
}
bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(64+k_Height_safeAreaInsetsBottom())
} }
} }
...@@ -161,6 +299,7 @@ extension YHActivityTravelViewController { ...@@ -161,6 +299,7 @@ extension YHActivityTravelViewController {
if !travelId.isEmpty { if !travelId.isEmpty {
viewModel.getActivityTravelDetail(travelId: travelId) { success, error in viewModel.getActivityTravelDetail(travelId: travelId) { success, error in
if success { if success {
self.updateBottomView()
self.tableView.reloadData() self.tableView.reloadData()
} else { } else {
let msg = error?.errorMsg ?? "获取数据出错" let msg = error?.errorMsg ?? "获取数据出错"
...@@ -186,7 +325,7 @@ extension YHActivityTravelViewController { ...@@ -186,7 +325,7 @@ extension YHActivityTravelViewController {
} }
} }
func clickBottomButton() { @objc func clickleftButton() {
if self.viewModel.activityTravelModel?.status.int == 2 { if self.viewModel.activityTravelModel?.status.int == 2 {
// 取消 // 取消
YHCommonAlertView.show("", "是否取消报名?", "是", "否", fullGuestureEnable: false) { YHCommonAlertView.show("", "是否取消报名?", "是", "否", fullGuestureEnable: false) {
...@@ -236,9 +375,6 @@ extension YHActivityTravelViewController: UITableViewDelegate, UITableViewDataSo ...@@ -236,9 +375,6 @@ extension YHActivityTravelViewController: UITableViewDelegate, UITableViewDataSo
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityTravelCell.cellReuseIdentifier, for: indexPath) as? YHActivityTravelCell else { return UITableViewCell() } guard let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityTravelCell.cellReuseIdentifier, for: indexPath) as? YHActivityTravelCell else { return UITableViewCell() }
cell.dataModel = viewModel.activityTravelModel cell.dataModel = viewModel.activityTravelModel
cell.block = {[weak self] in
self?.clickBottomButton()
}
return cell return cell
} }
......
...@@ -18,10 +18,7 @@ class YHActivityTravelCell: UITableViewCell { ...@@ -18,10 +18,7 @@ class YHActivityTravelCell: UITableViewCell {
updateUI() updateUI()
} }
} }
typealias Block = () -> Void
var block: Block?
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
} }
...@@ -58,22 +55,6 @@ class YHActivityTravelCell: UITableViewCell { ...@@ -58,22 +55,6 @@ class YHActivityTravelCell: UITableViewCell {
view.showLineFlag = false view.showLineFlag = false
return view return view
}() }()
// 取消活动
lazy var cancelButton: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandMainColor
button.titleLabel?.font = UIFont.PFSC_R(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("取消报名", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(clickCancelBtn), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
return button
}()
} }
extension YHActivityTravelCell { extension YHActivityTravelCell {
...@@ -83,41 +64,17 @@ extension YHActivityTravelCell { ...@@ -83,41 +64,17 @@ extension YHActivityTravelCell {
} }
if model.status.int == 2 { if model.status.int == 2 {
cancelButton.isHidden = false
cancelButton.setTitle("取消报名", for: .normal)
cancelButton.setTitle("取消报名", for: .highlighted)
cancelButton.setTitleColor(UIColor.mainTextColor, for: .normal)
cancelButton.setTitleColor(UIColor.mainTextColor, for: .highlighted)
cancelButton.backgroundColor = .clear
cancelButton.layer.borderWidth = 1
cancelButton.layer.borderColor = UIColor.mainTextColor50.cgColor
statusLable.text = "已报名" statusLable.text = "已报名"
} else if model.status.int == 4 || model.status.int == 1 {
cancelButton.isHidden = false
cancelButton.setTitle("重新报名", for: .normal)
cancelButton.setTitle("重新报名", for: .highlighted)
cancelButton.setTitleColor(UIColor.white, for: .normal)
cancelButton.setTitleColor(UIColor.white, for: .highlighted)
cancelButton.backgroundColor = .brandMainColor
cancelButton.layer.borderWidth = 0
cancelButton.layer.borderColor = UIColor.clear.cgColor
} else if model.status.int == 4 || model.status.int == 1 {
statusLable.text = "已取消" statusLable.text = "已取消"
} else if model.status.int == 3 {
cancelButton.isHidden = true
} else if model.status.int == 3 {
statusLable.text = "活动结束" statusLable.text = "活动结束"
} else if model.status.int == 5 { } else if model.status.int == 5 {
cancelButton.isHidden = true
statusLable.text = "已下架" statusLable.text = "已下架"
} else { } else {
cancelButton.isHidden = true
statusLable.text = "" statusLable.text = ""
} }
...@@ -141,25 +98,13 @@ extension YHActivityTravelCell { ...@@ -141,25 +98,13 @@ extension YHActivityTravelCell {
acitivityTips.snp.remakeConstraints { make in acitivityTips.snp.remakeConstraints { make in
make.top.equalTo(acitivityApplyInfo.snp.bottom).offset(32) make.top.equalTo(acitivityApplyInfo.snp.bottom).offset(32)
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.bottom.equalTo(-32)
} }
acitivityTips.layoutIfNeeded() acitivityTips.layoutIfNeeded()
lastView = acitivityTips lastView = acitivityTips
} else { } else {
acitivityTips.isHidden = true acitivityTips.isHidden = true
} }
cancelButton.snp.remakeConstraints { make in
make.top.equalTo(lastView.snp.bottom).offset(32)
make.width.equalTo(178)
make.height.equalTo(42)
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-46)
}
}
@objc func clickCancelBtn() {
self.block?()
} }
func setupUI() { func setupUI() {
...@@ -171,7 +116,6 @@ extension YHActivityTravelCell { ...@@ -171,7 +116,6 @@ extension YHActivityTravelCell {
contentView.addSubview(acitivityTitle) contentView.addSubview(acitivityTitle)
contentView.addSubview(acitivityApplyInfo) contentView.addSubview(acitivityApplyInfo)
contentView.addSubview(acitivityTips) contentView.addSubview(acitivityTips)
contentView.addSubview(cancelButton)
statusLable.snp.makeConstraints { make in statusLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20) make.top.equalToSuperview().offset(20)
...@@ -193,16 +137,9 @@ extension YHActivityTravelCell { ...@@ -193,16 +137,9 @@ extension YHActivityTravelCell {
acitivityTips.snp.makeConstraints { make in acitivityTips.snp.makeConstraints { make in
make.top.equalTo(acitivityApplyInfo.snp.bottom).offset(32) make.top.equalTo(acitivityApplyInfo.snp.bottom).offset(32)
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.bottom.equalTo(-32)
} }
acitivityTips.layoutIfNeeded() acitivityTips.layoutIfNeeded()
cancelButton.snp.makeConstraints { make in
make.top.equalTo(acitivityTips.snp.bottom).offset(32)
make.width.equalTo(178)
make.height.equalTo(42)
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-46)
}
} }
} }
...@@ -129,16 +129,20 @@ class YHApplyActivityAlert: UIView { ...@@ -129,16 +129,20 @@ class YHApplyActivityAlert: UIView {
}() }()
// 类方法 - 展示 // 类方法 - 展示
static func showApplyActivityAlertView(name: String = "", callBack: @escaping Block) { static func showApplyActivityAlertView(name: String = "", phone_number: String = "", callBack: @escaping Block) -> YHApplyActivityAlert {
let view = YHApplyActivityAlert(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)) let view = YHApplyActivityAlert(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
var ttt = name var ttt = name
let tName = ttt.slice(from: 0, length: 10) let tName = ttt.slice(from: 0, length: 10)
view.applyName = tName view.applyName = tName
view.nameTextField.text = tName view.nameTextField.text = tName
view.applyPhone = phone_number
view.phoneTextField.text = phone_number
view.block = callBack view.block = callBack
view.updateButtonUI()
let window = UIApplication.shared.yhKeyWindow() let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view) window?.addSubview(view)
return view
} }
override init(frame: CGRect) { override init(frame: CGRect) {
......
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