Commit 394c9674 authored by David黄金龙's avatar David黄金龙

登录注册页 视频播放

parent 08a31016
...@@ -11,6 +11,7 @@ import IQKeyboardManagerSwift ...@@ -11,6 +11,7 @@ import IQKeyboardManagerSwift
import SmartCodable import SmartCodable
import GKNavigationBarSwift import GKNavigationBarSwift
import DeviceKit import DeviceKit
import AVFoundation
@main @main
class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
...@@ -32,6 +33,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { ...@@ -32,6 +33,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
//4.本地用户信息加载 //4.本地用户信息加载
YHLoginManager.shared.loadLocalUserInfoData() YHLoginManager.shared.loadLocalUserInfoData()
YHConfigManager.shared.loadConfigData() YHConfigManager.shared.loadConfigData()
//5.预加载
preloadOP()
//微信注册app //微信注册app
WXApi.registerApp("wx06b21f3c7a5ba594", universalLink: "https://www.galaxy-immi.com/app1/") WXApi.registerApp("wx06b21f3c7a5ba594", universalLink: "https://www.galaxy-immi.com/app1/")
WXApi.startLog(by: .detail) { string in WXApi.startLog(by: .detail) { string in
...@@ -119,6 +124,23 @@ extension AppDelegate { ...@@ -119,6 +124,23 @@ extension AppDelegate {
window?.rootViewController = nav window?.rootViewController = nav
window?.makeKeyAndVisible() window?.makeKeyAndVisible()
} }
private func preloadOP() {
DispatchQueue.global().async {
guard let videoURL = Bundle.main.url(forResource: "loginBkg", withExtension: "mov") else { return }
let player: AVPlayer? = AVPlayer(url: videoURL)
player?.actionAtItemEnd = .none
let playerLayer: AVPlayerLayer? = AVPlayerLayer(player: player)
playerLayer?.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)
playerLayer?.videoGravity = .resizeAspectFill
player?.play()
player?.pause()
}
}
} }
...@@ -33,6 +33,7 @@ class YHPhoneLiginWithVideoBkgViewController: YHBaseViewController { ...@@ -33,6 +33,7 @@ class YHPhoneLiginWithVideoBkgViewController: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
YHAnalytics.timeStrat("loginTime") YHAnalytics.timeStrat("loginTime")
IQKeyboardManager.shared.enable = false
} }
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
...@@ -60,13 +61,42 @@ class YHPhoneLiginWithVideoBkgViewController: YHBaseViewController { ...@@ -60,13 +61,42 @@ class YHPhoneLiginWithVideoBkgViewController: YHBaseViewController {
lazy var contentHoldView: UIView = { lazy var contentHoldView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .clear view.backgroundColor = .clear
// view.backgroundColor = .red //for test hjl
return view return view
}() }()
// 视图控制器被销毁前,移除所有观察者
deinit {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}
} }
extension YHPhoneLiginWithVideoBkgViewController { extension YHPhoneLiginWithVideoBkgViewController {
@objc func keyboardWillShow(notification: NSNotification) {
if ((notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue) != nil {
contentHoldView.snp.remakeConstraints { make in
make.top.equalTo(loginSubTitleLabel.snp.bottom).offset(72)
make.left.right.equalToSuperview()
}
}
}
// 键盘将要隐藏时的处理函数
@objc func keyboardWillHide(notification: NSNotification) {
contentHoldView.snp.remakeConstraints { make in
make.bottom.equalToSuperview().offset(-40)
make.left.right.equalToSuperview()
}
}
func setView() { func setView() {
view.backgroundColor = .white view.backgroundColor = .white
...@@ -76,6 +106,12 @@ extension YHPhoneLiginWithVideoBkgViewController { ...@@ -76,6 +106,12 @@ extension YHPhoneLiginWithVideoBkgViewController {
viewModel = YHLoginViewModel() viewModel = YHLoginViewModel()
// 添加键盘显示的观察者
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
// 添加键盘隐藏的观察者
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
setupBackgroundVideo() setupBackgroundVideo()
setupFrontUI() setupFrontUI()
...@@ -169,9 +205,6 @@ extension YHPhoneLiginWithVideoBkgViewController { ...@@ -169,9 +205,6 @@ extension YHPhoneLiginWithVideoBkgViewController {
phoneMessageView = { phoneMessageView = {
let view = YHPhoneMessageView() let view = YHPhoneMessageView()
view.backgroundColor = .clear//UIColor.contentBkgColor view.backgroundColor = .clear//UIColor.contentBkgColor
// view.layer.cornerRadius = kCornerRadius6
// view.layer.borderWidth = 1
// view.layer.borderColor = UIColor(hex:0xebeef4).cgColor
view.phoneBlock = {[weak self] count in view.phoneBlock = {[weak self] count in
guard let self = self else { return } guard let self = self else { return }
if count == 0 { if count == 0 {
...@@ -227,9 +260,6 @@ extension YHPhoneLiginWithVideoBkgViewController { ...@@ -227,9 +260,6 @@ extension YHPhoneLiginWithVideoBkgViewController {
} }
@objc func getCode() { @objc func getCode() {
IQKeyboardManager.shared.resignFirstResponder()
let phoneNumer = phoneMessageView.phoneTextField.text ?? "" let phoneNumer = phoneMessageView.phoneTextField.text ?? ""
guard phoneNumer.isMobile() == true else { guard phoneNumer.isMobile() == true else {
YHHUD.flash(message: "请输入正确的手机号") YHHUD.flash(message: "请输入正确的手机号")
...@@ -279,7 +309,8 @@ extension YHPhoneLiginWithVideoBkgViewController { ...@@ -279,7 +309,8 @@ extension YHPhoneLiginWithVideoBkgViewController {
@objc func close() { @objc func close() {
YHLoginManager.shared.loginSuccessActionBlock = nil YHLoginManager.shared.loginSuccessActionBlock = nil
self.dismiss(animated: true) IQKeyboardManager.shared.enable = true
dismiss(animated: true)
} }
} }
...@@ -294,6 +325,7 @@ extension YHPhoneLiginWithVideoBkgViewController { ...@@ -294,6 +325,7 @@ extension YHPhoneLiginWithVideoBkgViewController {
playerLayer?.videoGravity = .resizeAspectFill playerLayer?.videoGravity = .resizeAspectFill
view.layer.insertSublayer(playerLayer!, at: 0) view.layer.insertSublayer(playerLayer!, at: 0)
player?.play() player?.play()
player?.seek(to: .zero)
NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidPlayToEndTimeNotification), name: AVPlayerItem.didPlayToEndTimeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidPlayToEndTimeNotification), name: AVPlayerItem.didPlayToEndTimeNotification, object: nil)
......
...@@ -29,7 +29,7 @@ class YHLoginPrivacyView: UIView { ...@@ -29,7 +29,7 @@ class YHLoginPrivacyView: UIView {
agreeButton = { agreeButton = {
let button = UIButton(type: .custom) let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "login_privacy_disagree"), for: .normal) button.setBackgroundImage(UIImage(named: "login_privacy_disagree"), for: .normal)
button.setBackgroundImage(UIImage(named: "login_privacy_agree"), for: .selected) button.setBackgroundImage(UIImage(named: "login_privacy_agree_white"), for: .selected)
button.addTarget(self, action: #selector(agreeClick), for: .touchUpInside) button.addTarget(self, action: #selector(agreeClick), for: .touchUpInside)
return button return button
}() }()
...@@ -61,7 +61,7 @@ class YHLoginPrivacyView: UIView { ...@@ -61,7 +61,7 @@ class YHLoginPrivacyView: UIView {
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 12) button.titleLabel?.font = UIFont.PFSC_M(ofSize: 12)
button.contentHorizontalAlignment = .center button.contentHorizontalAlignment = .center
button.setTitle("《隐私协议》", for: .normal) button.setTitle("《隐私协议》", for: .normal)
button.setTitleColor(UIColor.brandMainColor, for: .normal) button.setTitleColor(UIColor.white, for: .normal)
button.addTarget(self, action: #selector(firstUrlClick), for: .touchUpInside) button.addTarget(self, action: #selector(firstUrlClick), for: .touchUpInside)
return button return button
}() }()
...@@ -91,7 +91,7 @@ class YHLoginPrivacyView: UIView { ...@@ -91,7 +91,7 @@ class YHLoginPrivacyView: UIView {
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 12) button.titleLabel?.font = UIFont.PFSC_M(ofSize: 12)
button.contentHorizontalAlignment = .center button.contentHorizontalAlignment = .center
button.setTitle("《用户条款》", for: .normal) button.setTitle("《用户条款》", for: .normal)
button.setTitleColor(UIColor.brandMainColor, for: .normal) button.setTitleColor(UIColor.white, for: .normal)
button.addTarget(self, action: #selector(secondUrlClick), for: .touchUpInside) button.addTarget(self, action: #selector(secondUrlClick), for: .touchUpInside)
return button return button
}() }()
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 3040@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 3040@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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