SInfoAndSecurityViewController.swift 4.5 KB

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