123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- //
- // QuickOpenViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/27.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class QuickOpenViewController: BaseViewController {
- @IBOutlet weak var btnGetCode: CusButtonGetCode!
- @IBOutlet weak var txtCode: UITextField!
- @IBOutlet weak var txtPhone: UITextField!
- var shopOpen = ShopOpenEntity()
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "快速开通"
- initNavLeftBackButton()
- btnGetCode.setCornerRadius(size: 4)
- }
- // override func keyboardWasHidden(noti: NSNotification) {
- // txtCode.resignFirstResponder()
- // txtPhone.resignFirstResponder();
- // }
- @IBAction func btnGetCodeClick(_ sender: Any) {
- if txtPhone.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入手机号")
- return
- }
- if txtPhone.text!.length() < 11 {
- SVProgressHUD.showError(withStatus: "请输入正确的手机号")
- return
- }
- getCode()
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txtPhone.resignFirstResponder()
- txtCode.resignFirstResponder()
- }
- @IBAction func btnNextClick(_ sender: Any) {
- //
- // txtPhone.text = "15411111115";
- // self.shopOpen.phone = txtPhone.text!;
- // saveAppuser();
- // return;
- //// self.shopOpen.phone = txtPhone.text!;
- //// let vc = PersonalBaseViewController()
- //// self.shopOpen.phone = "14811122234";
- //// vc.shopOpen = self.shopOpen;
- //// toViewController(viewController:vc);
- // saveAppuser();
- // return;
- if txtPhone.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入手机号")
- return
- }
- if txtPhone.text!.length() < 11 {
- SVProgressHUD.showError(withStatus: "请输入正确的手机号")
- return
- }
- if txtCode.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入验证码")
- return
- }
- if txtCode.text!.length() < 4 {
- SVProgressHUD.showError(withStatus: "请输入正确的验证码")
- return
- }
- checkCode()
- }
- // MARK: =============加载数据===============
- func getCode() {
- let url = RequestURL.getCode
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "phone")
- params.setValue("5", forKey: "type")
- loadDataInfo(url: url, params: params, tag: 1001)
- }
- func checkCode() {
- let url = RequestURL.verificationCode
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "phone")
- params.setValue("5", forKey: "type")
- params.setValue(txtCode.text!, forKey: "code")
- loadDataInfo(url: url, params: params, tag: 1002)
- }
- let dicHK = NSMutableDictionary()
- //上报海科
- func saveAppuser() {
- let url = RequestURL.saveAppuser
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "regAccno")
- loadDataInfo(url: url, params: params, tag: 1003, reDic: dicHK)
- }
- let dicLocalBase = NSMutableDictionary()
- func loadLocalBaseInfo() {
- let url = RequestURL.hkMerchantInfo
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "regAccno")
- loadDataInfo(url: url, params: params, tag: 1004, reDic: dicLocalBase)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- btnGetCode.startGetCode()
- } else if tag == 1002 {
- let state = dicData.getInt(key: "state")
- if state == 1 {
- saveAppuser()
- } else {
- SVProgressHUD.showError(withStatus: "验证码不正确,请重新输入")
- }
- } else if tag == 1003 {
- let dichaike = dicHK["haike"] as? NSDictionary
- if dichaike != nil {
- let dicMessage = dichaike!["message"] as? NSDictionary
- if dicMessage != nil {
- if dicMessage!.getString(key: "code") == "success" {
- self.shopOpen.phone = txtPhone.text!
- let vc = PersonalBaseViewController()
- vc.shopOpen = self.shopOpen
- toViewController(viewController: vc)
- } else if dicMessage!.getString(key: "code") == "1111" {
- loadLocalBaseInfo()
- } else {
- SVProgressHUD.showError(withStatus: dicMessage!.getString(key: "content"))
- }
- } else {
- SVProgressHUD.showError(withStatus: "提交海科失败,请稍后重试!")
- }
- } else {
- SVProgressHUD.showError(withStatus: "提交海科失败,请稍后重试!")
- }
- } else if tag == 1004 {
- if dicLocalBase.getInt(key: "step") == 0 {
- self.shopOpen.phone = txtPhone.text!
- let vc = PersonalBaseViewController()
- vc.shopOpen = self.shopOpen
- toViewController(viewController: vc)
- } else {
- let dicHkMerchantInfo = dicLocalBase["hkMerchantInfo"] as? NSDictionary
- if dicHkMerchantInfo != nil {
- self.shopOpen.companyName = dicHkMerchantInfo!.getString(key: "companyName")
- self.shopOpen.name = dicHkMerchantInfo!.getString(key: "applicantName")
- self.shopOpen.card = dicHkMerchantInfo!.getString(key: "applicantCard")
- self.shopOpen.creditCardNum = dicHkMerchantInfo!.getString(key: "creditCardNum")
- self.shopOpen.creditCardPhone = dicHkMerchantInfo!.getString(key: "creditCardPhone")
- self.shopOpen.shopName = dicHkMerchantInfo!.getString(key: "shopName")
- self.shopOpen.addressDetail = dicHkMerchantInfo!.getString(key: "shopAddress")
- self.shopOpen.addressId1 = dicHkMerchantInfo!.getString(key: "shopProvinceId")
- self.shopOpen.addressName1 = dicHkMerchantInfo!.getString(key: "shopProvinceName")
- self.shopOpen.addressName2 = dicHkMerchantInfo!.getString(key: "shopCityName")
- self.shopOpen.addressId2 = dicHkMerchantInfo!.getString(key: "shopCityId")
- self.shopOpen.addressName3 = dicHkMerchantInfo!.getString(key: "shopAreaName")
- self.shopOpen.addressId3 = dicHkMerchantInfo!.getString(key: "shopAreaId")
- self.shopOpen.pmmerId = dicHkMerchantInfo!.getString(key: "pmmerId")
- self.shopOpen.phone = txtPhone.text!
- let vc = PersonalBindCardViewController()
- vc.shopOpen = self.shopOpen
- toViewController(viewController: vc)
- } else {
- SVProgressHUD.showError(withStatus: "提交海科失败,请稍后重试!")
- }
- }
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "QuickOpenViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|