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

处理 登录逻辑

parent 150c462b
......@@ -34,6 +34,12 @@ class YHServiceCenterMainViewController: YHBaseViewController {
return view
}()
private func loginOp() {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
......@@ -55,12 +61,25 @@ class YHServiceCenterMainViewController: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if YHLoginManager.shared.isLogin() == false {
loginTipsView.isHidden = false
noDataView.isHidden = true
homeTableView.isHidden = true
} else {
loginTipsView.isHidden = true
}
loadData()
}
}
extension YHServiceCenterMainViewController {
func loadData() {
if YHLoginManager.shared.isLogin() == false {
return
}
self.serviceCenterMainReqVM.getContactList { success, error in
if success == true {
......@@ -84,6 +103,10 @@ extension YHServiceCenterMainViewController {
gk_navTitle = "服务中心"
gk_navBarAlpha = 1.0
loginTipsView.clickLoginBtnCallBackBlock = {
self.loginOp()
}
view.addSubview(topBkg)
topBkg.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
......@@ -116,6 +139,13 @@ extension YHServiceCenterMainViewController {
self.homeTableView.isHidden = true
self.noDataView.isHidden = false
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
}
}
......@@ -170,3 +200,18 @@ extension YHServiceCenterMainViewController : UITableViewDelegate,UITableViewDat
self.navigationController?.pushViewController(vc)
}
}
extension YHServiceCenterMainViewController {
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
loadData()
}
@objc func logoutSuccess() {
loginTipsView.isHidden = false
noDataView.isHidden = true
self.homeTableView.isHidden = true
}
}
......@@ -49,10 +49,11 @@ extension YHLoginViewModel {
func login(phone: String, code: String,callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let params: [String : Any] = ["mobile": phone,
"sms_code": code,
"channel": "app",
"client": "super_app"]
let strUrl = "http://test.api.diymanager.galaxy-immi.com/" + "auth/login"
// let strUrl = "http://192.168.34.106:18088/" + "auth/login"
let strUrl = "http://test.api.diymanager.galaxy-immi.com/" + "infoflow/auth/login"
// http:test.api.diymanager.galaxy-immi.com/infoflow/auth/login
// let strUrl = "http://192.168.34.106:18088/" + "infoflow/auth/login"
let _ = YHNetRequest.postRequest(url: strUrl, params: params) {[weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
......@@ -62,6 +63,7 @@ extension YHLoginViewModel {
callBackBlock(false,error)
return
}
printLog(model)
let dic = model.data?.peel
guard let resultModel = YHUserModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
let error : YHErrorModel = YHErrorModel(errorCode:-1,errorMsg: "数据解析不成功")
......
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