123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- //
- // SelectBankViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/30.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class MyShopListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate {
- @IBOutlet weak var tableView: UITableView!
- @IBOutlet weak var imgBackgroud: UIImageView!
- @IBOutlet weak var txtCode: UITextField!
- @IBOutlet weak var viewMenu: UIView!
- @IBOutlet weak var viewRemark: UIView!
- @IBOutlet weak var lblRemark: UILabel!
- var queryEntity: ShopQueryModel!
- let contentV = CommonViewUntils.getViewForXIB(xibName: "MyShopMenuContent") as! MyShopMenuContent
- var menuView: XF_RightMenu = {
- let menuView = XF_RightMenu.init(frame: UIScreen.main.bounds)
- return menuView
- }()
- var sortType: String = "desc"
- var mid = ""
- var provinceId = ""
- var cityId = ""
- var shopEntity: ShopOpenEntity!
- var bankName = ""
- var machineType = "2"
- var strTitle = "商户"
- override func viewDidLoad() {
- super.viewDidLoad()
- queryEntity = ShopQueryModel()
- 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)
- tableView.register(UINib(nibName: "MyShopListTableViewCell", bundle: nil), forCellReuseIdentifier: "MyShopListTableViewCell")
- 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()
- })
- self.view.addSubview(menuView)
- loadData()
- menuView.contentView = contentV
- contentV.callBackForSure(backFunc: {[weak self] (queryEntityTemp) in
- self!.queryEntity.startTime = queryEntityTemp.startTime
- self!.queryEntity.endTime = queryEntityTemp.endTime
- self!.queryEntity.busType = queryEntityTemp.busType
- self!.queryEntity.miniRate = queryEntityTemp.miniRate
- self!.queryEntity.maxRate = queryEntityTemp.maxRate
- self!.menuView.hiddenView()
- self!.loadData()
- })
- }
- @IBAction func btnMenuClick(_ sender: UIButton) {
- switch (sender as UIButton).tag {
- case 1001:
- self.sortType = (self.sortType == "desc") ? "asc" : "desc"
- loadData()
- break
- case 1002:
- self.menuView.showView()
- break
- default:
- break
- }
- }
- @IBAction func btnQuery(_ sender: Any) {
- self.currentPage = 1
- loadData()
- }
- func textFieldShouldReturn(_ textField: UITextField) -> Bool {
- self.currentPage = 1
- loadData()
- return true
- }
- // MARK: =============加载数据===============
- func loadData() {
- let url = RequestURL.myMerchantList
- let params = NSMutableDictionary()
- params.setValue(CommonValue.getUserId(), forKey: "userId")
- params.setValue("1", forKey: "status")
- params.setValue(txtCode.text!, forKey: "likeStr")
- params.setValue(self.machineType, forKey: "machineTypeId")
- params.setValue(self.sortType, forKey: "sortType")
- params.setValue(self.queryEntity.startTime, forKey: "certificationStartTime")
- params.setValue(self.queryEntity.endTime, forKey: "certificationEndTime")
- params.setValue(self.queryEntity.busType, forKey: "busType")
- params.setValue(self.queryEntity.miniRate, forKey: "miniRate")
- params.setValue(self.queryEntity.maxRate, forKey: "maxRate")
- loadDataList(url: url, params: params, tableView: tableView, tag: 1001)
- }
- func submitData() {
- if selectedIndex == -1 {
- SVProgressHUD.showError(withStatus: "请选择分拨代理")
- return
- }
- let url = RequestURL.machineAllocation
- let params = NSMutableDictionary()
- params.setValue(getString(current: selectedIndex, key: "id"), forKey: "userId")
- params.setValue(mid, forKey: "machineId")
- submitData(url: url, params: params, tag: 1002)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- tableView.reloadData()
- } else if tag == 1002 {
- SVProgressHUD.showSuccess(withStatus: "分拨成功!")
- handleBack()
- }
- }
- 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 100
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MyShopListTableViewCell", for: indexPath as IndexPath) as! MyShopListTableViewCell
- cell.lblName.text = "\(getString(current: indexPath.row, key: "companyName"))"
- cell.lblPhone.text = "\(getString(current: indexPath.row, key: "createtime"))"
- cell.lblNumber.text = "SN:\(getString(current: indexPath.row, key: "machineSnCode"))"
- cell.lblMoney.text = "当月总额:\(getStringForInt(current: indexPath.row, key: "monthTranTotal"))元"
- cell.lblCount.text = "交易笔数:\(getStringForInt(current: indexPath.row, key: "monthTranSize"))笔"
- return cell
- }
- var selectedIndex = -1
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- if indexPath.row >= arrData.count {
- return
- }
- let machineTypeId = getString(current: indexPath.row, key: "machineTypeId")
- if machineTypeId == "1" {
- let vc = MyShopDetailTypeViewController()
- vc.id = getString(current: indexPath.row, key: "id")
- vc.dicData.setDic(dic: self.arrData[indexPath.row] as! NSDictionary)
- toViewController(viewController: vc)
- }else if machineTypeId == "777" || machineTypeId == "888" || machineTypeId == "999" || machineTypeId == "9999" || machineType == "1df30df31e5a43c1b468b73a6abf586a"{
- let vc = MyShopDetailViewController()
- vc.isKssSer = false
- vc.isHSF = machineType == "1df30df31e5a43c1b468b73a6abf586a" ? false : true
- vc.isXW = machineType == "1df30df31e5a43c1b468b73a6abf586a" ? true : false
- vc.id = getString(current: indexPath.row, key: "id")
- vc.dicData.setDic(dic: self.arrData[indexPath.row] as! NSDictionary)
- toViewController(viewController: vc)
- }
- else {
- let vc = MyShopDetailViewController()
- let index: NSInteger = brandIdList.lastIndex(of: machineTypeId) ?? 0
- if index == 2 || index == 3 {
- vc.isKssSer = true
- }
- vc.id = getString(current: indexPath.row, key: "id")
- vc.dicData.setDic(dic: self.arrData[indexPath.row] as! NSDictionary)
- toViewController(viewController: vc)
- }
- }
- @objc func btnCallClick(btn: UIButton) {
- if CommonUntils.getIsSimulator() {
- SVProgressHUD.showError(withStatus: "模拟器环境下不能拨打电话")
- } else {
- CommonUntils.callPhone(phone: getString(current: btn.tag, key: "phone"))
- }
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- appDelegate.setNavigationBarHidden(isHidden: true)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "MyShopListViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|