From a0071c0c7726d3e6742bc7c4c30536302766626a Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期一, 17 七月 2023 18:28:24 +0800 Subject: [PATCH] 完善 --- WanPai/Root/Activity/View/StudentUpdateInfoView.swift | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-) diff --git a/WanPai/Root/Activity/View/StudentUpdateInfoView.swift b/WanPai/Root/Activity/View/StudentUpdateInfoView.swift index 302435c..3e41306 100644 --- a/WanPai/Root/Activity/View/StudentUpdateInfoView.swift +++ b/WanPai/Root/Activity/View/StudentUpdateInfoView.swift @@ -7,21 +7,51 @@ import UIKit import JQTools +import QMUIKit +import RxSwift +let StudentUpdate_Nofi = Notification.Name.init("StudentUpdate_Nofi") class StudentUpdateInfoView: UIView,JQNibView{ @IBOutlet weak var view_container: UIView! @IBOutlet weak var cons_bottom: NSLayoutConstraint! + @IBOutlet weak var tf_height: QMUITextField! + @IBOutlet weak var tf_weight: QMUITextField! + @IBOutlet weak var tf_phone: QMUITextField! + + private var model:ActivityDetailPartModel? + private let disposeBag = DisposeBag() override func awakeFromNib() { super.awakeFromNib() cons_bottom.constant = -(JQ_ScreenW / 2) alpha = 0 layoutIfNeeded() + + NotificationCenter.default.rx.notification(UIApplication.keyboardWillHideNotification).subscribe(onNext: {noti in + if let userInfo = noti.userInfo{ + self.cons_bottom.constant = 0 + let duration = (userInfo["UIKeyboardAnimationDurationUserInfoKey"] as? Double) ?? 0 + UIView.animate(withDuration: duration) { + self.layoutIfNeeded() + } + } + }).disposed(by: disposeBag) + + NotificationCenter.default.rx.notification(UIApplication.keyboardWillShowNotification).subscribe(onNext: { noti in + if let userInfo = noti.userInfo{ + self.cons_bottom.constant = (userInfo["UIKeyboardFrameEndUserInfoKey"] as? CGRect)?.height ?? 0 + let duration = (userInfo["UIKeyboardAnimationDurationUserInfoKey"] as? Double) ?? 0 + UIView.animate(withDuration: duration) { + self.layoutIfNeeded() + } + } + }).disposed(by: disposeBag) } - static func show(){ + static func show(_ model:ActivityDetailPartModel){ let storesView = StudentUpdateInfoView.jq_loadNibView() + storesView.model = model storesView.frame = screnDelegate?.window?.frame ?? .zero screnDelegate?.window?.addSubview(storesView) storesView.cons_bottom.constant = 0 @@ -31,6 +61,30 @@ storesView.layoutIfNeeded() } } + + + @IBAction func saveAction(_ sender: UIButton) { + guard !tf_height.text!.isEmpty else {alertError(msg: "请输入身高");return} + guard !tf_weight.text!.isEmpty else {alertError(msg: "请输入体重");return} + + guard tf_height.text!.int != 0 else {alertError(msg: "请输入正确的身高");return} + guard tf_weight.text!.int != 0 else {alertError(msg: "请输入正确的体重");return} + + self.endEditing(true) + Services.editParticipant(id: model!.id, height: tf_height.text!.int!, weight: tf_weight.text!.int!, phone: tf_phone.text).subscribe(onNext: {data in + alertSuccess(msg: "修改成功") + DispatchQueue.main.asyncAfter(deadline: .now()+1) { + NotificationCenter.default.post(name: StudentUpdate_Nofi, object: nil) + self.close() + } + }).disposed(by: disposeBag) + } + + + @IBAction func closeAction(_ sender: UIButton) { + close() + } + private func close(){ self.cons_bottom.constant = -(JQ_ScreenW / 2) -- Gitblit v1.7.1