EstuLogPhotoListViewController.swift 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // EstuLogPhotoListViewController.swift
  3. // JiaPeiManage
  4. //
  5. // Created by Ning.ge on 2023/8/30.
  6. //
  7. import UIKit
  8. import RxSwift
  9. import RxCocoa
  10. import ReusableKit
  11. import Dollar
  12. final class EstuLogPhotoListViewController: BaseCollectionViewController {
  13. let cellIdentifier:String = "_EstuLogListCell"
  14. // MARK: 服务属性
  15. private let elogCoachService: ElogCoachServiceType = ElogCoachService(networking: ElogCoachNetworking())
  16. private struct Reusable {
  17. static let ephotoCell = ReusableCell<EstuLogPhotoCell>()
  18. static let headerView = ReusableView<EstuLogPhotoHeaderView>()
  19. }
  20. // MARK: UI let
  21. let statusBar = UIView().then {
  22. $0.backgroundColor = UIColor.db_theme
  23. }
  24. let navBar = MeTraineeNavBar.loadFromNib().then {
  25. $0.search_button.isHidden = true
  26. }
  27. let estuLogHeaderView = EstuLogHeaderView.loadFromNib()
  28. //学员ID
  29. var stuId:Int = 0
  30. var classId:String = ""
  31. var eteachLogPhotoDataModel:ETeachLogPhotoDataModel?
  32. var rows : [ETeachLogPhotoInfo] = []
  33. var page:Int = 1
  34. var pageSize:Int = 10
  35. override func setupConstraints() {
  36. statusBar.snp.makeConstraints { (make) in
  37. make.left.right.top.equalToSuperview()
  38. make.height.equalTo(Metric.statusBarHeight)
  39. }
  40. navBar.snp.remakeConstraints { (make) in
  41. make.left.right.equalToSuperview()
  42. make.height.equalTo(Metric.navBarHeight)
  43. make.top.equalTo(statusBar.snp.bottom)
  44. }
  45. collectionView.snp.remakeConstraints { make in
  46. make.top.equalTo(self.navBar.snp.bottom)
  47. make.left.right.bottom.equalTo(self.view)
  48. }
  49. self.loadViewIfNeeded()
  50. }
  51. // MARK: StatusBar
  52. override func viewWillAppear(_ animated: Bool) {
  53. super.viewWillAppear(animated)
  54. self.navigationController?.setNavigationBarHidden(true, animated: true)
  55. }
  56. required convenience init?(coder aDecoder: NSCoder) {
  57. fatalError("init(coder:) has not been implemented")
  58. }
  59. override func viewDidLoad() {
  60. super.viewDidLoad()
  61. configureMagicController()
  62. setupUI()
  63. biandView()
  64. }
  65. // MARK: 私有方法
  66. func setupUI(){
  67. self.navBar.title_label.text = "电子教学日志"
  68. self.navBar.back_button.addTarget(self, action: #selector(actionBackdo), for: .touchUpInside)
  69. }
  70. func configureMagicController(){
  71. self.view.addSubview(navBar)
  72. self.view.addSubview(statusBar)
  73. }
  74. func biandView(){
  75. collectionView.backgroundColor = UIColor.db_theme
  76. // collectionView.frame = self.view.bounds
  77. collectionView.register(Reusable.ephotoCell)
  78. collectionView.register(Reusable.headerView, kind: UICollectionView.elementKindSectionHeader)
  79. collectionView.delegate = self
  80. collectionView.dataSource = self
  81. self.isEmptyDisplay = false
  82. self.hideLoadAnimation()
  83. // if !isRcmd {
  84. //
  85. // setupRefreshHeader(collectionView,.rabbit) {[unowned self] in
  86. // self.netRequest()
  87. // }
  88. //
  89. // self.autoSetRefreshStatus(header: collectionView.header).disposed(by: disposeBag)
  90. // }
  91. //
  92. // netRequest()
  93. getStudentTeachLogPhotoList()
  94. }
  95. func getStudentTeachLogPhotoList (){
  96. self.elogCoachService.elogTmsStudentPhotoByIdRequest(city: LocalManager.userInfo.city!, classId: classId, id: stuId, pageNum: page, pageSize: pageSize).subscribe(onSuccess: {[unowned self] eteachLogPhotoDataModel in
  97. self.rows.removeAll()
  98. self.eteachLogPhotoDataModel = eteachLogPhotoDataModel
  99. self.rows += eteachLogPhotoDataModel.rows!
  100. print("elogTmsStudentPhotoByIdRequest成功")
  101. self.isEmptyDisplay = true
  102. self.hideLoadAnimation()
  103. self.stopRefresh()
  104. self.collectionView.reloadData()
  105. }, onError: { error in
  106. self.stopRefresh()
  107. NYTips.hide()
  108. })
  109. .disposed(by: disposeBag)
  110. }
  111. }
  112. extension EstuLogPhotoListViewController: UICollectionViewDataSource {
  113. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  114. return self.rows.count
  115. }
  116. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  117. let cell = collectionView.dequeue(Reusable.ephotoCell, for: indexPath)
  118. cell.setRowInfo(rowInfo: self.rows[indexPath.row])
  119. // cell.reactor = datasources[indexPath.item]
  120. return cell
  121. }
  122. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  123. collectionView.deselectItem(at: indexPath, animated: true)
  124. }
  125. // Provide header view for each section
  126. func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
  127. let headerView = collectionView.dequeue(Reusable.headerView, kind: kind, for: indexPath)
  128. // (ofKind: kind, withReuseIdentifier: Reusable.headerView, for: indexPath)
  129. return headerView
  130. }
  131. }
  132. extension EstuLogPhotoListViewController: UICollectionViewDelegateFlowLayout {
  133. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  134. // let cellReactor = datasources[indexPath.item]
  135. return CGSize(width: NYFitReal.screenWidth*0.5, height: 172) //Reusable.rcmdCell.class.cellSize(reactor: cellReactor)
  136. }
  137. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
  138. return UIEdgeInsets.zero
  139. }
  140. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
  141. return 0.f
  142. }
  143. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
  144. return 0.f
  145. }
  146. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
  147. return CGSize(width: NYFitReal.screenWidth, height: 99.f) //branchSectionDelegate.headerSize(collectionView: collectionView,section: dataSource[section])
  148. }
  149. }