Browse Source

1.添加手机号登陆

wenweiwei 4 years ago
parent
commit
fb83aa3b7e

+ 19 - 19
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Base/Controllers/MVBaseController.swift

@@ -4,11 +4,11 @@
 //
 //  Created by ak on 2021/6/2.
 //
- 
+
 import Alamofire
-import UIKit
-import NXFramework_Swift
 import BFFramework
+import NXFramework_Swift
+import UIKit
 public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
     // 侧滑拦截返回
     public var popGestureHandle: (() -> Void)?
@@ -23,17 +23,15 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
         }
     }
 
-    lazy public var manager: NetworkReachabilityManager? = {
+    public lazy var manager: NetworkReachabilityManager? = {
         let manager = NetworkReachabilityManager(host: "www.baidu.com")
         manager?.listener = { status in
-            if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {
-           
-            }
+            if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {}
         }
         return manager
     }()
 
-     override public func viewDidLoad() {
+    override public func viewDidLoad() {
         super.viewDidLoad()
         navigationController?.isNavigationBarHidden = true
         view.backgroundColor = UIColor.white
@@ -43,7 +41,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
         navHeadImageView?.backgroundColor = UIColor.white
         navHeadImageView?.frame = CGRect(x: 0, y: 0, width: cScreenWidth, height: cDevice_iPhoneNavBarAndStatusBarHei)
         view.addSubview(navHeadImageView!)
- 
+
         UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
         automaticallyAdjustsScrollViewInsets = false
         navigationController?.interactivePopGestureRecognizer?.delegate = self
@@ -52,7 +50,6 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
 
     public func hiddenNavigation() {
         navHeadImageView?.isHidden = true
-
     }
 
     func showNavigation() {
@@ -71,7 +68,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
         let leftButton = UIButton(type: .custom)
         leftButton.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
         leftButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
-        leftButton.setImage(UIImage(named:  image ?? "icon_detail_back"), for: .normal)
+        leftButton.setImage(UIImage(named: image ?? "icon_detail_back"), for: .normal)
         leftButton.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
         navHeadImageView?.addSubview(leftButton)
         backButton = leftButton
@@ -114,22 +111,25 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
     @objc func rightBtnClick(sender _: UIButton) {}
 
     @objc func backBtnClick() {
-        navigationController?.popViewController(animated: true)
+        if navigationController != nil {
+            navigationController?.popViewController(animated: true)
+        } else {
+            dismiss(animated: true, completion: nil)
+        }
     }
 
-    public override func viewDidAppear(_ animated: Bool) {
+    override public func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
-      
     }
 
-    public override func viewWillDisappear(_ animated: Bool) {
+    override public func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
 //        PQLoadingHUB.shared.dismissHUB()
     }
 
-    public override func viewDidDisappear(_ animated: Bool) {
+    override public func viewDidDisappear(_ animated: Bool) {
         super.viewDidDisappear(animated)
-       
+
         if view.viewWithTag(cGuideTag) != nil {
             view.viewWithTag(cGuideTag)?.removeFromSuperview()
         }
@@ -140,7 +140,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
         BFLog(message: "\(String(describing: type(of: self)))被销毁")
     }
 
-    public override var preferredStatusBarStyle: UIStatusBarStyle {
+    override public var preferredStatusBarStyle: UIStatusBarStyle {
         if #available(iOS 13.0, *) {
             return .darkContent
         } else {
@@ -149,7 +149,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
         }
     }
 
-    public override var prefersStatusBarHidden: Bool {
+    override public var prefersStatusBarHidden: Bool {
         return isHiddenStatus
     }
 

+ 23 - 16
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Login/Controllers/MVLoginController.swift

@@ -6,10 +6,10 @@
 //
 
 import AuthenticationServices
-import JWTDecode
-import UIKit
 import BFFramework
+import JWTDecode
 import TYAttributedLabel
+import UIKit
 
 class MVLoginController: MVBaseController {
     let nomalH: CGFloat = cDefaultMargin * 5
@@ -65,9 +65,9 @@ class MVLoginController: MVBaseController {
         return phoneLoginBtn
     }()
 
-    //icon
+    // icon
     lazy var IconView: UIImageView = {
-        let IconView = UIImageView.init(image: UIImage(named: "1024x1024px"))
+        let IconView = UIImageView(image: UIImage(named: "1024x1024px"))
         return IconView
     }()
 
@@ -86,12 +86,12 @@ class MVLoginController: MVBaseController {
             remindBtn.setTitle("  \(remindTitle ?? "登录")  ", for: .normal)
         }
     }
-    
+
     @objc override func backBtnClick() {
         dismiss(animated: true, completion: nil)
     }
 
-    override  func viewDidLoad() {
+    override func viewDidLoad() {
         super.viewDidLoad()
         view.addSubview(IconView)
         view.addSubview(remindBtn)
@@ -110,20 +110,21 @@ class MVLoginController: MVBaseController {
                     self?.loginBtn.setTitle(nil, for: .normal)
                     self?.phoneLoginBtn.setTitle(nil, for: .normal)
                 }
-                self?.loginBtn.setImage(UIImage.init(named: "mi_upload_share_friend"), for: .normal)
+                self?.loginBtn.setImage(UIImage(named: "mi_upload_share_friend"), for: .normal)
                 self?.loginBtn.backgroundColor = UIColor.black
-            }else{
-                self?.loginBtn.setImage(UIImage.init(named: "weichatLogin"), for: .normal)
+            } else {
+                self?.loginBtn.setImage(UIImage(named: "weichatLogin"), for: .normal)
                 self?.loginBtn.backgroundColor = UIColor.white
             }
             self?.addLayout()
             self?.phoneLoginBtn.isHidden = !PQSingletoMemoryUtil.shared.needLogin
         }
-        
+
         IconView.snp.makeConstraints { make in
             make.center.equalToSuperview()
             make.height.width.equalTo(260)
         }
+        addNotification(self, selector: #selector(dismissVC), name: cLoginSuccesssNotiKey, object: nil)
     }
 
     override func viewWillAppear(_: Bool) {
@@ -131,12 +132,10 @@ class MVLoginController: MVBaseController {
 
         showNavigation()
         leftButton(image: "close")
- 
     }
 
     override public func viewWillDisappear(_: Bool) {
         super.viewWillDisappear(true)
- 
     }
 
     func addLayout() {
@@ -146,7 +145,7 @@ class MVLoginController: MVBaseController {
             make.right.equalTo(view).offset(-cDefaultMargin * 2)
             make.height.equalTo(cScreenHeigth <= 568 ? cDefaultMargin * 4 : cDefaultMargin * 6)
         }
- 
+
         remindBtn.snp.makeConstraints { make in
 //            make.width.equalTo(cDefaultMargin * 13)
             make.height.equalTo(cDefaultMargin * 4)
@@ -154,7 +153,7 @@ class MVLoginController: MVBaseController {
             make.top.equalTo(IconView.snp_bottom).offset(cDefaultMargin * 4)
         }
         let isInstallWX = PQSingletoWXApiUtil.shared.isInstallWX()
-        
+
         if PQSingletoMemoryUtil.shared.needLogin {
             if #available(iOS 13.0, *) {
                 if isInstallWX {
@@ -211,6 +210,14 @@ class MVLoginController: MVBaseController {
             }
         }
     }
+
+    deinit {
+        PQNotification.removeObserver(self)
+    }
+
+    @objc func dismissVC() {
+        dismiss(animated: true, completion: nil)
+    }
 }
 
 extension MVLoginController: TYAttributedLabelDelegate {
@@ -233,7 +240,6 @@ extension MVLoginController: TYAttributedLabelDelegate {
 
 extension MVLoginController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding {
     @objc func wechatLoginAction() {
-        
         if !PQSingletoWXApiUtil.shared.isInstallWX() {
             cShowHUB(superView: nil, msg: "您还未安装微信客户端!")
             return
@@ -257,7 +263,8 @@ extension MVLoginController: ASAuthorizationControllerDelegate, ASAuthorizationC
 
     @objc func phoneLoginAction() {
         let vc = PQPhoneLoginController()
-        navigationController?.pushViewController(vc, animated: true)
+        vc.modalPresentationStyle = .fullScreen
+        present(vc, animated: true, completion: nil)
     }
 
     @objc func appleLoginAction() {

+ 1 - 1
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Login/Controllers/PQPhoneLoginController.swift

@@ -150,7 +150,7 @@ class PQPhoneLoginController: MVBaseController {
                 cShowHUB(superView: (self?.view)!, msg: "登录失败,请重试~")
             } else {
                 cShowHUB(superView: nil, msg: "登录成功")
-                self?.navigationController?.popToRootViewController(animated: true)
+                self?.dismiss(animated: true, completion: nil)
                 postNotification(name: cLoginSuccesssNotiKey)
             }
         }

+ 2 - 0
MusicVideoPlus/MusicVideoPlus/Info.plist

@@ -31,6 +31,8 @@
 	</array>
 	<key>CFBundleVersion</key>
 	<string>$(CURRENT_PROJECT_VERSION)</string>
+    <key>ITSAppUsesNonExemptEncryption</key>
+    <false/>
 	<key>LSApplicationQueriesSchemes</key>
 	<array>
 		<string>weixin</string>