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 | 101 | //电商h5订单支付成功通知 |
| 102 | 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 | 104 | self.cnWebView.configuration.userContentController.add(self, name: "toShare") |
| 105 | 105 | self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment") |
| 106 | 106 | self.cnWebView.configuration.userContentController.add(self, name: "getStatusHeight") |
| 107 | + self.cnWebView.configuration.userContentController.add(self, name: "shopLogin") | |
| 107 | 108 | } |
| 108 | 109 | |
| 109 | 110 | func webViewRemoveScriptMessageHandler(){ |
| ... | ... | @@ -111,6 +112,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate |
| 111 | 112 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "toShare") |
| 112 | 113 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "openAppPayment") |
| 113 | 114 | self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "getStatusHeight") |
| 115 | + self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "shopLogin") | |
| 114 | 116 | } |
| 115 | 117 | //电商h5的回调 |
| 116 | 118 | func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { |
| ... | ... | @@ -209,6 +211,14 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate |
| 209 | 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 | 224 | // MARK: - 字典转字符串 |
| ... | ... | @@ -216,7 +226,7 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate |
| 216 | 226 | guard let json = json else { |
| 217 | 227 | return nil |
| 218 | 228 | } |
| 219 | - | |
| 229 | + | |
| 220 | 230 | do { |
| 221 | 231 | let data = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) |
| 222 | 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 | 92 | override func viewDidLoad() { |
| 93 | 93 | super.viewDidLoad() |
| 94 | 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 | 101 | self.view.addSubview(self.webView) |
| 96 | 102 | |
| 97 | 103 | self.webView.webControllerUpdateNavSoundBlock = { isSound in |
| ... | ... | @@ -132,6 +138,12 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ |
| 132 | 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 | 148 | func h5StopVideoPlayer(){ |
| 137 | 149 | // call h5停止播放视频 | ... | ... |
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
| ... | ... | @@ -79,7 +79,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 79 | 79 | wxButton.addTarget(self, action: #selector(sendWXLoginActionMothod), for: .touchUpInside) |
| 80 | 80 | return wxButton |
| 81 | 81 | }() |
| 82 | - | |
| 82 | + | |
| 83 | 83 | lazy var tipLabel: UILabel = { |
| 84 | 84 | let tipLabel = UILabel.init() |
| 85 | 85 | tipLabel.text = "未注册的手机号验证后自动为您创建元码账户" |
| ... | ... | @@ -89,6 +89,12 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 89 | 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 | 99 | var is_agree : Bool = false //是否同意协议 |
| 94 | 100 | var countryCode: String = "86" |
| ... | ... | @@ -111,6 +117,20 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 111 | 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 | 134 | self.setupPhoneView() |
| 115 | 135 | self.setupVeriCodeView() |
| 116 | 136 | self.setupLoginButtonView() |
| ... | ... | @@ -302,7 +322,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 302 | 322 | CNLiveLoginViewModel.appleLogin(model: model) { result, status in |
| 303 | 323 | if status == .success{ |
| 304 | 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 | 327 | if respStatue == .success{ |
| 307 | 328 | if let res = result as? MineGetUserMsgUsersModel{ |
| 308 | 329 | let userInfo = UserInfoManager.shared.userInfo |
| ... | ... | @@ -318,8 +339,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 318 | 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 | 353 | }else{ |
| ... | ... | @@ -432,8 +460,10 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 432 | 460 | if status == .success{ |
| 433 | 461 | //登录成功 |
| 434 | 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 | 465 | if respStatue == .success{ |
| 466 | + | |
| 437 | 467 | if let res = result as? MineGetUserMsgUsersModel{ |
| 438 | 468 | let userInfo = UserInfoManager.shared.userInfo |
| 439 | 469 | userInfo.userMsgUsers = res |
| ... | ... | @@ -448,9 +478,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 448 | 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 | 491 | }else{ |
| 456 | 492 | let window = UIApplication.shared.delegate?.window |
| ... | ... | @@ -463,7 +499,8 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 463 | 499 | if res == "42013"{ |
| 464 | 500 | if (type == CNLiveSendAuthRespApple) { |
| 465 | 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 | 504 | if respStatue == .success{ |
| 468 | 505 | if let res = result as? MineGetUserMsgUsersModel{ |
| 469 | 506 | let userInfo = UserInfoManager.shared.userInfo |
| ... | ... | @@ -479,9 +516,15 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { |
| 479 | 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 | 529 | }else{ |
| 487 | 530 | let window = UIApplication.shared.delegate?.window |
| ... | ... | @@ -549,7 +592,8 @@ extension CNLiveLoginViewController { |
| 549 | 592 | CNLiveLoginViewModel.requestLoginAction(userName: phoneText.text ?? "", countryCode: countryCode, verCode: veriText.text ?? "") {[self] in |
| 550 | 593 | loginButton.stopAnimating() |
| 551 | 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 | 597 | if respStatue == .success{ |
| 554 | 598 | if let res = result as? MineGetUserMsgUsersModel{ |
| 555 | 599 | let userInfo = UserInfoManager.shared.userInfo |
| ... | ... | @@ -565,9 +609,15 @@ extension CNLiveLoginViewController { |
| 565 | 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 | 622 | }else{ |
| 573 | 623 | let window = UIApplication.shared.delegate?.window | ... | ... |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineViewController.swift
| ... | ... | @@ -110,8 +110,17 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, |
| 110 | 110 | // NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWiFi, object: nil) |
| 111 | 111 | // NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWWAN, object: nil) |
| 112 | 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 | 124 | func loadGift(){ |
| 116 | 125 | showLoading(message: "") |
| 117 | 126 | CNLiveHomePageViewModel.requestGetHomePageTopBannerGift{[weak self] result, status in |
| ... | ... | @@ -276,8 +285,9 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, |
| 276 | 285 | } |
| 277 | 286 | |
| 278 | 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 | 402 | |
| 393 | 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 | 412 | }else if name == "我的订单"{ |
| 399 | 413 | |
| 400 | 414 | }else if name == "帮助与反馈"{ | ... | ... |
metaCode/Classes/Main/MinePage/Controller/CNLiveTypeFeedBackViewController.swift
| ... | ... | @@ -172,13 +172,17 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 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 | 188 | if _show_type == .about { |
| ... | ... | @@ -201,6 +205,8 @@ class CNLiveTypeFeedBackViewController : CNLiveBaseViewController, UITableViewDe |
| 201 | 205 | logoutButton.startAnimating() |
| 202 | 206 | AlertTool.systemActionSheet(title: nil, message: nil, actionTitles: ["退出登录"]) { [self] index in |
| 203 | 207 | if index == 1 { |
| 208 | + NotificationCenter.default.post(name: Notification.Name.LoginManage.CNLiveLoginOutNotification, object: nil) | |
| 209 | + metaAppDelegate.isLogin = false | |
| 204 | 210 | logoutButton.stopAnimating() |
| 205 | 211 | UserDefaults.standard.set(false,forKey: "is_login") |
| 206 | 212 | UserInfoManager.clearUserInfo() |
| ... | ... | @@ -273,7 +279,11 @@ extension CNLiveTypeFeedBackViewController { |
| 273 | 279 | } |
| 274 | 280 | if _show_type == .setting { |
| 275 | 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 | 288 | if indexPath.section == 1 { |
| 279 | 289 | self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .privacy), animated: true) |
| ... | ... | @@ -282,7 +292,11 @@ extension CNLiveTypeFeedBackViewController { |
| 282 | 292 | self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .about), animated: true) |
| 283 | 293 | } |
| 284 | 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 | 302 | if _show_type == .privacy { | ... | ... |
metaCode/Classes/Main/MinePage/View/CNLiveMineHeaderView.swift
| ... | ... | @@ -32,6 +32,16 @@ class MineHeaderView : UIView { |
| 32 | 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 | 45 | lazy var tipBtn: UIButton = { |
| 36 | 46 | let tipBtn = UIButton(type: .custom) |
| 37 | 47 | tipBtn.backgroundColor = .clear |
| ... | ... | @@ -57,6 +67,14 @@ class MineHeaderView : UIView { |
| 57 | 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 | 78 | // addSubview(tipBtn) |
| 61 | 79 | // tipBtn.snp.makeConstraints { make in |
| 62 | 80 | // make.centerY.equalToSuperview().offset(10) |
| ... | ... | @@ -76,6 +94,10 @@ class MineHeaderView : UIView { |
| 76 | 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 | 101 | @objc func tipBtnAction() { |
| 80 | 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 | 363 | } |
| 364 | 364 | |
| 365 | 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 | 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 | 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 | 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 | 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 | 406 | @objc func imgTapAction(ges: UITapGestureRecognizer){ |
| 382 | 407 | let imageView = ges.view as! UIImageView |
| 383 | 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 | 239 | currentViewController()?.navigationController?.pushViewController(vc, animated: true) |
| 240 | 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 | 22 | var isCaptured = false //是否录屏中 |
| 23 | 23 | var isGift = false//是否忽必烈礼物 |
| 24 | 24 | var giftModel:CNLiveHomePageHuBiLieGiftModel?//送礼分享model |
| 25 | + var isLogin = false//是否登录 | |
| 25 | 26 | |
| 26 | 27 | // var orientationLock = UIInterfaceOrientationMask.allButUpsideDown // 默认支持方向 |
| 27 | 28 | // func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { |
| ... | ... | @@ -80,8 +81,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { |
| 80 | 81 | window = UIWindow.init(frame: UIScreen.main.bounds) |
| 81 | 82 | window?.backgroundColor = KVCBackgroupColor |
| 82 | 83 | let is_login = UserDefaults.standard.bool(forKey: "is_login") |
| 84 | + self.isLogin = is_login | |
| 83 | 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 | 88 | window?.makeKeyAndVisible() |
| 86 | 89 | if is_login{ |
| 87 | 90 | //获取用户信息 /api/identityApi/getUserMsg |
| ... | ... | @@ -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 | 187 | // MARK: - 响应录屏状态变化 |
| 176 | 188 | @objc private func handleScreenCaptureChange() { |
| 177 | 189 | if UIScreen.main.isCaptured { | ... | ... |