Commit e68e1c49 authored by David黄金龙's avatar David黄金龙

登录 注册页背景视频播放

parent a4bdef80
......@@ -419,6 +419,7 @@
A5DF3D462BF72BA1003D5F03 /* YHTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5DF3D452BF72BA0003D5F03 /* YHTestViewController.swift */; };
A5DF3D482BF9A1D0003D5F03 /* YHPhoneLiginWithVideoBkgViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5DF3D472BF9A1D0003D5F03 /* YHPhoneLiginWithVideoBkgViewController.swift */; };
A5DF3D4C2BF9A348003D5F03 /* loginBkg.mov in Resources */ = {isa = PBXBuildFile; fileRef = A5DF3D4B2BF9A348003D5F03 /* loginBkg.mov */; };
A5DF3D4E2BF9FDAC003D5F03 /* YHCodeSueecssWithVideoBkgViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5DF3D4D2BF9FDAC003D5F03 /* YHCodeSueecssWithVideoBkgViewController.swift */; };
A5E69D512BA304D400411932 /* DIN Alternate Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A5E69D502BA304D400411932 /* DIN Alternate Bold.ttf */; };
A5EF21312BA6DF94005027E6 /* YHMineSchemeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF21302BA6DF94005027E6 /* YHMineSchemeViewController.swift */; };
A5EF21332BA6E030005027E6 /* YHFileListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF21322BA6E030005027E6 /* YHFileListViewController.swift */; };
......@@ -889,6 +890,7 @@
A5DF3D452BF72BA0003D5F03 /* YHTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTestViewController.swift; sourceTree = "<group>"; };
A5DF3D472BF9A1D0003D5F03 /* YHPhoneLiginWithVideoBkgViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPhoneLiginWithVideoBkgViewController.swift; sourceTree = "<group>"; };
A5DF3D4B2BF9A348003D5F03 /* loginBkg.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = loginBkg.mov; sourceTree = "<group>"; };
A5DF3D4D2BF9FDAC003D5F03 /* YHCodeSueecssWithVideoBkgViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCodeSueecssWithVideoBkgViewController.swift; sourceTree = "<group>"; };
A5E69D502BA304D400411932 /* DIN Alternate Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DIN Alternate Bold.ttf"; sourceTree = "<group>"; };
A5EF21302BA6DF94005027E6 /* YHMineSchemeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMineSchemeViewController.swift; sourceTree = "<group>"; };
A5EF21322BA6E030005027E6 /* YHFileListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFileListViewController.swift; sourceTree = "<group>"; };
......@@ -2080,6 +2082,7 @@
04E86E0A2B70C13300A35F4B /* YHCodeSueecssViewController.swift */,
04E86E0C2B70D51D00A35F4B /* YHWebViewViewController.swift */,
A5DF3D472BF9A1D0003D5F03 /* YHPhoneLiginWithVideoBkgViewController.swift */,
A5DF3D4D2BF9FDAC003D5F03 /* YHCodeSueecssWithVideoBkgViewController.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2816,6 +2819,7 @@
A56D2D612B62020C009C83A8 /* YHContractMainItemStatusCell.swift in Sources */,
045EEECF2B9F171A0022A143 /* YHScoreOptionsView.swift in Sources */,
0445E6AF2BE9CFF6003C52F9 /* YHAppVersionForceUpdateView.swift in Sources */,
A5DF3D4E2BF9FDAC003D5F03 /* YHCodeSueecssWithVideoBkgViewController.swift in Sources */,
045EEEC12B9F171A0022A143 /* YHOtherInfoFillModel.swift in Sources */,
0468D43A2B579EAC00CFB916 /* YHLoginViewModel.swift in Sources */,
045EEE9E2B9F171A0022A143 /* YHWorkExampleModel.swift in Sources */,
......
......@@ -128,7 +128,6 @@ extension AppDelegate {
private func preloadOP() {
DispatchQueue.global().async {
guard let videoURL = Bundle.main.url(forResource: "loginBkg", withExtension: "mov") else { return }
......
......@@ -140,7 +140,7 @@ extension YHHKEventViewController {
YHShareManager.shared.sendLinkContent("一图看清香港办事", "", UIImage(named: "AppIcon") ?? UIImage(), link: urlString)
}
} else {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
}
......
......@@ -80,7 +80,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
view.likeBlock = { [weak self] flag in
guard let self = self else { return }
if YHLoginManager.shared.isLogin() == false {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
......@@ -111,7 +111,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
view.starBlock = { [weak self] flag in
guard let self = self else { return }
if YHLoginManager.shared.isLogin() == false {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
......@@ -244,7 +244,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
task.resume()
}
} else {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
}
......
......@@ -239,7 +239,7 @@ extension YHHomeCollectionViewCell {
}
}
} else {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.parentViewController?.navigationController?.present(vc, animated: true)
}
......
......@@ -212,16 +212,13 @@ class YHCodeSueecssViewController: YHBaseViewController {
sourceTimer.resume()
}
@objc func startClicked() {
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumber ?? "", callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
if success == true {
// YHHUD.flash(message: "验证码已下发,请注意查收")
self.startTime()
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
......
//
// YHCodeSueecssWithVideoBkgViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/5/19.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import IQKeyboardManagerSwift
import AVFoundation
class YHCodeSueecssWithVideoBkgViewController: YHBaseViewController {
var time = 60
var bgImageView: UIImageView!
var closeButton: UIButton!
var loginTitleLabel: UILabel!
var loginSubTitleLabel: UILabel!
var getCodeLabel: UILabel!
var getCodeButton: UIButton!
var smscodeView: YHSmsCodeInputView!
var phoneNumber: String?
var viewModel: YHLoginViewModel?
override func viewDidLoad() {
super.viewDidLoad()
setView()
startTime()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
smscodeView.textField.becomeFirstResponder()
}
//视频
private var player: AVPlayer?
private var playerLayer: AVPlayerLayer?
lazy var frontHoldView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x121A26, alpha: 0.32)
return view
}()
}
extension YHCodeSueecssWithVideoBkgViewController {
private func setupBackgroundVideo() {
guard let videoURL = Bundle.main.url(forResource: "loginBkg", withExtension: "mov") else { return }
player = AVPlayer(url: videoURL)
player?.actionAtItemEnd = .none
playerLayer = AVPlayerLayer(player: player)
playerLayer?.frame = view.bounds
playerLayer?.videoGravity = .resizeAspectFill
view.layer.insertSublayer(playerLayer!, at: 0)
player?.play()
player?.seek(to: .zero)
NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidPlayToEndTimeNotification), name: AVPlayerItem.didPlayToEndTimeNotification, object: nil)
}
@objc func playerItemDidPlayToEndTimeNotification() {
player?.seek(to: .zero)
}
}
extension YHCodeSueecssWithVideoBkgViewController {
func setView() {
viewModel = YHLoginViewModel()
gk_navBackgroundColor = .clear
gk_navShadowColor = .clear
gk_navigationBar.isHidden = true
view.backgroundColor = .white
setupBackgroundVideo()
setupFrontUI()
}
func requetLogin(phone: String, code: String) {
YHHUD.show(.progress(message: "登录中..."))
self.viewModel?.login(phone : phone, code: code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
if success == false {
YHHUD.flash(message: error?.errorMsg ?? "")
self.smscodeView.textField.becomeFirstResponder()
} else {
YHLoginManager.shared.loginSuccessActionBlock?()
YHHUD.flash(message: "登录成功")
IQKeyboardManager.shared.enable = true
self.dismiss(animated: true)
}
})
}
func startTime() {
getCodeLabel.isHidden = false
getCodeButton.isHidden = true
let sourceTimer = DispatchSource.makeTimerSource()
sourceTimer.schedule(deadline: DispatchTime.now(), repeating: DispatchTimeInterval.milliseconds(1000), leeway: DispatchTimeInterval.milliseconds(0))
sourceTimer.setEventHandler {
if self.time != 0 {
self.time -= 1
DispatchQueue.main.async {
self.getCodeLabel?.text = String.localizedStringWithFormat("重新获取(%ds)",self.time)
}
} else if self.time <= 0 {
sourceTimer.cancel()
DispatchQueue.main.async {
self.time = 60
self.getCodeLabel.isHidden = true
self.getCodeButton.isHidden = false
}
}
}
// 启动定时器
sourceTimer.resume()
}
@objc func startClicked() {
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumber ?? "", callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
if success == true {
self.startTime()
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
}
})
}
@objc func close() {
self.navigationController?.popViewController()
}
func setupFrontUI() {
// bgImageView = {
// let imageView = UIImageView()
// imageView.image = UIImage(named: "login_phone_bg_image")
// imageView.isUserInteractionEnabled = true
// return imageView
// }()
// view.addSubview(bgImageView)
// bgImageView.snp.makeConstraints { make in
// make.left.right.top.equalTo(view)
// make.height.equalTo(300)
// }
closeButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "login_back"), for: .normal)
button.addTarget(self, action: #selector(close), for: .touchUpInside)
return button
}()
view.addSubview(closeButton)
closeButton.snp.makeConstraints { make in
make.left.equalTo(13)
make.top.equalTo(51)
make.width.height.equalTo(30)
}
loginTitleLabel = {
let label = UILabel()
label.text = "请输入验证码"
label.font = UIFont.PFSC_M(ofSize: 28)
label.textColor = UIColor.mainTextColor
return label
}()
view.addSubview(loginTitleLabel)
loginTitleLabel.snp.makeConstraints { make in
make.left.equalTo(24)
make.right.equalTo(-24)
make.top.equalTo(203)
make.height.equalTo(25)
}
loginSubTitleLabel = {
let label = UILabel()
label.text = "已发送至 \(phoneNumber ?? "")"
label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = UIColor.placeHolderColor
return label
}()
view.addSubview(loginSubTitleLabel)
loginSubTitleLabel.snp.makeConstraints { make in
make.left.equalTo(24)
make.right.equalTo(-24)
make.top.equalTo(233)
make.height.equalTo(20)
}
smscodeView = {
let view = YHSmsCodeInputView(config: YHSmsCodeViewConfig())
view.complete = { [weak self] code in
guard let self = self else { return }
if let phone = self.phoneNumber {
// 登录接口需要加一个deviceToken参数
YHHUD.show(.progress(message: "登录中..."))
if YHLoginManager.shared.deviceTokenModel.registerId.isEmpty {
JPUSHService.registrationIDCompletionHandler {
resCode, registrationID in
YHHUD.hide()
YHLoginManager.shared.deviceTokenModel.registerId = registrationID ?? ""
self.requetLogin(phone: phone, code: code)
}
} else {
self.requetLogin(phone: phone, code: code)
}
} else {
printLog("errror : 电话号码为空")
}
}
return view
}()
view.addSubview(smscodeView)
smscodeView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(288)
make.height.equalTo(55)
}
getCodeLabel = {
let button = UILabel()
button.font = UIFont.PFSC_M(ofSize: 16)
button.text = "重新发送(58s)"
button.textColor = UIColor.init(hex: 0x000000,transparency: 0.4)
button.textAlignment = .center
button.isHidden = false
button.layer.cornerRadius = 24
button.backgroundColor = UIColor.init(hex: 0xffffff,transparency: 0.4)
button.clipsToBounds = true
// button.layer.borderWidth = 1
// button.layer.borderColor = UIColor(hex: 0xebeef4).cgColor
return button
}()
view.addSubview(getCodeLabel)
getCodeLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(382)
make.height.equalTo(48)
make.width.equalTo(335)
}
getCodeButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.contentHorizontalAlignment = .center
button.setTitle("获取验证码", for: .normal)
button.setTitleColor( UIColor(hex: 0x000000, alpha: 1.0), for: .normal)
button.addTarget(self, action: #selector(startClicked), for: .touchUpInside)
button.isHidden = true
button.layer.cornerRadius = 24
button.clipsToBounds = true
button.backgroundColor = UIColor(hex: 0xffffff, alpha: 1.0)
// button.layer.borderWidth = 1
// button.layer.borderColor = UIColor(hex: 0xebeef4).cgColor
return button
}()
view.addSubview(getCodeButton)
getCodeButton.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(382)
make.height.equalTo(48)
make.width.equalTo(335)
}
}
}
......@@ -69,6 +69,9 @@ class YHPhoneLiginWithVideoBkgViewController: YHBaseViewController {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
UITextField.appearance().tintColor = .brandMainColor
}
}
......@@ -82,7 +85,6 @@ extension YHPhoneLiginWithVideoBkgViewController {
make.top.equalTo(loginSubTitleLabel.snp.bottom).offset(72)
make.left.right.equalToSuperview()
}
}
}
......@@ -112,8 +114,9 @@ extension YHPhoneLiginWithVideoBkgViewController {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
setupBackgroundVideo()
UITextField.appearance().tintColor = .white
setupBackgroundVideo()
setupFrontUI()
}
......@@ -123,19 +126,6 @@ extension YHPhoneLiginWithVideoBkgViewController {
make.edges.equalToSuperview()
}
// bgImageView = {
// let imageView = UIImageView()
// imageView.image = UIImage(named: "login_phone_bg_image")
// imageView.isUserInteractionEnabled = true
// return imageView
// }()
// frontHoldView.addSubview(bgImageView)
// bgImageView.snp.makeConstraints { make in
// make.left.right.top.equalTo(view)
// make.height.equalTo(300)
// }
closeButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "login_close"), for: .normal)
......@@ -269,11 +259,9 @@ extension YHPhoneLiginWithVideoBkgViewController {
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumer, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
if success == true {
let vc = YHCodeSueecssViewController()
let vc = YHCodeSueecssWithVideoBkgViewController()
vc.phoneNumber = self.phoneMessageView.phoneTextField.text
self.navigationController?.pushViewController(vc)
} else {
......
......@@ -154,7 +154,7 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
func checkLogin()->Bool {
if YHLoginManager.shared.isLogin() == false {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return false
......@@ -275,7 +275,7 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
//#endif
if !checkLogin() {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
......
......@@ -139,7 +139,7 @@ class YHVideoPlayerVC: YHBaseViewController {
guard let self = self else { return }
if YHLoginManager.shared.isLogin() == false {
self.player.pause()
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
......@@ -171,7 +171,7 @@ class YHVideoPlayerVC: YHBaseViewController {
guard let self = self else { return }
if YHLoginManager.shared.isLogin() == false {
self.player.pause()
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
......@@ -266,7 +266,7 @@ extension YHVideoPlayerVC {
if YHLoginManager.shared.isLogin() == false {
self.player.pause()
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
let vc = UINavigationController(rootVC: YHPhoneLiginWithVideoBkgViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
......
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