Commit 4006bfa8 authored by 刘俊宏's avatar 刘俊宏

完善登录和退出登录逻辑

parent 13f15bec
...@@ -151,6 +151,7 @@ ...@@ -151,6 +151,7 @@
F933F6CD2452C68B00189561 /* PKHUDProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6BC2452C68B00189561 /* PKHUDProgressView.swift */; }; F933F6CD2452C68B00189561 /* PKHUDProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6BC2452C68B00189561 /* PKHUDProgressView.swift */; };
F933F6CE2452C68B00189561 /* PKHUDSquareBaseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6BD2452C68B00189561 /* PKHUDSquareBaseView.swift */; }; F933F6CE2452C68B00189561 /* PKHUDSquareBaseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6BD2452C68B00189561 /* PKHUDSquareBaseView.swift */; };
F933F6CF2452C68B00189561 /* PKHUDErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6BE2452C68B00189561 /* PKHUDErrorView.swift */; }; F933F6CF2452C68B00189561 /* PKHUDErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6BE2452C68B00189561 /* PKHUDErrorView.swift */; };
F933F6D22452DAE100189561 /* TabBarContentClassView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6D12452DAE000189561 /* TabBarContentClassView.swift */; };
F950FDA32451438A00C40530 /* AdminInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F950FDA22451438A00C40530 /* AdminInfoModel.swift */; }; F950FDA32451438A00C40530 /* AdminInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F950FDA22451438A00C40530 /* AdminInfoModel.swift */; };
F950FDA52451453A00C40530 /* ShopInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F950FDA42451453A00C40530 /* ShopInfoModel.swift */; }; F950FDA52451453A00C40530 /* ShopInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F950FDA42451453A00C40530 /* ShopInfoModel.swift */; };
F950FDA72451494500C40530 /* GeliPayInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F950FDA62451494500C40530 /* GeliPayInfoModel.swift */; }; F950FDA72451494500C40530 /* GeliPayInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F950FDA62451494500C40530 /* GeliPayInfoModel.swift */; };
...@@ -374,6 +375,7 @@ ...@@ -374,6 +375,7 @@
F933F6BD2452C68B00189561 /* PKHUDSquareBaseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDSquareBaseView.swift; sourceTree = "<group>"; }; F933F6BD2452C68B00189561 /* PKHUDSquareBaseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDSquareBaseView.swift; sourceTree = "<group>"; };
F933F6BE2452C68B00189561 /* PKHUDErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDErrorView.swift; sourceTree = "<group>"; }; F933F6BE2452C68B00189561 /* PKHUDErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDErrorView.swift; sourceTree = "<group>"; };
F933F6BF2452C68B00189561 /* PKHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PKHUD.h; sourceTree = "<group>"; }; F933F6BF2452C68B00189561 /* PKHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PKHUD.h; sourceTree = "<group>"; };
F933F6D12452DAE000189561 /* TabBarContentClassView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarContentClassView.swift; sourceTree = "<group>"; };
F950FDA22451438A00C40530 /* AdminInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminInfoModel.swift; sourceTree = "<group>"; }; F950FDA22451438A00C40530 /* AdminInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminInfoModel.swift; sourceTree = "<group>"; };
F950FDA42451453A00C40530 /* ShopInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShopInfoModel.swift; sourceTree = "<group>"; }; F950FDA42451453A00C40530 /* ShopInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShopInfoModel.swift; sourceTree = "<group>"; };
F950FDA62451494500C40530 /* GeliPayInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeliPayInfoModel.swift; sourceTree = "<group>"; }; F950FDA62451494500C40530 /* GeliPayInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeliPayInfoModel.swift; sourceTree = "<group>"; };
...@@ -655,6 +657,7 @@ ...@@ -655,6 +657,7 @@
E088CC882446FFA1000DAA8A /* Other */ = { E088CC882446FFA1000DAA8A /* Other */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F933F6D02452DAC300189561 /* TabBarVc */,
F933F6AD2452C65C00189561 /* HUD */, F933F6AD2452C65C00189561 /* HUD */,
F950FDB524518B3300C40530 /* 日历 */, F950FDB524518B3300C40530 /* 日历 */,
E0D197A72448430E002B080C /* 蓝牙 */, E0D197A72448430E002B080C /* 蓝牙 */,
...@@ -1001,6 +1004,14 @@ ...@@ -1001,6 +1004,14 @@
path = PKHUD; path = PKHUD;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
F933F6D02452DAC300189561 /* TabBarVc */ = {
isa = PBXGroup;
children = (
F933F6D12452DAE000189561 /* TabBarContentClassView.swift */,
);
path = TabBarVc;
sourceTree = "<group>";
};
F950FDAF245171E000C40530 /* TimeSelectView */ = { F950FDAF245171E000C40530 /* TimeSelectView */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1367,6 +1378,7 @@ ...@@ -1367,6 +1378,7 @@
files = ( files = (
F950FDE624518B9500C40530 /* FSCalendarAppearance.m in Sources */, F950FDE624518B9500C40530 /* FSCalendarAppearance.m in Sources */,
F9023F6D2449A9B100DD5A63 /* TitleAndTFCell.swift in Sources */, F9023F6D2449A9B100DD5A63 /* TitleAndTFCell.swift in Sources */,
F933F6D22452DAE100189561 /* TabBarContentClassView.swift in Sources */,
F933F6C82452C68B00189561 /* PKHUDTextView.swift in Sources */, F933F6C82452C68B00189561 /* PKHUDTextView.swift in Sources */,
E0B6036E244D376900A56B38 /* KuWeiCell.swift in Sources */, E0B6036E244D376900A56B38 /* KuWeiCell.swift in Sources */,
E0D197BA2448431C002B080C /* BabyDefine.m in Sources */, E0D197BA2448431C002B080C /* BabyDefine.m in Sources */,
......
...@@ -13,5 +13,17 @@ ...@@ -13,5 +13,17 @@
continueAfterRunningActions = "No"> continueAfterRunningActions = "No">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "DA0714E8-DD5C-48E8-93AF-CB4E86B966F9"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
breakpointStackSelectionBehavior = "1"
scope = "1"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Transparent@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "background_dark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -120,18 +120,18 @@ extension NetworkRequest { ...@@ -120,18 +120,18 @@ extension NetworkRequest {
success(Mapper<T>().map(JSONObject: value)) success(Mapper<T>().map(JSONObject: value))
}else if json["code"].intValue == 3 { }else if json["code"].intValue == 3 {
//业务逻辑运行异常,一般作用于验证失败、参数异常(缺失)等异常情况返回 //业务逻辑运行异常,一般作用于验证失败、参数异常(缺失)等异常情况返回
HUD.flash(.label(json["message"].stringValue), delay: 2.0) HUD.flash(.label(json["message"].stringValue), delay: 1.5)
failture(DogError.DataInvalidError) failture(DogError.DataInvalidError)
}else if json["code"].intValue == 10 { }else if json["code"].intValue == 10 {
NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil) NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil)
HUD.flash(.label(json["message"].stringValue), delay: 2.0) HUD.flash(.label(json["message"].stringValue), delay: 1.5)
failture(DogError.DataInvalidError) failture(DogError.DataInvalidError)
}else if json["code"].intValue == 11 { }else if json["code"].intValue == 11 {
HUD.flash(.label(json["message"].stringValue), delay: 2.0) HUD.flash(.label(json["message"].stringValue), delay: 1.5)
failture(DogError.DataInvalidError) failture(DogError.DataInvalidError)
}else{ }else{
HUD.flash(.label(json["message"].stringValue), delay: 2.0) HUD.flash(.label(json["message"].stringValue), delay: 1.5)
failture(DogError.DataInvalidError) failture(DogError.DataInvalidError)
} }
case .failure(let error): case .failure(let error):
......
...@@ -37,7 +37,7 @@ open class PKHUDTextView: PKHUDWideBaseView { ...@@ -37,7 +37,7 @@ open class PKHUDTextView: PKHUDWideBaseView {
public let titleLabel: UILabel = { public let titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.textAlignment = .center label.textAlignment = .center
label.font = UIFont.systemFont(ofSize: 15.0) label.font = UIFont.systemFont(ofSize: 13.0)
label.textColor = UIColor.white label.textColor = UIColor.white
label.adjustsFontSizeToFitWidth = true label.adjustsFontSizeToFitWidth = true
label.numberOfLines = 0 label.numberOfLines = 0
......
...@@ -12,7 +12,7 @@ import UIKit ...@@ -12,7 +12,7 @@ import UIKit
/// PKHUDWideBaseView provides a wide base view, which you can subclass and add additional views to. /// PKHUDWideBaseView provides a wide base view, which you can subclass and add additional views to.
open class PKHUDWideBaseView: UIView { open class PKHUDWideBaseView: UIView {
static let defaultWideBaseViewFrame = CGRect(origin: CGPoint.zero, size: CGSize(width: 160, height: 60)) static let defaultWideBaseViewFrame = CGRect(origin: CGPoint.zero, size: CGSize(width: 150, height: 50))
public init() { public init() {
super.init(frame: PKHUDWideBaseView.defaultWideBaseViewFrame) super.init(frame: PKHUDWideBaseView.defaultWideBaseViewFrame)
......
//
// TabBarContentClassView.swift
// GeliBusinessPlatform
//
// Created by 刘俊宏 on 2020/4/15.
// Copyright © 2020 junye lu. All rights reserved.
//
import UIKit
import ESTabBarController_swift
//MARK:--tab
class ExampleBouncesContentView: ExampleBasicContentView {
public var duration = 0.3
override init(frame: CGRect) {
super.init(frame: frame)
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func selectAnimation(animated: Bool, completion: (() -> ())?) {
self.bounceAnimation()
completion?()
}
override func reselectAnimation(animated: Bool, completion: (() -> ())?) {
self.bounceAnimation()
completion?()
}
func bounceAnimation() {
let impliesAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
impliesAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
impliesAnimation.duration = duration * 2
impliesAnimation.calculationMode = CAAnimationCalculationMode.cubic
imageView.layer.add(impliesAnimation, forKey: nil)
}
override func badgeChangedAnimation(animated: Bool, completion: (() -> ())?) {
super.badgeChangedAnimation(animated: animated, completion: nil)
notificationAnimation()
}
func notificationAnimation() {
let impliesAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
impliesAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
impliesAnimation.duration = duration * 2
impliesAnimation.calculationMode = CAAnimationCalculationMode.cubic
self.badgeView.layer.add(impliesAnimation, forKey: nil)
}
}
class ExampleBasicContentView: ESTabBarItemContentView {
override init(frame: CGRect) {
super.init(frame: frame)
textColor = UIColor.init(named: "灰色字体颜色")!
highlightTextColor = UIColor.init(named: "蓝色字体颜色")!
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
//MARK:--颜色转换为图片
func imageWithColor(_ color: UIColor) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: 375, height: 50)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(color.cgColor)
context?.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
...@@ -8,27 +8,103 @@ ...@@ -8,27 +8,103 @@
import UIKit import UIKit
import SwiftUI import SwiftUI
import ESTabBarController_swift
class SceneDelegate: UIResponder, UIWindowSceneDelegate { class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDelegate, loginDelegate {
var window: UIWindow? var window: UIWindow?
var sceneC: UIScene?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
sceneC = scene
if UserToken == nil {
addLoginVc(isAgain: false)
}else{
addTabBarVcs(isAgain: false)
}
}
//MARK:--成功登录并反馈
func successLogin() {
addTabBarVcs(isAgain: true)
}
//MARK:--退出登录并反馈
@objc func popLogout() {
addLoginVc(isAgain: true)
}
//MARK:--loginVC
func addLoginVc (isAgain:Bool){
let vc = LoginViewController()
vc.delegate = self
let contentView = vc
if let windowScene = sceneC as? UIWindowScene {
if isAgain {
let transtition = CATransition()
transtition.duration = 0.5
transtition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)
UIApplication.shared.keyWindow?.layer.add(transtition, forKey: "animation")
let rootV = NavViewController(rootViewController: contentView)
UIApplication.shared.keyWindow?.rootViewController = rootV
}else{
let window = UIWindow(windowScene: windowScene)
let rootV = NavViewController(rootViewController: contentView)
window.rootViewController = rootV;
self.window = window
window.makeKeyAndVisible()
}
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { }
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. }
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene. //MARK:--tabbarVCs
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). func addTabBarVcs (isAgain:Bool) {
let tabBarController = ESTabBarController()
tabBarController.delegate = self
tabBarController.tabBar.backgroundColor = UIColor.white
tabBarController.tabBar.shadowImage = UIImage(named: "transparent")
let img = imageWithColor(UIColor.white)
tabBarController.tabBar.backgroundImage = img
NotificationCenter.default.addObserver(self, selector: #selector(popLogout), name: NSNotification.Name(rawValue: "logout"), object: nil)
// Create the SwiftUI view that provides the window contents. let v1 = GoodsManageListVC()
let contentView = JiPaiFangShiViewController() let v2 = GoodsManageListVC()
let v3 = GoodsManageListVC()
let v4 = LoginViewController()
let v5 = DemoViewController()
v1.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "订单管理", image: UIImage(named: "daixuan"), selectedImage: UIImage(named: "kuwei"))
v2.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "商品管理", image: UIImage(named: "daixuan"), selectedImage: UIImage(named: "kuwei"))
v3.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "工作中心", image: UIImage(named: "daixuan"), selectedImage: UIImage(named: "kuwei"))
v4.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "仓库管理", image: UIImage(named: "daixuan"), selectedImage: UIImage(named: "kuwei"))
v5.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "个人中心", image: UIImage(named: "daixuan"), selectedImage: UIImage(named: "kuwei"))
// Use a UIHostingController as window root view controller. tabBarController.viewControllers = [v1, v2, v3, v4, v5]
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene) let contentView = tabBarController
let rootV = NavViewController(rootViewController: contentView) if let windowScene = sceneC as? UIWindowScene {
window.rootViewController = rootV;
self.window = window if isAgain {
window.makeKeyAndVisible() let transtition = CATransition()
transtition.duration = 0.5
transtition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)
UIApplication.shared.keyWindow?.layer.add(transtition, forKey: "animation")
let rootV = NavViewController(rootViewController: contentView)
UIApplication.shared.keyWindow?.rootViewController = rootV
}else{
let window = UIWindow(windowScene: windowScene)
let rootV = NavViewController(rootViewController: contentView)
window.rootViewController = rootV;
self.window = window
window.makeKeyAndVisible()
}
}
if let tabBarItem = v2.tabBarItem as? ESTabBarItem {
DispatchQueue.main.asyncAfter(deadline: .now() + 2 ) {
tabBarItem.badgeValue = "1"
}
} }
} }
...@@ -38,28 +114,28 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { ...@@ -38,28 +114,28 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Release any resources associated with this scene that can be re-created the next time the scene connects. // Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
} }
func sceneDidBecomeActive(_ scene: UIScene) { func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state. // Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
} }
func sceneWillResignActive(_ scene: UIScene) { func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state. // Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call). // This may occur due to temporary interruptions (ex. an incoming phone call).
} }
func sceneWillEnterForeground(_ scene: UIScene) { func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground. // Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background. // Use this method to undo the changes made on entering the background.
} }
func sceneDidEnterBackground(_ scene: UIScene) { func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background. // Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information // Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state. // to restore the scene back to its current state.
} }
} }
...@@ -85,7 +85,13 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -85,7 +85,13 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
//MARK:--新增触发 //MARK:--新增触发
@IBAction func addNewGoodsAction(_ sender: UIButton) { @IBAction func addNewGoodsAction(_ sender: UIButton) {
print("新增触发-") print("新增触发-")
// let vc = DemoViewController()
// self.navigationController?.pushViewController(vc, animated: true)
//模拟退出登录
NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil)
// UserDefaults.standard.set(dataM.data?.user_token, forKey: "user_token")
UserDefaults.standard.removeObject(forKey: "user_token")
UserDefaults.standard.synchronize()
} }
//MARK:--下拉视图各种代理 //MARK:--下拉视图各种代理
func showAction(sender: Int) { func showAction(sender: Int) {
......
...@@ -11,9 +11,12 @@ import Alamofire ...@@ -11,9 +11,12 @@ import Alamofire
import CryptoSwift import CryptoSwift
import LGButton import LGButton
protocol loginDelegate {
func successLogin()
}
class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDelegate { class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDelegate {
var delegate :loginDelegate?
//MARK: - 输入账号、密码、验证码 //MARK: - 输入账号、密码、验证码
@IBOutlet weak var loginBtn: LGButton! @IBOutlet weak var loginBtn: LGButton!
@IBOutlet weak var codeView: UIView! @IBOutlet weak var codeView: UIView!
...@@ -75,21 +78,35 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel ...@@ -75,21 +78,35 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel
print("\(codeNum) == \(codeTF.text)") print("\(codeNum) == \(codeTF.text)")
// zxpf // zxpf
// 123456 // 123456
if phoneTF.text?.count == 0 {
HUD.flash(.label("请填写用户名"), delay: 1.2)
return
}
if passTF.text?.count == 0 {
HUD.flash(.label("请填写密码"), delay: 1.2)
return
}
if codeTF.text?.count == 0 {
HUD.flash(.label("请填写验证码"), delay: 1.2)
return
}
if codeNum == codeTF.text { if codeNum == codeTF.text {
//登录中状态 //登录中状态
loginBtn.isLoading = true loginBtn.isLoading = true
login(["user_name":phoneTF.text as Any,"pwd":passTF.text as Any], success: { (data) in login(["user_name":phoneTF.text as Any,"pwd":passTF.text as Any], success: { (data) in
let dataM = data as! LoginModel let dataM = data as! LoginModel
UserDefaults.standard.setValue(dataM.data?.user_token, forKey: "user_token") UserDefaults.standard.set(dataM.data?.user_token, forKey: "user_token")
UserDefaults.standard.synchronize()
self.loginBtn.isLoading = false self.loginBtn.isLoading = false
self.delegate?.successLogin()
}) { (error) in }) { (error) in
self.loginBtn.isLoading = false self.loginBtn.isLoading = false
} }
}else{ }else{
HUD.flash(.label("请填写正确的验证码"), delay: 2.0) HUD.flash(.label("请填写正确的验证码"), delay: 1.2)
} }
} }
} }
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