//
//  DetailsViewController.swift
//  MobilePortal
//
//  Created by caiyang on 2020/4/8.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

class DetailsViewController: BaseViewController {
    
    var detailsId:String?
    var httpModel = DetailsHttpModel()
    var delegate:DetailsViewControllerDelegate!
    var dataSource = NSMutableArray()
   
    lazy var helpBtnView: HelpBtnView = {
        let helpBtnView = HelpBtnView.init(frame: CGRect(x:0, y: SCREEN_HEIGHT()-(46.67+HEIGHT_BOTTOM_MARGIN()), width:SCREEN_WHIDTH() , height:46.67+HEIGHT_BOTTOM_MARGIN()))
//        let helpBtnView = HelpBtnView.init(frame: CGRect(x:0, y: 100, width:SCREEN_WHIDTH() , height:46.67+HEIGHT_BOTTOM_MARGIN()))
        helpBtnView.backgroundColor = UIColor.white
        return helpBtnView
    }()
    
    lazy var myTableView: UITableView = {
        let myTableView = UITableView.init()
        self.view.addSubview(myTableView)
        myTableView.snp.makeConstraints { (make) in
            make.width.height.equalToSuperview()
            make.center.equalToSuperview()
        }
        if #available(iOS 11.0, *) {
            myTableView.contentInsetAdjustmentBehavior = .never
            myTableView.scrollIndicatorInsets = myTableView.contentInset
            myTableView.contentInset = UIEdgeInsetsMake(UIApplication.shared.statusBarFrame.size.height+44, 0, 0, 0)
        }else{
            myTableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
        }
        registerCell(myTableView, cell: DetailsTableViewCell.self)
        registerCell(myTableView, cell: RecommendTableViewCell.self)
        registerCell(myTableView, cell: RecommendTitleTableViewCell.self)
        myTableView.backgroundColor = loginBg_Color
        setExtraCellLineHidden(tableView: myTableView)
        return myTableView
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.red
        initTitleBar()
//        self.edgesForExtendedLayout = UIRectEdge.bottom
        self.title = "问题详情"
        
//        addHelpBtnView()
        self.actionHttpGCD()
        
        // Do any additional setup after loading the view.
    }
    func addHelpBtnView(){
        helpBtnView.trueBlock = {
            
        }
        helpBtnView.falseBlock = {
            
        }
        helpBtnView.advisoryBlock = {[weak self] in
            self?.gotoCustomerVC()
        }
        self.view.addSubview(helpBtnView)
    }
    /// 跳转智能客服对话页面
    func gotoCustomerVC() {
        let vc = DialogueViewController()
        self.pushViewController(viewController: vc, animated: true)
    }
    func actionHttpGCD(){
        queue.async(group: group, execute: {[weak self] in
            self?.group.enter()
            self?.getDetailsHttpGetCmd()
        })
        group.notify(queue: DispatchQueue.main) {[weak self] in
//            self?.titleView.titleLabel.text = judgmentStrNil(str: self?.httpModel.title)
            self?.addInitTableView()
        }
    }
}
