123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- //
- // ShopAddressViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/29.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class ShopIndustryViewController: BaseViewController {
- var shopOpen: ShopOpenEntity!
- @IBOutlet weak var txt2: UITextField!
- @IBOutlet weak var txt1: UITextField!
- override func viewDidLoad() {
- super.viewDidLoad()
- initNavLeftBackButton()
- self.title = "所属行业"
- loadDefaultData()
- // Do any additional setup after loading the view.
- }
- func loadDefaultData() {
- txt2.text = shopOpen.typeName2
- txt1.text = shopOpen.typeName1
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txt1.resignFirstResponder()
- txt2.resignFirstResponder()
- }
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 经营范围
- loadType = 0
- loadTypeData()
- break
- case 1002: // 所属类别
- loadType = 1
- loadTypeData()
- break
- case 1003: // 完成
- if shopOpen.typeId1 == "" {
- SVProgressHUD.showError(withStatus: "请选择经营范围")
- return
- }
- // if(shopOpen.typeId2 == "")
- // {
- // SVProgressHUD.showError(withStatus: "请选择所属类型")
- // return;
- // }
- handleBack()
- break
- case 1004: //
- break
- case 1005: //
- break
- case 1006: //
- break
- default:
- break
- }
- }
- var arrType1 = NSMutableArray()
- var arrType2 = NSMutableArray()
- var loadType = 0
- // MARK: =============加载数据===============
- func loadTypeData() {
- let url = RequestURL.industryList
- let params = NSMutableDictionary()
- if loadType == 0 {
- if arrType1.count > 0 {
- returnData(tag: 1001)
- } else {
- params.setValue("FFFFFF", forKey: "industryId")
- loadDataList(url: url, params: params, tag: 1001, array: arrType1)
- }
- } else {
- if shopOpen.typeId1 == "" {
- SVProgressHUD.showError(withStatus: "请先选择经营范围")
- return
- }
- params.setValue(shopOpen.typeId1, forKey: "industryId")
- arrType2.removeAllObjects()
- loadDataList(url: url, params: params, tag: 1001, array: arrType2)
- }
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- var arrAlert = [String]()
- if loadType == 0 {
- for i in 0 ..< arrType1.count {
- arrAlert.append(getStringForArray(key: "name", arr: arrType1, current: i))
- }
- } else {
- for i in 0 ..< arrType2.count {
- arrAlert.append(getStringForArray(key: "name", arr: arrType2, current: i))
- }
- }
- CommonUntils.AlertView(controller: self, title: "请选择", message: nil, buttons: arrAlert, style: .actionSheet) {[weak self] (index, _) in
- if self!.loadType == 0 {
- self!.shopOpen.typeId1 = self!.getStringForArray(key: "id", arr: self!.arrType1, current: index)
- self!.shopOpen.typeName1 = self!.getStringForArray(key: "name", arr: self!.arrType1, current: index)
- self!.txt1.text = self!.shopOpen.typeName1
- } else {
- self!.shopOpen.typeId2 = self!.getStringForArray(key: "id", arr: self!.arrType2, current: index)
- self!.shopOpen.typeName2 = self!.getStringForArray(key: "name", arr: self!.arrType2, current: index)
- self!.txt2.text = self!.shopOpen.typeName2
- }
- }
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "ShopIndustryViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|