SMobileModifyViewController.swift 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // SMobileModifyViewController.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2016/10/17.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import Eureka
  10. import Alamofire
  11. import AlamofireImage
  12. import AlamofireObjectMapper
  13. import ObjectMapper
  14. class SMobileModifyViewController: FormViewController {
  15. override func viewDidLoad() {
  16. super.viewDidLoad()
  17. self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "更新", style: .plain, target: self, action:#selector(self.modifyButtonAction(sender:)))
  18. self.navigationItem.rightBarButtonItem?.isEnabled = false
  19. LabelRow.defaultCellUpdate = {
  20. cell,row in
  21. cell.textLabel?.font = setting_content_textFont
  22. cell.textLabel?.textColor = setting_content_textColor
  23. cell.accessoryType = .disclosureIndicator
  24. }
  25. TextRow.defaultCellUpdate = {
  26. cell,row in
  27. cell.textLabel?.font = setting_content_textFont
  28. cell.textLabel?.textColor = setting_content_textColor
  29. }
  30. PhoneRow.defaultCellUpdate = {
  31. cell,row in
  32. cell.textLabel?.font = setting_content_textFont
  33. cell.textLabel?.textColor = setting_content_textColor
  34. }
  35. form +++ Section()
  36. <<< LabelRow() {
  37. row in
  38. row.title = "国家和地区"
  39. row.value = "+86"
  40. }
  41. +++ Section()
  42. <<< PhoneRow("phoneNumber"){
  43. row in
  44. row.title = "手机号码"
  45. row.placeholder = "请输入手机号"
  46. }.cellUpdate({ (cell, row) in
  47. self.isEnableAction()
  48. })
  49. <<< TextRow("vaildCode"){
  50. row in
  51. row.title = "确认手机号"
  52. row.placeholder = "确认手机号"
  53. }.cellUpdate({ (cell, row) in
  54. self.isEnableAction()
  55. })
  56. }
  57. private func isEnableAction(){
  58. let p1 = form.rowBy(tag: "phoneNumber") as! PhoneRow
  59. let p2 = form.rowBy(tag: "vaildCode") as! TextRow
  60. if let _ = p1.value,let _ = p2.value {
  61. self.navigationItem.rightBarButtonItem?.isEnabled = true
  62. }else{
  63. self.navigationItem.rightBarButtonItem?.isEnabled = false
  64. }
  65. }
  66. @objc func modifyButtonAction(sender:Any){
  67. let p1 = form.rowBy(tag: "phoneNumber") as! PhoneRow
  68. let p2 = form.rowBy(tag: "vaildCode") as! TextRow
  69. if let _ = p1.value,let _ = p2.value {
  70. }
  71. }
  72. override func didReceiveMemoryWarning() {
  73. super.didReceiveMemoryWarning()
  74. // Dispose of any resources that can be recreated.
  75. }
  76. }