BJHKPhoneViewController.swift 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // QuickOpenViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/3/27.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class BJHKPhoneViewController: BaseViewController {
  10. @IBOutlet weak var btnGetCode: CusButtonGetCode!
  11. @IBOutlet weak var txtCode: UITextField!
  12. @IBOutlet weak var txtPhone: UITextField!
  13. var shopOpen: ShopOpenEntity!
  14. @IBOutlet weak var btnXY: UIButton!
  15. override func viewDidLoad() {
  16. super.viewDidLoad()
  17. self.title = "快速开通"
  18. initNavLeftBackButton()
  19. btnGetCode.setCornerRadius(size: 4)
  20. }
  21. @IBAction func btnGetCodeClick(_ sender: Any) {
  22. if txtPhone.text!.length() < 1 {
  23. SVProgressHUD.showError(withStatus: "请输入手机号")
  24. return
  25. }
  26. if txtPhone.text!.length() < 11 {
  27. SVProgressHUD.showError(withStatus: "请输入正确的手机号")
  28. return
  29. }
  30. if !btnXY.isSelected {
  31. SVProgressHUD.showError(withStatus: "请先阅读并同意协议")
  32. return
  33. }
  34. getCode()
  35. }
  36. override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
  37. txtPhone.resignFirstResponder()
  38. txtCode.resignFirstResponder()
  39. }
  40. @IBAction func btnMenuClick(_ sender: AnyObject) {
  41. switch (sender as! UIButton).tag {
  42. case 1001: // 同意协议
  43. btnXY.isSelected = !btnXY.isSelected
  44. break
  45. case 1002: //
  46. break
  47. case 1003: //
  48. break
  49. case 1004: //
  50. break
  51. case 1005: //
  52. break
  53. case 1006: //
  54. break
  55. default:
  56. break
  57. }
  58. }
  59. @IBAction func btnNextClick(_ sender: Any) {
  60. // appDelegate.openMerchants.userId = CommonValue.getUserId();
  61. // appDelegate.openMerchants.phone = txtPhone.text!
  62. // toViewController(viewController: BJShopInfoViewController());
  63. // return;
  64. if txtPhone.text!.length() < 1 {
  65. SVProgressHUD.showError(withStatus: "请输入手机号")
  66. return
  67. }
  68. if txtPhone.text!.length() < 11 {
  69. SVProgressHUD.showError(withStatus: "请输入正确的手机号")
  70. return
  71. }
  72. if txtCode.text!.length() < 1 {
  73. SVProgressHUD.showError(withStatus: "请输入验证码")
  74. return
  75. }
  76. if txtCode.text!.length() < 4 {
  77. SVProgressHUD.showError(withStatus: "请输入正确的验证码")
  78. return
  79. }
  80. if !btnXY.isSelected {
  81. SVProgressHUD.showError(withStatus: "请先阅读并同意协议")
  82. return
  83. }
  84. checkCode()
  85. }
  86. // MARK: =============加载数据===============
  87. func getCode() {
  88. let url = RequestURL.getCode
  89. let params = NSMutableDictionary()
  90. params.setValue(txtPhone.text!, forKey: "phone")
  91. params.setValue("5", forKey: "type")
  92. loadDataInfo(url: url, params: params, tag: 1001)
  93. }
  94. func checkCode() {
  95. let url = RequestURL.verificationCode
  96. let params = NSMutableDictionary()
  97. params.setValue(txtPhone.text!, forKey: "phone")
  98. params.setValue("5", forKey: "type")
  99. params.setValue(txtCode.text!, forKey: "code")
  100. loadDataInfo(url: url, params: params, tag: 1002)
  101. }
  102. override func returnData(tag: Int) {
  103. if tag == 1001 {
  104. btnGetCode.startGetCode()
  105. } else if tag == 1002 {
  106. let state = dicData.getInt(key: "state")
  107. if state == 1 {
  108. appDelegate.openMerchants.userId = CommonValue.getUserId()
  109. appDelegate.openMerchants.phone = txtPhone.text!
  110. toViewController(viewController: BJBusinessViewController())
  111. // self.shopOpen.phone = txtPhone.text!;
  112. // let vc = OpenDetailViewController()
  113. // vc.shopOpen = self.shopOpen;
  114. // vc.isSaveLocal = true;
  115. // toViewController(viewController:vc);
  116. } else {
  117. SVProgressHUD.showError(withStatus: "验证码不正确,请重新输入")
  118. }
  119. }
  120. }
  121. override func returnError(tag: Int, type: String) {
  122. }
  123. override func viewWillAppear(_ animated: Bool) {
  124. super.viewWillAppear(animated)
  125. }
  126. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  127. super.init(nibName: "BJHKPhoneViewController", bundle: nil)
  128. }
  129. required init?(coder aDecoder: NSCoder) {
  130. fatalError("init(coder:) has not been implemented")
  131. }
  132. }