| | |
| | | self.taskListView.setTreeInfoModel(m) |
| | | |
| | | //检查hash,进行同步 |
| | | if m.toJSON()?.jq_hash() != self.treeInfoModel?.toJSON()?.jq_hash(){ |
| | | // if m.toJSON()?.jq_hash() != self.treeInfoModel?.toJSON()?.jq_hash(){ |
| | | self.treeInfoModel = m |
| | | self.updateTreeInfo() |
| | | } |
| | | |
| | | try? self.cacheTreeInfoModel.save(m) |
| | | self.updateAni(false) |
| | | try? self.cacheTreeInfoModel.save(m) |
| | | // } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | |
| | | // if treeLevel.rawValue != treeInfoModel?.treeLevelType.rawValue{ |
| | | // treeLevel = treeInfoModel!.treeLevelType |
| | | // } |
| | | |
| | | icon_energy.text = String(format: "当前能量值:%ld", treeInfoModel!.currentEnergyValue) |
| | | icon_energy.text = String(format: "当前能量值:%ld", treeInfoModel!.energyValue) |
| | | setProgress(current: treeInfoModel!.growthValue, total: treeInfoModel!.nextLevel) |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | taskListView.signSuccess {[weak self] in |
| | | self?.getTreeData() |
| | | } |
| | | } |
| | | |
| | | // 0 - 100 |
| | |
| | | |
| | | //能量明细 |
| | | @IBAction func energyDetailAction(_ sender: TapBtn) { |
| | | guard sceneDelegate!.checkisLoginState() else {return} |
| | | let vc = TreeTeskDetailVC() |
| | | push(vc: vc) |
| | | } |
| | | |
| | | //兑换 |
| | | @IBAction func exchangeAction(_ sender: TapBtn) { |
| | | guard sceneDelegate!.checkisLoginState() else {return} |
| | | let vc = TreeTeskEnergyExchangeVC() |
| | | push(vc: vc) |
| | | } |
| | | |
| | | @IBAction func wateringAction(_ sender: UIButton) { |
| | | guard sceneDelegate!.checkisLoginState() else {return} |
| | | |
| | | sender.isUserInteractionEnabled = false |
| | | |
| | | if treeInfoModel == nil {return} |
| | | |
| | | guard treeInfoModel!.currentEnergyValue != 0 else{ |
| | | guard treeInfoModel!.energyValue != 0 else{ |
| | | alert(msg: "已经没有能量值了,快去做任务吧");return |
| | | } |
| | | |
| | |
| | | guard let weakSelf = self else { return } |
| | | if let m = data.data{ |
| | | sender.isUserInteractionEnabled = true |
| | | if m.isNext{ |
| | | let type = weakSelf.treeInfoModel?.treeLevelType ?? .level_1 |
| | | if m.isNext{ |
| | | let type = weakSelf.treeInfoModel?.treeLevelType ?? .level_1 |
| | | weakSelf.treeInfoModel!.treeLevelType = TreeLevel(rawValue: type.rawValue + 1) ?? .level_1 |
| | | |
| | | let h = (JQ_ScreenW - 90) * 0.7729 |
| | | TreeTeskFirstRuleView.show(title: "升级", content:"恭喜!你的树苗已升级为\(weakSelf.treeInfoModel!.treeLevelType.title)阶段!",textAlignment: .center,height: h,textTopOffset: 57) |
| | | let h = (JQ_ScreenW - 90) * 0.7729 |
| | | TreeTeskFirstRuleView.show(title: "升级", content:"恭喜!你的树苗已升级为\(weakSelf.treeInfoModel!.treeLevelType.title)阶段!",textAlignment: .center,height: h,textTopOffset: 57) |
| | | |
| | | if let soundURL = URL(string:weakSelf.treeInfoModel?.treeLevelType.sound){ |
| | | weakSelf.voicePlayer.replaceCurrentItem(with: AVPlayerItem(url: soundURL)) |
| | | weakSelf.voicePlayer.play() |
| | | } |
| | | weakSelf.updateAni() |
| | | } |
| | | weakSelf.treeInfoModel?.currentEnergyValue = 0 |
| | | weakSelf.getTreeData() |
| | | return |
| | | } |
| | | |
| | | weakSelf.treeInfoModel?.growthValue = m.growthValue |
| | | weakSelf.treeInfoModel?.energyValue = 0 |
| | | weakSelf.treeInfoModel?.nextLevel = m.nextLevel |
| | | weakSelf.updateTreeInfo() |
| | | } |
| | |
| | | push(vc: vc) |
| | | } |
| | | |
| | | private func updateAni(){ |
| | | private func updateAni(_ needAni:Bool = true){ |
| | | let treeLevel = treeInfoModel?.treeLevelType ?? .level_1 |
| | | |
| | | guard let animateUrl = Bundle.main.url(forResource: treeLevel.aniResource, withExtension: "png") else {return} |
| | |
| | | make.height.equalTo(731 * scale) |
| | | } |
| | | |
| | | UIView.animate(withDuration: 0.6) { |
| | | let duration = needAni ? 0.6:0 |
| | | UIView.animate(withDuration: duration) { |
| | | self.aPNGTreeImageView?.alpha = 0 |
| | | |
| | | }completion: { state in |