PersonalBaseViewController.swift 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // PersonalBaseViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/11/2.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class PersonalBaseViewController: BaseViewController, AVCaptureViewControllerDelegate {
  10. @IBOutlet weak var txtShopDetailAddress: UITextField!
  11. @IBOutlet weak var txtShopAddress: UITextField!
  12. @IBOutlet weak var txtBusinessName: UITextField!
  13. @IBOutlet weak var txtXYKPhone: UITextField!
  14. @IBOutlet weak var txtXYKCard: UITextField!
  15. @IBOutlet weak var txtIDCard: UITextField!
  16. @IBOutlet weak var txtName: UITextField!
  17. @IBOutlet weak var txtShopName: UITextField!
  18. var shopOpen: ShopOpenEntity!
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21. self.title = "完善资料"
  22. initNavLeftBackButton()
  23. }
  24. override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
  25. txtShopDetailAddress.resignFirstResponder()
  26. txtShopAddress.resignFirstResponder()
  27. txtBusinessName.resignFirstResponder()
  28. txtXYKPhone.resignFirstResponder()
  29. txtXYKCard.resignFirstResponder()
  30. txtIDCard.resignFirstResponder()
  31. txtName.resignFirstResponder()
  32. txtShopName.resignFirstResponder()
  33. }
  34. var viewSelectCity: Virgil_SelectCity!
  35. //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
  36. @IBAction func btnMenuClick(_ sender: AnyObject) {
  37. switch (sender as! UIButton).tag {
  38. case 1001: // 名称说明
  39. let vc = CommonWebViewViewController()
  40. vc.strTitle = "公司名称规则"
  41. vc.sourceType = 1
  42. vc.url = "\(RequestURL.sysConfigWeb)?type=company_name"
  43. toViewController(viewController: vc)
  44. break
  45. case 1002: // 身份证号拍照
  46. let vc = AVCaptureViewController()
  47. vc.delegate = self
  48. vc.cardType = 0
  49. self.present(vc, animated: true) {
  50. }
  51. break
  52. case 1003: // 选择店铺所在地区
  53. let addressList = CommonUntils.getPlistArrayForName(fileName: "AddressNew")
  54. if viewSelectCity == nil {
  55. viewSelectCity = Virgil_SelectCity(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: view.height()))
  56. viewSelectCity.modelType = 2
  57. viewSelectCity.initView(arrAddress: addressList) {[weak self] (dic) in
  58. self!.shopOpen.addressId1 = self!.getString(key: "addressId1", dic: dic)
  59. self!.shopOpen.addressId2 = self!.getString(key: "addressId2", dic: dic)
  60. self!.shopOpen.addressId3 = self!.getString(key: "addressId3", dic: dic)
  61. self!.shopOpen.addressName1 = self!.getString(key: "addressName1", dic: dic)
  62. self!.shopOpen.addressName2 = self!.getString(key: "addressName2", dic: dic)
  63. self!.shopOpen.addressName3 = self!.getString(key: "addressName3", dic: dic)
  64. //self!.shopOpen.address = self!.getString(key: "address", dic: dic);
  65. self!.txtShopAddress.text = self!.getString(key: "address", dic: dic)
  66. }
  67. self.view.addSubview(viewSelectCity)
  68. }
  69. viewSelectCity.showPickerView()
  70. break
  71. case 1004: // 下一步
  72. submitHK()
  73. break
  74. case 1005: //
  75. break
  76. case 1006: //
  77. break
  78. default:
  79. break
  80. }
  81. }
  82. // MARK: =============加载数据===============
  83. func submitHK() {
  84. if txtBusinessName.text!.length() < 1 {
  85. SVProgressHUD.showError(withStatus: "请输入商户名称")
  86. return
  87. }
  88. if txtName.text!.length() < 1 {
  89. SVProgressHUD.showError(withStatus: "请输入法人名称")
  90. return
  91. }
  92. if txtIDCard.text!.length() < 1 {
  93. SVProgressHUD.showError(withStatus: "请输入身份证号")
  94. return
  95. }
  96. if txtXYKCard.text!.length() < 1 {
  97. SVProgressHUD.showError(withStatus: "请输入信用卡号")
  98. return
  99. }
  100. if txtXYKPhone.text!.length() < 1 {
  101. SVProgressHUD.showError(withStatus: "请输入信用卡预留手机号")
  102. return
  103. }
  104. if txtShopName.text!.length() < 1 {
  105. SVProgressHUD.showError(withStatus: "请输入店铺名称")
  106. return
  107. }
  108. if self.shopOpen.addressId1 == "" || self.shopOpen.addressId2 == "" || self.shopOpen.addressId3 == "" {
  109. SVProgressHUD.showError(withStatus: "请选择店铺所在地区")
  110. return
  111. }
  112. if txtShopDetailAddress.text!.length() < 1 {
  113. SVProgressHUD.showError(withStatus: "请输入店铺地址")
  114. return
  115. }
  116. let url = RequestURL.improveInfo
  117. let params = NSMutableDictionary()
  118. params.setValue(shopOpen.phone, forKey: "regAccno")
  119. params.setValue(txtBusinessName.text!, forKey: "companyName")
  120. params.setValue(txtName.text!, forKey: "applicantName")
  121. params.setValue(txtIDCard.text!, forKey: "applicantCard")
  122. params.setValue(txtXYKCard.text!, forKey: "creditCardNum")
  123. params.setValue(txtXYKPhone.text!, forKey: "creditCardPhone")
  124. params.setValue(txtShopName.text!, forKey: "shopName")
  125. params.setValue(txtShopDetailAddress.text!, forKey: "shopAddress")
  126. params.setValue(self.shopOpen.addressId1, forKey: "shopProvinceId")
  127. params.setValue(self.shopOpen.addressName1, forKey: "shopProvinceName")
  128. params.setValue(self.shopOpen.addressName2, forKey: "shopCityName")
  129. params.setValue(self.shopOpen.addressId2, forKey: "shopCityId")
  130. params.setValue(self.shopOpen.addressName3, forKey: "shopAreaName")
  131. params.setValue(self.shopOpen.addressId3, forKey: "shopAreaId")
  132. submitData(url: url, params: params, tag: 1001)
  133. }
  134. override func returnData(tag: Int) {
  135. if tag == 1001 {
  136. let dichaike = dicBackData["haike"] as? NSDictionary
  137. if dichaike != nil {
  138. let dicResult = dichaike!["result"] as? NSDictionary
  139. if dicResult != nil {
  140. if dicResult!.getString(key: "regFlag") == "1" {
  141. self.shopOpen.pmmerId = dicResult!.getString(key: "pmmerId")
  142. self.shopOpen.companyName = txtBusinessName.text!
  143. self.shopOpen.name = txtName.text!
  144. self.shopOpen.card = txtIDCard.text!
  145. self.shopOpen.creditCardNum = txtXYKCard.text!
  146. self.shopOpen.creditCardPhone = txtXYKPhone.text!
  147. self.shopOpen.shopName = txtShopName.text!
  148. self.shopOpen.addressDetail = txtShopDetailAddress.text!
  149. let vc = PersonalBindCardViewController()
  150. vc.shopOpen = self.shopOpen
  151. toViewController(viewController: vc)
  152. } else {
  153. let dicMessage = dichaike!["message"] as? NSDictionary
  154. if dicMessage != nil {
  155. SVProgressHUD.showError(withStatus: dicMessage!.getString(key: "content"))
  156. } else {
  157. SVProgressHUD.showError(withStatus: "提交海科失败,请稍后重试!")
  158. }
  159. }
  160. } else {
  161. let dicMessage = dichaike!["message"] as? NSDictionary
  162. if dicMessage != nil {
  163. SVProgressHUD.showError(withStatus: dicMessage!.getString(key: "content"))
  164. } else {
  165. SVProgressHUD.showError(withStatus: "提交海科失败,请稍后重试!")
  166. }
  167. }
  168. } else {
  169. SVProgressHUD.showError(withStatus: "提交海科失败,请稍后重试!")
  170. }
  171. }
  172. }
  173. override func returnError(tag: Int, type: String) {
  174. }
  175. func avCaptureViewReData(_ iDInfo: IDInfo!, img: UIImage!) {
  176. txtIDCard.text = iDInfo.num!
  177. //imgShow.image = img;
  178. }
  179. override func viewWillAppear(_ animated: Bool) {
  180. super.viewWillAppear(animated)
  181. }
  182. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  183. super.init(nibName: "PersonalBaseViewController", bundle: nil)
  184. }
  185. required init?(coder aDecoder: NSCoder) {
  186. fatalError("init(coder:) has not been implemented")
  187. }
  188. }