123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //
- // HelpListViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/16.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class HelpListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate {
- @IBOutlet weak var viewMenu: UIView!
- @IBOutlet weak var tableView: UITableView!
- override func viewDidLoad() {
- super.viewDidLoad()
- initNavLeftBackButton()
- self.title = "帮助中心"
- tableView.register(UINib(nibName: "HelpListTableViewCell", bundle: nil), forCellReuseIdentifier: "HelpListTableViewCell")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.estimatedRowHeight = 100
- tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
- self!.currentPage = 1
- self!.loadData()
- })
- tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
- // tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
- // self!.currentPage += 1
- // self!.loadData()
- // })
- loadType()
- // tableView.mj_header.beginRefreshing();
- // Do any additional setup after loading the view.
- }
- //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 在线客服
- let qySource = QYSource()
- qySource.title = "客服"
- qySource.urlString = ""
- qySource.customInfo = CommonValue.getUserNickName()
- let sessionQY = QYSDK.shared().sessionViewController()
- if sessionQY != nil {
- sessionQY!.sessionTitle = "在线客服"// CommonValue.getNikeName()
- sessionQY!.source = qySource
- sessionQY!.hidesBottomBarWhenPushed = true
- toViewController(viewController: sessionQY!)
- initCusServiceBackButton(viewController: sessionQY!)
- }
- break
- case 1002: // 电话客服
- if CommonUntils.getIsSimulator() {
- SVProgressHUD.showError(withStatus: "模拟器环境下不能拨打电话")
- } else {
- if CommonValue.getDefaultValueForKey(key: "customer_phone") != "" {
- CommonUntils.callPhone(phone: CommonValue.getDefaultValueForKey(key: "customer_phone"))
- }
- }
- break
- case 1003: //
- break
- case 1004: //
- break
- case 1005: //
- break
- case 1006: //
- break
- default:
- break
- }
- }
- var typeId = ""
- ///加载头部的菜单
- func loadMenu() {
- var arrTitle = [String]()
- for i in 0 ..< arrType.count {
- arrTitle.append(arrType.getString(index: i, key: "name"))
- }
- 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
- self!.currentPage = 1
- self!.typeId = self!.arrType.getString(index: index, key: "machine_type")
- self!.tableView.mj_header?.beginRefreshing()
- }
- self.viewMenu.addSubview(segment)
- typeId = arrType.getString(index: 0, key: "machine_type")
- tableView.mj_header?.beginRefreshing()
- }
- let arrType = NSMutableArray()
- // MARK: =============加载数据===============
- func loadType() {
- let url = RequestURL.getMachineNameList
- let params = NSMutableDictionary()
- TloadDataList(url: url, params: params, tag: 1002, array: arrType)
- }
- // MARK: =============加载数据===============
- func loadData() {
- let url = RequestURL.getHelpQuestList
- let params = NSMutableDictionary()
- params.setValue(typeId, forKey: "id")
- TloadDataList(url: url, params: params, tableView: self.tableView, tag: 1001)
- }
- override func returnData(tag: Int) {
- if tag == 1002 {
- if arrType.count > 0 {
- loadMenu()
- } else {
- SVProgressHUD.showError(withStatus: "文案类型加载失败,请重试")
- loadData()
- }
- } else
- if tag == 1001 {
- tableView.reloadData()
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- // MARK: TABLEVLEW 实现
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.arrData.count
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "HelpListTableViewCell", for: indexPath as IndexPath) as! HelpListTableViewCell
- cell.lblTitle.text = getString(current: indexPath.row, key: "title")
- cell.lblTitle.setTextLineSpace(lineSpace: 4)
- return cell
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- if indexPath.row >= arrData.count {
- return
- }
- // let view = CommonWebViewViewController()
- // view.strTitle = "详情"//getString(current: indexPath.row, key: "title");
- // view.url = getString(current: indexPath.row, key: "webUrl")
- // toViewController(viewController: view)
- let view = ContentViewController()
- view.titleStr = "详情"//getString(current: indexPath.row, key: "title");
- view.strHtml = getString(current: indexPath.row, key: "content")
- toViewController(viewController: view)
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "HelpListViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|