123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- //
- // BindDeviceViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/11.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class BindDeviceViewController: BaseViewController {
- @IBOutlet weak var btnOpen: UIButton!
- @IBOutlet weak var btnScan: UIButton!
- @IBOutlet weak var txtCode: UITextField!
- var merchantsId = ""
- ///0:返回上一层 1:返回首页
- var fromType = 0
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "绑定设备"
- initNavLeftBackButton()
- txtCode.setCornerRadius(size: 4)
- txtCode.setContentMarginLeft(leftWidth: 20)
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txtCode.resignFirstResponder()
- }
- func cusHandleBack() {
- if !CommonUntils.reBackView(controller: self, aclass: ShopManagerViewController.classForCoder()) {
- self.navigationController?.popToRootViewController(animated: true)
- }
- }
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 扫码
- //取值在viewWillApper里 根据appDelegate.mainViewControllerIsGo mainViewControllerIsGoType mainViewControllerIsGoValue 取值
- let view = ScannerViewController()
- self.navigationController?.pushViewController(view, animated: true)
- break
- case 1002: // 开通
- loadData()
- break
- case 1003: //
- break
- case 1004: //
- break
- case 1005: //
- break
- case 1006: //
- break
- default:
- break
- }
- }
- // MARK: =============加载数据===============
- func loadData() {
- txtCode.resignFirstResponder()
- if txtCode.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入SN码")
- return
- }
- let url = RequestURL.bandMachine
- let params = NSMutableDictionary()
- params.setValue(CommonValue.getUserId(), forKey: "userId")
- params.setValue(merchantsId, forKey: "merchantsId")
- params.setValue(txtCode.text!, forKey: "machineSnCode")
- loadDataInfo(url: url, params: params, tag: 1001)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- let viewState = CommonViewUntils.getViewForXIB(xibName: "BindCheckView") as! BindCheckView
- viewState.initView(state: 1) {[weak self] (_, _) in
- appDelegate.navController.hiddenBackgroudViewNoAnimate()
- if self!.fromType == 0 {
- self!.handleBack()
- } else {
- self!.cusHandleBack()
- }
- }
- appDelegate.navController.showBackgroudView(viewContent: viewState, isCenter: true, clickOtherIsClose: false)
- }
- }
- override func returnError(tag: Int, type: String) {
- isAlertError = false
- if tag == 1001 {
- let viewState = CommonViewUntils.getViewForXIB(xibName: "BindCheckView") as! BindCheckView
- viewState.initView(state: 0) {(_, _) in
- appDelegate.navController.hiddenBackgroudViewNoAnimate()
- }
- appDelegate.navController.showBackgroudView(viewContent: viewState, isCenter: true)
- }
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- if mainViewControllerIsGo {
- txtCode.text = mainViewControllerIsGoValue
- }
- mainViewControllerIsGo = false
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "BindDeviceViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|