| | |
| | | //回答正确 |
| | | 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 |
| | |
| | | |
| | | 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 |
| | |
| | | |
| | | 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() |
| | | |
| | |
| | | } |
| | | |
| | | 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) |
| | |
| | | } |
| | | |
| | | @objc func playAction(){ |
| | | VoicePlayer.share().playerAt(url: model.voice) |
| | | cellPlaying() |
| | | //防止穿透点击播放 |
| | | if pocketEnum == .toFrom{ |
| | | VoicePlayer.share().playerAt(url: model.voice) |
| | | cellPlaying() |
| | | } |
| | | } |
| | | |
| | | func setSimpleModel(_ model:SimpleListenDataModel){ |
| | |
| | | |
| | | 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 |
| | |
| | | |
| | | 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 |
| | |
| | | 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) |
| | | } |
| | | |
| | | } |
| | |
| | | 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) |
| | | } |
| | | } |
| | |
| | | /// 学习类完成 |
| | | /// - 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) |
| | |
| | | }).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 |
| | |
| | | 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 |
| | |
| | | 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() |
| | | } |
| | |
| | | } |
| | | |
| | | 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 |
| | |
| | | view_studyHandleView.playing() |
| | | timer?.fireDate = .distantFuture //播放中,暂停计时 |
| | | // label_hint.text = "播放中" |
| | | label_hint.text = "" |
| | | // label_hint.text = "" |
| | | label_hint.text = "请在\(times)s内选择答案!" |
| | | } |
| | | |
| | | } |
| | |
| | | @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 |
| | |
| | | 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{ |
| | |
| | | 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 |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | <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"/> |
| | |
| | | <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> |
| | |
| | | <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"/> |
| | |
| | | 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{ |
| | |
| | | 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) |