fix
无故事王国
2024-07-01 803e04b1ba7a513e8a04899c82b38f3c2fac131c
DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenFightVC.swift
@@ -177,7 +177,7 @@
        super.viewDidLoad()
                        yy_popBlock = {[weak self] in
                                    self?.quitAction()
                                    self?.quitAction(isPop: true)
                        }
                        btn_exit.addTarget(self, action: #selector(quitAction), for: .touchUpInside)
@@ -288,7 +288,7 @@
                                                                        }
                                                            case .story1,.story2:
                                                                        if let dict = noti.object as? Dictionary<String,Any>{
                                                                                    let type = weakSelf.viewModel.listenType.value == .story1 ? 1:0
                                                                                    let type = weakSelf.viewModel.listenType.value == .story1 ? 1:2
                                                                                    let accracy = Int(Double(weakSelf.viewModel.correctNum) / Double(weakSelf.viewModel.correctNum + weakSelf.viewModel.errorNum) * 100)
                                                                                    weakSelf.storyComplete(storyId: dict["storyId"] as! Int, accuracy: accracy, studyTime: weakSelf.viewModel.times, type: type, integral: dict["storyIntegral"] as! Int)
                                                                        }
@@ -373,8 +373,9 @@
                        toalIntegral = floor(Double(toalIntegral) * (Double(accracy) / 100.0)).int
                        let vc = HomeStudyCompleteVC(correctNum: viewModel.correctNum, errorNum: viewModel.errorNum, totalCoin: toalIntegral, listenType: viewModel.listenType.value)
                        let vc = HomeStudyCompleteVC(totalCoin: toalIntegral,viewModel: viewModel,studyScheduleModel: studyScheduleModel!)
                        vc.title = viewModel.listenType.value.rawTitle
                        vc.viewModel = viewModel
                        push(vc: vc)
            }
@@ -397,7 +398,7 @@
                                    name = "超级记忆"
                                    let v = viewModel.answerItems.first?.value as! Listen1Model
                                    totalNum = Double(v.photoList.count)
                                    if totalNum > 0{
                                    if totalNum > 0 && viewModel.correctNum > 0 && viewModel.errorNum > 0{
                                                accuracy = Int(Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100)
                                    }
                                    toalIntegral = floor(Double(integral) * (Double(accuracy) / 100.0)).int
@@ -409,8 +410,9 @@
                        timer.invalidate()
                        let vc = HomeStudyCompleteVC(correctNum: viewModel.correctNum, errorNum: viewModel.errorNum, totalCoin: toalIntegral, listenType: viewModel.listenType.value,totalNum:totalNum.int)
                        let vc = HomeStudyCompleteVC(totalCoin: toalIntegral,totalNum:totalNum.int,viewModel: viewModel,studyScheduleModel: studyScheduleModel!)
                        vc.title = viewModel.listenType.value.rawTitle
                        vc.viewModel = viewModel
                        push(vc: vc)
            }
@@ -420,8 +422,9 @@
                                    NotificationCenter.default.post(name: Refresh_ListenSchedule_Noti, object: nil)
                        }).disposed(by: disposeBag)
                        let vc = HomeStudyCompleteVC(correctNum: viewModel.correctNum, errorNum: viewModel.errorNum, totalCoin: integral, listenType: viewModel.listenType.value)
                        let vc = HomeStudyCompleteVC(totalCoin: integral,viewModel: viewModel,studyScheduleModel: studyScheduleModel!)
                        vc.title = viewModel.listenType.value.rawTitle
                        vc.viewModel = viewModel
                        push(vc: vc)
            }
@@ -429,12 +432,21 @@
                        timer.invalidate()
            }
            @objc func quitAction(){
            @objc func quitAction(isPop:Bool = false){
                        if btn_exit.titleLabel?.text == "完成"{
                                    if viewModel.listenType.value == .story2{
                                                if isPop{
                                                            self.navigationController?.popViewController();return
                                                }
                                                guard (pageVC.currentController as! HomeListenStory_2_VC).isPlayEnd else {
                                                            alert(msg: "请听完");return
                                                }
                                                let v = data as! Listen1Model
                                                let accuracy = 100
                                                storyComplete(storyId: v.data!.id, accuracy: accuracy, studyTime: viewModel.times, type: 1, integral: v.data!.lookIntegral)
                                                storyComplete(storyId: v.data!.id, accuracy: accuracy, studyTime: viewModel.times, type: viewModel.listenType.value == .story1 ? 1:2, integral: v.data!.integral)
                                    }
                        }else{
                                    CommonAlertView.show(content: "未完成全部答题,确认退出吗?") {[weak self] () in
@@ -455,13 +467,26 @@
                                                            case .lesson1,.lesson2,.lesson3,.lesson4,.lesson5:
                                                                        if temIds.count > 0 && topicIds.count > 0{
                                                                                    let totalNum = weakSelf.viewModel.correctNum + weakSelf.viewModel.errorNum
                                                                                    Services.exitLearning(type:weakSelf.viewModel.listenType.value.rawValue,week: weakSelf.viewModel.week.value!, day: weakSelf.viewModel.day.value!, teamIds: temIds, topicIds: topicIds,answerNumber: totalNum,correctNumber:weakSelf.viewModel.correctNum,studyTime:weakSelf.viewModel.times,schedule: schedule).subscribe(onNext: { data in
                                                                                    Services.exitLearning(type:weakSelf.viewModel.listenType.value.rawValue,quarter: weakSelf.viewModel.quarter.value!,week: weakSelf.viewModel.week.value!, day: weakSelf.viewModel.day.value!, teamIds: temIds, topicIds: topicIds,answerNumber: totalNum,correctNumber:weakSelf.viewModel.correctNum,studyTime:weakSelf.viewModel.times,schedule: schedule).subscribe(onNext: { data in
                                                                                                NotificationCenter.default.post(name: MeUserInfoUpdate_Noti, object: nil)
                                                                                    }).disposed(by: weakSelf.disposeBag)
                                                                        }
                                                            default:break
                                                            case .game1,.game2,.story1,.story2:
                                                                        Services.exitGameOrStory(studyTime: weakSelf.viewModel.times).subscribe(onNext: { _ in
                                                                        }).disposed(by: weakSelf.disposeBag)
                                                }
                                                weakSelf.navigationController?.popViewController(animated: true)
                                                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
                                                            }
                                                }
                                    }
                        }
            }
@@ -469,6 +494,11 @@
            @objc func nextAction(){
                        listenFightLine = .next
                        if viewModel.listenType.value == .story2{
                                    guard (pageVC.currentController as! HomeListenStory_2_VC).isPlayEnd else {
                                                alert(msg: "请听完");return
                                    }
                                    let v = data as! Listen1Model
                                    var dict = Dictionary<String,Any>()
                                    dict["storyId"] = v.data?.id ?? 0