258 lines
8.5 KiB
Swift
258 lines
8.5 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)
|
|
view.addSubview(autonymView)
|
|
|
|
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(-28)
|
|
make.top.equalTo(view).offset(NavHeight + 20)
|
|
}
|
|
let width = (ScreenWidth - 56 - 11)/2
|
|
myRoomView.snp.makeConstraints { make in
|
|
make.height.equalTo(rechargeView)
|
|
make.width.equalTo(width)
|
|
make.top.equalTo(rechargeView.snp.bottom).offset(12)
|
|
make.left.equalTo(view).inset(28)
|
|
}
|
|
autonymView.snp.makeConstraints { make in
|
|
make.height.width.equalTo(myRoomView)
|
|
make.top.equalTo(rechargeView.snp.bottom).offset(12)
|
|
make.right.equalTo(view).inset(28)
|
|
}
|
|
mobileView.snp.makeConstraints { make in
|
|
make.left.equalTo(view).offset(28)
|
|
make.height.equalTo(68)
|
|
make.top.equalTo(myRoomView.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 autonymView: UserFunctionView = {
|
|
let _autonymView = UserFunctionView()
|
|
_autonymView.delegate = self
|
|
let item = UserFunctionItem(title: "实名认证", isHiddenIcon: true ,itmeType: .autonym)
|
|
_autonymView.item = item
|
|
return _autonymView
|
|
}()
|
|
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 params = ["uid":"\(AuthManager.userUid)","intoUid":"\(AuthManager.userUid)"]
|
|
RequestGet(path: "room/get", parma: params) { data in
|
|
if let info = Deserialized<RoomDataModel>.toModel(with: data) {
|
|
if info.isReselect{
|
|
if let isCertified = self.info?.isCertified,isCertified == false{
|
|
let popUpView = PlanetStarPopUpView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight))
|
|
self.view.addSubview(popUpView)
|
|
popUpView.textView.text = "为了营造更安全的网络环境\n在 开通个人房间前\n需要先进行实名认证"
|
|
popUpView.senderView.setTitle("去认证", for: .normal)
|
|
popUpView.bgPointView.isHidden = true
|
|
popUpView.pointTextView.isHidden = true
|
|
popUpView.clickSendBlcok = {[weak self] in
|
|
let web = WebViewController(url: "mew/\(H5Utils.autonym.rawValue)")
|
|
self?.navigationController?.pushViewController(web, animated: true)
|
|
}
|
|
}
|
|
}else{
|
|
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)
|
|
}
|
|
}
|
|
} fail: { code, message in
|
|
HUDTool.show(with: message)
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
case .logoff:
|
|
let web = WebViewController(url: "yinmeng/\(H5Utils.logoff.rawValue)")
|
|
self.navigationController?.pushViewController(web, animated: true)
|
|
case .about:
|
|
self.navigationController?.pushViewController(AboutUsVC(), animated: true)
|
|
case .autonym:
|
|
let web = WebViewController(url: "mew/\(H5Utils.autonym.rawValue)")
|
|
self.navigationController?.pushViewController(web, animated: true)
|
|
|
|
}
|
|
}
|
|
}
|