| | |
| | | import MJRefresh |
| | | import SDWebImage |
| | | import CoreTelephony |
| | | import AVKit |
| | | |
| | | let SetBGMSuccess_Noti = Notification.Name.init("SetBGMSuccess_Noti") |
| | | let ToShowTree_Noti = Notification.Name.init("ToShowTree_Noti") |
| | |
| | | } |
| | | |
| | | |
| | | if AudioPlayer.getSharedInstance().scenePlayer?.timeControlStatus == .paused && UserDefaultSettingViewModel.getSetting()?.sceneMusicModel != nil{ |
| | | if (AudioPlayer.getSharedInstance().scenePlayer?.timeControlStatus == .paused && UserDefaultSettingViewModel.getSetting()?.sceneMusicModel != nil) && UserViewModel.getSceneSwitch(){ |
| | | AudioPlayer.getSharedInstance().playSceneAt(UserDefaultSettingViewModel.getSetting()!.sceneMusicModel!.audioFile) |
| | | } |
| | | |
| | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | DispatchQueue.main.asyncAfter(delay: 3.0) { |
| | | self.checkNewVersion() |
| | | } |
| | | |
| | | titleItems.removeAll() |
| | | |
| | | timer = Timer.scheduledTimer(timeInterval: 30, target: self, selector: #selector(autoUpdate), userInfo: nil, repeats: true) |
| | |
| | | titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation")) |
| | | titleItems.append(TitleItem(title: "私人订制", subTitle: "Private Customization",hasMore: true)) |
| | | titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide")) |
| | | |
| | | |
| | | |
| | | tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: { |
| | | self.getData() |
| | |
| | | weakSelf.present(vc, animated: true) |
| | | } |
| | | } |
| | | |
| | | DispatchQueue.main.async { |
| | | self?.getBGMData() |
| | | self?.tableView.mj_header?.beginRefreshing() |
| | | } |
| | | default:break |
| | | } |
| | | } |
| | | |
| | | topMenuView.resetTopImage() |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | } |
| | | |
| | | NotificationCenter.default.rx.notification(SetBGMSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in |
| | | self.topMenuView.resetTopImage() |
| | | self.getBGMData() |
| | | }).disposed(by: disposeBag) |
| | | |
| | | |
| | | NotificationCenter.default.rx.notification(LoginSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in |
| | | self.getBGMData() |
| | | }).disposed(by: disposeBag) |
| | | |
| | | NotificationCenter.default.rx.notification(LoginQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in |
| | | self.getBGMData() |
| | | }).disposed(by: disposeBag) |
| | | |
| | | |
| | | |
| | | NotificationCenter.default.rx.notification(PlantGuideQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]data in |
| | | guard let weakSelf = self else { return } |
| | |
| | | if let m = data.data{ |
| | | self.viewModel.meditationList.removeAll() |
| | | self.titleItems.removeAll() |
| | | self.titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation")) |
| | | if self.viewModel.todyModel?.isShow == 1{ |
| | | self.titleItems.append(TitleItem(title: "泉疗愈微电影", subTitle: "Spring Healing Microfilm")) |
| | | }else{ |
| | | self.titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation")) |
| | | } |
| | | |
| | | self.titleItems.append(TitleItem(title: "私人订制", subTitle: "Private Customization",hasMore: true)) |
| | | self.titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide")) |
| | | self.titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide",hasMore: true)) |
| | | |
| | | |
| | | self.viewModel.meditationList = m |
| | |
| | | } |
| | | |
| | | private func getBGMData(){ |
| | | Services.quryUserSceneMusic().subscribe(onNext: {data in |
| | | if var userDefaultSettingModel = UserDefaultSettingViewModel.getSetting(){ |
| | | userDefaultSettingModel.sceneMusicModel = data.data |
| | | UserDefaultSettingViewModel.saveSetting(userDefaultSettingModel) |
| | | |
| | | if AudioPlayer.getSharedInstance().bgmPlayer != nil && PayMusicVC.getCurrentStatus() != .pause{ |
| | | AudioPlayer.getSharedInstance().bgmPlayer?.play() |
| | | return |
| | | if UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true{ |
| | | Services.getBGM().subscribe(onNext: {[weak self]data in |
| | | if let m = data.data,let model = m.first{ |
| | | if var userDefaultSettingModel = UserDefaultSettingViewModel.getSetting(){ |
| | | userDefaultSettingModel.sceneMusicModel = model |
| | | UserDefaultSettingViewModel.saveSetting(userDefaultSettingModel) |
| | | self?.updateBGMData(userDefaultSettingModel: userDefaultSettingModel) |
| | | self?.topMenuView.resetTopImage() |
| | | } |
| | | } |
| | | |
| | | if AudioPlayer.getSharedInstance().scenePlayer == nil || AudioPlayer.getSharedInstance().scenePlayer?.timeControlStatus == .paused{ |
| | | AudioPlayer.getSharedInstance().playSceneAt(userDefaultSettingModel.sceneMusicModel!.audioFile) |
| | | }).disposed(by: disposeBag) |
| | | }else{ |
| | | Services.quryUserSceneMusic().subscribe(onNext: {data in |
| | | if var userDefaultSettingModel = UserDefaultSettingViewModel.getSetting(){ |
| | | userDefaultSettingModel.sceneMusicModel = data.data |
| | | UserDefaultSettingViewModel.saveSetting(userDefaultSettingModel) |
| | | self.updateBGMData(userDefaultSettingModel: userDefaultSettingModel) |
| | | self.topMenuView.resetTopImage() |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | if let imageUrl = userDefaultSettingModel.sceneMusicModel?.imageUrl,imageUrl.isEmpty == false{ |
| | | self.topMenuView.image_top.sd_setImage(with: URL(string: imageUrl.jq_urlEncoded())) |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | private func updateBGMData(userDefaultSettingModel:UserDefaultSettingModel){ |
| | | if AudioPlayer.getSharedInstance().bgmPlayer != nil && PayMusicVC.getCurrentStatus() != .pause{ |
| | | AudioPlayer.getSharedInstance().bgmPlayer?.play() |
| | | return |
| | | } |
| | | |
| | | if (AudioPlayer.getSharedInstance().scenePlayer == nil || AudioPlayer.getSharedInstance().scenePlayer?.timeControlStatus == .paused) && UserViewModel.getSceneSwitch(){ |
| | | AudioPlayer.getSharedInstance().playSceneAt(userDefaultSettingModel.sceneMusicModel!.audioFile) |
| | | } |
| | | } |
| | | |
| | | @objc func autoUpdate() { |
| | |
| | | Services.getTopdayMedita().subscribe(onNext: { [weak self] data in |
| | | guard let self = self else { return } |
| | | self.viewModel.todyModel = data.data |
| | | self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none) |
| | | |
| | | if data.data?.isShow == 1{ |
| | | self.titleItems[0] = TitleItem(title: "泉疗愈微电影", subTitle: "Spring Healing Microfilm") |
| | | }else{ |
| | | self.titleItems[0] = TitleItem(title: "每日疗愈", subTitle: "Daily Meditation") |
| | | } |
| | | |
| | | |
| | | // self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none) |
| | | // self.tableView.reloadRows(at: [IndexPath(row: 1, section: 0)], with: .none) |
| | | self.tableView.reloadData() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | |
| | | nav.modalPresentationStyle = .fullScreen |
| | | present(nav, animated: true) |
| | | break |
| | | case 202: |
| | | let vc = WebVC(type: .guide) |
| | | vc.title = "泉疗愈" |
| | | push(vc: vc) |
| | | default: |
| | | let topTitle = titleItems[sender.tag - 200].title |
| | | let m = viewModel.meditationList[sender.tag - 200 - 3] |
| | |
| | | let vc = HomeItemListVC(topTitle: topTitle, id: id,showType: .vertical) |
| | | push(vc: vc) |
| | | } |
| | | } |
| | | } |
| | | |
| | | private func checkNewVersion(){ |
| | | JQTool.checkVersion(appid: AppleID){ stat, model, url in |
| | | let version = UserDefaults.standard.value(forKey: "ignoreVersion") as? String |
| | | if stat && version != model?.version ?? "1.0.0"{ |
| | | DispatchQueue.main.async { |
| | | if let m = model{ |
| | | UpdateVersionView.show(model:m) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | |
| | | if indexPath.section == 0{ |
| | | guard let m = viewModel.todyModel, let detailId = m.clientMeditationVO?.id else { |
| | | alert(msg: "平台暂未设置今日疗愈") |
| | | guard let m = viewModel.todyModel else { |
| | | alert(msg: "平台暂未设置今日疗愈");return |
| | | } |
| | | |
| | | //停止播放背景音 |
| | | AudioPlayer.getSharedInstance().pauseScene() |
| | | |
| | | if m.isShow == 1{ |
| | | if let videoUrl = m.meditationVideo?.videoUrl.jq_urlEncoded(){ |
| | | let videoPlayVC = VideoPlayVC(playUrl: videoUrl,titleL: m.meditationVideo?.title ?? "") |
| | | videoPlayVC.modalPresentationStyle = .fullScreen |
| | | push(vc: videoPlayVC) |
| | | } |
| | | return |
| | | } |
| | | |
| | | |
| | | |
| | | let audioPlayer = AudioPlayer.getSharedInstance() |
| | | let isSameMeditation = audioPlayer.meditationModel?.id == m.meditationId |
| | | let isPaused = audioPlayer.bgmPlayer?.timeControlStatus == .paused |
| | |
| | | } |
| | | } else { |
| | | // 游客模式都能播放 |
| | | Services.getMeditationDetail(id: detailId).subscribe(onNext: { [weak self] data in |
| | | guard let self = self, let m = data.data else { return } |
| | | if let detailId = m.clientMeditationVO?.id{ |
| | | Services.getMeditationDetail(id: detailId).subscribe(onNext: { [weak self] data in |
| | | guard let self = self, let m = data.data else { return } |
| | | |
| | | if m.chargeType == .payment{ |
| | | if UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true{ |
| | | sceneDelegate?.needLogin();return |
| | | }else if m.isBuy == .no{ |
| | | let vc = PaymentOrderVC(museItemModel: m, type: .muse, showType: DisplayType.horizontal) |
| | | jq_push(vc: vc);return |
| | | if m.chargeType == .payment{ |
| | | if UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true{ |
| | | sceneDelegate?.needLogin();return |
| | | }else if m.isBuy == .no{ |
| | | let vc = PaymentOrderVC(museItemModel: m, type: .muse, showType: DisplayType.horizontal) |
| | | jq_push(vc: vc);return |
| | | } |
| | | } |
| | | } |
| | | |
| | | if m.chargeType == .vipFree && UserViewModel.getAvatarInfo().isVip != .yes{ |
| | | let vipCenterVC = VIPCenterVC() |
| | | jq_push(vc: vipCenterVC) |
| | | return |
| | | } |
| | | if m.chargeType == .vipFree && UserViewModel.getAvatarInfo().isVip != .yes{ |
| | | let vipCenterVC = VIPCenterVC() |
| | | jq_push(vc: vipCenterVC) |
| | | return |
| | | } |
| | | |
| | | if audioPlayer.meditationModel?.id == m.id && audioPlayer.bgmPlayer?.timeControlStatus == .playing { |
| | | return |
| | | } |
| | | audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self) |
| | | PayMusicVC.show(model: m, isHidden: false) |
| | | self.viewModel.todyModel?.playAtMe = true |
| | | DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { |
| | | self.tableView.reloadData() |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | if audioPlayer.meditationModel?.id == m.id && audioPlayer.bgmPlayer?.timeControlStatus == .playing { |
| | | return |
| | | } |
| | | audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self) |
| | | PayMusicVC.show(model: m, isHidden: false) |
| | | self.viewModel.todyModel?.playAtMe = true |
| | | DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { |
| | | self.tableView.reloadData() |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | if indexPath.section == 0 && indexPath.row == 0{ |
| | | //每日疗愈 |
| | | //每日疗愈 & 泉疗愈微电影 |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_1_TCell") as! Home_Style_1_TCell |
| | | if let m = viewModel.todyModel,m.id != 0{ |
| | | cell.setTodayMeditationModel(m) |
| | |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| | | if indexPath.section == 0 || indexPath.section == 1 || indexPath.section == 2{ |
| | | if indexPath.section == 0 || indexPath.section == 1{ |
| | | return JQ_ScreenW * 0.551 |
| | | }else if indexPath.section == 2{ |
| | | return 0 |
| | | }else{ |
| | | let index = indexPath.section - 3 |
| | | let m = viewModel.meditationList[index] |
| | |
| | | |
| | | if section == 1{ |
| | | headerView.btn_more.setImage(UIImage(named: "btn_more"), for: .normal) |
| | | }else if section == 2{ |
| | | headerView.btn_more.setImage(UIImage(named: "icon_guide_more"), for: .normal) |
| | | }else{ |
| | | headerView.btn_more.setImage(UIImage(named: "icon_exchange"), for: .normal) |
| | | } |