Commit 62fb1aac96b65c9d7bd4ed6183d6aa06b3f74d2b
1 parent
f4abd0f4
未登录不能进入
我的- 收藏 已购 订单 ,绑定管理, 注销账号 首页- 商品详情页 退出登录- 到游客首页(暂时到登录页)
Showing
10 changed files
with
221 additions
and
49 deletions
metaCode/Classes/Config/CNLiveConfigManager.swift
| @@ -101,5 +101,10 @@ extension Notification.Name { | @@ -101,5 +101,10 @@ extension Notification.Name { | ||
| 101 | //电商h5订单支付成功通知 | 101 | //电商h5订单支付成功通知 |
| 102 | public static let kDSSuccessPayOrderNotification = Notification.Name("kDSSuccessPayOrderNotification") | 102 | public static let kDSSuccessPayOrderNotification = Notification.Name("kDSSuccessPayOrderNotification") |
| 103 | } | 103 | } |
| 104 | - | 104 | + struct LoginManage{ |
| 105 | + //登录成功通知 | ||
| 106 | + public static let CNLiveLoginSuccessNotification = Notification.Name("CNLiveLoginSuccessNotification") | ||
| 107 | + //退出登录失败通知 | ||
| 108 | + public static let CNLiveLoginOutNotification = Notification.Name("CNLiveLoginOutNotification") | ||
| 109 | + } | ||
| 105 | } | 110 | } |
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebView.swift
| @@ -104,6 +104,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | @@ -104,6 +104,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | ||
| 104 | self.cnWebView.configuration.userContentController.add(self, name: "toShare") | 104 | self.cnWebView.configuration.userContentController.add(self, name: "toShare") |
| 105 | self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment") | 105 | self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment") |
| 106 | self.cnWebView.configuration.userContentController.add(self, name: "getStatusHeight") | 106 | self.cnWebView.configuration.userContentController.add(self, name: "getStatusHeight") |
| 107 | + self.cnWebView.configuration.userContentController.add(self, name: "shopLogin") | ||
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | func webViewRemoveScriptMessageHandler(){ | 110 | func webViewRemoveScriptMessageHandler(){ |
| @@ -111,6 +112,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | @@ -111,6 +112,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | ||
| 111 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "toShare") | 112 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "toShare") |
| 112 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "openAppPayment") | 113 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "openAppPayment") |
| 113 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "getStatusHeight") | 114 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "getStatusHeight") |
| 115 | + self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "shopLogin") | ||
| 114 | } | 116 | } |
| 115 | //电商h5的回调 | 117 | //电商h5的回调 |
| 116 | func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { | 118 | func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { |
| @@ -209,6 +211,14 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | @@ -209,6 +211,14 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | ||
| 209 | print("JavaScript执行结果: \(result)") | 211 | print("JavaScript执行结果: \(result)") |
| 210 | } | 212 | } |
| 211 | } | 213 | } |
| 214 | + }else if message.name == "shopLogin" { | ||
| 215 | + ////电商登录 | ||
| 216 | + print("\(self.currentUrl)") | ||
| 217 | + if metaAppDelegate.isLogin{ | ||
| 218 | + | ||
| 219 | + }else{ | ||
| 220 | + metaAppDelegate.pushLoginVC() | ||
| 221 | + } | ||
| 212 | } | 222 | } |
| 213 | } | 223 | } |
| 214 | // MARK: - 字典转字符串 | 224 | // MARK: - 字典转字符串 |
| @@ -216,7 +226,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | @@ -216,7 +226,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate | ||
| 216 | guard let json = json else { | 226 | guard let json = json else { |
| 217 | return nil | 227 | return nil |
| 218 | } | 228 | } |
| 219 | - | 229 | + |
| 220 | do { | 230 | do { |
| 221 | let data = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) | 231 | let data = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) |
| 222 | if let string = String(data: data, encoding: .utf8) { | 232 | if let string = String(data: data, encoding: .utf8) { |
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebViewController.swift
| @@ -92,6 +92,12 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ | @@ -92,6 +92,12 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ | ||
| 92 | override func viewDidLoad() { | 92 | override func viewDidLoad() { |
| 93 | super.viewDidLoad() | 93 | super.viewDidLoad() |
| 94 | navigationBarHidden = self.isHiddenNavigationBar | 94 | navigationBarHidden = self.isHiddenNavigationBar |
| 95 | + | ||
| 96 | + | ||
| 97 | + //登录成功通知 | ||
| 98 | + NotificationCenter.default.addObserver(self, selector: #selector(CNLiveLoginSuccessNotificationAction), name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil) | ||
| 99 | + | ||
| 100 | + | ||
| 95 | self.view.addSubview(self.webView) | 101 | self.view.addSubview(self.webView) |
| 96 | 102 | ||
| 97 | self.webView.webControllerUpdateNavSoundBlock = { isSound in | 103 | self.webView.webControllerUpdateNavSoundBlock = { isSound in |
| @@ -132,6 +138,12 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ | @@ -132,6 +138,12 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ | ||
| 132 | make.left.right.bottom.equalToSuperview() | 138 | make.left.right.bottom.equalToSuperview() |
| 133 | } | 139 | } |
| 134 | } | 140 | } |
| 141 | + | ||
| 142 | + @objc func CNLiveLoginSuccessNotificationAction() { | ||
| 143 | + //登录成功 | ||
| 144 | + self.webView.loadUrl(url: self.url?.absoluteString ?? "") | ||
| 145 | + } | ||
| 146 | + | ||
| 135 | 147 | ||
| 136 | func h5StopVideoPlayer(){ | 148 | func h5StopVideoPlayer(){ |
| 137 | // call h5停止播放视频 | 149 | // call h5停止播放视频 |
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
| @@ -79,7 +79,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -79,7 +79,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 79 | wxButton.addTarget(self, action: #selector(sendWXLoginActionMothod), for: .touchUpInside) | 79 | wxButton.addTarget(self, action: #selector(sendWXLoginActionMothod), for: .touchUpInside) |
| 80 | return wxButton | 80 | return wxButton |
| 81 | }() | 81 | }() |
| 82 | - | 82 | + |
| 83 | lazy var tipLabel: UILabel = { | 83 | lazy var tipLabel: UILabel = { |
| 84 | let tipLabel = UILabel.init() | 84 | let tipLabel = UILabel.init() |
| 85 | tipLabel.text = "未注册的手机号验证后自动为您创建元码账户" | 85 | tipLabel.text = "未注册的手机号验证后自动为您创建元码账户" |
| @@ -89,6 +89,12 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -89,6 +89,12 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 89 | return tipLabel | 89 | return tipLabel |
| 90 | }() | 90 | }() |
| 91 | 91 | ||
| 92 | + lazy var navBackButton: UIButton = { | ||
| 93 | + let wxButton = UIButton() | ||
| 94 | + wxButton.setImage(UIImage(named: "mine_header_icon_white_back"), for: .normal) | ||
| 95 | + wxButton.addTarget(self, action: #selector(ClickBackBtn), for: .touchUpInside) | ||
| 96 | + return wxButton | ||
| 97 | + }() | ||
| 92 | 98 | ||
| 93 | var is_agree : Bool = false //是否同意协议 | 99 | var is_agree : Bool = false //是否同意协议 |
| 94 | var countryCode: String = "86" | 100 | var countryCode: String = "86" |
| @@ -111,6 +117,20 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -111,6 +117,20 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 111 | make.height.equalTo(KSreenWidth*250/375) | 117 | make.height.equalTo(KSreenWidth*250/375) |
| 112 | } | 118 | } |
| 113 | 119 | ||
| 120 | + self.view.addSubview(self.navBackButton) | ||
| 121 | + self.navBackButton.snp.makeConstraints { make in | ||
| 122 | + make.left.equalTo(0) | ||
| 123 | + make.top.equalTo(get_system_nav_height()-10) | ||
| 124 | + make.width.equalTo(50) | ||
| 125 | + make.height.equalTo(30) | ||
| 126 | + } | ||
| 127 | + let count = self.navigationController?.viewControllers.count ?? 1 | ||
| 128 | + if count > 1{ | ||
| 129 | + self.navBackButton.isHidden = false | ||
| 130 | + }else{ | ||
| 131 | + self.navBackButton.isHidden = true | ||
| 132 | + } | ||
| 133 | + | ||
| 114 | self.setupPhoneView() | 134 | self.setupPhoneView() |
| 115 | self.setupVeriCodeView() | 135 | self.setupVeriCodeView() |
| 116 | self.setupLoginButtonView() | 136 | self.setupLoginButtonView() |
| @@ -302,7 +322,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -302,7 +322,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 302 | CNLiveLoginViewModel.appleLogin(model: model) { result, status in | 322 | CNLiveLoginViewModel.appleLogin(model: model) { result, status in |
| 303 | if status == .success{ | 323 | if status == .success{ |
| 304 | //获取用户信息 /api/identityApi/getUserMsg | 324 | //获取用户信息 /api/identityApi/getUserMsg |
| 305 | - CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { result, respStatue in | 325 | + CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { [weak self] result, respStatue in |
| 326 | + guard let self = self else { return } | ||
| 306 | if respStatue == .success{ | 327 | if respStatue == .success{ |
| 307 | if let res = result as? MineGetUserMsgUsersModel{ | 328 | if let res = result as? MineGetUserMsgUsersModel{ |
| 308 | let userInfo = UserInfoManager.shared.userInfo | 329 | let userInfo = UserInfoManager.shared.userInfo |
| @@ -318,8 +339,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -318,8 +339,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 318 | UserDefaults.standard.synchronize() | 339 | UserDefaults.standard.synchronize() |
| 319 | } | 340 | } |
| 320 | 341 | ||
| 321 | - let window = UIApplication.shared.delegate?.window | ||
| 322 | - window??.rootViewController = CNLiveBaseTabBarViewController.init() | 342 | + if self.navBackButton.isHidden{ |
| 343 | + let window = UIApplication.shared.delegate?.window | ||
| 344 | + window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 345 | + }else{ | ||
| 346 | + //发通知 | ||
| 347 | + NotificationCenter.default.post(name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil) | ||
| 348 | + metaAppDelegate.isLogin = true | ||
| 349 | + self.navigationController?.popViewController(animated: true) | ||
| 350 | + } | ||
| 323 | 351 | ||
| 324 | } | 352 | } |
| 325 | }else{ | 353 | }else{ |
| @@ -432,8 +460,10 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -432,8 +460,10 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 432 | if status == .success{ | 460 | if status == .success{ |
| 433 | //登录成功 | 461 | //登录成功 |
| 434 | //获取用户信息 /api/identityApi/getUserMsg | 462 | //获取用户信息 /api/identityApi/getUserMsg |
| 435 | - CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { result, respStatue in | 463 | + CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) {[weak self] result, respStatue in |
| 464 | + guard let self = self else { return } | ||
| 436 | if respStatue == .success{ | 465 | if respStatue == .success{ |
| 466 | + | ||
| 437 | if let res = result as? MineGetUserMsgUsersModel{ | 467 | if let res = result as? MineGetUserMsgUsersModel{ |
| 438 | let userInfo = UserInfoManager.shared.userInfo | 468 | let userInfo = UserInfoManager.shared.userInfo |
| 439 | userInfo.userMsgUsers = res | 469 | userInfo.userMsgUsers = res |
| @@ -448,9 +478,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -448,9 +478,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 448 | UserDefaults.standard.synchronize() | 478 | UserDefaults.standard.synchronize() |
| 449 | } | 479 | } |
| 450 | 480 | ||
| 451 | - let window = UIApplication.shared.delegate?.window | ||
| 452 | - window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 453 | - | 481 | + if self.navBackButton.isHidden{ |
| 482 | + let window = UIApplication.shared.delegate?.window | ||
| 483 | + window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 484 | + }else{ | ||
| 485 | + //发通知 | ||
| 486 | + NotificationCenter.default.post(name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil) | ||
| 487 | + metaAppDelegate.isLogin = true | ||
| 488 | + self.navigationController?.popViewController(animated: true) | ||
| 489 | + } | ||
| 454 | } | 490 | } |
| 455 | }else{ | 491 | }else{ |
| 456 | let window = UIApplication.shared.delegate?.window | 492 | let window = UIApplication.shared.delegate?.window |
| @@ -463,7 +499,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -463,7 +499,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 463 | if res == "42013"{ | 499 | if res == "42013"{ |
| 464 | if (type == CNLiveSendAuthRespApple) { | 500 | if (type == CNLiveSendAuthRespApple) { |
| 465 | //获取用户信息 /api/identityApi/getUserMsg | 501 | //获取用户信息 /api/identityApi/getUserMsg |
| 466 | - CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { result, respStatue in | 502 | + CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { [weak self] result, respStatue in |
| 503 | + guard let self = self else { return } | ||
| 467 | if respStatue == .success{ | 504 | if respStatue == .success{ |
| 468 | if let res = result as? MineGetUserMsgUsersModel{ | 505 | if let res = result as? MineGetUserMsgUsersModel{ |
| 469 | let userInfo = UserInfoManager.shared.userInfo | 506 | let userInfo = UserInfoManager.shared.userInfo |
| @@ -479,9 +516,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | @@ -479,9 +516,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { | ||
| 479 | UserDefaults.standard.synchronize() | 516 | UserDefaults.standard.synchronize() |
| 480 | } | 517 | } |
| 481 | 518 | ||
| 482 | - let window = UIApplication.shared.delegate?.window | ||
| 483 | - window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 484 | - | 519 | + if self.navBackButton.isHidden{ |
| 520 | + let window = UIApplication.shared.delegate?.window | ||
| 521 | + window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 522 | + }else{ | ||
| 523 | + //发通知 | ||
| 524 | + NotificationCenter.default.post(name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil) | ||
| 525 | + metaAppDelegate.isLogin = true | ||
| 526 | + self.navigationController?.popViewController(animated: true) | ||
| 527 | + } | ||
| 485 | } | 528 | } |
| 486 | }else{ | 529 | }else{ |
| 487 | let window = UIApplication.shared.delegate?.window | 530 | let window = UIApplication.shared.delegate?.window |
| @@ -549,7 +592,8 @@ extension CNLiveLoginViewController { | @@ -549,7 +592,8 @@ extension CNLiveLoginViewController { | ||
| 549 | CNLiveLoginViewModel.requestLoginAction(userName: phoneText.text ?? "", countryCode: countryCode, verCode: veriText.text ?? "") {[self] in | 592 | CNLiveLoginViewModel.requestLoginAction(userName: phoneText.text ?? "", countryCode: countryCode, verCode: veriText.text ?? "") {[self] in |
| 550 | loginButton.stopAnimating() | 593 | loginButton.stopAnimating() |
| 551 | //获取用户信息 /api/identityApi/getUserMsg | 594 | //获取用户信息 /api/identityApi/getUserMsg |
| 552 | - CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { result, respStatue in | 595 | + CNLiveMineViewModel.requestGetUserMsg(sid: UserInfoManager.shared.userInfo.uid) { [weak self] result, respStatue in |
| 596 | + guard let self = self else { return } | ||
| 553 | if respStatue == .success{ | 597 | if respStatue == .success{ |
| 554 | if let res = result as? MineGetUserMsgUsersModel{ | 598 | if let res = result as? MineGetUserMsgUsersModel{ |
| 555 | let userInfo = UserInfoManager.shared.userInfo | 599 | let userInfo = UserInfoManager.shared.userInfo |
| @@ -565,9 +609,15 @@ extension CNLiveLoginViewController { | @@ -565,9 +609,15 @@ extension CNLiveLoginViewController { | ||
| 565 | UserDefaults.standard.synchronize() | 609 | UserDefaults.standard.synchronize() |
| 566 | } | 610 | } |
| 567 | 611 | ||
| 568 | - let window = UIApplication.shared.delegate?.window | ||
| 569 | - window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 570 | - | 612 | + if self.navBackButton.isHidden{ |
| 613 | + let window = UIApplication.shared.delegate?.window | ||
| 614 | + window??.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 615 | + }else{ | ||
| 616 | + //发通知 | ||
| 617 | + NotificationCenter.default.post(name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil) | ||
| 618 | + metaAppDelegate.isLogin = true | ||
| 619 | + self.navigationController?.popViewController(animated: true) | ||
| 620 | + } | ||
| 571 | } | 621 | } |
| 572 | }else{ | 622 | }else{ |
| 573 | let window = UIApplication.shared.delegate?.window | 623 | let window = UIApplication.shared.delegate?.window |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineViewController.swift
| @@ -110,8 +110,17 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, | @@ -110,8 +110,17 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, | ||
| 110 | // NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWiFi, object: nil) | 110 | // NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWiFi, object: nil) |
| 111 | // NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWWAN, object: nil) | 111 | // NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWWAN, object: nil) |
| 112 | // StandAuthNotificationSuccessAction() | 112 | // StandAuthNotificationSuccessAction() |
| 113 | + | ||
| 114 | + //登录成功通知 | ||
| 115 | + NotificationCenter.default.addObserver(self, selector: #selector(CNLiveLoginSuccessNotificationAction), name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil) | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @objc func CNLiveLoginSuccessNotificationAction() { | ||
| 119 | + //登录成功 | ||
| 120 | + self.headerView.loginBtn.isHidden = true | ||
| 113 | } | 121 | } |
| 114 | 122 | ||
| 123 | + | ||
| 115 | func loadGift(){ | 124 | func loadGift(){ |
| 116 | showLoading(message: "") | 125 | showLoading(message: "") |
| 117 | CNLiveHomePageViewModel.requestGetHomePageTopBannerGift{[weak self] result, status in | 126 | CNLiveHomePageViewModel.requestGetHomePageTopBannerGift{[weak self] result, status in |
| @@ -276,8 +285,9 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, | @@ -276,8 +285,9 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, | ||
| 276 | } | 285 | } |
| 277 | 286 | ||
| 278 | deinit { | 287 | deinit { |
| 279 | - NotificationCenter.default.removeObserver(self, name: Notification.Name.StandAuth.StandAuthNotificationSuccess, object: nil) | ||
| 280 | - NotificationCenter.default.removeObserver(self, name: Notification.Name.StandAuth.StandAuthSortNotificationResult, object: nil) | 288 | + NotificationCenter.default.removeObserver(self) |
| 289 | +// NotificationCenter.default.removeObserver(self, name: Notification.Name.StandAuth.StandAuthNotificationSuccess, object: nil) | ||
| 290 | +// NotificationCenter.default.removeObserver(self, name: Notification.Name.StandAuth.StandAuthSortNotificationResult, object: nil) | ||
| 281 | } | 291 | } |
| 282 | } | 292 | } |
| 283 | 293 | ||
| @@ -392,9 +402,13 @@ extension CNLiveMineViewController { | @@ -392,9 +402,13 @@ extension CNLiveMineViewController { | ||
| 392 | 402 | ||
| 393 | }else if name == "已购内容"{ | 403 | }else if name == "已购内容"{ |
| 394 | //已购内容 | 404 | //已购内容 |
| 395 | - let webVC = CNWebViewController() | ||
| 396 | - webVC.url = URL(string: "http://wjjh5.cnlive.com/cnYjzg.html?id=6&channelName=yjzg&isShowTitle=true") | ||
| 397 | - self.navigationController?.pushViewController(webVC, animated: true) | 405 | + if metaAppDelegate.isLogin{ |
| 406 | + let webVC = CNWebViewController() | ||
| 407 | + webVC.url = URL(string: "http://wjjh5.cnlive.com/cnYjzg.html?id=6&channelName=yjzg&isShowTitle=true") | ||
| 408 | + self.navigationController?.pushViewController(webVC, animated: true) | ||
| 409 | + }else{ | ||
| 410 | + metaAppDelegate.pushLoginVC() | ||
| 411 | + } | ||
| 398 | }else if name == "我的订单"{ | 412 | }else if name == "我的订单"{ |
| 399 | 413 | ||
| 400 | }else if name == "帮助与反馈"{ | 414 | }else if name == "帮助与反馈"{ |
metaCode/Classes/Main/MinePage/Controller/CNLiveTypeFeedBackViewController.swift
| @@ -172,13 +172,17 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe | @@ -172,13 +172,17 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe | ||
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | if _show_type == .setting { | 174 | if _show_type == .setting { |
| 175 | - view.addSubview(logoutButton) | ||
| 176 | - logoutButton.snp.makeConstraints { make in | ||
| 177 | - make.centerX.equalToSuperview() | ||
| 178 | - make.left.equalToSuperview().offset(10) | ||
| 179 | - make.right.equalToSuperview().offset(-10) | ||
| 180 | - make.height.equalTo(45) | ||
| 181 | - make.bottom.equalToSuperview().offset(-get_system_tabbar_ui_offsetHeight() - 20) | 175 | + if metaAppDelegate.isLogin{ |
| 176 | + view.addSubview(logoutButton) | ||
| 177 | + logoutButton.snp.makeConstraints { make in | ||
| 178 | + make.centerX.equalToSuperview() | ||
| 179 | + make.left.equalToSuperview().offset(10) | ||
| 180 | + make.right.equalToSuperview().offset(-10) | ||
| 181 | + make.height.equalTo(45) | ||
| 182 | + make.bottom.equalToSuperview().offset(-get_system_tabbar_ui_offsetHeight() - 20) | ||
| 183 | + } | ||
| 184 | + }else{ | ||
| 185 | + | ||
| 182 | } | 186 | } |
| 183 | } | 187 | } |
| 184 | if _show_type == .about { | 188 | if _show_type == .about { |
| @@ -201,6 +205,8 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe | @@ -201,6 +205,8 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe | ||
| 201 | logoutButton.startAnimating() | 205 | logoutButton.startAnimating() |
| 202 | AlertTool.systemActionSheet(title: nil, message: nil, actionTitles: ["退出登录"]) { [self] index in | 206 | AlertTool.systemActionSheet(title: nil, message: nil, actionTitles: ["退出登录"]) { [self] index in |
| 203 | if index == 1 { | 207 | if index == 1 { |
| 208 | + NotificationCenter.default.post(name: Notification.Name.LoginManage.CNLiveLoginOutNotification, object: nil) | ||
| 209 | + metaAppDelegate.isLogin = false | ||
| 204 | logoutButton.stopAnimating() | 210 | logoutButton.stopAnimating() |
| 205 | UserDefaults.standard.set(false,forKey: "is_login") | 211 | UserDefaults.standard.set(false,forKey: "is_login") |
| 206 | UserInfoManager.clearUserInfo() | 212 | UserInfoManager.clearUserInfo() |
| @@ -273,7 +279,11 @@ extension CNLiveTypeFeedBackViewController { | @@ -273,7 +279,11 @@ extension CNLiveTypeFeedBackViewController { | ||
| 273 | } | 279 | } |
| 274 | if _show_type == .setting { | 280 | if _show_type == .setting { |
| 275 | if indexPath.section == 0 { | 281 | if indexPath.section == 0 { |
| 276 | - self.navigationController?.pushViewController(CNLiveMineBindingManagerController.init(), animated: true) | 282 | + if metaAppDelegate.isLogin{ |
| 283 | + self.navigationController?.pushViewController(CNLiveMineBindingManagerController.init(), animated: true) | ||
| 284 | + }else{ | ||
| 285 | + metaAppDelegate.pushLoginVC() | ||
| 286 | + } | ||
| 277 | } | 287 | } |
| 278 | if indexPath.section == 1 { | 288 | if indexPath.section == 1 { |
| 279 | self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .privacy), animated: true) | 289 | self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .privacy), animated: true) |
| @@ -282,7 +292,11 @@ extension CNLiveTypeFeedBackViewController { | @@ -282,7 +292,11 @@ extension CNLiveTypeFeedBackViewController { | ||
| 282 | self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .about), animated: true) | 292 | self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .about), animated: true) |
| 283 | } | 293 | } |
| 284 | if indexPath.section == 3 { | 294 | if indexPath.section == 3 { |
| 285 | - self.navigationController?.pushViewController(CNLiveMineSignOutViewController.init(), animated: true) | 295 | + if metaAppDelegate.isLogin{ |
| 296 | + self.navigationController?.pushViewController(CNLiveMineSignOutViewController.init(), animated: true) | ||
| 297 | + }else{ | ||
| 298 | + metaAppDelegate.pushLoginVC() | ||
| 299 | + } | ||
| 286 | } | 300 | } |
| 287 | } | 301 | } |
| 288 | if _show_type == .privacy { | 302 | if _show_type == .privacy { |
metaCode/Classes/Main/MinePage/View/CNLiveMineHeaderView.swift
| @@ -32,6 +32,16 @@ class MineHeaderView : UIView { | @@ -32,6 +32,16 @@ class MineHeaderView : UIView { | ||
| 32 | return nameLabel | 32 | return nameLabel |
| 33 | }() | 33 | }() |
| 34 | 34 | ||
| 35 | + lazy var loginBtn: UIButton = { | ||
| 36 | + let tipBtn = UIButton(type: .custom) | ||
| 37 | + tipBtn.backgroundColor = HexColor("#DBE9FF") | ||
| 38 | + tipBtn.setTitle("点击登录", for: .normal) | ||
| 39 | + tipBtn.setTitleColor(HexColor("#1F76FF"), for: .normal) | ||
| 40 | + tipBtn.layer.cornerRadius = 16 | ||
| 41 | + tipBtn.clipsToBounds = true | ||
| 42 | + tipBtn.addTarget(self, action: #selector(loginBtnAction), for: .touchUpInside) | ||
| 43 | + return tipBtn | ||
| 44 | + }() | ||
| 35 | lazy var tipBtn: UIButton = { | 45 | lazy var tipBtn: UIButton = { |
| 36 | let tipBtn = UIButton(type: .custom) | 46 | let tipBtn = UIButton(type: .custom) |
| 37 | tipBtn.backgroundColor = .clear | 47 | tipBtn.backgroundColor = .clear |
| @@ -57,6 +67,14 @@ class MineHeaderView : UIView { | @@ -57,6 +67,14 @@ class MineHeaderView : UIView { | ||
| 57 | make.left.equalTo(iconView.snp.right).offset(15) | 67 | make.left.equalTo(iconView.snp.right).offset(15) |
| 58 | } | 68 | } |
| 59 | 69 | ||
| 70 | + addSubview(loginBtn) | ||
| 71 | + loginBtn.snp.makeConstraints { make in | ||
| 72 | + make.left.equalTo(self.iconView.snp.right).offset(19) | ||
| 73 | + make.centerY.equalTo(self.iconView.snp.centerY) | ||
| 74 | + make.width.equalTo(120) | ||
| 75 | + make.height.equalTo(32) | ||
| 76 | + } | ||
| 77 | + loginBtn.isHidden = metaAppDelegate.isLogin | ||
| 60 | // addSubview(tipBtn) | 78 | // addSubview(tipBtn) |
| 61 | // tipBtn.snp.makeConstraints { make in | 79 | // tipBtn.snp.makeConstraints { make in |
| 62 | // make.centerY.equalToSuperview().offset(10) | 80 | // make.centerY.equalToSuperview().offset(10) |
| @@ -76,6 +94,10 @@ class MineHeaderView : UIView { | @@ -76,6 +94,10 @@ class MineHeaderView : UIView { | ||
| 76 | fatalError("init(coder:) has not been implemented") | 94 | fatalError("init(coder:) has not been implemented") |
| 77 | } | 95 | } |
| 78 | 96 | ||
| 97 | + @objc func loginBtnAction() { | ||
| 98 | + currentViewController()?.navigationController?.pushViewController(CNLiveLoginViewController(), animated: true) | ||
| 99 | + } | ||
| 100 | + | ||
| 79 | @objc func tipBtnAction() { | 101 | @objc func tipBtnAction() { |
| 80 | currentViewController()?.navigationController?.pushViewController(CNLiveMineAddInfoViewController.init(show_type: .message), animated: true) | 102 | currentViewController()?.navigationController?.pushViewController(CNLiveMineAddInfoViewController.init(show_type: .message), animated: true) |
| 81 | } | 103 | } |
metaCode/Classes/Main/MinePage/View/CNLiveMineMineOrderCell.swift
| @@ -363,33 +363,62 @@ class CNLiveMineMineOrderCell : UITableViewCell { | @@ -363,33 +363,62 @@ class CNLiveMineMineOrderCell : UITableViewCell { | ||
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | @objc func allOrderBtnAction(){ | 365 | @objc func allOrderBtnAction(){ |
| 366 | - CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "0") | 366 | + if metaAppDelegate.isLogin{ |
| 367 | + let vc = CNLiveHomeMoreController() | ||
| 368 | + CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "0") | ||
| 369 | + }else{ | ||
| 370 | + metaAppDelegate.pushLoginVC() | ||
| 371 | + } | ||
| 367 | } | 372 | } |
| 368 | @objc func waitPayBtnAction(){ | 373 | @objc func waitPayBtnAction(){ |
| 369 | - CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "1") | 374 | + if metaAppDelegate.isLogin{ |
| 375 | + let vc = CNLiveHomeMoreController() | ||
| 376 | + CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "1") | ||
| 377 | + }else{ | ||
| 378 | + metaAppDelegate.pushLoginVC() | ||
| 379 | + } | ||
| 370 | } | 380 | } |
| 371 | @objc func waitFaHuoBtnAction(){ | 381 | @objc func waitFaHuoBtnAction(){ |
| 372 | - CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "2") | 382 | + if metaAppDelegate.isLogin{ |
| 383 | + let vc = CNLiveHomeMoreController() | ||
| 384 | + CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "2") | ||
| 385 | + }else{ | ||
| 386 | + metaAppDelegate.pushLoginVC() | ||
| 387 | + } | ||
| 373 | } | 388 | } |
| 374 | @objc func yiFaHuoBtnAction(){ | 389 | @objc func yiFaHuoBtnAction(){ |
| 375 | - CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "3") | 390 | + if metaAppDelegate.isLogin{ |
| 391 | + let vc = CNLiveHomeMoreController() | ||
| 392 | + CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "3") | ||
| 393 | + }else{ | ||
| 394 | + metaAppDelegate.pushLoginVC() | ||
| 395 | + } | ||
| 376 | } | 396 | } |
| 377 | @objc func shouHouBtnAction(){ | 397 | @objc func shouHouBtnAction(){ |
| 378 | - CNLiveDownSlideTool.pushShopH5WithType(type: "4", state: "") | 398 | + if metaAppDelegate.isLogin{ |
| 399 | + let vc = CNLiveHomeMoreController() | ||
| 400 | + CNLiveDownSlideTool.pushShopH5WithType(type: "4", state: "") | ||
| 401 | + }else{ | ||
| 402 | + metaAppDelegate.pushLoginVC() | ||
| 403 | + } | ||
| 379 | } | 404 | } |
| 380 | 405 | ||
| 381 | @objc func imgTapAction(ges: UITapGestureRecognizer){ | 406 | @objc func imgTapAction(ges: UITapGestureRecognizer){ |
| 382 | let imageView = ges.view as! UIImageView | 407 | let imageView = ges.view as! UIImageView |
| 383 | let i = imageView.tag-1000 | 408 | let i = imageView.tag-1000 |
| 384 | - if i == 0{ | ||
| 385 | - //我的订单 | ||
| 386 | - CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "0") | ||
| 387 | - }else if i == 1{ | ||
| 388 | - //购物车 | ||
| 389 | - CNLiveDownSlideTool.pushShopH5WithType(type: "2", state: "") | ||
| 390 | - }else if i == 2{ | ||
| 391 | - //地址管理 | ||
| 392 | - CNLiveDownSlideTool.pushShopH5WithType(type: "3", state: "") | 409 | + if metaAppDelegate.isLogin{ |
| 410 | + if i == 0{ | ||
| 411 | + //我的订单 | ||
| 412 | + CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "0") | ||
| 413 | + }else if i == 1{ | ||
| 414 | + //购物车 | ||
| 415 | + CNLiveDownSlideTool.pushShopH5WithType(type: "2", state: "") | ||
| 416 | + }else if i == 2{ | ||
| 417 | + //地址管理 | ||
| 418 | + CNLiveDownSlideTool.pushShopH5WithType(type: "3", state: "") | ||
| 419 | + } | ||
| 420 | + }else{ | ||
| 421 | + metaAppDelegate.pushLoginVC() | ||
| 393 | } | 422 | } |
| 394 | } | 423 | } |
| 395 | 424 |
metaCode/Classes/Main/MinePage/View/CNLiveMinePlayHistoryCell.swift
| @@ -239,8 +239,12 @@ class CNLiveMinePlayHistoryCell : UITableViewCell ,UICollectionViewDelegate, UIC | @@ -239,8 +239,12 @@ class CNLiveMinePlayHistoryCell : UITableViewCell ,UICollectionViewDelegate, UIC | ||
| 239 | currentViewController()?.navigationController?.pushViewController(vc, animated: true) | 239 | currentViewController()?.navigationController?.pushViewController(vc, animated: true) |
| 240 | }else if i == 1{ | 240 | }else if i == 1{ |
| 241 | //我的收藏 | 241 | //我的收藏 |
| 242 | - let vc = CNLiveHomeMoreController() | ||
| 243 | - currentViewController()?.navigationController?.pushViewController(vc, animated: true) | 242 | + if metaAppDelegate.isLogin{ |
| 243 | + let vc = CNLiveHomeMoreController() | ||
| 244 | + currentViewController()?.navigationController?.pushViewController(vc, animated: true) | ||
| 245 | + }else{ | ||
| 246 | + metaAppDelegate.pushLoginVC() | ||
| 247 | + } | ||
| 244 | } | 248 | } |
| 245 | } | 249 | } |
| 246 | 250 |
metaCode/Classes/Other/AppDelegate.swift
| @@ -22,6 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -22,6 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| 22 | var isCaptured = false //是否录屏中 | 22 | var isCaptured = false //是否录屏中 |
| 23 | var isGift = false//是否忽必烈礼物 | 23 | var isGift = false//是否忽必烈礼物 |
| 24 | var giftModel:CNLiveHomePageHuBiLieGiftModel?//送礼分享model | 24 | var giftModel:CNLiveHomePageHuBiLieGiftModel?//送礼分享model |
| 25 | + var isLogin = false//是否登录 | ||
| 25 | 26 | ||
| 26 | // var orientationLock = UIInterfaceOrientationMask.allButUpsideDown // 默认支持方向 | 27 | // var orientationLock = UIInterfaceOrientationMask.allButUpsideDown // 默认支持方向 |
| 27 | // func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { | 28 | // func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { |
| @@ -80,8 +81,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -80,8 +81,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| 80 | window = UIWindow.init(frame: UIScreen.main.bounds) | 81 | window = UIWindow.init(frame: UIScreen.main.bounds) |
| 81 | window?.backgroundColor = KVCBackgroupColor | 82 | window?.backgroundColor = KVCBackgroupColor |
| 82 | let is_login = UserDefaults.standard.bool(forKey: "is_login") | 83 | let is_login = UserDefaults.standard.bool(forKey: "is_login") |
| 84 | + self.isLogin = is_login | ||
| 83 | //CNLiveBaseTabBarViewController.init() | 85 | //CNLiveBaseTabBarViewController.init() |
| 84 | - window?.rootViewController = is_login ? CNLiveLaunchAdController.init() : UINavigationController(rootViewController: CNLiveLoginViewController.init()) | 86 | +// window?.rootViewController = is_login ? CNLiveLaunchAdController.init() : UINavigationController(rootViewController: CNLiveLoginViewController.init()) |
| 87 | + window?.rootViewController = is_login ? CNLiveLaunchAdController.init() : CNLiveBaseTabBarViewController.init() | ||
| 85 | window?.makeKeyAndVisible() | 88 | window?.makeKeyAndVisible() |
| 86 | if is_login{ | 89 | if is_login{ |
| 87 | //获取用户信息 /api/identityApi/getUserMsg | 90 | //获取用户信息 /api/identityApi/getUserMsg |
| @@ -172,6 +175,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -172,6 +175,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| 172 | 175 | ||
| 173 | } | 176 | } |
| 174 | 177 | ||
| 178 | + // MARK: - rootLoginVC | ||
| 179 | + func rootLoginVC(){ | ||
| 180 | + window?.rootViewController = UINavigationController(rootViewController: CNLiveLoginViewController.init()) | ||
| 181 | + } | ||
| 182 | + func pushLoginVC(){ | ||
| 183 | + currentViewController()?.navigationController?.pushViewController(CNLiveLoginViewController.init(), animated: true) | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + | ||
| 175 | // MARK: - 响应录屏状态变化 | 187 | // MARK: - 响应录屏状态变化 |
| 176 | @objc private func handleScreenCaptureChange() { | 188 | @objc private func handleScreenCaptureChange() { |
| 177 | if UIScreen.main.isCaptured { | 189 | if UIScreen.main.isCaptured { |