无故事王国
5 天以前 510991a68acc59e22602d95582e3b1cabdd093c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
//
//  HomeListenSubV2VC.swift
//  DolphinEnglishLearnStudent
//
//  Created by 无故事王国 on 2025/7/27.
//
 
import UIKit
 
class HomeListenSubV2VC: BaseVC {
 
    private var quarter:Int!
    private var week:Int!
    private(set) var tableView:UITableView!
    var studyScheduleModel:StudyScheduleModel?
 
    required init(quarter:Int,week:Int,studyScheduleModel:StudyScheduleModel) {
        super.init(nibName: nil, bundle: nil)
        self.quarter = quarter
        self.week = week
        self.studyScheduleModel = studyScheduleModel
    }
 
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
 
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationItem.titleView = UIView()
    }
 
    override func setUI() {
        super.setUI()
        tableView = UITableView(frame: .zero, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.separatorStyle = .none
        tableView.showsVerticalScrollIndicator = false
        tableView.showsHorizontalScrollIndicator = false
        tableView.backgroundColor = Config.ThemeBGColor
        tableView.register(UINib(nibName: "HomeListen_process_TCell", bundle: nil), forCellReuseIdentifier: "_HomeListen_process_TCell")
        tableView.register(UINib(nibName: "HomeListen_item_TV2Cell", bundle: nil), forCellReuseIdentifier: "_HomeListen_item_TV2Cell")
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
 
        let uIImageView = UIImageView(image: UIImage(named: "erji"))
        view.addSubview(uIImageView)
        uIImageView.snp.makeConstraints { make in
            make.trailing.equalTo(-28)
            make.width.equalTo(272)
            make.height.equalTo(174)
            make.centerY.equalToSuperview()
        }
 
        let uiLabel = UILabel()
        uiLabel.text = "听懂英语的声音世界"
        uiLabel.font = UIFont.systemFont(ofSize: 26, weight: .medium)
        uiLabel.textColor = UIColor(hexString: "#2B3648")
        view.addSubview(uiLabel)
        uiLabel.snp.makeConstraints { make in
            make.top.equalTo(uIImageView.snp.bottom).offset(33)
            make.centerX.equalTo(uIImageView)
            make.height.equalTo(37)
        }
 
        let ui1Label = UILabel()
        ui1Label.text = "万物有声"
        ui1Label.numberOfLines = 0
        ui1Label.font = UIFont.systemFont(ofSize: 25, weight: .semibold)
        ui1Label.textColor = UIColor.black
        view.addSubview(ui1Label)
        ui1Label.snp.makeConstraints { make in
            make.top.equalTo(uIImageView.snp.top).offset(39)
            make.centerX.equalTo(uIImageView)
            make.width.equalTo(26)
        }
    }
 
    func jumpAt(listenType:ListenType){
        let row = listenType.rawValue - 1
        let jumpIndex:IndexPath = IndexPath(row: row, section: 1)
        tableView(self.tableView, didSelectRowAt: jumpIndex)
    }
}
 
extension HomeListenSubV2VC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
 
        sceneDelegate?.startTimer()
 
        let day = indexPath.row + 1
        if indexPath.row == 0{
            Services.teamSchedule(type: .lesson1, week: week, day: day).subscribe(onNext: {[weak self] teamSchedule in
                guard let weakSelf = self else { return }
                //听音选图
                Services.listenSelectPicture(day:day, quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self] result in
                    guard let weakSelf = self else { return }
                    if let data = result.data{
                        let fightVC = HomeListenFightVC(listenType: .lesson1,quarter:weakSelf.quarter,week: weakSelf.week,day:day)
                        fightVC.title = ListenType.lesson1.rawTitle
                        fightVC.teamScheduleModel = teamSchedule.data
                        fightVC.data = data
                        fightVC.studyScheduleModel = self?.studyScheduleModel
                        JQ_currentViewController().jq_push(vc:fightVC)
                    }
                }).disposed(by: weakSelf.disposeBag)
            }).disposed(by: disposeBag)
        }
 
        if indexPath.row == 1{
            //看图选音
            Services.teamSchedule(type: .lesson2, week: week, day: day).subscribe(onNext: {[weak self] teamSchedule in
                guard let weakSelf = self else { return }
                Services.pictureSelectVoice(day: day, quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self] result in
                    guard let weakSelf = self else { return }
                    if let data = result.data{
                        let fightVC = HomeListenFightVC(listenType: .lesson2,quarter:weakSelf.quarter,week: weakSelf.week,day:day)
                        fightVC.title = ListenType.lesson2.rawTitle
                        fightVC.teamScheduleModel = teamSchedule.data
                        fightVC.data = data
                        fightVC.studyScheduleModel = self?.studyScheduleModel
                        JQ_currentViewController().jq_push(vc:fightVC)
                    }
                }).disposed(by: weakSelf.disposeBag)
            }).disposed(by: disposeBag)
 
        }
 
        if indexPath.row == 2{
            //归纳排除
            Services.teamSchedule(type: .lesson3, week: week, day: day).subscribe(onNext: {[weak self] teamSchedule in
                guard let weakSelf = self else { return }
                Services.induceExclude(day: day, quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self] result in
                    guard let weakSelf = self else { return }
                    if let data = result.data{
                        let fightVC = HomeListenFightVC(listenType: .lesson3,quarter:weakSelf.quarter,week: weakSelf.week,day:day)
                        fightVC.title = ListenType.lesson3.rawTitle
                        fightVC.teamScheduleModel = teamSchedule.data
                        fightVC.data = data
                        fightVC.studyScheduleModel = self?.studyScheduleModel
                        JQ_currentViewController().jq_push(vc: fightVC)
                    }
                }).disposed(by: weakSelf.disposeBag)
            }).disposed(by: disposeBag)
        }
 
        if indexPath.row == 3{
            //有问有答
            Services.teamSchedule(type: .lesson4, week: week, day: day).subscribe(onNext: {[weak self] teamSchedule in
                guard let weakSelf = self else { return }
                Services.questionsAndAnswers(day: day, quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self] result in
                    guard let weakSelf = self else { return }
                    if let data = result.data{
                        let fightVC = HomeListenFightVC(listenType: .lesson4,quarter:weakSelf.quarter,week: weakSelf.week,day:day)
                        fightVC.title = ListenType.lesson4.rawTitle
                        fightVC.teamScheduleModel = teamSchedule.data
                        fightVC.data = data
                        fightVC.studyScheduleModel = self?.studyScheduleModel
                        JQ_currentViewController().jq_push(vc: fightVC)
                    }
                }).disposed(by: weakSelf.disposeBag)
            }).disposed(by: disposeBag)
        }
 
        if indexPath.row == 4{
            //音图相配
            Services.teamSchedule(type: .lesson5, week: week, day: day).subscribe(onNext: {[weak self] teamSchedule in
                guard let weakSelf = self else { return }
                Services.pictureMateVoice(day: day, quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self] result in
                    guard let weakSelf = self else { return }
                    if let data = result.data{
                        let fightVC = HomeListenFightVC(listenType: .lesson5,quarter:weakSelf.quarter,week: weakSelf.week,day:day)
                        fightVC.title = ListenType.lesson5.rawTitle
                        fightVC.teamScheduleModel = teamSchedule.data
                        fightVC.data = data
                        fightVC.studyScheduleModel = self?.studyScheduleModel
                        JQ_currentViewController().jq_push(vc: fightVC)
                    }
                }).disposed(by: weakSelf.disposeBag)
            }).disposed(by: disposeBag)
        }
 
        guard (studyScheduleModel?.day ?? 0) >= 6 else {return}
 
        //自主游戏
        if indexPath.row == 5{
            CommonAlertSheetView.show(type: .single, titles: ["自主游戏1","自主游戏2"]) {[weak self] index, str in
                guard let weakSelf = self else { return }
                switch index{
                case 0:
                    let fightVC = HomeListenFightVC(listenType: .game1,quarter: weakSelf.quarter,week: weakSelf.week,day: day)
                    fightVC.title = ListenType.game1.rawTitle
                    fightVC.studyScheduleModel = weakSelf.studyScheduleModel
                    JQ_currentViewController().jq_push(vc:fightVC)
                case 1:
                    Services.gameMemory(quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self]result in
                        guard let weakSelf = self else { return }
                        if let data = result.data{
                            let fightVC = HomeListenFightVC(listenType: .game2,quarter: weakSelf.quarter,week: weakSelf.week,day: day)
                            fightVC.title = ListenType.game2.rawTitle
                            fightVC.data = data
                            fightVC.studyScheduleModel = self?.studyScheduleModel
                            JQ_currentViewController().jq_push(vc: fightVC)
                        }
                    }).disposed(by: weakSelf.disposeBag)
                default:break
                }
            }
        }
 
        //听故事
        if indexPath.row == 6{
            CommonAlertSheetView.show(type: .single, titles: ["看图配音","框架记忆"]) {[weak self] index, str in
                guard let weakSelf = self else { return }
                switch index {
                case 0:
                    Services.lookpictureDbu(quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self]result in
                        guard let weakSelf = self else { return }
                        if let data = result.data{
                            let fightVC = HomeListenFightVC(listenType: .story1,quarter: weakSelf.quarter,week: weakSelf.week,day: day)
                            fightVC.title = ListenType.story1.rawTitle
                            fightVC.data = data
                            fightVC.studyScheduleModel = self?.studyScheduleModel
                            JQ_currentViewController().jq_push(vc: fightVC)
                        }
                    }).disposed(by: weakSelf.disposeBag)
 
                case 1:
                    Services.frameworkMemory(quarter: weakSelf.quarter, week: weakSelf.week).subscribe(onNext: {[weak self]result in
                        guard let weakSelf = self else { return }
                        if let data = result.data{
                            let fightVC = HomeListenFightVC(listenType: .story2,quarter: weakSelf.quarter,week: weakSelf.week,day: day)
                            fightVC.title = ListenType.story2.rawTitle
                            fightVC.data = data
                            fightVC.studyScheduleModel = self?.studyScheduleModel
                            JQ_currentViewController().jq_push(vc: fightVC)
                        }
                    }).disposed(by: weakSelf.disposeBag)
                default:break
                }
            }
        }
 
    }
}
 
extension HomeListenSubV2VC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 0{return 1}
        return 7
    }
 
    func numberOfSections(in tableView: UITableView) -> Int {
        return 2
    }
 
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if indexPath.section == 0{
            let cell = tableView.dequeueReusableCell(withIdentifier: "_HomeListen_process_TCell", for: indexPath) as! HomeListen_process_TCell
            cell.studyScheduleModel = studyScheduleModel
            cell.label_currentWeek.text = "当前周目:\(week.jq_cn)周目"
            return cell
        }else{
            let cell = tableView.dequeueReusableCell(withIdentifier: "_HomeListen_item_TV2Cell", for: indexPath) as! HomeListen_item_TV2Cell
            cell.label_title.text = "\(indexPath.row + 1)"
            cell.label_title.text = "第\(indexPath.row + 1)天"
            cell.view_state.isHidden = false
 
            switch indexPath.row {
            case 0:
                cell.label_subTitle.text = "自主学习1-听音选图"
                cell.setProgress(progress: studyScheduleModel?.listen ?? 0)
                cell.view_center.backgroundColor = UIColor.white
            case 1:
                cell.label_subTitle.text = "自主学习2-看图选音"
                cell.setProgress(progress: studyScheduleModel?.look ?? 0)
                if (studyScheduleModel?.listen ?? 0) >= 90{
                    cell.view_center.backgroundColor = UIColor.white
                }
 
            case 2:
                cell.label_subTitle.text = "自主学习3-归纳排除"
                cell.setProgress(progress: studyScheduleModel?.computeSchedule ?? 0)
                if (studyScheduleModel?.look ?? 0) >= 90{
                    cell.view_center.backgroundColor = UIColor.white
                }
            case 3:
                cell.label_subTitle.text = "自主学习4-有问有答"
                cell.setProgress(progress: studyScheduleModel?.answer ?? 0)
                if (studyScheduleModel?.computeSchedule ?? 0) >= 90{
                    cell.view_center.backgroundColor = UIColor.white
                }
            case 4:
                cell.label_subTitle.text = "自主学习5-音图相配"
                cell.setProgress(progress: studyScheduleModel?.pair ?? 0)
                if (studyScheduleModel?.answer ?? 0) >= 90{
                    cell.view_center.backgroundColor = UIColor.white
                }
            case 5:
                cell.label_subTitle.text = "自主游戏"
                cell.view_state.isHidden = true
                if (studyScheduleModel?.day ?? 0) >= 6{
                    cell.setProgress(progress: 100)
                }else{
                    cell.setProgress(progress: 0)
                }
            case 6:
                cell.label_subTitle.text = "听故事"
                cell.view_state.isHidden = true
                if (studyScheduleModel?.day ?? 0) >= 6{
                    cell.setProgress(progress: 100)
                }else{
                    cell.setProgress(progress: 0)
                }
            default:break
            }
 
            return cell
        }
    }
 
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.section == 0{return 145.5}
        return 90
    }
}