From d7282009847ce7dffcd5ec5c3faf2ef569f75744 Mon Sep 17 00:00:00 2001 From: 无故事王国 <841720330@qq.com> Date: 星期四, 04 七月 2024 16:50:15 +0800 Subject: [PATCH] fix bug --- DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_5_VC.swift | 4 +- DolphinEnglishLearnStudent/Moudle/Me/View/ShareView.swift | 2 DolphinEnglishLearnStudent/Moudle/Home/Listen/TCell/HomeListen_item_TCell.swift | 2 DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.xib | 10 +++-- DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift | 22 ++--------- DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.swift | 20 +++++++-- DolphinEnglishLearnStudent/Moudle/Home/HomeListenFight_lesson_1_VC.swift | 1 DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenGame_1_VC.swift | 3 + DolphinEnglishLearnStudent/Moudle/Home/Listen/CCell/ListenFight_Game_Pocket_CCell.swift | 21 +++++++++- DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_4_VC.swift | 6 +++ DolphinEnglishLearnStudent/Moudle/Home/VC/HomeStudyCompleteVC.swift | 2 11 files changed, 57 insertions(+), 36 deletions(-) diff --git a/DolphinEnglishLearnStudent/Moudle/Home/HomeListenFight_lesson_1_VC.swift b/DolphinEnglishLearnStudent/Moudle/Home/HomeListenFight_lesson_1_VC.swift index e4dcb20..8907c83 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/HomeListenFight_lesson_1_VC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/HomeListenFight_lesson_1_VC.swift @@ -250,6 +250,7 @@ //回答正确 private func answerSuccess(_ cell:ListenFight_lesson_1_CCell){ menuView?.snp.removeConstraints() + menuView?.playing() let v = cell.view_topHandle.convert(cell.bounds, to: self.view) UIView.animate(withDuration: 0.3) { self.menuView?.snp.updateConstraints { make in diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/CCell/ListenFight_Game_Pocket_CCell.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/CCell/ListenFight_Game_Pocket_CCell.swift index 6986a3e..f92d910 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/CCell/ListenFight_Game_Pocket_CCell.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/CCell/ListenFight_Game_Pocket_CCell.swift @@ -10,6 +10,11 @@ class ListenFight_Game_Pocket_CCell: UICollectionViewCell { + enum PocketEnum{ + case toFrom + case toback + } + lazy var mask_img:UIImageView = { let image = UIImageView(image: UIImage(named: "bg_card")) return image @@ -32,6 +37,8 @@ let img1 = UIImageView(image: UIImage(named: "icon_play_1")!.withTintColor(UIColor(hexString: "#41A2EB")!)) let img2 = UIImageView(image: UIImage(named: "icon_playing")!.withTintColor(UIColor(hexString: "#41A2EB")!)) + + private var pocketEnum = PocketEnum.toback let stateImg = UIImageView() @@ -86,7 +93,8 @@ } playBtn.addTarget(self, action: #selector(playAction), for: .touchUpInside) - playBtn.setImage(UIImage(named: "icon_play")?.withTintColor(UIColor(hexString: "#41A2EB")!), for: .normal) + playBtn.setBackgroundImage(UIImage(named: "icon_play")?.withTintColor(UIColor(hexString: "#41A2EB")!), for: .normal) + playBtn.isEnabled = false contentVoiceView.addSubview(playBtn) playBtn.snp.makeConstraints { make in make.right.equalTo(-self.width * 0.0958) @@ -150,8 +158,11 @@ } @objc func playAction(){ - VoicePlayer.share().playerAt(url: model.voice) - cellPlaying() + //防止穿透点击播放 + if pocketEnum == .toFrom{ + VoicePlayer.share().playerAt(url: model.voice) + cellPlaying() + } } func setSimpleModel(_ model:SimpleListenDataModel){ @@ -170,6 +181,8 @@ func toFromAction(_ superView:UIView? = nil,c:Bool? = nil){ superView?.isUserInteractionEnabled = false + pocketEnum = .toFrom + playBtn.isEnabled = true UIView.transition(from: mask_img, to: answer_img, duration: 0.6, options: [.transitionFlipFromLeft,.showHideTransitionViews]) { _ in if c == true{ superView?.isUserInteractionEnabled = true @@ -179,6 +192,8 @@ func toBackAction(_ superView:UIView? = nil,c:Bool? = nil){ superView?.isUserInteractionEnabled = false + pocketEnum = .toback + playBtn.isEnabled = false UIView.transition(from: answer_img, to: mask_img, duration: 0.6,options: [.transitionFlipFromRight,.showHideTransitionViews]){ _ in if c == true{ superView?.isUserInteractionEnabled = true diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/TCell/HomeListen_item_TCell.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/TCell/HomeListen_item_TCell.swift index 0087034..2c960f5 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/TCell/HomeListen_item_TCell.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/TCell/HomeListen_item_TCell.swift @@ -29,7 +29,7 @@ label_state.text = "已完成" }else if progress > 0 && progress < 100{ view_state.backgroundColor = UIColor(hexString: "#FF8A66") - label_state.text = String(format: "%ld%%", progress) + label_state.text = String(format: "剩余:%ld%%", progress) } } diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift index cee56e4..484ce22 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift @@ -330,7 +330,7 @@ case .story1,.story2: if let dict = noti.object as? Dictionary<String,Any>{ let type = weakSelf.viewModel.listenType.value == .story1 ? 1:2 - let accracy = String(format: "%.0lf", Double(weakSelf.viewModel.correctNum) / Double(weakSelf.viewModel.correctNum + weakSelf.viewModel.errorNum) * 100).int ?? 0 + let accracy = floor(Double(weakSelf.viewModel.correctNum) / Double(weakSelf.viewModel.correctNum + weakSelf.viewModel.errorNum) * 100).int weakSelf.storyComplete(storyId: dict["storyId"] as! Int, accuracy: accracy, studyTime: weakSelf.viewModel.times, type: type, integral: dict["storyIntegral"] as! Int) } } @@ -394,17 +394,10 @@ /// 学习类完成 /// - Parameter ignorePush: 是否忽略跳转(未完成答题 :true) private func studyComplete(){ - // var toalIntegral:Int = 0 let ids:String = viewModel.answerItems_1.keys.sorted().joined(separator: ",") - switch viewModel.listenType.value { - case .lesson1,.lesson2,.lesson3,.lesson4,.lesson5: - let data = (data as! ListenNewModel).data - // toalIntegral = data?.integral ?? 0 - default:break - } //正确率 - let accracy = String(format: "%.0lf", Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100).int ?? 0 + let accracy = floor(Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100).int Services.completeLearing(type: viewModel.listenType.value.rawValue, studyTime: viewModel.times, studyIds: ids, quarter: viewModel.quarter.value!, week: viewModel.week.value!, day: viewModel.day.value!, accracy: accracy).subscribe(onNext: {data in NotificationCenter.default.post(name: Refresh_ListenSchedule_Noti, object: nil) @@ -412,8 +405,6 @@ }).disposed(by: disposeBag) timer.invalidate() - - // toalIntegral = floor(Double(toalIntegral) * (Double(accracy) / 100.0)).int let vc = HomeStudyCompleteVC(viewModel: viewModel,studyScheduleModel: studyScheduleModel!) vc.title = viewModel.listenType.value.rawTitle @@ -427,27 +418,22 @@ var name = "" var accuracy:Int = 0 var totalNum:Double = 0 - // var toalIntegral:Int = 0 if viewModel.listenType.value == .game1{ name = "超级听力" totalNum = Double(viewModel.correctNum + viewModel.errorNum) if totalNum > 0{ - accuracy = String(format: "%.0lf", Double(viewModel.correctNum) / totalNum * 100).int ?? 0 + accuracy = floor(Double(viewModel.correctNum) / totalNum * 100).int } - // toalIntegral = floor(Double(integral) * (Double(accuracy) / 100.0)).int }else{ name = "超级记忆" let v = viewModel.answerItems.first?.value as! Listen1Model //11887:完成答题页,总题目、错误题目 数量计算逻辑错误(只要是没有答对的题目就算错误题目,不管是否答,相当于错误题目就是总题目减去正确题目) totalNum = Double(v.photoList.count) if totalNum > 0 && viewModel.correctNum > 0 && viewModel.errorNum > 0{ - accuracy = String(format: "%.0lf", Double(viewModel.correctNum) / Double(totalNum) * 100).int ?? 0 + accuracy = floor(Double(viewModel.correctNum) / Double(totalNum) * 100).int } - viewModel.errorNum = Int(totalNum) - viewModel.correctNum - - // toalIntegral = floor(Double(integral) * (Double(accuracy) / 100.0)).int } Services.completeGames(gameId: gameId, gameName: name, difficulty: viewModel.gameLevel.value, accuracy: accuracy, useTime: viewModel.times).subscribe(onNext: {data in diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_4_VC.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_4_VC.swift index 98dd935..64e2645 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_4_VC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_4_VC.swift @@ -396,6 +396,12 @@ func playComplete() { self.view.isUserInteractionEnabled = true + for subV in stackView.arrangedSubviews{ + if let s = subV as? Lesson_4_AnswerView{ + s.playEnd() + } + } + if let indexPath = viewModel.selectIndex.value ,let cell = collectionView.cellForItem(at: indexPath) as? ListenFight_lesson_4_CCell{ cell.playEnd() } diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_5_VC.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_5_VC.swift index a9b2843..95aab12 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_5_VC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFight_lesson_5_VC.swift @@ -235,13 +235,13 @@ } let tempSubV = stackView.arrangedSubviews[self.playVoiceRealAt!] as! VoiceHandleView - + label_hint.text = "" + switch answerType { case .success: answterCount += 1 rootViewModel.correctNum += 1 viewModel.answerType.accept(.success) - label_hint.text = "" let copyView = tempSubV.copyView() copyView.listenType = .lesson5 diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenGame_1_VC.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenGame_1_VC.swift index bddea29..abeba3e 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenGame_1_VC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenGame_1_VC.swift @@ -368,7 +368,8 @@ view_studyHandleView.playing() timer?.fireDate = .distantFuture //播放中,暂停计时 // label_hint.text = "播放中" - label_hint.text = "" +// label_hint.text = "" + label_hint.text = "请在\(times)s内选择答案!" } } diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.swift index 3521739..74cd3d7 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.swift @@ -16,6 +16,7 @@ @IBOutlet weak var view_handle: UIView! @IBOutlet weak var btn_isAnswer: UIButton! @IBOutlet weak var img_play: UIImageView! + @IBOutlet weak var btn_playing: UIButton! var voiceUrl:String? var isCopy:Bool = false @@ -25,11 +26,11 @@ super.awakeFromNib() img_state.alpha = 0 img_play.alpha = 0 - VoicePlayer.share().playEnd { - if self.isCopy{ - self.img_play.alpha = 1 - } - } +// VoicePlayer.share().playEnd { +// if self.isCopy{ +// self.img_play.alpha = 1 +// } +// } } func copyView()->Lesson_4_AnswerView{ @@ -42,11 +43,20 @@ self.playAtClouse = clouse } + func playEnd(){ + btn_isAnswer.isHidden = false + btn_playing.setImage(UIImage(named: "icon_play_1"), for: .normal) + } + @IBAction func playAction(_ sender: UIButton) { if let url = voiceUrl{ VoicePlayer.share().playerAt(url: url) img_play.alpha = 0 playAtClouse?(self.tag) + btn_playing.setImage(UIImage(named: "icon_playing"), for: .normal) + btn_isAnswer.isHidden = true + img_play.isHidden = true + } } } diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.xib b/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.xib index 641b0a3..444e352 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.xib +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/View/Lesson_4_AnswerView.xib @@ -20,17 +20,17 @@ <rect key="frame" x="0.0" y="0.0" width="152" height="52"/> <subviews> <button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="otl-1Z-qED"> - <rect key="frame" x="18" y="15" width="28" height="22"/> + <rect key="frame" x="15.5" y="15" width="28" height="22"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <state key="normal" image="icon_answer"/> </button> <button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mba-RI-50M"> - <rect key="frame" x="65" y="12.5" width="27" height="27"/> + <rect key="frame" x="62.5" y="12.5" width="27" height="27"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <state key="normal" image="icon_play_1"/> </button> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_fail" translatesAutoresizingMaskIntoConstraints="NO" id="mkh-g4-79e"> - <rect key="frame" x="103" y="10" width="32" height="32"/> + <rect key="frame" x="100.5" y="10" width="32" height="32"/> <constraints> <constraint firstAttribute="height" constant="32" id="unt-83-tZW"/> <constraint firstAttribute="width" constant="32" id="yDR-8r-kHx"/> @@ -52,15 +52,16 @@ <constraint firstItem="mba-RI-50M" firstAttribute="leading" secondItem="otl-1Z-qED" secondAttribute="trailing" constant="19" id="0nx-t9-1zV"/> <constraint firstItem="YeU-8E-35u" firstAttribute="centerY" secondItem="tfO-7L-o0T" secondAttribute="centerY" id="2DM-IT-SGr"/> <constraint firstAttribute="width" constant="152" id="3Zx-vg-H2U"/> - <constraint firstItem="otl-1Z-qED" firstAttribute="leading" secondItem="qsr-6I-w3R" secondAttribute="leading" constant="18" id="6CA-c8-Zr7"/> <constraint firstAttribute="bottom" secondItem="tfO-7L-o0T" secondAttribute="bottom" id="8ro-2n-YNH"/> <constraint firstAttribute="trailing" secondItem="tfO-7L-o0T" secondAttribute="trailing" id="A2h-po-R4k"/> <constraint firstAttribute="trailing" secondItem="YeU-8E-35u" secondAttribute="trailing" constant="18" id="DAX-dg-Ase"/> <constraint firstItem="mba-RI-50M" firstAttribute="centerY" secondItem="otl-1Z-qED" secondAttribute="centerY" id="FTc-eb-PWk"/> <constraint firstItem="tfO-7L-o0T" firstAttribute="top" secondItem="qsr-6I-w3R" secondAttribute="top" id="HqC-Ia-1OU"/> + <constraint firstItem="mba-RI-50M" firstAttribute="centerX" secondItem="tfO-7L-o0T" secondAttribute="centerX" id="M4G-fi-i36"/> <constraint firstItem="mkh-g4-79e" firstAttribute="centerY" secondItem="otl-1Z-qED" secondAttribute="centerY" id="N6f-d4-80e"/> <constraint firstItem="tfO-7L-o0T" firstAttribute="leading" secondItem="qsr-6I-w3R" secondAttribute="leading" id="QfH-1Q-LyV"/> <constraint firstItem="mkh-g4-79e" firstAttribute="leading" secondItem="mba-RI-50M" secondAttribute="trailing" constant="11" id="a9o-Lq-9SP"/> + <constraint firstItem="mba-RI-50M" firstAttribute="centerY" secondItem="tfO-7L-o0T" secondAttribute="centerY" id="gPd-3s-zX2"/> <constraint firstItem="otl-1Z-qED" firstAttribute="centerY" secondItem="qsr-6I-w3R" secondAttribute="centerY" id="v0P-gn-zbN"/> </constraints> <userDefinedRuntimeAttributes> @@ -101,6 +102,7 @@ <connections> <outlet property="btn_choose" destination="v7f-gv-EWR" id="wFE-Gp-xAd"/> <outlet property="btn_isAnswer" destination="otl-1Z-qED" id="0Fg-A8-9dl"/> + <outlet property="btn_playing" destination="mba-RI-50M" id="Gmt-aT-rn4"/> <outlet property="img_play" destination="YeU-8E-35u" id="Xvc-ls-0sz"/> <outlet property="img_state" destination="mkh-g4-79e" id="IzD-w8-jjK"/> <outlet property="view_handle" destination="qsr-6I-w3R" id="ptU-09-NIc"/> diff --git a/DolphinEnglishLearnStudent/Moudle/Home/VC/HomeStudyCompleteVC.swift b/DolphinEnglishLearnStudent/Moudle/Home/VC/HomeStudyCompleteVC.swift index 5c7ed6b..b09e7c5 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/VC/HomeStudyCompleteVC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/VC/HomeStudyCompleteVC.swift @@ -56,7 +56,7 @@ if viewModel.correctNum + viewModel.errorNum == 0{ label_ratioNum.text = String(format: "正确率:0%%") }else{ - label_ratioNum.text = String(format: "正确率:%.0lf%%", Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100) + label_ratioNum.text = String(format: "正确率:%ld%%", floor(Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100).int) } if totalNum != nil && viewModel.listenType.value == .game2{ diff --git a/DolphinEnglishLearnStudent/Moudle/Me/View/ShareView.swift b/DolphinEnglishLearnStudent/Moudle/Me/View/ShareView.swift index ac09ae5..904db57 100644 --- a/DolphinEnglishLearnStudent/Moudle/Me/View/ShareView.swift +++ b/DolphinEnglishLearnStudent/Moudle/Me/View/ShareView.swift @@ -75,7 +75,7 @@ SDWebImageDownloader.shared.downloadImage(with: URL(string: m.img)) { iamge, data, error, state in hiddenHUD() guard error == nil else {alert(msg: "图片获取失败");return} - WeChatTools.shareUrl("https://dollearn.com/", title: m.title, desc: "", thumb: iamge!, scene: scene) + WeChatTools.shareUrl("https://dollearn.com/", title:"海豚智能教育平台" , desc: m.title, thumb: iamge!, scene: scene) } } }).disposed(by: disposeBag) -- Gitblit v1.7.1