BJBusinessViewController.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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 BJBusinessViewController: BaseViewController, AVCaptureViewControllerDelegate, CommonDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIScrollViewDelegate, UITextFieldDelegate {
  10. @IBOutlet weak var viewTitle1: UIView!
  11. @IBOutlet weak var viewTitle2: UIView!
  12. @IBOutlet weak var viewTitle4: UIView!
  13. @IBOutlet weak var view1: UIView!
  14. @IBOutlet weak var view2: UIView!
  15. @IBOutlet weak var view3: UIView!
  16. @IBOutlet weak var view4: UIView!
  17. @IBOutlet weak var view5: UIView!
  18. @IBOutlet weak var view6: UIView!
  19. @IBOutlet weak var view7: UIView!
  20. @IBOutlet weak var view8: UIView!
  21. @IBOutlet weak var view9: UIView!
  22. @IBOutlet weak var scrollView: UIScrollView!
  23. @IBOutlet weak var btnMenu1: UIButton!
  24. @IBOutlet weak var btnMenu2: UIButton!
  25. @IBOutlet weak var btnMenu3: UIButton!
  26. @IBOutlet weak var imgCard3: UIImageView!
  27. @IBOutlet weak var imgCard1: UIImageView!
  28. @IBOutlet weak var imgCard2: UIImageView!
  29. @IBOutlet weak var txtAddress: UITextField!
  30. @IBOutlet weak var txtChildBankName: UITextField!
  31. @IBOutlet weak var txtBankName: UITextField!
  32. @IBOutlet weak var txtJSYHYXQ: UITextField!
  33. @IBOutlet weak var txtFRYXQ: UITextField!
  34. @IBOutlet weak var viewContentHeight: NSLayoutConstraint!
  35. @IBOutlet weak var viewContentWidth: NSLayoutConstraint!
  36. @IBOutlet weak var viewContent: UIView!
  37. @IBOutlet weak var txtPhone: UITextField!
  38. @IBOutlet weak var txtBankCard: UITextField!
  39. @IBOutlet weak var txtIDCard: UITextField!
  40. @IBOutlet weak var txtName: UITextField!
  41. override func viewDidLoad() {
  42. super.viewDidLoad()
  43. self.title = "结算信息"
  44. initNavLeftBackButton()
  45. viewContentWidth.constant = ScreenWidth
  46. scrollView.delegate = self
  47. txtChildBankName.delegate = self
  48. txtPhone.delegate = self
  49. }
  50. override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
  51. txtName.resignFirstResponder()
  52. txtIDCard.resignFirstResponder()
  53. txtBankCard.resignFirstResponder()
  54. txtPhone.resignFirstResponder()
  55. txtChildBankName.resignFirstResponder()
  56. }
  57. var bankCardProvCode = ""
  58. var bankCardCityCode = ""
  59. var bankCardCityName = ""
  60. var namem = ""
  61. /// 0:选择结算银行
  62. var commonSelectType = 0
  63. //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
  64. @IBAction func btnMenuClick(_ sender: AnyObject) {
  65. KeyboardHidden(gestureRecognizer: UIGestureRecognizer())
  66. switch (sender as! UIButton).tag {
  67. case 1001: // 识别身份证号
  68. let vc = AVCaptureViewController()
  69. vc.delegate = self
  70. self.present(vc, animated: true) {
  71. }
  72. break
  73. case 1013: // 识别身份证号
  74. let vc = AVCaptureViewController()
  75. vc.delegate = self
  76. vc.cardType = 1
  77. self.present(vc, animated: true) {
  78. }
  79. break
  80. case 1012://银行卡识别
  81. uploadImage(type: 3)
  82. break
  83. case 1002: // 法人证件有效期
  84. let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
  85. var defaultDate: Date!
  86. if self.txtFRYXQ.text! == "" || self.txtFRYXQ.text!.length() != 10 {
  87. defaultDate = Date()
  88. } else {
  89. defaultDate = CommonDate.getDateForString(dateStr: self.txtFRYXQ.text!, dateFormat: "yyyy-MM-dd")
  90. }
  91. //viewDatePicer.datePicker.maximumDate = Date();
  92. viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
  93. self!.txtFRYXQ.text = str
  94. }
  95. break
  96. case 1003: // 下一步
  97. if txtName.text!.length() < 1 {
  98. SVProgressHUD.showError(withStatus: "请输入结算卡姓名")
  99. return
  100. }
  101. if txtIDCard.text!.length() < 1 {
  102. SVProgressHUD.showError(withStatus: "请输入法人证件号")
  103. return
  104. }
  105. if self.txtFRYXQ.text!.length() < 1 {
  106. SVProgressHUD.showError(withStatus: "请选择法人证件有效期")
  107. return
  108. }
  109. // if(txtJSYHYXQ.text!.length() < 1)
  110. // {
  111. // SVProgressHUD.showError(withStatus: "请选择结算银行证件有效期")
  112. // return;
  113. // }
  114. if txtBankCard.text!.length() < 1 {
  115. SVProgressHUD.showError(withStatus: "请输入结算卡号")
  116. return
  117. }
  118. if txtPhone.text!.length() < 1 {
  119. SVProgressHUD.showError(withStatus: "请输入银行预留手机号")
  120. return
  121. }
  122. if txtBankName.text!.length() < 1 {
  123. SVProgressHUD.showError(withStatus: "请选择结算银行名称")
  124. return
  125. }
  126. if txtChildBankName.text!.length() < 1 {
  127. SVProgressHUD.showError(withStatus: "请输入结算银行支行名称")
  128. return
  129. }
  130. if bankCardCityCode.length() < 1 {
  131. SVProgressHUD.showError(withStatus: "请选择开户地区")
  132. return
  133. }
  134. if !btnMenu1.isSelected {
  135. SVProgressHUD.showError(withStatus: "请上传身份证正面")
  136. return
  137. }
  138. if !btnMenu2.isSelected {
  139. SVProgressHUD.showError(withStatus: "请上传身份证背面")
  140. return
  141. }
  142. if !btnMenu3.isSelected {
  143. SVProgressHUD.showError(withStatus: "请上传手持身份证照")
  144. return
  145. }
  146. appDelegate.openMerchants.settleName = txtName.text!
  147. appDelegate.openMerchants.bankcardID = txtIDCard.text!
  148. appDelegate.openMerchants.idCardNum = txtIDCard.text!
  149. appDelegate.openMerchants.legalcardValidityPeroid = txtFRYXQ.text!
  150. appDelegate.openMerchants.bankcardValidityPeroid = txtFRYXQ.text!//txtJSYHYXQ.text!
  151. appDelegate.openMerchants.accNum = txtBankCard.text!
  152. appDelegate.openMerchants.phoneShow = txtPhone.text!
  153. appDelegate.openMerchants.bankName = txtBankName.text!
  154. appDelegate.openMerchants.bankNameBranchCode = bankNameBranchCode
  155. appDelegate.openMerchants.bankNameBranchNo = bankNameBranchNo
  156. appDelegate.openMerchants.bankNameBranch = txtChildBankName.text!
  157. appDelegate.openMerchants.bankCardProvCode = bankCardProvCode
  158. appDelegate.openMerchants.bankCardCityCode = bankCardCityCode
  159. appDelegate.openMerchants.verifyDebitCardNum = ""
  160. appDelegate.openMerchants.verifyDebitPhoneYL = ""
  161. appDelegate.openMerchants.cardPositivePhoto = arrImages[0]
  162. appDelegate.openMerchants.cardNegativePhoto = arrImages[1]
  163. appDelegate.openMerchants.cardHandHoldPhoto = arrImages[2]
  164. appDelegate.openMerchants.cardPositivePhotoLocal = arrImagesLocal[0]
  165. appDelegate.openMerchants.cardNegativePhotoLocal = arrImagesLocal[1]
  166. appDelegate.openMerchants.cardHandHoldPhotoLocal = arrImagesLocal[2]
  167. toViewController(viewController: BJShopInfoViewController())
  168. break
  169. case 1004: // 结算银行证件有效期
  170. let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
  171. var defaultDate: Date!
  172. if self.txtJSYHYXQ.text! == "" || self.txtJSYHYXQ.text!.length() != 10 {
  173. defaultDate = Date()
  174. } else {
  175. defaultDate = CommonDate.getDateForString(dateStr: self.txtJSYHYXQ.text!, dateFormat: "yyyy-MM-dd")
  176. }
  177. //viewDatePicer.datePicker.maximumDate = Date();
  178. viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
  179. self!.txtJSYHYXQ.text = str
  180. }
  181. break
  182. case 1005: // 结算银行名称
  183. // commonSelectType = 0;
  184. // let vc = CommonSelectViewController();
  185. // vc.delegate = self;
  186. // vc.type = 2;
  187. // toViewController(viewController: vc);
  188. let vc = BJSelectBankViewController()
  189. vc.provinceId = ""//addressIds[0]
  190. vc.cityId = ""//addressIds[1];
  191. vc.bankName = "" //txtBank.text!;
  192. toViewController(viewController: vc)
  193. break
  194. case 1006: // 开户地区
  195. btnSelectAddressClick()
  196. break
  197. case 1007: // 正面
  198. uploadImage(type: 0)
  199. break
  200. case 1008: // 反面
  201. uploadImage(type: 1)
  202. break
  203. case 1009: // 手持身份证照
  204. uploadImage(type: 2)
  205. break
  206. case 1010: // 选择支行名称
  207. let vc = SelectBankViewController()
  208. vc.provinceId = self.bankCardProvCode//addressIds[0]
  209. vc.cityId = self.bankCardCityCode//addressIds[1];
  210. var substr = ""
  211. if self.bankCardCityName.contains("市") {
  212. let arr = self.bankCardCityName.components(separatedBy: "市")
  213. substr = arr[0]
  214. }else {
  215. substr = self.bankCardCityName
  216. }
  217. namem = self.txtBankName.text! + substr
  218. vc.bankName = namem //txtBank.text!;
  219. toViewController(viewController: vc)
  220. break
  221. default:
  222. break
  223. }
  224. }
  225. func avCaptureViewReData(_ iDInfo: IDInfo!, img: UIImage!) {
  226. if iDInfo.type == 1 {
  227. txtIDCard.text = iDInfo.num!
  228. }
  229. if iDInfo.type == 2 {
  230. txtFRYXQ.text = iDInfo.valid!
  231. }
  232. //imgShow.image = img;
  233. }
  234. var bankNameBranchCode = ""
  235. var bankNameBranchNo = ""
  236. func rebackFunction(dic: NSMutableDictionary) {
  237. if commonSelectType == 0 {
  238. txtBankName.text = dic.getString(key: "issuser_name")
  239. bankNameBranchCode = dic.getString(key: "bank_code")
  240. bankNameBranchNo = dic.getString(key: "bank_link_no")
  241. } else if commonSelectType == 1 {
  242. }
  243. }
  244. ///选择所在地区
  245. var viewSelectCity: Virgil_SelectCity!
  246. func btnSelectAddressClick() {
  247. //var viewSelectCity:Virgil_SelectCity!
  248. let addressList = CommonUntils.getPlistArrayForName(fileName: "AddressNew")
  249. if viewSelectCity == nil {
  250. viewSelectCity = Virgil_SelectCity(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: view.height()))
  251. viewSelectCity.modelType = 2
  252. viewSelectCity.initView(arrAddress: addressList) {[weak self] (dic) in
  253. self!.bankCardProvCode = self!.getString(key: "addressId1", dic: dic)
  254. self!.bankCardCityCode = self!.getString(key: "addressId2", dic: dic)
  255. self!.bankCardCityName = self!.getString(key: "addressName2", dic: dic)
  256. //self!.shopOpen.addressName1 = self!.getString(key: "addressName1", dic: dic) ;
  257. self!.txtAddress.text = dic.getString(key: "address")
  258. }
  259. self.view.addSubview(viewSelectCity)
  260. }
  261. viewSelectCity.showPickerView()
  262. }
  263. // MARK: ============上传图片============
  264. var isUpload = false
  265. var uploadImageType = 0
  266. func uploadImage(type: Int) {
  267. scrollView.contentOffset.y = (viewContentHeight.constant - (ScreenHeight - common_nav_status_height - common_bottom_height))
  268. if isUpload {
  269. return
  270. }
  271. CommonUntils.AlertView(controller: self, title: nil, message: nil, buttons: ["拍照上传", "从相册上传"], style: .actionSheet) {[weak self] (index, _) in
  272. self!.isUpload = true
  273. self!.uploadImageType = type
  274. let ipc = UIImagePickerController()
  275. if index == 0 {
  276. ipc.sourceType = .camera
  277. } else {
  278. ipc.sourceType = .photoLibrary
  279. }
  280. ipc.delegate = self!
  281. ipc.allowsEditing = false
  282. self!.present(ipc, animated: true, completion: nil)
  283. }
  284. }
  285. var imgTemp: UIImage!
  286. func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
  287. self.dismiss(animated: true) {[weak self] in
  288. var imgTemp: UIImage? = info[UIImagePickerController.InfoKey.originalImage] as? UIImage
  289. if picker.allowsEditing {
  290. imgTemp = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
  291. }
  292. if imgTemp != nil {
  293. self!.UploadFile(img: imgTemp!)
  294. } else {
  295. self!.isUpload = false
  296. SVProgressHUD.showError(withStatus: "图片选择失败,请重试")
  297. }
  298. }
  299. }
  300. func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
  301. self.isUpload = false
  302. self.dismiss(animated: true) {
  303. }
  304. }
  305. var arrImages = ["", "", "", ""]
  306. var arrImagesLocal = ["", "", "", ""]
  307. func UploadFile(img: UIImage) {
  308. MBProgressHUD.showAdded(to: self.view, animated: true)
  309. let uploadFile = QiNiuUploadFile()
  310. uploadFile.uploadFile(img: img) {[weak self] (type, str) in
  311. if type == 1 {
  312. let userLoginUrl = RequestURL.qiNiuImageUrl + str
  313. self!.arrImages[self!.uploadImageType] = userLoginUrl
  314. self!.uploadWeb(img: img)
  315. } else {
  316. self!.isUpload = false
  317. MBProgressHUD.hide(for: self!.view, animated: true)
  318. SVProgressHUD.showError(withStatus: "上传失败")
  319. }
  320. }
  321. }
  322. func uploadWeb(img: UIImage) {
  323. let manage = CommonValue.getHttp()
  324. let param = NSMutableDictionary()
  325. var url = RequestURL.uploadFile
  326. if self.uploadImageType == 0 {
  327. url = RequestURL.uploadMerchantFile
  328. param.setValue("2", forKey: "type")
  329. } else if self.uploadImageType == 1 {
  330. url = RequestURL.uploadMerchantFile
  331. param.setValue("3", forKey: "type")
  332. } else if self.uploadImageType == 2 {
  333. param.setValue("7", forKey: "type")
  334. }else if self.uploadImageType == 3 {
  335. url = RequestURL.uploadMerchantFile
  336. param.setValue("8", forKey: "type")
  337. }
  338. manage.requestSerializer.timeoutInterval = 60.0
  339. manage.post(url, parameters: param, constructingBodyWith: { (formDate) in
  340. formDate.appendPart(withFileData: img.jpegData(compressionQuality: 0.4)!, name: "fileInput", fileName: "fileInput", mimeType: "multipart/form-data")
  341. }, progress: nil, success: {[weak self] (op, json1) in
  342. self!.isUpload = false
  343. let json = json1 as! NSDictionary
  344. print(json)
  345. let succeed = json.object(forKey: "succeed") as! String
  346. if succeed == "000" {
  347. if self!.uploadImageType == 0 {
  348. let status = (json["dataInfo"] as! NSDictionary).getInt(key: "statusCode")
  349. if status == 200 {
  350. let haike = (json["dataInfo"] as! NSDictionary)["haike"] as! NSDictionary
  351. let hkResult = haike["result"] as! NSDictionary
  352. let hkResultData = hkResult["data"] as! NSDictionary
  353. self!.txtName.text = hkResultData.getString(key: "name")
  354. self!.txtIDCard.text = hkResultData.getString(key: "idNumber")
  355. self!.uploadWebImg(img: img)
  356. } else {
  357. SVProgressHUD.showError(withStatus: "身份证识别失败,请重新上传!")
  358. }
  359. } else if self!.uploadImageType == 1 {
  360. let status = (json["dataInfo"] as! NSDictionary).getInt(key: "statusCode")
  361. if status == 200 {
  362. let haike = (json["dataInfo"] as! NSDictionary)["haike"] as! NSDictionary
  363. let hkResult = haike["result"] as! NSDictionary
  364. let hkResultData = hkResult["data"] as! NSDictionary
  365. let str = hkResultData.getString(key: "validity") as NSString
  366. let saleArray = str.components(separatedBy: "-")
  367. if saleArray.count > 1 {
  368. let strNew = saleArray[1]
  369. let newArray = strNew.components(separatedBy: ".")
  370. if newArray.count > 1 {
  371. self!.txtFRYXQ.text = "\(newArray[0])"+"-"+"\(newArray[1])"+"-"+"\(newArray[2])"
  372. }else {
  373. SVProgressHUD.showInfo(withStatus: "识别身份证有效期为长期,请自己再手动选择日期哦")
  374. self!.txtFRYXQ.text = ""
  375. }
  376. }else {
  377. SVProgressHUD.showError(withStatus: "身份证识别失败,请重新上传!")
  378. }
  379. self!.uploadWebImg(img: img)
  380. } else {
  381. SVProgressHUD.showError(withStatus: "身份证识别失败,请重新上传!")
  382. }
  383. } else if self!.uploadImageType == 2 {
  384. self!.btnMenu3.isSelected = true
  385. self!.imgCard3.loadImage(imgUrl: self!.arrImages[self!.uploadImageType], defaultImage: "")
  386. self!.arrImagesLocal[self!.uploadImageType] = (json["dataInfo"] as! NSDictionary).getString(key: "url")
  387. }else if self!.uploadImageType == 3 {
  388. let status = (json["dataInfo"] as! NSDictionary).getInt(key: "statusCode")
  389. if status == 200 {
  390. let haike = (json["dataInfo"] as! NSDictionary)["haike"] as! NSDictionary
  391. let hkResult = haike["result"] as! NSDictionary
  392. let hkResultData = hkResult["data"] as! NSDictionary
  393. // self!.txtBankName.text = hkResultData.getString(key: "bankName")
  394. self!.txtBankCard.text = hkResultData.getString(key: "cardNumber")
  395. self!.loadData(key: hkResultData.getString(key: "bankName"))
  396. } else {
  397. SVProgressHUD.showError(withStatus: "银行卡识别失败,请重新上传或手动输入")
  398. }
  399. }
  400. } else {
  401. SVProgressHUD.showInfo(withStatus: "上传失败,请重新上传")
  402. }
  403. MBProgressHUD.hide(for: self!.view, animated: true)
  404. }) {[weak self] (_, _) in
  405. self!.isUpload = false
  406. SVProgressHUD.showInfo(withStatus: "上传失败,请重新上传")
  407. MBProgressHUD.hide(for: self!.view, animated: true)
  408. }
  409. }
  410. func loadData(key: String) //str:String
  411. {
  412. if (self.txtBankName.text == "未识别银行"){
  413. return
  414. }
  415. let url = RequestURL.qybFindBankList
  416. let params = NSMutableDictionary()
  417. if key != "" {
  418. params.setValue(key, forKey: "issuser_name")
  419. } else {
  420. params.setValue(self.txtBankName.text!, forKey: "issuser_name")
  421. }
  422. loadDataList(url: url, params: params, tag: 1001)
  423. }
  424. override func returnData(tag: Int) {
  425. if self.arrData.count > 0 {
  426. let dicNew = NSMutableDictionary(dictionary: self.arrData[0] as! NSDictionary)
  427. mainViewControllerIsGoValue = dicNew.getString(key: "issuser_name")
  428. mainViewControllerIsGoValue1 = dicNew.getString(key: "bank_code")
  429. mainViewControllerIsGoValue2 = dicNew.getString(key: "bank_link_no")
  430. txtBankName.text = mainViewControllerIsGoValue
  431. bankNameBranchCode = mainViewControllerIsGoValue1
  432. bankNameBranchNo = mainViewControllerIsGoValue2
  433. }else{
  434. txtBankName.text = ""
  435. SVProgressHUD.showInfo(withStatus: "请手动选择结算银行名称")
  436. }
  437. }
  438. func uploadWebImg(img: UIImage) {
  439. let manage = CommonValue.getHttp()
  440. let param = NSMutableDictionary()
  441. let url = RequestURL.uploadFile
  442. if self.uploadImageType == 0 {
  443. param.setValue("2", forKey: "type")
  444. } else if self.uploadImageType == 1 {
  445. param.setValue("3", forKey: "type")
  446. }
  447. manage.requestSerializer.timeoutInterval = 60.0
  448. manage.post(url, parameters: param, constructingBodyWith: { (formDate) in
  449. formDate.appendPart(withFileData: img.jpegData(compressionQuality: 0.4)!, name: "fileInput", fileName: "fileInput", mimeType: "multipart/form-data")
  450. }, progress: nil, success: {[weak self] (op, json1) in
  451. self!.isUpload = false
  452. let json = json1 as! NSDictionary
  453. print(json)
  454. let succeed = json.object(forKey: "succeed") as! String
  455. if succeed == "000" {
  456. if self!.uploadImageType == 0 {
  457. self!.btnMenu1.isSelected = true
  458. self!.imgCard1.loadImage(imgUrl: self!.arrImages[self!.uploadImageType], defaultImage: "")
  459. self!.arrImagesLocal[self!.uploadImageType] = (json["dataInfo"] as! NSDictionary).getString(key: "url")
  460. } else if self!.uploadImageType == 1 {
  461. self!.btnMenu2.isSelected = true
  462. self!.imgCard2.loadImage(imgUrl: self!.arrImages[self!.uploadImageType], defaultImage: "")
  463. self!.arrImagesLocal[self!.uploadImageType] = (json["dataInfo"] as! NSDictionary).getString(key: "url")
  464. }
  465. } else {
  466. SVProgressHUD.showInfo(withStatus: "上传失败,请重新上传")
  467. }
  468. MBProgressHUD.hide(for: self!.view, animated: true)
  469. }) {[weak self] (_, _) in
  470. self!.isUpload = false
  471. SVProgressHUD.showInfo(withStatus: "上传失败,请重新上传")
  472. MBProgressHUD.hide(for: self!.view, animated: true)
  473. }
  474. }
  475. func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
  476. var top: CGFloat = 0
  477. if textField.tag == 2001 {
  478. top = 406
  479. } else if textField.tag == 20011 {
  480. top = 457
  481. } else if textField.tag == 2002 {
  482. top = 558
  483. } else if textField.tag == 2003 {
  484. top = 609
  485. }
  486. scrollView.contentOffset.y = top - (viewContentHeight.constant - (ScreenHeight - common_nav_status_height - common_bottom_height)) / 2
  487. // scrollView.contentOffset.y = (viewContentHeight.constant - (ScreenHeight - common_nav_status_height - common_bottom_height));
  488. //top - (viewContentHeight.constant - (ScreenHeight - common_nav_status_height - common_bottom_height)) / 2
  489. return true
  490. }
  491. func scrollViewDidScroll(_ scrollView: UIScrollView) {
  492. print("==\(scrollView.contentOffset.y)===")
  493. }
  494. override func viewWillAppear(_ animated: Bool) {
  495. super.viewWillAppear(animated)
  496. if mainViewControllerIsGo {
  497. mainViewControllerIsGo = false
  498. if mainViewControllerIsGoType == 0 {
  499. txtChildBankName.text = mainViewControllerIsGoValue
  500. } else if mainViewControllerIsGoType == 9901 {
  501. txtBankName.text = mainViewControllerIsGoValue
  502. bankNameBranchCode = mainViewControllerIsGoValue1
  503. bankNameBranchNo = mainViewControllerIsGoValue2
  504. }
  505. }
  506. }
  507. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  508. super.init(nibName: "BJBusinessViewController", bundle: nil)
  509. }
  510. required init?(coder aDecoder: NSCoder) {
  511. fatalError("init(coder:) has not been implemented")
  512. }
  513. }