SettingViewController.swift 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // SettingViewController.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/7/6.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import Alamofire
  10. import AlamofireImage
  11. import AlamofireObjectMapper
  12. import SwiftyJSON
  13. import SDWebImage
  14. import CocoaLumberjack
  15. import O2OA_Auth_SDK
  16. import Flutter
  17. class SettingViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
  18. @IBOutlet weak var settingHeaderView: SettingHeaderView!
  19. @IBOutlet weak var iconImageView: UIImageView!
  20. @IBOutlet weak var nameLabel: UILabel!
  21. @IBOutlet weak var settingItemTableView: UITableView!
  22. @IBOutlet weak var SettingHeaderViewTopConstraint: NSLayoutConstraint!
  23. var itemModels:[Int:[SettingHomeCellModel]] {
  24. let item1 = SettingHomeCellModel(iconName: "setting_accout", title: "账号与安全", status: nil,segueIdentifier:"showInfoAndSecuritySegue")
  25. let itemSkin = SettingHomeCellModel(iconName: "icon_skin", title: "个性换肤", status: nil,segueIdentifier:"showSkinViewSegue")
  26. let item2 = SettingHomeCellModel(iconName: "setting_newMessage", title: "新消息通知", status: nil,segueIdentifier:"showMessageNotiSegue")
  27. let item3 = SettingHomeCellModel(iconName: "setting_common", title: "通用", status: nil,segueIdentifier:"showCommonSegue")
  28. // let item4 = SettingHomeCellModel(iconName: "setting_myCRM", title: "我的客服", status: nil,segueIdentifier:"showServiceSegue")
  29. // let item5 = SettingHomeCellModel(iconName: "setting_ideaback", title: "意见反馈", status: nil,segueIdentifier:"showIdeaBackSegue")
  30. let item6 = SettingHomeCellModel(iconName: "setting_about", title: "关于", status: nil,segueIdentifier:"showAboutSegue")
  31. return [0:[item1],1:[itemSkin, item2,item3],2:[item6]]
  32. }
  33. override func viewWillAppear(_ animated: Bool) {
  34. self.navigationController?.navigationBar.isHidden = true
  35. }
  36. override func viewWillDisappear(_ animated: Bool) {
  37. self.navigationController?.navigationBar.isHidden = false
  38. }
  39. override func viewDidLoad() {
  40. super.viewDidLoad()
  41. //更新头像之后刷新
  42. NotificationCenter.default.addObserver(self, selector: #selector(loadAvatar), name: Notification.Name("reloadMyIcon"), object: nil)
  43. if #available(iOS 11.0, *) {
  44. let topConstant = CGFloat(0 - IOS11_TOP_STATUSBAR_HEIGHT)
  45. self.SettingHeaderViewTopConstraint.constant = topConstant
  46. }
  47. self.settingHeaderView.theme_backgroundColor = ThemeColorPicker(keyPath: "Base.base_color")
  48. self.iconImageView.layer.masksToBounds = true
  49. self.iconImageView.layer.cornerRadius = 75 / 2.0
  50. self.iconImageView.layer.borderColor = UIColor.white.cgColor
  51. self.iconImageView.layer.borderWidth = 1
  52. self.settingItemTableView.delegate = self
  53. self.settingItemTableView.dataSource = self
  54. self.loadAvatar()
  55. }
  56. override var preferredStatusBarStyle : UIStatusBarStyle {
  57. return .lightContent
  58. }
  59. func numberOfSections(in tableView: UITableView) -> Int {
  60. return itemModels.keys.count
  61. }
  62. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  63. return (itemModels[section]?.count)!
  64. }
  65. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  66. let cell = tableView.dequeueReusableCell(withIdentifier: "SettingHomeCellIdentifier", for: indexPath) as! SettingHomeCell
  67. cell.cellModel = itemModels[(indexPath as NSIndexPath).section]![(indexPath as NSIndexPath).row]
  68. return cell
  69. }
  70. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  71. let cellModel = self.itemModels[indexPath.section]?[indexPath.row]
  72. if let segue = cellModel?.segueIdentifier {
  73. if segue == "showIdeaBackSegue" {
  74. // PgyManager.shared().showFeedbackView()
  75. // self.testShowPicker()
  76. }else{
  77. self.performSegue(withIdentifier: segue, sender: nil)
  78. }
  79. }
  80. }
  81. @IBAction func showPersonDetail(_ sender: UITapGestureRecognizer) {
  82. self.performSegue(withIdentifier: "showPersonSegue", sender: nil)
  83. }
  84. // In a storyboard-based application, you will often want to do a little preparation before navigation
  85. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  86. }
  87. @objc private func loadAvatar() {
  88. DDLogInfo("刷新头像和名字。。。。。。。。。。。。。。。。。。。。。")
  89. let me = O2AuthSDK.shared.myInfo()
  90. self.nameLabel.text = me?.name
  91. let avatarUrlString = AppDelegate.o2Collect.generateURLWithAppContextKey(ContactContext.contactsContextKeyV2, query: ContactContext.personIconByNameQueryV2, parameter: ["##name##":me?.id as AnyObject])
  92. let avatarUrl = URL(string: avatarUrlString!)
  93. self.iconImageView.hnk_setImageFromURL(avatarUrl!)
  94. }
  95. }