From 0d8f5fc8a516bfd07e425909e4a4432600572ee7 Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期三, 05 七月 2023 21:21:35 +0800 Subject: [PATCH] 修复BUG --- OKProject/Class/Home/Controller/HomeVC.swift | 358 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 179 insertions(+), 179 deletions(-) diff --git a/OKProject/Class/Home/Controller/HomeVC.swift b/OKProject/Class/Home/Controller/HomeVC.swift index c546832..e9446d9 100644 --- a/OKProject/Class/Home/Controller/HomeVC.swift +++ b/OKProject/Class/Home/Controller/HomeVC.swift @@ -1,10 +1,10 @@ -// -// HomeVC.swift -// OKProject -// -// Created by alvin_y on 2020/5/27. -// Copyright © 2020 yangwang. All rights reserved. -// + // + // HomeVC.swift + // OKProject + // + // Created by alvin_y on 2020/5/27. + // Copyright © 2020 yangwang. All rights reserved. + // import UIKit import VTMagic @@ -12,24 +12,24 @@ import RxSwift import SwifterSwift -/// 主页 + /// 主页 class HomeVC: YYViewController { - /// 协议 + /// 协议 private let agreement = AgreementView.instance() - /// 标题 + /// 标题 private let view_title: HomeTitleView = HomeTitleView.instance() - /// 广告 + /// 广告 private let advertising = AdvertisingView() - /// 是否跳转用户中心 + /// 是否跳转用户中心 private var isUserInfo = true let customerViewModel = MineContactCustomerServiceViewModel() - /// 消息按钮 + /// 消息按钮 private let button_message: UIButton = { let btn = UIButton.init(type: .custom) btn.setImage(UIImage.init(named: "icon_nav_news")!, for: .normal) @@ -39,7 +39,7 @@ return btn }() - /// 扫码按钮 + /// 扫码按钮 private let button_scan: UIButton = { let btn = UIButton.init(type: .custom) btn.setImage(UIImage.init(named: "icon_nav_scan")!, for: .normal) @@ -49,7 +49,7 @@ return btn }() - /// 个人中心按钮 + /// 个人中心按钮 private let button_user: UIButton = { let btn = UIButton.init(type: .custom) btn.setImage(UIImage.init(named: "icon_nav_user")!, for: .normal) @@ -59,17 +59,17 @@ return btn }() -// private let button_more:UIButton = { -// let btn = UIButton.init(type: .custom) -// btn.isHidden = true -// btn.setImage(UIImage.init(named: "btn_more")!, for: .normal) -// btn.setTitle("", for: .normal) -// btn.backgroundColor = .white -// btn.addShadow(ofColor: UIColor(hexString: "#E6E6E6")!.withAlphaComponent(0.5), radius: 4, offset: CGSize(width: -1, height: 0), opacity: 1) -// return btn -// }() + private let button_more:UIButton = { + let btn = UIButton.init(type: .custom) + btn.isHidden = true + btn.setImage(UIImage.init(named: "btn_more")!, for: .normal) + btn.setTitle("", for: .normal) + btn.backgroundColor = .white + btn.addShadow(ofColor: UIColor(hexString: "#E6E6E6")!.withAlphaComponent(0.5), radius: 4, offset: CGSize(width: -1, height: 0), opacity: 1) + return btn + }() - /// VTMagicController + /// VTMagicController private lazy var vtmagic: VTMagicController = { let vc = VTMagicController() vc.magicView.navigationColor = UIColor.color(light: UIColor.color(hexString: "#FFFFFF"), dark: UIColor.color(hexString: "#191919")) @@ -83,10 +83,10 @@ return vc }() - /// 左侧菜单 + /// 左侧菜单 let leftMenu = HomeLeftMenuView.instance() - /// 定位 + /// 定位 let locationViewModel = YYLocationViewModel() let viewModel = HomeViewModel() @@ -95,7 +95,7 @@ private var showModularItems = [ShowModularModel]() - /// UICollectionView + /// UICollectionView private lazy var collectionView: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.minimumLineSpacing = 0 @@ -113,8 +113,8 @@ override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. - // 判断有没有同意协议 + // Do any additional setup after loading the view. + // 判断有没有同意协议 if !UserDefaults.standard.bool(forKey: AgreeNotification){ agreement.show() agreement.agree.delegate(on: self) { (self, _) in @@ -149,21 +149,21 @@ } }).disposed(by: disposeBag) -// viewModel.queryShowModular() + // viewModel.queryShowModular() } - //MARK: - 一些初始化操作 + //MARK: - 一些初始化操作 func setup() { YYSocketManager.shared().startSocket() - // 之前没开通或没有选择定位 + // 之前没开通或没有选择定位 self.locationViewModel.requestLocation() viewModel.queryUserInfo() viewModel.queryShowModular() } - /// 设置广告 + /// 设置广告 func setupAdvert() { viewModel.getAdvertising() DispatchQueue.main.asyncAfter(deadline: .now()+5) { @@ -176,7 +176,7 @@ } } - //MARK: - UI + //MARK: - UI override func setupViews() { super.setupViews() navigationItem.titleView = view_title @@ -190,105 +190,105 @@ collectionView.backgroundColor = UIColor.color(light: UIColor.color(hexString: "#FFFFFF"), dark: UIColor.color(hexString: "#191919")) view.addSubview(collectionView) app.window?.addSubview(leftMenu) - leftMenu.didSelectRow.delegate(on: self) { (self, row) in + leftMenu.didSelectRow.delegate(on: self) { (self, name) in DispatchQueue.main.async { [self] in - switch row{ - case 0://我的订单 + + if name.contains("企业认证"){ + let vc = EnterpriseAuthVC() + self.yy_push(vc: vc) + return + } + + if name.contains("订单审核"){ + let vc = OrderReviewListVC() + self.yy_push(vc: vc) + return + } + + switch name{ + case "我的订单"://我的订单 let vc = MyOrderListVC() self.yy_push(vc: vc) break - case 1: // 优惠券 + case "优惠券": // 优惠券 let vc = MineCouponsVC() self.yy_push(vc: vc) - break - case 2: //企业认证 - let vc = EnterpriseAuthVC() + case "我的卡包": //卡包 + let vc = TravelCardVC() self.yy_push(vc: vc) - break - case 3: //钱包 + case "钱包": //开发票 let vc = MineWalletVC() self.yy_push(vc: vc) break - case 4: //订单审核 - let vc = OrderReviewListVC() - self.yy_push(vc: vc) - -// self.show() -// APIManager.shared.provider.rx.request(.getUserUserList).map(YYModel<[UserRelationModel]>.self).validate().subscribe(onSuccess: {data in -// self.hide() -// if data.data!.count > 0{ -// let vc = BindRelationVC() -// vc.relationM = data.data ?? [] -// self.yy_push(vc: vc) -// }else{ -// let vc = BindRelationAgreementVC() -// self.yy_push(vc: vc) -// } -// }) { error in -// self.hide() -// alert(text: error.localizedDescription) -// }.disposed(by: self.disposeBag) + case "亲密账户": //亲密账户 + self.show() + APIManager.shared.provider.rx.request(.getUserUserList).map(YYModel<[UserRelationModel]>.self).validate().subscribe(onSuccess: {data in + self.hide() + if data.data!.count > 0{ + let vc = BindRelationVC() + vc.relationM = data.data ?? [] + self.yy_push(vc: vc) + }else{ + let vc = BindRelationAgreementVC() + self.yy_push(vc: vc) + } + }) { error in + self.hide() + alert(text: error.localizedDescription) + }.disposed(by: self.disposeBag) break - case 5: //开发票 + case "开发票": //开发票 let vc = InvoiceViewController() self.yy_push(vc: vc) break - case 6: //意见反馈 + case "入驻成为商家": + APIManager.shared.provider.rx.request(.getMerchant).map(YYModel<MerchantInfoModel>.self).subscribe { model in + self.hide() + if model.data?.state == .delete || model.data?.state == .freeze{ + alert(text: String(format: "您的商家账号已%@,请联系平台:%@", model.data!.state.rawStr,self.customerViewModel.platform.value)) + return + } + + if model.data?.auditStatus == .waiting{ + let vc = BusinessSubmitSuccessVC() + self.yy_push(vc: vc) + }else if model.data?.auditStatus == .agreent{ + let vc = MerchantVC() + vc.merchantInfoModel = model.data + self.yy_push(vc: vc) + }else{ + let vc = BusinessVC() + vc.merchantInfoModel = model.data + self.yy_push(vc: vc) + } + } onError: { error in + + }.disposed(by: self.rx.disposeBag) + + case "我的评论": //分享 + let vc = MineCommoentVC() + self.yy_push(vc: vc) + break + case "我发布的": // 意见反馈 + let vc = MinePublishVC() + self.yy_push(vc: vc) + case "安全": //客服 + let vc = MineSafeVC() + self.yy_push(vc: vc) + break + case "意见反馈": //设置 let vc = MineFeedbackVC() self.yy_push(vc: vc) -// self.show() -// APIManager.shared.provider.rx.request(.getMerchant).map(YYModel<MerchantInfoModel>.self).subscribe { model in -// self.hide() -// if model.data?.state == .delete || model.data?.state == .freeze{ -// alert(text: String(format: "您的商家账号已%@,请联系平台:%@", model.data!.state.rawStr,self.customerViewModel.platform.value)) -// return -// } -// -// if model.data?.auditStatus == .waiting{ -// let vc = BusinessSubmitSuccessVC() -// self.yy_push(vc: vc) -// }else if model.data?.auditStatus == .agreent{ -// let vc = MerchantVC() -// vc.merchantInfoModel = model.data -// self.yy_push(vc: vc) -// }else{ -// let vc = BusinessVC() -// vc.merchantInfoModel = model.data -// self.yy_push(vc: vc) -// } -// } onError: { error in -// -// }.disposed(by: self.rx.disposeBag) break - case 7: //客服 - let vc = MineCustomerServiceVC() - self.yy_push(vc: vc) -// let vc = MineCommoentVC() -// self.yy_push(vc: vc) - break - case 8://设置 - let vc = MineSetUpVC() - self.yy_push(vc: vc) -// let vc = MinePublishVC() -// self.yy_push(vc: vc) - case 9: //分享 - let vc = MineShareVC() - self.yy_push(vc: vc) -// let vc = MineSafeVC() -// self.yy_push(vc: vc) - break - case 10: // 意见反馈 - let vc = MineFeedbackVC() - self.yy_push(vc: vc) - case 11: //客服 + case "客服": //分享 let vc = MineCustomerServiceVC() self.yy_push(vc: vc) break - case 12: //设置 + case "设置": let vc = MineSetUpVC() self.yy_push(vc: vc) break - case 13: //分享 + case "分享": let vc = MineShareVC() self.yy_push(vc: vc) break @@ -309,7 +309,7 @@ } - //MARK: - Layouts + //MARK: - Layouts override func defineLayouts() { super.defineLayouts() view_title.snp.makeConstraints { (make) in @@ -335,21 +335,21 @@ } vtmagic.magicView.reloadData() -// view.addSubview(button_more) -// button_more.addTarget(self, action: #selector(itemMoreAction), for: .touchUpInside) -// button_more.snp.makeConstraints { make in -// make.top.equalToSuperview() -// make.right.equalToSuperview() -// make.width.equalTo(54) -// make.height.equalTo(36) -// } + view.addSubview(button_more) + button_more.addTarget(self, action: #selector(itemMoreAction), for: .touchUpInside) + button_more.snp.makeConstraints { make in + make.top.equalToSuperview() + make.right.equalToSuperview() + make.width.equalTo(54) + make.height.equalTo(36) + } } deinit { NotificationCenter.default.removeObserver(self) } - //MARK: - Rx + //MARK: - Rx override func bindRx() { super.bindRx() @@ -399,12 +399,12 @@ YYMapViewManager.share.callState .subscribeOn(MainScheduler.instance) .subscribe(onNext: { (state) in - // if state == .normal{ - // 判断 - // if self.collectionView.frame.origin.y < navH{ - // return - // } - // } + // if state == .normal{ + // 判断 + // if self.collectionView.frame.origin.y < navH{ + // return + // } + // } self.button_user.setImage(state == .called ? UIImage.init(named: "icon_back") : UIImage.init(named: "icon_nav_user")!, for: .normal) self.isUserInfo = !(state == .called) self.view_title.isHidden = state == .called ? true : false @@ -433,7 +433,7 @@ } }).disposed(by: disposeBag) - // 切换城市 + // 切换城市 NotificationCenter.default.rx.notification(Notification.Name(rawValue: SwitchCityNotification), object: nil) .subscribe(onNext: {[unowned self] (_) in self.view_title.text = YYLocationManager.shared.currentCity @@ -529,14 +529,14 @@ self.userInfo() }).disposed(by: disposeBag) - // 弹窗广告 + // 弹窗广告 viewModel.popUpAdvert.bind(to: self.advertising.items).disposed(by: disposeBag) viewModel.queryShowModularSubject.subscribe(onNext: { status in switch status{ case .success(let model): - //74104 【更多服务】后台配置,关闭所有后,更多按钮也不应显示 + //74104 【更多服务】后台配置,关闭所有后,更多按钮也不应显示 let hidden = (model as? [ShowModularModel])?.filter({ m in if m.type == 1 && m.userShow == 1{return true} if m.type == 2 && m.userShow == 1{return true} @@ -546,7 +546,7 @@ return false }).count == 0 -// self.button_more.isHidden = hidden + self.button_more.isHidden = hidden if let modularArray = model as? [ShowModularModel],modularArray.count > 0{ @@ -554,7 +554,7 @@ return m1.nameIndex < m2.nameIndex } - //74067 【特惠购卡】需根据返回的状态,是否显示 购卡模块、 我的商家中心模块 + //74067 【特惠购卡】需根据返回的状态,是否显示 购卡模块、 我的商家中心模块 for item in modularArray { if item.type == 6{ self.leftMenu.isHiddenMerchant = item.userShow == 2 @@ -573,8 +573,8 @@ }.disposed(by: disposeBag) } - /// 是否隐藏导航栏 - /// - Parameter hidden: Bool + /// 是否隐藏导航栏 + /// - Parameter hidden: Bool func hiddenNavigationController(hidden: Bool) { self.button_user.setImage(hidden ? UIImage.init(named: "arrow_up") : UIImage.init(named: "icon_nav_user")!, for: .normal) self.isUserInfo = !hidden @@ -583,7 +583,7 @@ self.view_title.isHidden = hidden } - //MARK: - Acttion + //MARK: - Acttion @objc func itemMoreAction(){ @@ -599,7 +599,7 @@ let vc = CarSaleListVC() weakSelf.yy_push(vc: vc) case 5: - let vc = PublishSaleCarVC(nil, isEdit: false) + let vc = PublishSaleCarVC(nil, isEdit: false) weakSelf.yy_push(vc: vc) case 2: let vc = CarContractVC() @@ -620,7 +620,7 @@ } } - /// 用户信息 + /// 用户信息 @objc func userInfo(){ if self.isUserInfo{ // 个人中心 @@ -630,18 +630,18 @@ }else{ if YYMapViewManager.share.callState.value == .called{ YYMapViewManager.share.clearData() - // 收起 + // 收起 NotificationCenter.default.post(Notification.init(name: Notification.Name(rawValue: YYTableViewReset))) }else{ - // 收起 - // YYMapViewManager.share.callState.accept(.normal) + // 收起 + // YYMapViewManager.share.callState.accept(.normal) NotificationCenter.default.post(Notification.init(name: Notification.Name(rawValue: YYTableViewReset))) } } } - /// 消息 + /// 消息 @objc func message(){ if isUserLogined(){ let vc = MessageVC() @@ -649,20 +649,20 @@ } } - /// 扫码 + /// 扫码 @objc func scan(){ if isUserLogined(){ let vc = ScanVC() - // if let cuurentVc = vtmagic.currentViewController,cuurentVc.isKind(of: TravelCityHomeVC.classForCoder()){ - // // 跨城的扫码直接跳转 - // vc.type = .scan - // } + // if let cuurentVc = vtmagic.currentViewController,cuurentVc.isKind(of: TravelCityHomeVC.classForCoder()){ + // // 跨城的扫码直接跳转 + // vc.type = .scan + // } self.yy_push(vc: vc) } } - //MARK: - Other - /// 检测位置权限 + //MARK: - Other + /// 检测位置权限 func detectionLocationPermissions() { openLocationServiceWithBlock(false) {[unowned self] (success) in if success == true{ @@ -676,7 +676,7 @@ } } } -// MARK: - VTMagicViewDataSource + // MARK: - VTMagicViewDataSource extension HomeVC: VTMagicViewDataSource { func menuTitles(for magicView: VTMagicView) -> [String] { @@ -749,24 +749,24 @@ } } -// MARK: - VTMagicViewDelegate + // MARK: - VTMagicViewDelegate extension HomeVC: VTMagicViewDelegate{ func magicView(_ magicView: VTMagicView, didSelectItemAt itemIndex: UInt) { } func magicView(_ magicView: VTMagicView, viewDidAppear viewController: UIViewController, atPage pageIndex: UInt) { - // let name = viewModel.menu.value.map{$0.name}[Int(pageIndex)] - // switch name { - // case "出租车": - // YYMapViewManager.share.orderType.accept(.taxi) - // case "快车": - // YYMapViewManager.share.orderType.accept(.special) - // default: - // break - // } + // let name = viewModel.menu.value.map{$0.name}[Int(pageIndex)] + // switch name { + // case "出租车": + // YYMapViewManager.share.orderType.accept(.taxi) + // case "快车": + // YYMapViewManager.share.orderType.accept(.special) + // default: + // break + // } } } -// MARK: - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout + // MARK: - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout extension HomeVC: UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -799,17 +799,17 @@ extension UIViewController { - /// 判断用户是否登录 - /// - Returns: Bool + /// 判断用户是否登录 + /// - Returns: Bool func isUserLogined() -> Bool { if app.loginInfo.token == "" { let vc = YYNavigationController.init(rootViewController: LoginVC()) self.present(vc, animated: true, completion: nil) return false - //下方是一键登录 + //下方是一键登录 - /// 没有sim卡 + /// 没有sim卡 if !UMCommonUtils.simSupportedIsOK(){ let vc = YYNavigationController.init(rootViewController: LoginVC()) self.present(vc, animated: true, completion: nil) @@ -825,33 +825,33 @@ model.loginBtnFrameBlock = { (size,superSize,frame) in return CGRect(x: frame.origin.x, y: frame.origin.y, width: screenW-28, height: 44) } - //2.调用取号接口,加速授权页的弹起 - // UMCommonHandler.accelerateLoginPage(withTimeout: 30) { (dict) in - // YYAlertKit.dismiss() - // if dict["resultCode"] as! String != PNSCodeSuccess { - // alert(text: "授权失败") - // let vc = YYNavigationController.init(rootViewController: LoginVC()) - // self.present(vc, animated: true, completion: nil) - // return - // } - //3.调用获取登录Token接口,可以立马弹起授权页 + //2.调用取号接口,加速授权页的弹起 + // UMCommonHandler.accelerateLoginPage(withTimeout: 30) { (dict) in + // YYAlertKit.dismiss() + // if dict["resultCode"] as! String != PNSCodeSuccess { + // alert(text: "授权失败") + // let vc = YYNavigationController.init(rootViewController: LoginVC()) + // self.present(vc, animated: true, completion: nil) + // return + // } + //3.调用获取登录Token接口,可以立马弹起授权页 UMCommonHandler.getLoginToken(withTimeout: 30, controller: self, model: model) { (reslutDict) in let code = reslutDict["resultCode"] as! String - // 点击一键登录 + // 点击一键登录 if code == PNSCodeSuccess{ - // 获取token成功 + // 获取token成功 let token = reslutDict["token"] as! String print("一键登录token======\(token)") self.requsetLogin(token: token) }else if code == PNSCodeLoginControllerClickChangeBtn{ - // 其他登录方式 + // 其他登录方式 UMCommonHandler.cancelLoginVC(animated: true) { let vc = YYNavigationController.init(rootViewController: LoginVC()) self.present(vc, animated: true, completion: nil) } } - // } + // } } return false } else { @@ -876,7 +876,7 @@ app.loginInfo.id = data.id app.userInfo.save(model: data) DispatchQueue.main.asyncAfter(deadline: .now()+2) { - //一键登录导致的BUG:需要重新连接Socket + //一键登录导致的BUG:需要重新连接Socket YYSocketManager.shared().startSocket() } UMCommonHandler.cancelLoginVC(animated: true) { -- Gitblit v1.7.1