无故事王国
2024-07-02 655a0215e597e3c46834d9d8a609bab729a1816f
DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift
@@ -100,6 +100,8 @@
            var listenFightLine:ListenFightLine = .none
            var data:Any?
            private var notiObject:Dictionary<String,Any>?
            private lazy var label_pageNum:UILabel = {
                        let label = UILabel()
                        label.font = .systemFont(ofSize: 14, weight: .medium)
@@ -283,8 +285,15 @@
                                                            case .lesson1,.lesson2,.lesson3,.lesson4,.lesson5:
                                                                        weakSelf.studyComplete()
                                                            case .game1,.game2:
                                                                        if let dict = noti.object as? Dictionary<String,Any>{
                                                                                    weakSelf.gamesComplete(gameId: dict["gameId"] as! Int,integral: dict["gameIntegral"] as! Int)
                                                                        weakSelf.notiObject = noti.object as? Dictionary<String,Any>
                                                                        weakSelf.timer.invalidate()
                                                                        if let isComplete = weakSelf.notiObject?["complete"] as? Bool{
                                                                                    if isComplete{
                                                                                                weakSelf.btn_exit.setTitle("提交", for: .normal)
                                                                                    }else{
                                                                                                weakSelf.gamesComplete(gameId: weakSelf.notiObject!["gameId"] as! Int,integral: weakSelf.notiObject!["gameIntegral"] as! Int)
                                                                                    }
                                                                        }
                                                            case .story1,.story2:
                                                                        if let dict = noti.object as? Dictionary<String,Any>{
@@ -367,6 +376,7 @@
                        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)
                                    NotificationCenter.default.post(name: StudyCompleteCoinUpdate_Noti, object: data.data ?? 0)
                        }).disposed(by: disposeBag)
                        timer.invalidate()
@@ -397,15 +407,20 @@
                        }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 = Int(Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100)
                                                accuracy = Int(Double(viewModel.correctNum) / Double(totalNum) * 100)
                                    }
                                    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
                                    NotificationCenter.default.post(name: Refresh_ListenSchedule_Noti, object: nil)
                                    NotificationCenter.default.post(name: StudyCompleteCoinUpdate_Noti, object: data.data ?? 0)
                        }).disposed(by: disposeBag)
                        timer.invalidate()
@@ -420,6 +435,7 @@
                        timer.invalidate()
                        Services.completeStory(storyId: storyId, accuracy: accuracy, studyTime: studyTime, type: type).subscribe(onNext: {data in
                                    NotificationCenter.default.post(name: Refresh_ListenSchedule_Noti, object: nil)
                                    NotificationCenter.default.post(name: StudyCompleteCoinUpdate_Noti, object: data.data ?? 0)
                        }).disposed(by: disposeBag)
                        let vc = HomeStudyCompleteVC(totalCoin: integral,viewModel: viewModel,studyScheduleModel: studyScheduleModel!)
@@ -437,7 +453,19 @@
                                    if viewModel.listenType.value == .story2{
                                                if isPop{
                                                            self.navigationController?.popViewController();return
                                                            CommonAlertView.show(content: "未完成全部答题,确认退出吗?") {[weak self] () in
                                                                        guard let weakSelf = self else { return }
                                                                        for vc in weakSelf.navigationController?.viewControllers ?? []{
                                                                                    if vc.isKind(of: HomeListenMenuVC.self){
                                                                                                weakSelf.navigationController?.popToViewController(vc, animated: true);break
                                                                                    }
                                                                                    if vc.isKind(of: HomeListenVC.self){
                                                                                                weakSelf.navigationController?.popToViewController(vc, animated: true);break
                                                                                    }
                                                                        }
                                                            }
                                                            return
                                                }
                                                guard (pageVC.currentController as! HomeListenStory_2_VC).isPlayEnd else {
@@ -448,7 +476,13 @@
                                                let accuracy = 100
                                                storyComplete(storyId: v.data!.id, accuracy: accuracy, studyTime: viewModel.times, type: viewModel.listenType.value == .story1 ? 1:2, integral: v.data!.integral)
                                    }
                        }else{
                        }else if btn_exit.titleLabel?.text == "提交"{
                                    if viewModel.listenType.value == .game1 || viewModel.listenType.value == .game2{
                                                if let dict = notiObject{
                                                            gamesComplete(gameId: dict["gameId"] as! Int,integral: dict["gameIntegral"] as! Int)
                                                }
                                    }
                        } else{
                                    CommonAlertView.show(content: "未完成全部答题,确认退出吗?") {[weak self] () in
                                                guard let weakSelf = self else { return }
@@ -508,6 +542,11 @@
            }
            @objc func beforeAction(){
                        guard (pageVC.currentController as! HomeListenStory_2_VC).isPlayEnd else {
                                    alert(msg: "请听完");return
                        }
                        listenFightLine = .before
                        let beforePage = max(0, viewModel.currentPage.value - 1)
                        switch viewModel.listenType.value {