SMobileChangeViewController.swift 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // SMobileChangeViewController.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2016/10/17.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import Alamofire
  10. import AlamofireImage
  11. import AlamofireObjectMapper
  12. import ObjectMapper
  13. import O2OA_Auth_SDK
  14. class SMobileChangeViewController: UIViewController {
  15. @IBOutlet weak var modifyButton: UIButton!
  16. @IBOutlet weak var phoneNumberLabel: UILabel!
  17. override func awakeFromNib() {
  18. }
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21. let mobile = O2AuthSDK.shared.bindDevice()?.mobile
  22. self.phoneNumberLabel.text = mobile
  23. self.modifyButton.layer.borderWidth = 1.0
  24. self.modifyButton.layer.cornerRadius = 20
  25. self.modifyButton.layer.masksToBounds = true
  26. self.modifyButton.layer.borderColor = RGB(251, g: 71, b: 71).cgColor
  27. }
  28. override func didReceiveMemoryWarning() {
  29. super.didReceiveMemoryWarning()
  30. // Dispose of any resources that can be recreated.
  31. }
  32. @IBAction func modifyMobileAction(_ sender: UIButton) {
  33. let confirmController = UIAlertController(title: "", message: "", preferredStyle: .alert)
  34. //属性文本
  35. let str = "操作前需要验证你的登录密码"
  36. let titleAttribText = NSMutableAttributedString(string: str)
  37. titleAttribText.addAttribute(NSAttributedString.Key.font, value: UIFont(name: "PingFangSC-Thin", size: 13.0)!, range: NSMakeRange(0, str.length))
  38. confirmController.setValue(titleAttribText, forKey: "attributedMessage")
  39. confirmController.addTextField { (textField) in
  40. textField.attributedPlaceholder = NSAttributedString(string: "请输入登录密码", attributes:[NSAttributedString.Key.font:UIFont(name: "PingFangSC-Thin", size: 12.0)!])
  41. }
  42. let cancelAction = UIAlertAction(title: "取消", style: .cancel) { (action) in
  43. }
  44. cancelAction.setValue(RGB(51, g: 51, b: 51), forKey: "titleTextColor")
  45. let okAction = UIAlertAction(title: "确定", style: .destructive) { (action) in
  46. if let inputText = confirmController.textFields?[0].text {
  47. //验证
  48. let account = O2AuthSDK.shared.myInfo()
  49. if inputText == account?.mobile {
  50. //修改手机号码界面
  51. self.performSegue(withIdentifier: "showModifyActionSegue", sender: nil)
  52. }else{
  53. ProgressHUD.showError("密码错误")
  54. }
  55. }
  56. }
  57. confirmController.addAction(cancelAction)
  58. confirmController.addAction(okAction)
  59. self.present(confirmController, animated: true, completion: nil)
  60. }
  61. }