214 lines
6.2 KiB
Swift
214 lines
6.2 KiB
Swift
//
|
|
// UserInfoVC.swift
|
|
// yinmeng-ios
|
|
//
|
|
// Created by yinmeng on 2024/2/25.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class UserInfoVC: BaseViewController, HiddenNavigationBarProtocol {
|
|
|
|
var vm = UserViewModel.userVM
|
|
|
|
var info:UserObject?
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
loadSubView()
|
|
|
|
vm.selfInfo.subscribe(onNext: { [weak self] info in
|
|
self?.info = info
|
|
}).disposed(by: rx.disposeBag)
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
vm.getUserInfo(uid: AuthManager.userUid)
|
|
}
|
|
|
|
private func loadSubView() {
|
|
view.addSubview(backImgView)
|
|
view.addSubview(titleLb)
|
|
view.addSubview(rechargeView)
|
|
view.addSubview(myRoomView)
|
|
view.addSubview(mobileView)
|
|
view.addSubview(passwordView)
|
|
view.addSubview(aboutView)
|
|
view.addSubview(logOffView)
|
|
view.addSubview(logoutBtn)
|
|
|
|
backImgView.snp.makeConstraints { make in
|
|
make.edges.equalTo(view)
|
|
}
|
|
|
|
titleLb.snp.makeConstraints { make in
|
|
make.centerX.equalTo(view)
|
|
make.top.equalTo(view).offset(StatusBarHeight + 10)
|
|
make.height.equalTo(25)
|
|
}
|
|
|
|
rechargeView.snp.makeConstraints { make in
|
|
make.left.equalTo(view).inset(28)
|
|
make.height.equalTo(68)
|
|
make.right.equalTo(myRoomView.snp.left).offset(-11)
|
|
make.top.equalTo(view).offset(NavHeight + 20)
|
|
}
|
|
myRoomView.snp.makeConstraints { make in
|
|
make.centerY.height.width.equalTo(rechargeView)
|
|
make.right.equalTo(view).offset(-28)
|
|
}
|
|
mobileView.snp.makeConstraints { make in
|
|
make.left.equalTo(view).offset(28)
|
|
make.height.equalTo(68)
|
|
make.top.equalTo(rechargeView.snp.bottom).offset(12)
|
|
make.right.equalTo(passwordView.snp.left).offset(-11)
|
|
}
|
|
|
|
passwordView.snp.makeConstraints { make in
|
|
make.centerY.height.width.equalTo(mobileView)
|
|
make.right.equalTo(view).offset(-28)
|
|
}
|
|
|
|
aboutView.snp.makeConstraints { make in
|
|
make.width.centerX.height.equalTo(mobileView)
|
|
make.top.equalTo(mobileView.snp.bottom).offset(12)
|
|
}
|
|
|
|
logOffView.snp.makeConstraints { make in
|
|
make.width.centerX.height.equalTo(passwordView)
|
|
make.centerY.equalTo(aboutView)
|
|
}
|
|
|
|
logoutBtn.snp.makeConstraints { make in
|
|
make.left.right.equalTo(view).inset(40)
|
|
make.height.equalTo(48)
|
|
make.top.equalTo(logOffView.snp.bottom).offset(48)
|
|
}
|
|
|
|
}
|
|
|
|
@objc func logoutBtnAction() {
|
|
AuthViewModel.authVM.logout()
|
|
}
|
|
|
|
private lazy var backImgView: UIImageView = {
|
|
let imageView = UIImageView()
|
|
imageView.image = UIImage(named: "auth_login_bg")
|
|
imageView.isUserInteractionEnabled = true
|
|
imageView.layer.masksToBounds = true
|
|
imageView.contentMode = .scaleAspectFill
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var titleLb: UILabel = {
|
|
let label = UILabel()
|
|
label.textColor = .white
|
|
label.font = UIFont.systemFont(ofSize: 18, weight: .medium)
|
|
label.text = "我的"
|
|
return label
|
|
}()
|
|
|
|
private lazy var rechargeView: UserFunctionView = {
|
|
let view = UserFunctionView()
|
|
view.delegate = self
|
|
let item = UserFunctionItem(title: "充值", isHiddenIcon: false ,itmeType: .recharge)
|
|
view.item = item
|
|
return view
|
|
}()
|
|
private lazy var myRoomView: UserFunctionView = {
|
|
let _myRoomView = UserFunctionView()
|
|
_myRoomView.delegate = self
|
|
let item = UserFunctionItem(title: "我的房间", isHiddenIcon: true ,itmeType: .myRoom)
|
|
_myRoomView.item = item
|
|
return _myRoomView
|
|
}()
|
|
private lazy var mobileView: UserFunctionView = {
|
|
let view = UserFunctionView()
|
|
view.delegate = self
|
|
let item = UserFunctionItem(title: "手机号码", isHiddenIcon: true ,itmeType: .mobile)
|
|
view.item = item
|
|
return view
|
|
}()
|
|
|
|
|
|
private lazy var passwordView: UserFunctionView = {
|
|
let view = UserFunctionView()
|
|
view.delegate = self
|
|
let item = UserFunctionItem(title: "设置密码", isHiddenIcon: true ,itmeType: .password)
|
|
view.item = item
|
|
return view
|
|
}()
|
|
|
|
private lazy var aboutView: UserFunctionView = {
|
|
let view = UserFunctionView()
|
|
view.delegate = self
|
|
let item = UserFunctionItem(title: "关于", isHiddenIcon: true ,itmeType: .about)
|
|
view.item = item
|
|
return view
|
|
}()
|
|
|
|
private lazy var logOffView: UserFunctionView = {
|
|
let view = UserFunctionView()
|
|
view.delegate = self
|
|
let item = UserFunctionItem(title: "注销账号", isHiddenIcon: true ,itmeType: .logoff)
|
|
view.item = item
|
|
return view
|
|
}()
|
|
|
|
|
|
private lazy var logoutBtn: UIButton = {
|
|
let button = UIButton(type: .custom)
|
|
button.setBackgroundImage(UIImage.gradient([ThemeColor(hexStr: "#FF60FD"), ThemeColor(hexStr: "#8974FF"), ThemeColor(hexStr: "#69EBFF")], radius: 0), for: .normal)
|
|
button.setTitle("退出登录", for: .normal)
|
|
button.setTitleColor(UIColor.white, for: .normal)
|
|
button.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
|
|
button.layer.masksToBounds = true
|
|
button.layer.cornerRadius = 24
|
|
button.addTarget(self, action: #selector(logoutBtnAction), for: .touchUpInside)
|
|
return button
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
extension UserInfoVC: UserFunctionViewProtocol{
|
|
func didClickItem(type: UserFunctionType) {
|
|
switch type {
|
|
|
|
case .recharge:
|
|
let vc = UserPayViewController()
|
|
self.navigationController?.pushViewController(vc, animated: true)
|
|
print("aaa")
|
|
case .myRoom:
|
|
|
|
let vc = RoomVC(roomUid: "\(AuthManager.userUid)")
|
|
vc.roomText = (self.info?.nick ?? "") + "的房间"
|
|
let nav = BaseNavigationViewController.init(rootViewController: vc)
|
|
nav.modalPresentationStyle = .fullScreen
|
|
self.present(nav, animated: true, completion: nil)
|
|
case .mobile:
|
|
if self.info?.isBindPhone == true {
|
|
HUDTool.show(with: "您已绑定手机号")
|
|
} else {
|
|
self.navigationController?.pushViewController(BindMobileVC(), animated: true)
|
|
}
|
|
case .password:
|
|
if self.info?.isBindPhone == true {
|
|
let vc = PasswordSetVC()
|
|
vc.isSet = !(self.info?.isBindPasswd ?? false)
|
|
vc.phone = self.info?.phone
|
|
self.navigationController?.pushViewController(vc, animated: true)
|
|
} else {
|
|
self.navigationController?.pushViewController(BindMobileVC(), animated: true)
|
|
}
|
|
print("aaa")
|
|
case .logoff:
|
|
let web = WebViewController(url: "yinmeng/\(H5Utils.logoff.rawValue)")
|
|
self.navigationController?.pushViewController(web, animated: true)
|
|
case .about:
|
|
self.navigationController?.pushViewController(AboutUsVC(), animated: true)
|
|
}
|
|
}
|
|
}
|