BJShopInfoViewController.swift 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // ShopAuthViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/8/12.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class BJShopInfoViewController: BaseViewController, AVCaptureViewControllerDelegate, CommonDelegate {
  10. @IBOutlet weak var txtQYFL: UITextField!
  11. @IBOutlet weak var txtType: UITextField!
  12. @IBOutlet weak var txtAddress2: UITextField!
  13. @IBOutlet weak var txtAddress1: UITextField!
  14. @IBOutlet weak var viewContentHeight: NSLayoutConstraint!
  15. @IBOutlet weak var viewContentWidth: NSLayoutConstraint!
  16. @IBOutlet weak var viewContent: UIView!
  17. @IBOutlet weak var txtIDCard: UITextField!
  18. @IBOutlet weak var txtName: UILabel!
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21. self.title = "商户认证"
  22. initNavLeftBackButton()
  23. viewContentWidth.constant = ScreenWidth
  24. let substr = appDelegate.openMerchants.phone.suffix(4)
  25. txtName.text = "个体户\(appDelegate.openMerchants.settleName)\(substr)"
  26. }
  27. override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
  28. txtIDCard.resignFirstResponder()
  29. txtAddress2.resignFirstResponder()
  30. }
  31. var custom_code = ""
  32. var custom_name = ""
  33. var mcc_code = ""
  34. var mcc_name = ""
  35. var mcc_type = ""
  36. var provCode = ""
  37. var cityCode = ""
  38. var areaCode = ""
  39. var arrRateContent = [String]()
  40. ///0:行业类别 1:Mcc类型
  41. var commonSelectType = 0
  42. @IBAction func btnMenuClick(_ sender: AnyObject) {
  43. switch (sender as! UIButton).tag {
  44. case 1001: // 识别身份证号
  45. let vc = AVCaptureViewController()
  46. vc.delegate = self
  47. vc.cardType = 0
  48. self.present(vc, animated: true) {
  49. }
  50. break
  51. case 1002: // 所在地区
  52. btnSelectAddressClick()
  53. break
  54. case 1003: // 下一步
  55. if txtName.text!.length() < 1 {
  56. SVProgressHUD.showError(withStatus: "请输入商户名")
  57. return
  58. }
  59. // if(txtIDCard.text!.length() < 1)
  60. // {
  61. // SVProgressHUD.showError(withStatus: "请输入身份证号")
  62. // return;
  63. // }
  64. if self.areaCode.length() < 1 {
  65. SVProgressHUD.showError(withStatus: "请选择所在地区")
  66. return
  67. }
  68. if txtAddress2.text!.length() < 1 {
  69. SVProgressHUD.showError(withStatus: "请输入营业地址")
  70. return
  71. }
  72. if mcc_code.length() < 1 {
  73. SVProgressHUD.showError(withStatus: "请选择经营范围")
  74. return
  75. }
  76. if txtQYFL.text!.length() < 1 || txtQYFL.text! == "请选择" {
  77. SVProgressHUD.showError(withStatus: "请选择签约费率")
  78. return
  79. }
  80. appDelegate.openMerchants.mercName = txtName.text!
  81. //appDelegate.openMerchants.idCardNum = txtIDCard.text!
  82. appDelegate.openMerchants.provCode = provCode
  83. appDelegate.openMerchants.cityCode = cityCode
  84. appDelegate.openMerchants.areaCode = areaCode
  85. appDelegate.openMerchants.addrDetail = txtAddress1.text!
  86. appDelegate.openMerchants.bizScope = txtAddress2.text!
  87. appDelegate.openMerchants.customMccType = custom_code
  88. appDelegate.openMerchants.mccType = ""
  89. appDelegate.openMerchants.mcc = ""
  90. appDelegate.openMerchants.mccCode = mcc_code
  91. appDelegate.openMerchants.posRateCode = ""//txtQYFL.text!.replacingOccurrences(of: "%", with: "")
  92. appDelegate.openMerchants.qybRate = txtQYFL.text!.replacingOccurrences(of: "%", with: "")
  93. toViewController(viewController: BJBindViewController())
  94. break
  95. case 1004:
  96. break
  97. case 1005: // 经营范围
  98. commonSelectType = 1
  99. let vc = CommonSelectViewController()
  100. vc.delegate = self
  101. vc.type = 1
  102. toViewController(viewController: vc)
  103. break
  104. // case 1006: // Mcc类型
  105. // if custom_code == "" {
  106. // SVProgressHUD.showError(withStatus: "请先选择行业类别")
  107. // return
  108. // }
  109. // commonSelectType = 1
  110. // let vc = CommonSelectViewController()
  111. // vc.delegate = self
  112. // vc.type = 1
  113. // vc.custom_code = custom_code
  114. // toViewController(viewController: vc)
  115. // break
  116. case 1007: // 签约费率
  117. self.getFeiLv()
  118. break
  119. case 1008: // 增收手续费
  120. break
  121. default:
  122. break
  123. }
  124. }
  125. // MARK: =============加载数据===============
  126. func loadData() {
  127. let url = RequestURL.qybFindBankList
  128. let params = NSMutableDictionary()
  129. params.setValue("", forKey: "subjectId")
  130. params.setValue("", forKey: "showTimeSort")
  131. params.setValue("", forKey: "priceSort")
  132. loadDataInfo(url: url, params: params, tag: 1001)
  133. }
  134. ///费率
  135. let dicFL = NSMutableDictionary()
  136. func getFeiLv() {
  137. if dicFL.count > 0 {
  138. returnData(tag: 1003)
  139. return
  140. }
  141. let params = NSMutableDictionary()
  142. let url = RequestURL.rateConfig
  143. params.setValue(appDelegate.openMerchants.machineTypeId, forKey: "machine_type_id")
  144. params.setValue("0", forKey: "merchant_type")
  145. params.setValue(appDelegate.openMerchants.productTypeId, forKey: "product_type_id")
  146. loadDataInfo(url: url, params: params, tag: 1003, reDic: dicFL)
  147. }
  148. override func returnData(tag: Int) {
  149. if tag == 1001 {
  150. }
  151. if tag == 1003 {
  152. var rateMin = dicFL.getDouble(key: "loan_card_rate_min") * 100
  153. let rateMax = dicFL.getDouble(key: "loan_card_rate_max") * 100
  154. arrRateContent.removeAll()
  155. var arrTitle = [String]()
  156. while Int(rateMin) <= Int(rateMax) {
  157. arrTitle.append("\(String.init(format: "%.2f", rateMin / 100))%")
  158. arrRateContent.append(String.init(format: "%.2f", rateMin / 100))
  159. rateMin += 1
  160. }
  161. CommonUntils.AlertView(controller: self, title: nil, message: "请选择费率", buttons: arrTitle, style: .actionSheet) {[weak self] (index, _) in
  162. self!.txtQYFL.text = "\(self!.arrRateContent[index])%"
  163. }
  164. }
  165. }
  166. override func returnError(tag: Int, type: String) {
  167. }
  168. ///选择所在地区
  169. var viewSelectCity: Virgil_SelectCity!
  170. func btnSelectAddressClick() {
  171. //var viewSelectCity:Virgil_SelectCity!
  172. let addressList = CommonUntils.getPlistArrayForName(fileName: "AddressNew")
  173. if viewSelectCity == nil {
  174. viewSelectCity = Virgil_SelectCity(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: view.height()))
  175. viewSelectCity.modelType = 2
  176. viewSelectCity.initView(arrAddress: addressList) {[weak self] (dic) in
  177. self!.provCode = self!.getString(key: "addressId1", dic: dic)
  178. self!.cityCode = self!.getString(key: "addressId2", dic: dic)
  179. self!.areaCode = self!.getString(key: "addressId3", dic: dic)
  180. //self!.shopOpen.addressName1 = self!.getString(key: "addressName1", dic: dic) ;
  181. self!.txtAddress1.text = dic.getString(key: "address")
  182. }
  183. self.view.addSubview(viewSelectCity)
  184. }
  185. viewSelectCity.showPickerView()
  186. }
  187. func avCaptureViewReData(_ iDInfo: IDInfo!, img: UIImage!) {
  188. txtIDCard.text = iDInfo.num!
  189. //imgShow.image = img;
  190. }
  191. func rebackFunction(dic: NSMutableDictionary) {
  192. if commonSelectType == 0 {
  193. if custom_code != dic.getString(key: "code") {
  194. mcc_code = ""
  195. mcc_name = ""
  196. mcc_type = ""
  197. }
  198. custom_code = dic.getString(key: "code")
  199. custom_name = dic.getString(key: "name")
  200. txtType.text = custom_name
  201. } else if commonSelectType == 1 {
  202. mcc_code = dic.getString(key: "mcc_code")
  203. mcc_name = dic.getString(key: "mcc_name")
  204. mcc_type = dic.getString(key: "mcc_type")
  205. txtType.text = mcc_name
  206. }
  207. }
  208. override func viewWillAppear(_ animated: Bool) {
  209. super.viewWillAppear(animated)
  210. }
  211. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  212. super.init(nibName: "BJShopInfoViewController", bundle: nil)
  213. }
  214. required init?(coder aDecoder: NSCoder) {
  215. fatalError("init(coder:) has not been implemented")
  216. }
  217. }