无故事王国
2023-10-26 152da0e2d8cd3bd522fb04d1114f0930c33c9fdf
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
//
//  CourseInfoVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/6/21.
//
 
import UIKit
import JQTools
import SPPageMenu
import FFPage
import QMUIKit
 
let StudentRefresh_Nofi = Notification.Name.init("StudentRefresh_Nofi")
 
class CourseInfoVC: BaseVC {
 
    @IBOutlet weak var scrollView: CourseInfoScrollView!
    @IBOutlet weak var view_container: UIView!
    @IBOutlet weak var img_header: UIImageView!
    @IBOutlet weak var label_stu_name: UILabel!
    @IBOutlet weak var label_stu_hei: UILabel!
    @IBOutlet weak var label_stu_wei: UILabel!
    @IBOutlet weak var label_stu_BMI: UILabel!
    @IBOutlet weak var img_gender: UIImageView!
    @IBOutlet weak var label_age: UILabel!
    @IBOutlet weak var view_menu: UIView!
    @IBOutlet weak var cons_menuHeight: NSLayoutConstraint!
    @IBOutlet weak var btn_record: UIButton!
    @IBOutlet weak var view_schedule: UIView!
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var cons_tableHei: NSLayoutConstraint!
    @IBOutlet weak var mentalCollectionView: UICollectionView!
    @IBOutlet weak var cons_mentalViewHei: NSLayoutConstraint!
    @IBOutlet weak var exerciseCollectionView: UICollectionView!
    @IBOutlet weak var label_weeklyScope: UILabel!
    @IBOutlet weak var label_totalNums: UILabel!
    @IBOutlet weak var label_deductedNums: UILabel!
    @IBOutlet weak var label_remainingNums: UILabel!
    @IBOutlet weak var stack_courseExercise: UIStackView!
    @IBOutlet weak var view_exerciseTitle: UIView!
    @IBOutlet weak var view_footer: UIView!
 
 
    var startClouseHomeModel:StartClouseHomeModel?
    var weeklyCourseModel:WeeklyCourseModel?
    private var currentDate = Date()
    private var unDispatchNum:Int?
    private var mentals = [StudentMedalModel]()
 
    private var pageMenu:SPPageMenu = {
        let pageMenu = SPPageMenu(frame: .zero, trackerStyle: .line)
        // 追踪线
        pageMenu.trackerWidth = 56
        pageMenu.setTrackerHeight(3, cornerRadius: 1.5)
        pageMenu.tracker.backgroundColor = .clear
        pageMenu.trackerFollowingMode = .always
        pageMenu.contentInset = UIEdgeInsets(top: 0, left: 19, bottom: 0, right: 19)
 
        // 分割线
        pageMenu.dividingLine.backgroundColor = .clear
        pageMenu.dividingLineHeight = 1
 
        // item
        pageMenu.spacing = 27.0
        pageMenu.permutationWay = .scrollAdaptContent
 
        // 字体
        pageMenu.selectedItemTitleFont = UIFont.systemFont(ofSize: 18, weight: .medium)
        pageMenu.unSelectedItemTitleFont = UIFont.systemFont(ofSize: 18,weight: .medium)
        // 颜色
        pageMenu.selectedItemTitleColor = UIColor(hexStr: "#6CC366")
        pageMenu.unSelectedItemTitleColor = UIColor(hexStr: "#A4A4A4")
 
        return pageMenu
    }()
 
    lazy var pageViewController:FFPageViewController = {
        let pageVC = FFPageViewController()
        pageVC.view.backgroundColor = .clear
        pageVC.scrollview.backgroundColor = .clear
 
        pageVC.scrollview.bounces = false
        return pageVC
    }()
 
    private lazy var btn_dispatchCourse:UIButton = {
        let btn = UIButton(type: .custom)
        btn.setTitleColor(Def_ThemeColor, for: .normal)
 
        let attribute = AttributedStringbuilder.build().add(string: "未分配课时", withFont: UIFont.systemFont(ofSize: 14), withColor: Def_ThemeColor).underLine(color: Def_ThemeColor).mutableAttributedString
        btn.setAttributedTitle(attribute, for: .normal)
        btn.addTarget(self, action: #selector(dispatchCourseAction), for: .touchUpInside)
        return btn
 
    }()
 
    override func viewDidLoad() {
        super.viewDidLoad()
        updateData()
    }
 
 
    override func setUI() {
        cons_menuHeight.constant = 0
        scrollView.contentInset = UIEdgeInsets( top: 265 - JQ_NavBarHeight, left: 0, bottom: 0, right: 0)
        scrollView.delegate = self
        scrollView.bringSubviewToFront(img_header)
 
        scrollView.bounces = false
        scrollView.contentInsetAdjustmentBehavior = .never
 
        let attribute = AttributedStringbuilder()
        attribute.add(string: "上课记录", withFont: UIFont.systemFont(ofSize: 14), withColor: Def_ThemeColor)
        attribute.underLine(color: Def_ThemeColor)
        btn_record.titleLabel?.attributedText = attribute.mutableAttributedString
 
 
        view_schedule.addSubview(pageViewController.view)
        addChild(pageViewController)
        pageViewController.delegate = self
        view_schedule.insertSubview(pageViewController.view, at: 0)
        pageViewController.didMove(toParent: self)
        pageViewController.view.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 90)
 
        tableView.delegate = self
        tableView.dataSource = self
        tableView.isScrollEnabled = false
        if #available(iOS 15.0, *) {
            tableView.sectionHeaderTopPadding = 0
        } else {
 
        }
        tableView.separatorStyle = .none
        tableView.register(UINib(nibName: "CourseBookingTCell", bundle: nil), forCellReuseIdentifier: "_CourseBookingTCell")
        tableView.backgroundColor = .clear
 
        mentalCollectionView.delegate = self
        mentalCollectionView.dataSource = self
        mentalCollectionView.contentInset = UIEdgeInsets(top: 0, left: 58, bottom: 0, right: 58)
        mentalCollectionView.tag = 1000
        mentalCollectionView.isScrollEnabled = false
        mentalCollectionView.register(UINib(nibName: "StudentMedalCCell", bundle: nil), forCellWithReuseIdentifier: "_StudentMedalCCell")
 
        exerciseCollectionView.delegate = self
        exerciseCollectionView.dataSource = self
        exerciseCollectionView.tag = 1001
        exerciseCollectionView.register(UINib(nibName: "StudentVideoCCell", bundle: nil), forCellWithReuseIdentifier: "_StudentVideoCCell")
 
//        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBtn)
 
    }
 
    override func setRx() {
        NotificationCenter.default.rx.notification(StudentRefresh_Nofi).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in
            guard let weakSelf = self else { return }
            Services.startCourseHome().subscribe(onNext: {[weak self] data in
                if let model = data.data{
                    self?.startClouseHomeModel = model
                    self?.updateData()
                }
            }).disposed(by: weakSelf.disposeBag)
        }).disposed(by: disposeBag)
 
 
        NotificationCenter.default.rx.notification(StudentUpdate_Nofi).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in
            guard let weakSelf = self else { return }
            Services.startCourseHome().subscribe(onNext: {[weak self] data in
                if let model = data.data{
                    if model.isThere == 1{
                        let courseInfoVC = CourseInfoVC()
                        courseInfoVC.startClouseHomeModel = model
                        let clouseNav = BaseNav(rootViewController: courseInfoVC)
                        clouseNav.tabBarItem = UITabBarItem(title: "玩湃运动营", image: UIImage(named: "tabbar_course"), selectedImage: UIImage(named: "tabbar_course_s")!.withRenderingMode(.alwaysOriginal))
                        self?.tabBarController?.viewControllers![1] = clouseNav
                    }else {
                        if let vc = (self?.tabBarController?.viewControllers?[1] as? BaseNav)?.topViewController as? CourseVC{
                            vc.startClouseHomeModel = model
                            self?.viewDidLoad()
                        }
                    }
                }
            }).disposed(by: weakSelf.disposeBag)
        }).disposed(by: disposeBag)
 
        NotificationCenter.default.rx.notification(UpdateCurrentStore_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in
            self?.getSelectDayData()
        }) { error in
 
        }.disposed(by: disposeBag)
    }
 
    private func updateData(){
        if let m = startClouseHomeModel{
 
            img_header.sd_setImage(with: URL(string: m.stuImg))
            label_stu_name.text = m.stuName
            img_gender.image = m.stuSex == .man ? UIImage(named: "icon_man") : UIImage(named: "icon_woman")
            label_age.text = "/\(m.stuAge)岁"
 
            label_stu_hei.attributedText = setAttribute(t1: "\(m.height)", t2: "cm")
            label_stu_wei.attributedText = setAttribute(t1: "\(m.weight)", t2: "kg")
            label_stu_BMI.attributedText = setAttribute(t1: m.bmi.jq_formatFloat, t2: m.bodyStatus)
 
            if m.courseList.count > 0{
                pageMenu.frame = CGRect(origin: .zero, size: CGSize(width: JQ_ScreenW - 100, height: 25))
                pageMenu.delegate = self
                view_menu.addSubview(pageMenu)
                cons_menuHeight.constant = 25
                pageMenu.setItems(m.courseList.map({$0.courseName}), selectedItemIndex: 0)
            }
 
            view_menu.addSubview(btn_dispatchCourse)
            btn_dispatchCourse.snp.makeConstraints { make in
                make.right.equalTo(-19)
                make.centerY.equalToSuperview()
                make.height.equalTo(25)
            }
 
            exerciseCollectionView.reloadData()
            label_totalNums.text = "总课时数\( m.courseList.first?.totalNums ?? 0)"
            label_deductedNums.text = "已扣课时数\( m.courseList.first?.deductedNums ?? 0)"
            label_remainingNums.text = "剩余课时数\( m.courseList.first?.remainingNums ?? 0)"
 
            exerciseCollectionView.isHidden = m.exerciseVideoList.isEmpty
            view_exerciseTitle.isHidden = m.exerciseVideoList.isEmpty
//            view_footer.isHidden = m.exerciseVideoList.isEmpty
 
            Services.studMedalList(studentId: m.stuId).subscribe(onNext: {[weak self] data in
                guard let weakSelf = self else { return }
                if let models = data.data{
                    weakSelf.mentals = models
                    weakSelf.mentalCollectionView.reloadData()
                    let he = ceil(Double(models.count) / 3) * 91 + floor(Double(models.count) / 3) * 35
                    weakSelf.cons_mentalViewHei.constant = he
                    UIView.animate(withDuration: 0.3) {
                        weakSelf.view.layoutIfNeeded()
                    }
                }
            }).disposed(by: disposeBag)
 
            Services.weeksOfGetHours().subscribe(onNext: {[weak self] data in
                    //                self?.btn_dispatchCourse.isHidden = data.data == 0
                self?.unDispatchNum = data.data
            }) { error in
 
            }.disposed(by: disposeBag)
            getSelectDayData()
        }
    }
 
    private func setAttribute(t1:String,t2:String)->NSMutableAttributedString{
        let color:UIColor = UIColor(hexStr: "#2F5264")
        let a1 = AttributedStringbuilder()
        a1.add(string: t1, withFont: UIFont.systemFont(ofSize: 22), withColor: color)
            .add(string: t2, withFont: UIFont.systemFont(ofSize: 12), withColor: color)
        return a1.mutableAttributedString
    }
 
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 42)
    }
 
    @objc func dispatchCourseAction(){
        guard unDispatchNum != 0 else {
            alert(msg: "没有未分配的课时");return
        }
        CourseUnAssignView.show(startClouseHomeModel?.courseList ?? [], num: unDispatchNum ?? 0)
    }
 
    @IBAction func addStudentAction(_ sender: QMUIButton) {
        let vc = AddStudentVC(type: .course)
        push(vc: vc)
    }
 
    @IBAction func exchangeAction(_ sender: UIButton) {
        let vc = StudentExchangeVC()
        push(vc: vc)
    }
 
    
 
    @IBAction func reportAction(_ sender: UIButton) {
        guard startClouseHomeModel != nil else {return}
        let vc = StudentReportVC(stuId: startClouseHomeModel!.stuId)
        push(vc: vc)
    }
 
 
    @IBAction func detailAction(_ sender: UIButton) {
        guard (startClouseHomeModel?.courseList.count ?? 0) > 0 else {return}
 
        let index = pageMenu.selectedItemIndex
        let models = startClouseHomeModel!.courseList
        let studentModel = StudentSimpleProfileModel(stuId: startClouseHomeModel!.stuId, stuName: startClouseHomeModel!.stuName, stuImage: startClouseHomeModel!.stuImg)
        let vc = StudentCourseDetailVC(models: models,defaultIndex: index,studentModel: studentModel)
        push(vc: vc)
    }
 
 
    @IBAction func renewalAction(_ sender: UIButton) {
        let index = pageMenu.selectedItemIndex
        let models = startClouseHomeModel!.courseList
        guard index < models.count else {return}
        Services.queryCourseInfo(id: models[index].courseId).subscribe(onNext: {[weak self] data in
            if let m = data.data{
                let vc = CourseDetailApplyVC(detailModel: m,isExtend: true)
                self?.push(vc: vc)
            }
        }).disposed(by: disposeBag)
    }
    
    @IBAction func bookingRecordAction(_ sender: UIButton) {
        guard startClouseHomeModel != nil else {return}
        let vc = CourseBookingListVC(student: startClouseHomeModel!)
        push(vc: vc)
    }
 
 
    @IBAction func remarkAction(_ sender: UIButton) {
        guard startClouseHomeModel != nil else {return}
        let vc = StudentRemarkListVC(stuId: startClouseHomeModel!.stuId)
        push(vc: vc)
    }
 
 
    @IBAction func forwardWeekAction(_ sender: UIButton) {
        let forwardPage = pageViewController.currentPage - 1
        pageViewController.scroll(toPage: forwardPage, animation: true)
    }
 
    @IBAction func nextWeekAction(_ sender: UIButton) {
        let nextPage = pageViewController.currentPage + 1
        pageViewController.scroll(toPage: nextPage, animation: true)
    }
 
 
    @IBAction func exerciseAction(_ sender: UITapGestureRecognizer) {
        let vc = CourseExerciseSubListVC()
        push(vc: vc)
    }
    
    private func getSelectDayData(){
        if let model = startClouseHomeModel{
            if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{
                if let deserModel = HomeStoreModel.deserialize(from: storeStr){
                    Services.weeksOfCourseDetails(stuId: model.stuId, time: currentDate,storeId: deserModel.storeId).subscribe(onNext: {[weak self] data in
                        if let model = data.data{
                            self?.weeklyCourseModel = model
                            self?.cons_tableHei.constant = 58 + 72 * Double(model.data.count)
                            UIView.animate(withDuration: 0.3) {
                                self?.view.layoutIfNeeded()
                                self?.viewDidLayoutSubviews()
                            }
                            self?.tableView.reloadData()
                        }
                    }).disposed(by: disposeBag)
                }
            }
        }
    }
 
    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }
 
//    func scrollViewDidScroll(_ scrollView: UIScrollView) {
//        let offsetX = min(1,max(0,-(scrollView.contentOffset.y / 177.0)))
//        leftBtn.alpha = offsetX
//    }
 
    @objc func localDetailAction(btn:UIButton){
        let index = btn.tag - 10
        if let model = weeklyCourseModel?.data[index]{
            JQ_MapNavigationTool.startNav(CLLocationCoordinate2D(latitude: weeklyCourseModel!.lat, longitude: weeklyCourseModel!.lon), distanceName: weeklyCourseModel?.name ?? "未命名地址", scheme: "weparklife")
        }
    }
}
 
extension CourseInfoVC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//         let m = weeklyCourseModel?.data[indexPath.row]
        let vc = SignUpCourseVC()
        push(vc: vc)
    }
}
 
extension CourseInfoVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "_CourseBookingTCell") as! CourseBookingTCell
 
        cell.view_corner.jq_addShadows(shadowColor: UIColor(hexStr: "#DADADA").withAlphaComponent(0.5), corner: 16, radius: 3.5, offset: CGSize(width: 0, height: 2), opacity: 1)
 
        cell.weeklyCourseItemModel = weeklyCourseModel?.data[indexPath.row]
        cell.clickClouse = {[weak self] m in
            guard let weakSelf = self else { return }
            if let stuId = weakSelf.startClouseHomeModel?.stuId{
                //请假
                if m.type == 1 && m.isType == 0{
                    CommonAlertView.show(title: "提示", content: "确认请假?") { status in
                        if status{
                            Services.startCourceRreverse(courseId: m.id, time: weakSelf.currentDate.jq_format("yyyy-MM-dd"), stuId: stuId).subscribe(onNext: {[weak self] data in
                                alertSuccess(msg: "请假成功")
                                self?.getSelectDayData()
 
                            }).disposed(by: weakSelf.disposeBag)
                        }
                    }
                }
                //购课
                if m.type == 2{
                    let vc = ExperienceCourseVC(courseId: m.id)
                    weakSelf.push(vc: vc)
                }
 
            }
        }
 
 
        return cell
    }
 
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return weeklyCourseModel?.data.count ?? 0
}
 
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
 
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 72
    }
 
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        if let m = weeklyCourseModel{
            var headerView  = tableView.dequeueReusableHeaderFooterView(withIdentifier: "header")
            if headerView == nil{
                headerView = UITableViewHeaderFooterView(reuseIdentifier: "header")
 
                let contentView = UIView()
                contentView.borderColor = UIColor(hexStr: "#E7E3E3")
                contentView.borderWidth = 1
                contentView.cornerRadius = 11
                headerView?.contentView.addSubview(contentView)
                contentView.snp.makeConstraints { make in
                    make.center.equalToSuperview()
                    make.left.right.equalToSuperview()
                    make.height.equalTo(22)
                }
 
                let label_address = UILabel()
                label_address.tag = 1000
                label_address.text = "成都非遗玩湃全科体育公园   0.0km"
                label_address.font = UIFont.systemFont(ofSize: 10, weight: .medium)
                label_address.textColor = UIColor(hexStr: "#AFB4BC")
                contentView.addSubview(label_address)
                label_address.snp.makeConstraints { make in
                    make.left.equalToSuperview().offset(12)
                    make.centerY.equalToSuperview()
                    make.right.equalTo(-50)
                }
 
                let btn_detial = QMUIButton(type: .custom)
                btn_detial.setTitle("位置详情", for: .normal)
                btn_detial.tag = 10 + section
                btn_detial.addTarget(self, action: #selector(localDetailAction(btn:)), for: .touchUpInside)
                btn_detial.titleLabel?.font = UIFont.systemFont(ofSize: 10)
                btn_detial.setTitleColor(UIColor(hexStr: "#AFB4BC"), for: .normal)
                btn_detial.setImage(UIImage(named: "icon_pop"), for: .normal)
                btn_detial.imagePosition = .left
                btn_detial.spacingBetweenImageAndTitle = 3
                contentView.addSubview(btn_detial)
                btn_detial.snp.makeConstraints { make in
                    make.right.equalTo(-10)
                    make.centerY.equalToSuperview()
                }
            }
 
            if let label = headerView?.contentView.viewWithTag(1000) as? UILabel{
                label.text = String(format: "%@ %.1lfkm", m.name,m.distance)
            }
 
            headerView?.contentView.backgroundColor = .white
            return headerView
        }
        return nil
    }
 
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 58
    }
}
 
 
extension CourseInfoVC:UICollectionViewDelegate{
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
 
        if collectionView.tag == 1000{
            guard let stuId = startClouseHomeModel?.stuId else { return }
            let vc = StudentMentalListVC(stuId: stuId)
            push(vc: vc)
        }else{
            let vc = CourseVideoDetailVC(id: 0)
            vc.title = "课后练习"
            push(vc: vc)
        }
    }
}
 
extension CourseInfoVC:UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
 
        if collectionView.tag == 1000{
            return mentals.count
        }else{
            return startClouseHomeModel?.exerciseVideoList.count ?? 0
        }
    }
 
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        if collectionView.tag == 1000{
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_StudentMedalCCell", for: indexPath) as! StudentMedalCCell
            cell.img.image = mentals[indexPath.row].medalType.image
            cell.t1.text = mentals[indexPath.row].medalType.title_en
            cell.t2.text = mentals[indexPath.row].medalType.title
            return cell
        } else{
            let model = startClouseHomeModel!.exerciseVideoList[indexPath.row]
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_StudentVideoCCell", for: indexPath) as! StudentVideoCCell
            cell.videoListModel = model
            return cell
        }
    }
}
 
extension CourseInfoVC:UICollectionViewDelegateFlowLayout{
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        if collectionView.tag == 1000{
            return 30
        }else {
            return 12
        }
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        if collectionView.tag == 1000{
            return 30
        }else {
            return 0
        }
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        if collectionView.tag == 1000{
            let CellW = (JQ_ScreenW - 116 - 62 * 2) / 3
            return CGSize(width: CellW, height: 91)
        }else {
            let CellW = (JQ_ScreenW - 44 - 13) / 2
            return CGSize(width: CellW, height: 166)
        }
    }
}
 
extension CourseInfoVC:SPPageMenuDelegate{
    func pageMenu(_ pageMenu: SPPageMenu, itemSelectedAt index: Int) {
        guard startClouseHomeModel != nil else {return}
        if let m = startClouseHomeModel?.courseList[index]{
            label_totalNums.text = "总课时数\( m.totalNums)"
            label_deductedNums.text = "已扣学时数\( m.deductedNums)"
            label_remainingNums.text = "剩余学时数\( m.remainingNums)"
        }
    }
}
 
 
extension CourseInfoVC:FFPageViewControllerDelegate{
 
    func pageViewController(_ pageViewController: FFPageViewController, currentPageChanged currentPage: Int) {
        let vc = pageViewController.currentController as! CourseInfoScheduleVC
        vc.currentSelectDate = currentDate
        let first = vc.dates.first?.jq_format("yyyy.MM.dd")
        let last = vc.dates.last?.jq_format("yyyy.MM.dd")
        label_weeklyScope.text = "\(first ?? "")-\(last ?? "")"
    }
 
    func totalPagesOfpageViewController(_ pageViewConteoller: FFPageViewController) -> UInt {
        return 11
    }
 
    func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController {
        let vc = CourseInfoScheduleVC(index: page) {[weak self] date in
            self?.currentDate = date
            self?.getSelectDayData()
        }
        return vc
    }
}
 
public class CourseInfoScrollView:UIScrollView{
    public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        for subView in subviews{
            let p = subView.convert(point, to: self)
            let hitTestView = subView.hitTest(p, with: event)
            return hitTestView
        }
        return nil
    }
}