无故事王国
2024-07-02 655a0215e597e3c46834d9d8a609bab729a1816f
DolphinEnglishLearnStudent/Moudle/Home/VC/HomeStudyCompleteVC.swift
@@ -8,6 +8,7 @@
import UIKit
let StudyCompleteNextLession_Noti = Notification.Name.init("StudyCompleteNextLession_Noti")
let StudyCompleteCoinUpdate_Noti = Notification.Name.init("StudyCompleteCoinUpdate_Noti")
class HomeStudyCompleteVC: BaseVC {
            @IBOutlet weak var label_coin: UILabel!
@@ -51,7 +52,12 @@
                        label_correctNum.text = "\(viewModel.correctNum)次"
                        label_errorNum.text = "\(viewModel.errorNum)次"
                        label_totalNum.text = "\(viewModel.correctNum + viewModel.errorNum)次"
                        label_ratioNum.text = String(format: "正确率:%.0lf%%", Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100)
                        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)
                        }
                        if totalNum != nil && viewModel.listenType.value == .game2{
                                    label_title_totalNum.text = "总题目:"
@@ -64,9 +70,10 @@
                                    label_errorNum.text = "\(viewModel.errorNum)"
                        }
                        btn_next.isHidden = viewModel.listenType.value == .lesson5
                        switch viewModel.listenType.value{
                                    case .lesson5,.game1,.game2,.story1,.story2:btn_next.isHidden = true
                                    default:btn_next.isHidden = false
                        }
                        stackView.isHidden = viewModel.listenType.value == .story2
                        label_ratioNum.isHidden = viewModel.listenType.value == .story2
@@ -78,6 +85,19 @@
                        super.setUI()
            }
            override func setRx() {
                        NotificationCenter.default.rx.notification(StudyCompleteCoinUpdate_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] data in
                                    guard let weakSelf = self else { return }
                                    if let coin = data.object as? Int{
                                                switch weakSelf.viewModel.listenType.value {
                                                            case .game2:weakSelf.label_coin.text = "恭喜您,已完成游戏!获得\(coin)积分!"
                                                            default:weakSelf.label_coin.text = "恭喜您,已完成全部答题!获得\(coin)积分!"
                                                }
                                    }
                        }).disposed(by: disposeBag)
            }
            @IBAction func backHomeAction(_ sender: UIButton) {
                        backAction()
            }