| | |
| | | import MediaPlayer |
| | | import MJRefresh |
| | | import SDWebImage |
| | | import CoreTelephony |
| | | |
| | | let SetBGMSuccess_Noti = Notification.Name.init("SetBGMSuccess_Noti") |
| | | |
| | |
| | | private var titleItems = [TitleItem]() |
| | | private var viewModel = HomeViewModel() |
| | | |
| | | private var cellularData:CTCellularData! |
| | | |
| | | override func viewDidAppear(_ animated: Bool) { |
| | | super.viewDidAppear(animated) |
| | | |
| | | //获取用户信息 |
| | | if !(UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true){ |
| | | Services.getUserDetail().subscribe(onNext: {data in |
| | | if let m = data.data{UserViewModel.saveAvatarInfo(m)} |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | |
| | | } |
| | | |
| | | getData() |
| | | |
| | | cellularData = CTCellularData() |
| | | cellularData.cellularDataRestrictionDidUpdateNotifier = {[weak self] state in |
| | | |
| | | switch state{ |
| | | case .notRestricted: |
| | | if UserDefaultSettingViewModel.getSetting()?.userFirstLaunch ?? true{ |
| | | DispatchQueue.main.async {[weak self] in |
| | | guard let weakSelf = self else { return } |
| | | let vc = LoginTreatyVC() |
| | | vc.topIndex = 0 |
| | | vc.clickHandle { state in |
| | | if !state{ |
| | | exit(0) |
| | | }else{ |
| | | //跳转计划引导 |
| | | let nav = BaseNav(rootViewController: PlanGuideVC()) |
| | | nav.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(nav, animated: true) |
| | | } |
| | | } |
| | | vc.modalPresentationStyle = .custom |
| | | weakSelf.present(vc, animated: true) |
| | | } |
| | | } |
| | | default:break |
| | | } |
| | | } |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | self.topMenuView.resetTopImage() |
| | | }).disposed(by: disposeBag) |
| | | |
| | | NotificationCenter.default.rx.notification(PlantGuideQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in |
| | | self.getData() |
| | | if UserDefaultSettingViewModel.getSetting()?.userFirstOpenTreeTask ?? true{ |
| | | self.navigationController?.tabBarController?.selectedIndex = 2 |
| | | } |
| | | NotificationCenter.default.rx.notification(PlantGuideQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]data in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.getData() |
| | | |
| | | Services.isFirst().subscribe(onNext: {data in |
| | | if data.data == true{ |
| | | weakSelf.navigationController?.tabBarController?.selectedIndex = 2 |
| | | var viewModel = UserDefaultSettingViewModel.getSetting() |
| | | viewModel?.userFirstOpenTreeTask = false |
| | | UserDefaultSettingViewModel.saveSetting(viewModel!) |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | |
| | | }).disposed(by: disposeBag) |
| | | |
| | | NotificationCenter.default.rx.notification(LoginSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in |
| | |
| | | } |
| | | |
| | | }).disposed(by: disposeBag) |
| | | |
| | | if !(UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true){ |
| | | Services.getUserDetail().subscribe(onNext: {data in |
| | | if let m = data.data{UserViewModel.saveAvatarInfo(m)} |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | @objc func searchAction(){ |
| | |
| | | let topTitle = titleItems[sender.tag - 200].title |
| | | let m = viewModel.meditationList[sender.tag - 200 - 3] |
| | | if let id = m.clientMeditationCategoryVO?.id{ |
| | | let vc = HomeItemListVC(topTitle: topTitle, id: id,showType: m.clientMeditationCategoryVO!.showType) |
| | | let vc = HomeItemListVC(topTitle: topTitle, id: id,showType: .vertical) |
| | | push(vc: vc) |
| | | } |
| | | } |