Files
yingmeng-ios-switf/yinmeng-ios/Modules/Auth/VC/AuthLaunchVC.swift
2024-02-29 01:07:15 +08:00

332 lines
8.7 KiB
Swift

//
// AuthLaunchVC.swift
// yinmeng-ios
//
// Created by MaiMang on 2024/2/21.
//
import UIKit
class AuthLaunchVC: BaseViewController, HiddenNavigationBarProtocol {
var viewModel:AuthViewModel = AuthViewModel.authVM
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(backImgView)
view.addSubview(logoImgView)
view.addSubview(titleLb)
view.addSubview(phoneLoginBtn)
view.addSubview(otherStackView)
view.addSubview(loginStackView)
view.addSubview(stackView)
view.addSubview(privacyView)
otherStackView.addArrangedSubview(leftView)
otherStackView.addArrangedSubview(otherLb)
otherStackView.addArrangedSubview(rightView)
loginStackView.addArrangedSubview(idView)
loginStackView.addArrangedSubview(appleView)
stackView.addArrangedSubview(boxBtn)
stackView.addArrangedSubview(protocolStackView)
protocolStackView.addArrangedSubview(agreeLb)
protocolStackView.addArrangedSubview(userProtocolBtn)
protocolStackView.addArrangedSubview(andLb)
protocolStackView.addArrangedSubview(privacyBtn)
privacyView.snp.makeConstraints { make in
make.edges.equalTo(view)
}
backImgView.snp.makeConstraints { make in
make.edges.equalTo(view)
}
logoImgView.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 88, height: 88))
make.centerX.equalTo(view)
make.top.equalTo(view).offset(StatusBarHeight + 76)
}
titleLb.snp.makeConstraints { make in
make.centerX.equalTo(view)
make.top.equalTo(logoImgView.snp.bottom).offset(16)
}
phoneLoginBtn.snp.makeConstraints { make in
make.left.right.equalTo(view).inset(40)
make.height.equalTo(52)
make.top.equalTo(titleLb.snp.bottom).offset(110)
}
otherStackView.snp.makeConstraints { make in
make.centerX.equalTo(view)
make.bottom.equalTo(loginStackView.snp.top).offset(-32)
}
leftView.snp.makeConstraints { make in
make.width.equalTo(100)
make.height.equalTo(0.5)
}
rightView.snp.makeConstraints { make in
make.width.equalTo(100)
make.height.equalTo(0.5)
}
loginStackView.snp.makeConstraints { make in
make.centerX.equalTo(view)
make.bottom.equalTo(stackView.snp.top).offset(-56)
}
idView.snp.makeConstraints { make in
make.width.equalTo(47)
make.height.equalTo(70)
}
appleView.snp.makeConstraints { make in
make.width.equalTo(47)
make.height.equalTo(70)
}
stackView.snp.makeConstraints { make in
make.centerX.equalTo(view)
make.bottom.equalTo(view).offset(-23 - SafeAraeBottomHeight)
}
boxBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 14, height: 14))
}
if UserDefaults.standard.bool(forKey: AuthPrivacyShowKey) == true {
privacyView.isHidden = true
} else {
UIView.animate(withDuration: 0.5) {
self.privacyView.isHidden = false
}
}
}
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 logoImgView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "auth_login_logo")
imageView.isUserInteractionEnabled = true
imageView.layer.masksToBounds = true
imageView.contentMode = .scaleAspectFill
return imageView
}()
private lazy var titleLb: UILabel = {
let label = UILabel()
label.textColor = UIColor.white
label.font = UIFont.systemFont(ofSize: 28, weight: .medium)
label.text = "欢迎来到音萌"
return label
}()
private lazy var phoneLoginBtn: 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 = 26
button.addTarget(self, action: #selector(phoneLoginBtnAction), for: .touchUpInside)
return button
}()
private lazy var otherStackView: UIStackView = {
let stackView = UIStackView()
stackView.distribution = .fill
stackView.axis = .horizontal
stackView.alignment = .center
stackView.spacing = 15
return stackView
}()
private lazy var leftView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var otherLb: UILabel = {
let label = UILabel()
label.textColor = .white
label.text = "其他登录方式"
label.font = UIFont.systemFont(ofSize: 13)
return label
}()
private lazy var rightView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var loginStackView: UIStackView = {
let stackView = UIStackView()
stackView.distribution = .fill
stackView.axis = .horizontal
stackView.alignment = .fill
stackView.spacing = 89
return stackView
}()
private lazy var idView: AuthItmeButton = {
let view = AuthItmeButton()
view.imageName = "auth_login_id"
view.title = "账号登录"
view.backgroundColor = .clear
view.addTarget(self, action: #selector(idClick), for: .touchUpInside)
return view
}()
private lazy var appleView: AuthItmeButton = {
let view = AuthItmeButton()
view.imageName = "auth_login_apple"
view.title = "iPhone登录"
view.backgroundColor = .clear
view.addTarget(self, action: #selector(appleClick), for: .touchUpInside)
return view
}()
private lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.distribution = .fill
stackView.axis = .horizontal
stackView.alignment = .fill
stackView.spacing = 4
return stackView
}()
private lazy var boxBtn: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "auth_login_box"), for: .normal)
button.setImage(UIImage(named: "auth_login_box_sel"), for: .selected)
button.addTarget(self, action: #selector(boxBtnAction), for: .touchUpInside)
return button
}()
private lazy var protocolStackView: UIStackView = {
let stackView = UIStackView()
stackView.distribution = .fill
stackView.axis = .horizontal
stackView.alignment = .fill
stackView.spacing = 0
return stackView
}()
private lazy var agreeLb: UILabel = {
let label = UILabel()
label.textColor = .white
label.font = UIFont.systemFont(ofSize: 12)
label.text = "同意"
return label
}()
private lazy var userProtocolBtn: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("《用户服务协议》", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 12)
button.addTarget(self, action: #selector(userProtocolBtnAction), for: .touchUpInside)
return button
}()
private lazy var andLb: UILabel = {
let label = UILabel()
label.textColor = .white
label.text = ""
label.font = UIFont.systemFont(ofSize: 12)
return label
}()
private lazy var privacyBtn: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("《隐私协议》", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 12)
button.addTarget(self, action: #selector(privacyBtnAction), for: .touchUpInside)
return button
}()
private lazy var privacyView: AuthPrivacyView = {
let view = AuthPrivacyView()
view.backgroundColor = .clear
view.isHidden = true
return view
}()
@objc func privacyBtnAction() {
let web = WebViewController(url: "yinmeng/\(H5Utils.privacy.rawValue)")
self.navigationController?.pushViewController(web, animated: true)
}
@objc func userProtocolBtnAction() {
let web = WebViewController(url: "yinmeng/\(H5Utils.privacy.rawValue)")
self.navigationController?.pushViewController(web, animated: true)
}
@objc func phoneLoginBtnAction() {
if self.boxBtn.isSelected == false {
HUDTool.show(with: "请阅读并勾选协议")
return
}
let loginVC = AuthLoginVC()
loginVC.index = 0
self.navigationController?.pushViewController(loginVC, animated: true)
}
@objc func idClick() {
if self.boxBtn.isSelected == false {
HUDTool.show(with: "请阅读并勾选协议")
return
}
let loginVC = AuthLoginVC()
loginVC.index = 1
self.navigationController?.pushViewController(loginVC, animated: true)
}
@objc func appleClick() {
if self.boxBtn.isSelected == false {
HUDTool.show(with: "请阅读并勾选协议")
return
}
AuthAppleManager.manager.authorizatio { info in
if let infor = info{
self.viewModel.authApple(params: infor)
}
}
}
@objc func boxBtnAction() {
self.boxBtn.isSelected = !self.boxBtn.isSelected
}
}
extension AuthLaunchVC {
private func loginApple() {
}
}