SInfoAndSecurityViewController.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // SInfoAndSecurityViewController.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. class SInfoAndSecurityViewController: FormViewController {
  11. var bioType = O2BiometryType.None
  12. var typeTitle = "生物识别登录"
  13. var typeValue = "功能不可用"
  14. override func viewDidLoad() {
  15. super.viewDidLoad()
  16. let account = O2AuthSDK.shared.myInfo()
  17. LabelRow.defaultCellUpdate = {
  18. cell,row in
  19. cell.textLabel?.font = setting_content_textFont
  20. cell.textLabel?.textColor = setting_content_textColor
  21. cell.detailTextLabel?.font = setting_value_textFont
  22. cell.detailTextLabel?.textColor = setting_value_textColor
  23. cell.accessoryType = .disclosureIndicator
  24. }
  25. if O2IsConnect2Collect {
  26. let unit = O2AuthSDK.shared.bindUnit()
  27. form +++ Section()
  28. <<< LabelRow(){
  29. $0.title = "绑定服务器"
  30. $0.value = unit?.name
  31. }.cellUpdate({ (cell, row) in
  32. cell.accessoryType = .none
  33. })
  34. }
  35. form +++ Section()
  36. <<< LabelRow(){
  37. $0.title = "登录帐号"
  38. $0.value = account?.name
  39. }.cellUpdate({ (cell, row) in
  40. cell.accessoryType = .none
  41. })
  42. <<< LabelRow(){
  43. $0.title = "登录密码"
  44. $0.value = "修改密码"
  45. }.onCellSelection({ (cell,row) in
  46. self.performSegue(withIdentifier: "showPassworChangeSegue", sender: nil)
  47. })
  48. form +++ Section()
  49. <<< LabelRow("bioAuthRow"){
  50. $0.title = typeTitle
  51. $0.value = typeValue
  52. }.onCellSelection({ (cell, row) in
  53. if self.bioType != O2BiometryType.None {
  54. self.performSegue(withIdentifier: "showAccountSecSegue", sender: nil)
  55. }else {
  56. self.showError(title: "手机系统未开启或不支持识别功能")
  57. }
  58. })
  59. if O2IsConnect2Collect {
  60. let mobile = O2AuthSDK.shared.bindDevice()?.mobile
  61. form +++ Section()
  62. <<< LabelRow() {
  63. $0.title = "变更手机号码"
  64. $0.value = mobile
  65. }.onCellSelection({ (cell,row) in
  66. self.performSegue(withIdentifier: "showMobileChangeSegue", sender: nil)
  67. })
  68. form +++ Section()
  69. <<< LabelRow() {
  70. $0.title = "设备"
  71. $0.value = "常用设备管理"
  72. }.onCellSelection({ (cell, row) in
  73. self.performSegue(withIdentifier: "showDeviceListSegue", sender: nil)
  74. })
  75. }
  76. }
  77. override func viewWillAppear(_ animated: Bool) {
  78. super.viewWillAppear(animated)
  79. // 显示的时候刷新数据
  80. self.checkBioType()
  81. let authRow = self.form.rowBy(tag: "bioAuthRow") as? LabelRow
  82. authRow?.title = typeTitle
  83. authRow?.value = typeValue
  84. authRow?.updateCell()
  85. }
  86. private func checkBioType() {
  87. let bioAuthUser = AppConfigSettings.shared.bioAuthUser
  88. var isAuthed = false
  89. //判断是否当前绑定的服务器的
  90. if !bioAuthUser.isBlank {
  91. let array = bioAuthUser.split("^^")
  92. if array.count == 2 {
  93. if array[0] == O2AuthSDK.shared.bindUnit()?.id {
  94. isAuthed = true
  95. }
  96. }
  97. }
  98. bioType = O2BioLocalAuth.shared.checkBiometryType()
  99. switch bioType {
  100. case O2BiometryType.FaceID:
  101. typeTitle = "人脸识别登录"
  102. typeValue = (isAuthed ? "已开启":"未开启")
  103. break
  104. case O2BiometryType.TouchID:
  105. typeTitle = "指纹识别登录"
  106. typeValue = (isAuthed ? "已开启":"未开启")
  107. break
  108. case O2BiometryType.None:
  109. typeTitle = "生物识别登录"
  110. typeValue = "功能不可用"
  111. break
  112. }
  113. }
  114. override func didReceiveMemoryWarning() {
  115. super.didReceiveMemoryWarning()
  116. // Dispose of any resources that can be recreated.
  117. }
  118. }