无故事王国
2023-10-23 29ca792f9cd6216f5618cf8706d35a51b57b1376
WanPai/Root/Course/VC/CourseInfoVC.swift
@@ -73,19 +73,6 @@
        return pageMenu
    }()
//    private lazy var leftBtn:QMUIButton = {
//        let btn = QMUIButton(type: .custom)
//        btn.setTitle("添加学员", for: .normal)
//        btn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
//        btn.setTitleColor(.white, for: .normal)
//        btn.setImage(UIImage(named: "btn_add_shadow"), for: .normal)
//        btn.imagePosition = .left
//        btn.spacingBetweenImageAndTitle = 0
//        btn.imageEdgeInsets = UIEdgeInsets(top: 2, left: 0, bottom: 0, right: 0)
//        btn.addTarget(self, action: #selector(addStudentAction), for: .touchUpInside)
//        return btn
//    }()
    lazy var pageViewController:FFPageViewController = {
        let pageVC = FFPageViewController()
        pageVC.view.backgroundColor = .clear
@@ -158,7 +145,7 @@
            }).disposed(by: disposeBag)
         Services.weeksOfGetHours().subscribe(onNext: {[weak self] data in
            self?.btn_dispatchCourse.isHidden = data.data == 0
//            self?.btn_dispatchCourse.isHidden = data.data == 0
            self?.unDispatchNum = data.data
         }) { error in
@@ -200,6 +187,7 @@
        }
        tableView.separatorStyle = .none
        tableView.register(UINib(nibName: "CourseBookingTCell", bundle: nil), forCellReuseIdentifier: "_CourseBookingTCell")
      tableView.backgroundColor = .clear
        mentalCollectionView.delegate = self
        mentalCollectionView.dataSource = self
@@ -237,13 +225,19 @@
            }
         }).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 setAttribute(t1:String,t2:String)->NSMutableAttributedString{
        let color:UIColor = UIColor(hexStr: "#2F5264")
        let a1 = AttributedStringbuilder()
        a1.add(string: t1, withFont: UIFont.systemFont(ofSize: 26), withColor: color)
            .add(string: t2, withFont: UIFont.systemFont(ofSize: 16), withColor: color)
        a1.add(string: t1, withFont: UIFont.systemFont(ofSize: 22), withColor: color)
            .add(string: t2, withFont: UIFont.systemFont(ofSize: 12), withColor: color)
        return a1.mutableAttributedString
    }
@@ -253,6 +247,9 @@
    }
   @objc func dispatchCourseAction(){
      guard unDispatchNum != 0 else {
         alert(msg: "没有未分配的课时");return
      }
      CourseUnAssignView.show(startClouseHomeModel?.courseList ?? [], num: unDispatchNum ?? 0)
   }
@@ -296,6 +293,18 @@
        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)
   }
    private func getSelectDayData(){
        if let model = startClouseHomeModel{
         if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{
@@ -303,7 +312,7 @@
               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 + 70 * Double(model.data.count)
                     self?.cons_tableHei.constant = 58 + 72 * Double(model.data.count)
                     UIView.animate(withDuration: 0.3) {
                        self?.view.layoutIfNeeded()
                        self?.viewDidLayoutSubviews()
@@ -317,7 +326,7 @@
    }
    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .darkContent
      return .lightContent
    }
//    func scrollViewDidScroll(_ scrollView: UIScrollView) {
@@ -335,7 +344,7 @@
extension CourseInfoVC:UITableViewDelegate{
   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
       let m = weeklyCourseModel?.data[indexPath.row]
//       let m = weeklyCourseModel?.data[indexPath.row]
      let vc = SignUpCourseVC()
      push(vc: vc)
   }
@@ -344,39 +353,32 @@
extension CourseInfoVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "_CourseBookingTCell") as! CourseBookingTCell
        cell.contentView.backgroundColor = UIColor(hexStr: "#F2F6F9")
      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)
        if indexPath.row == 0 && weeklyCourseModel?.data.count == 1{
            cell.contentView.jq_addCorners(corner: [.allCorners], radius: 16,width: JQ_ScreenW - 48,height: 70)
        }else if indexPath.row == 0 && weeklyCourseModel?.data.count != 1{
            cell.contentView.jq_addCorners(corner: [.topLeft,.topRight], radius: 16,width: JQ_ScreenW - 48,height: 70)
      }else if indexPath.row == (weeklyCourseModel?.data.count ?? 0) - 1{
            cell.contentView.jq_addCorners(corner: [.bottomLeft,.bottomRight], radius: 16,width: JQ_ScreenW - 48,height: 70)
        }else{
            cell.contentView.jq_addCorners(corner: [.allCorners], radius: 0,width: JQ_ScreenW - 48,height: 70)
        }
      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{
               Services.startCourceRreverse(courseId: m.id, time: weakSelf.currentDate.jq_format("yyyy-MM-dd"), stuId: stuId).subscribe(onNext: { data in
                  alertSuccess(msg: "请假成功")
                  tableView.beginUpdates()
                  weakSelf.weeklyCourseModel?.data.remove(at: indexPath.row)
                  tableView.deleteRows(at: [indexPath], with: .automatic)
                  tableView.endUpdates()
                  weakSelf.cons_tableHei.constant = 58 + 70 * Double(weakSelf.weeklyCourseModel?.data.count ?? 0)
                  UIView.animate(withDuration: 0.3) {
                     weakSelf.view.layoutIfNeeded()
                     weakSelf.viewDidLayoutSubviews()
            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: { data in
                        alertSuccess(msg: "请假成功")
                        tableView.beginUpdates()
                        weakSelf.weeklyCourseModel?.data.remove(at: indexPath.row)
                        tableView.deleteRows(at: [indexPath], with: .automatic)
                        tableView.endUpdates()
                        weakSelf.cons_tableHei.constant = 58 + 70 * Double(weakSelf.weeklyCourseModel?.data.count ?? 0)
                        UIView.animate(withDuration: 0.3) {
                           weakSelf.view.layoutIfNeeded()
                           weakSelf.viewDidLayoutSubviews()
                        }
                     }).disposed(by: weakSelf.disposeBag)
                  }
               }).disposed(by: weakSelf.disposeBag)
               }
            }
            //购课
            if m.type == 2{
               let vc = ExperienceCourseVC(courseId: m.id)
@@ -385,6 +387,8 @@
         }
        }
        return cell
    }
@@ -397,7 +401,7 @@
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 70
        return 72
    }
   func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {