123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // CommunityReportViewController.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/8/31.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class CommunityReportViewController: BaseViewController {
- var reportCategorys : [ReportCategory]?
- var postId : Int?
- var uId : Int?
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
- setupData()
- }
-
- override func setupViews() {
- navigationBar.title = "举报"
- view.addSubview(tableView)
- }
-
- override func setupLayouts() {
- tableView.snp.makeConstraints { (make) in
- make.top.equalTo(kNavBarTotalHeight)
- make.left.right.bottom.equalToSuperview()
- }
- }
-
- override func setupData() {
- reportCategorys = ConfigModel.shared.object()?.reportCategory
- if reportCategorys?.isEmpty ?? true {
- DIYEmptyView.emptyNoDataTableView(tableView: tableView,imageStr:.one,detailStr:.one)
- }
- tableView.tableHeaderView = communityReportHeaderView
- tableView.reloadData()
- }
-
- private lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
- tableView.separatorStyle = .none
- tableView.backgroundColor = kf7f8faColor
- tableView.rowHeight = 48
- tableView.dataSource = self
- tableView.delegate = self
- return tableView
- }()
-
- private lazy var communityReportHeaderView: CommunityReportHeaderView = {
- let communityReportHeaderView = CommunityReportHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 44))
- return communityReportHeaderView
- }()
-
- func userMemberReportApi(reportCategoryId:Int?) {
- SwiftMoyaNetWorkServiceUser.shared().userMemberReportApi(reportType: 1, postId: postId ?? 0, reportCategory: reportCategoryId ?? 0) {[weak self](data) -> (Void) in
- self?.navigationController?.popViewController(animated: true)
- }
- }
-
- func userMemberReportUserApi(reportCategoryId:Int?) {
- SwiftMoyaNetWorkServiceUser.shared().userMemberReportApi(reportType: 0, objectUid: uId ?? 0, reportCategory: reportCategoryId ?? 0) {[weak self](data) -> (Void) in
- self?.navigationController?.popViewController(animated: true)
- }
- }
- }
- extension CommunityReportViewController : UITableViewDelegate,UITableViewDataSource {
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return reportCategorys?.count ?? 0
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = CommunityReportTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
- cell.reportCategory = reportCategorys?[indexPath.row]
- return cell
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- let reportCategory = reportCategorys?[indexPath.row]
- if uId != nil && uId != 0 {
- userMemberReportUserApi(reportCategoryId: reportCategory?.id)
- }else {
- userMemberReportApi(reportCategoryId: reportCategory?.id)
- }
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 0.000001
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 0.000001
- }
-
- func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
- return nil
- }
-
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- return nil
- }
-
- }
|