HelpListViewController.swift 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // HelpListViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/4/16.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class HelpListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate {
  10. @IBOutlet weak var viewMenu: UIView!
  11. @IBOutlet weak var tableView: UITableView!
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14. initNavLeftBackButton()
  15. self.title = "帮助中心"
  16. tableView.register(UINib(nibName: "HelpListTableViewCell", bundle: nil), forCellReuseIdentifier: "HelpListTableViewCell")
  17. tableView.delegate = self
  18. tableView.dataSource = self
  19. tableView.separatorStyle = .none
  20. tableView.showsVerticalScrollIndicator = false
  21. tableView.estimatedRowHeight = 100
  22. tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
  23. self!.currentPage = 1
  24. self!.loadData()
  25. })
  26. tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
  27. // tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
  28. // self!.currentPage += 1
  29. // self!.loadData()
  30. // })
  31. loadType()
  32. // tableView.mj_header.beginRefreshing();
  33. // Do any additional setup after loading the view.
  34. }
  35. //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
  36. @IBAction func btnMenuClick(_ sender: AnyObject) {
  37. switch (sender as! UIButton).tag {
  38. case 1001: // 在线客服
  39. let qySource = QYSource()
  40. qySource.title = "客服"
  41. qySource.urlString = ""
  42. qySource.customInfo = CommonValue.getUserNickName()
  43. let sessionQY = QYSDK.shared().sessionViewController()
  44. if sessionQY != nil {
  45. sessionQY!.sessionTitle = "在线客服"// CommonValue.getNikeName()
  46. sessionQY!.source = qySource
  47. sessionQY!.hidesBottomBarWhenPushed = true
  48. toViewController(viewController: sessionQY!)
  49. initCusServiceBackButton(viewController: sessionQY!)
  50. }
  51. break
  52. case 1002: // 电话客服
  53. if CommonUntils.getIsSimulator() {
  54. SVProgressHUD.showError(withStatus: "模拟器环境下不能拨打电话")
  55. } else {
  56. if CommonValue.getDefaultValueForKey(key: "customer_phone") != "" {
  57. CommonUntils.callPhone(phone: CommonValue.getDefaultValueForKey(key: "customer_phone"))
  58. }
  59. }
  60. break
  61. case 1003: //
  62. break
  63. case 1004: //
  64. break
  65. case 1005: //
  66. break
  67. case 1006: //
  68. break
  69. default:
  70. break
  71. }
  72. }
  73. var typeId = ""
  74. ///加载头部的菜单
  75. func loadMenu() {
  76. var arrTitle = [String]()
  77. for i in 0 ..< arrType.count {
  78. arrTitle.append(arrType.getString(index: i, key: "name"))
  79. }
  80. let segment = Virgil_SegmentView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: 47), titles: arrTitle, defaultColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), currentColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x2094F5, alpha: 1.0), lineHeight: 2, lineIsBottom: true) {[weak self] (index) in
  81. self!.currentPage = 1
  82. self!.typeId = self!.arrType.getString(index: index, key: "machine_type")
  83. self!.tableView.mj_header?.beginRefreshing()
  84. }
  85. self.viewMenu.addSubview(segment)
  86. typeId = arrType.getString(index: 0, key: "machine_type")
  87. tableView.mj_header?.beginRefreshing()
  88. }
  89. let arrType = NSMutableArray()
  90. // MARK: =============加载数据===============
  91. func loadType() {
  92. let url = RequestURL.getMachineNameList
  93. let params = NSMutableDictionary()
  94. TloadDataList(url: url, params: params, tag: 1002, array: arrType)
  95. }
  96. // MARK: =============加载数据===============
  97. func loadData() {
  98. let url = RequestURL.getHelpQuestList
  99. let params = NSMutableDictionary()
  100. params.setValue(typeId, forKey: "id")
  101. TloadDataList(url: url, params: params, tableView: self.tableView, tag: 1001)
  102. }
  103. override func returnData(tag: Int) {
  104. if tag == 1002 {
  105. if arrType.count > 0 {
  106. loadMenu()
  107. } else {
  108. SVProgressHUD.showError(withStatus: "文案类型加载失败,请重试")
  109. loadData()
  110. }
  111. } else
  112. if tag == 1001 {
  113. tableView.reloadData()
  114. }
  115. }
  116. override func returnError(tag: Int, type: String) {
  117. }
  118. // MARK: TABLEVLEW 实现
  119. func numberOfSections(in tableView: UITableView) -> Int {
  120. return 1
  121. }
  122. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  123. return self.arrData.count
  124. }
  125. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  126. let cell = tableView.dequeueReusableCell(withIdentifier: "HelpListTableViewCell", for: indexPath as IndexPath) as! HelpListTableViewCell
  127. cell.lblTitle.text = getString(current: indexPath.row, key: "title")
  128. cell.lblTitle.setTextLineSpace(lineSpace: 4)
  129. return cell
  130. }
  131. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  132. if indexPath.row >= arrData.count {
  133. return
  134. }
  135. // let view = CommonWebViewViewController()
  136. // view.strTitle = "详情"//getString(current: indexPath.row, key: "title");
  137. // view.url = getString(current: indexPath.row, key: "webUrl")
  138. // toViewController(viewController: view)
  139. let view = ContentViewController()
  140. view.titleStr = "详情"//getString(current: indexPath.row, key: "title");
  141. view.strHtml = getString(current: indexPath.row, key: "content")
  142. toViewController(viewController: view)
  143. }
  144. override func viewWillAppear(_ animated: Bool) {
  145. super.viewWillAppear(animated)
  146. }
  147. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  148. super.init(nibName: "HelpListViewController", bundle: nil)
  149. }
  150. required init?(coder aDecoder: NSCoder) {
  151. fatalError("init(coder:) has not been implemented")
  152. }
  153. }