| | |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | 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() |
| | | } |
| | | updateData() |
| | | } |
| | | |
| | | |
| | |
| | | Services.startCourseHome().subscribe(onNext: {[weak self] data in |
| | | if let model = data.data{ |
| | | self?.startClouseHomeModel = model |
| | | if model.courseList.count > 0{ |
| | | self?.pageMenu.setItems(model.courseList.map({$0.courseName}), selectedItemIndex: 0) |
| | | } |
| | | self?.updateData() |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | }).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{ |
| | |
| | | push(vc: vc) |
| | | } |
| | | |
| | | |
| | | |
| | | @IBAction func reportAction(_ sender: UIButton) { |
| | | guard startClouseHomeModel != nil else {return} |
| | | let vc = StudentReportVC(stuId: startClouseHomeModel!.stuId) |
| | |
| | | @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) |
| | |
| | | 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 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() |
| | | } |
| | | weakSelf.tableView.reloadData() |
| | | // 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) |
| | | } |
| | | } |