123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- //
- // SelectBankViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/30.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class MachineManagerViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate {
- @IBOutlet weak var viewMenu1: UIView!
- @IBOutlet weak var viewMenu2: UIView!
- @IBOutlet weak var viewMenu3: UIView!
- @IBOutlet weak var viewMenu4: UIView!
- @IBOutlet weak var lblCount3: UILabel!
- @IBOutlet weak var lblCount2: UILabel!
- @IBOutlet weak var lblCount1: UILabel!
- @IBOutlet weak var viewRemark: UIView!
- @IBOutlet weak var tableView: UITableView!
- @IBOutlet weak var imgBackgroud: UIImageView!
- @IBOutlet weak var txtCode: UITextField!
- @IBOutlet weak var viewMenu: UIView!
- @IBOutlet weak var lblRemark: UILabel!
- var mid = ""
- var provinceId = ""
- var cityId = ""
- var shopEntity: ShopOpenEntity!
- var bankName = ""
- ///0:代理 1:商户
- var type = 0
- override func viewDidLoad() {
- super.viewDidLoad()
- let strTitle = "终端"
- let viewNav = (CommonViewUntils.getViewForXIB(xibName: "NavView") as! NavView)
- viewNav.initView(title: "我的\(strTitle)") {[weak self] (index, _) in
- if index == 0 {
- self!.handleBack()
- }
- }
- self.view.addSubview(viewNav)
- viewNav.marginTop(top: 0)
- self.view.addSubview(viewNav)
- viewNav.marginTop(top: 0)
- viewMenu.marginTop(top: viewNav.bottom())
- txtCode.setCornerRadius(size: 4)
- txtCode.setContentMarginLeft(leftWidth: 15)
- txtCode.setContentMarginRight(rightWidth: 30)
- imgBackgroud.setSizeHeight(height: viewMenu.bottom())
- viewRemark.marginTop(top: 0, view: imgBackgroud)
- tableView.marginTop(top: 1, view: viewRemark)
- tableView.setSizeHeight(height: ScreenHeight - imgBackgroud.height() - 49 - 26)
- tableView.register(UINib(nibName: "MachineManagerTableViewCell", bundle: nil), forCellReuseIdentifier: "MachineManagerTableViewCell")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.estimatedRowHeight = 100
- tableView.keyboardDismissMode = .onDrag
- txtCode.delegate = self
- txtCode.returnKeyType = .search
- 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()
- })
- loadInfo()
- CommonViewUntils.setViewAverage(arrView: [viewMenu1, viewMenu2, viewMenu3])
- //CommonViewUntils.getAttributedString(str: "直属\(strTitle)(3人)", left: [5,strTitle.length() + 2,strTitle.length() + 4], color: [UIColor])
- // lblRemark.text = "直属\(strTitle)(3人)"
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txtCode.resignFirstResponder()
- }
- @IBAction func btnQuery(_ sender: Any) {
- self.currentPage = 1
- loadData()
- }
- func textFieldShouldReturn(_ textField: UITextField) -> Bool {
- self.currentPage = 1
- loadData()
- return true
- }
- // MARK: =============加载数据===============
- func loadData() //str:String
- {
- let url = RequestURL.myMachineList
- let params = NSMutableDictionary()
- params.setValue(CommonValue.getUserId(), forKey: "userId")
- params.setValue(txtCode.text!, forKey: "snCode")
- loadDataList(url: url, params: params, tableView: tableView, tag: 1001)
- }
- func loadInfo() {
- let url = RequestURL.myMachineInfo
- let params = NSMutableDictionary()
- loadDataInfo(url: url, params: params, tag: 1002)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- tableView.reloadData()
- } else if tag == 1002 {
- lblCount1.text = "\(getIntValue(key: "total"))"
- lblCount2.text = "\(getIntValue(key: "status1"))"
- lblCount3.text = "\(getIntValue(key: "status2"))"
- }
- }
- 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, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 82
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MachineManagerTableViewCell", for: indexPath as IndexPath) as! MachineManagerTableViewCell
- if getString(current: indexPath.row, key: "productTypeCN") != "" {
- cell.lblName.text = "\(getString(current: indexPath.row, key: "machineTypeCN"))(\(getString(current: indexPath.row, key: "productTypeCN")))"
- } else {
- cell.lblName.text = "\(getString(current: indexPath.row, key: "machineTypeCN"))"
- }
- cell.lblDate.text = "\(getString(current: indexPath.row, key: "sn_code"))"
- let state = getIntValue(current: indexPath.row, key: "status")
- if state == 0 {
- cell.lblRemark.text = "未绑定"
- cell.lblRemark.textColor = UIColor.red
- } else if state == 1 {
- cell.lblRemark.text = "已绑定"
- cell.lblRemark.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x666666, alpha: 1.0)
- } else {
- cell.lblRemark.text = "已激活"
- cell.lblRemark.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x666666, alpha: 1.0)
- }
- return cell
- }
- var selectedIndex = -1
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- if indexPath.row >= arrData.count {
- return
- }
- let vc = MachineDetailViewController()
- vc.id = getString(current: indexPath.row, key: "id")
- toViewController(viewController: vc)
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- appDelegate.setNavigationBarHidden(isHidden: true)
- self.currentPage = 1
- loadData()
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "MachineManagerViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|