ShopIndustryViewController.swift 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // ShopAddressViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/3/29.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class ShopIndustryViewController: BaseViewController {
  10. var shopOpen: ShopOpenEntity!
  11. @IBOutlet weak var txt2: UITextField!
  12. @IBOutlet weak var txt1: UITextField!
  13. override func viewDidLoad() {
  14. super.viewDidLoad()
  15. initNavLeftBackButton()
  16. self.title = "所属行业"
  17. loadDefaultData()
  18. // Do any additional setup after loading the view.
  19. }
  20. func loadDefaultData() {
  21. txt2.text = shopOpen.typeName2
  22. txt1.text = shopOpen.typeName1
  23. }
  24. override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
  25. txt1.resignFirstResponder()
  26. txt2.resignFirstResponder()
  27. }
  28. @IBAction func btnMenuClick(_ sender: AnyObject) {
  29. switch (sender as! UIButton).tag {
  30. case 1001: // 经营范围
  31. loadType = 0
  32. loadTypeData()
  33. break
  34. case 1002: // 所属类别
  35. loadType = 1
  36. loadTypeData()
  37. break
  38. case 1003: // 完成
  39. if shopOpen.typeId1 == "" {
  40. SVProgressHUD.showError(withStatus: "请选择经营范围")
  41. return
  42. }
  43. // if(shopOpen.typeId2 == "")
  44. // {
  45. // SVProgressHUD.showError(withStatus: "请选择所属类型")
  46. // return;
  47. // }
  48. handleBack()
  49. break
  50. case 1004: //
  51. break
  52. case 1005: //
  53. break
  54. case 1006: //
  55. break
  56. default:
  57. break
  58. }
  59. }
  60. var arrType1 = NSMutableArray()
  61. var arrType2 = NSMutableArray()
  62. var loadType = 0
  63. // MARK: =============加载数据===============
  64. func loadTypeData() {
  65. let url = RequestURL.industryList
  66. let params = NSMutableDictionary()
  67. if loadType == 0 {
  68. if arrType1.count > 0 {
  69. returnData(tag: 1001)
  70. } else {
  71. params.setValue("FFFFFF", forKey: "industryId")
  72. loadDataList(url: url, params: params, tag: 1001, array: arrType1)
  73. }
  74. } else {
  75. if shopOpen.typeId1 == "" {
  76. SVProgressHUD.showError(withStatus: "请先选择经营范围")
  77. return
  78. }
  79. params.setValue(shopOpen.typeId1, forKey: "industryId")
  80. arrType2.removeAllObjects()
  81. loadDataList(url: url, params: params, tag: 1001, array: arrType2)
  82. }
  83. }
  84. override func returnData(tag: Int) {
  85. if tag == 1001 {
  86. var arrAlert = [String]()
  87. if loadType == 0 {
  88. for i in 0 ..< arrType1.count {
  89. arrAlert.append(getStringForArray(key: "name", arr: arrType1, current: i))
  90. }
  91. } else {
  92. for i in 0 ..< arrType2.count {
  93. arrAlert.append(getStringForArray(key: "name", arr: arrType2, current: i))
  94. }
  95. }
  96. CommonUntils.AlertView(controller: self, title: "请选择", message: nil, buttons: arrAlert, style: .actionSheet) {[weak self] (index, _) in
  97. if self!.loadType == 0 {
  98. self!.shopOpen.typeId1 = self!.getStringForArray(key: "id", arr: self!.arrType1, current: index)
  99. self!.shopOpen.typeName1 = self!.getStringForArray(key: "name", arr: self!.arrType1, current: index)
  100. self!.txt1.text = self!.shopOpen.typeName1
  101. } else {
  102. self!.shopOpen.typeId2 = self!.getStringForArray(key: "id", arr: self!.arrType2, current: index)
  103. self!.shopOpen.typeName2 = self!.getStringForArray(key: "name", arr: self!.arrType2, current: index)
  104. self!.txt2.text = self!.shopOpen.typeName2
  105. }
  106. }
  107. }
  108. }
  109. override func returnError(tag: Int, type: String) {
  110. }
  111. override func viewWillAppear(_ animated: Bool) {
  112. super.viewWillAppear(animated)
  113. }
  114. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  115. super.init(nibName: "ShopIndustryViewController", bundle: nil)
  116. }
  117. required init?(coder aDecoder: NSCoder) {
  118. fatalError("init(coder:) has not been implemented")
  119. }
  120. }