Commit 48923549 authored by Steven杜宇's avatar Steven杜宇

// 人脉

parent ef34a84a
......@@ -13,6 +13,7 @@ class YHMyNameCardViewController: YHBaseViewController {
var userId: String = ""
var cardInfoArr:[YHUserNameCardInfo] = []
let viewModel = YHMatchUserViewModel()
let authorModel = YHInformationAuthorizeViewModel()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
tableView.estimatedSectionHeaderHeight = 100
......@@ -200,6 +201,12 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
extension YHMyNameCardViewController {
func requestAuthorization() {
self.authorModel.requestUserAuthorization { success, error in
self.requestNameCardInfo()
}
}
func requestNameCardInfo() {
self.viewModel.getUserNameCardInfo(uid: self.userId) {
success, error in
......
......@@ -79,6 +79,8 @@ class YHUserNameCardInfo: SmartCodable {
// 自定义属性
var type:YHNameCardInfoType = .unknown
var isHiddenEducation = false
var isHiddenWorkExperience = false
required init() {
......
......@@ -7,6 +7,7 @@
//
import UIKit
import AttributedString
class YHMyNameCardAvatarInfoCell: UITableViewCell {
typealias EditBlock = () -> ()
......@@ -19,7 +20,31 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
if let url = URL(string: self.userModel.avatar) {
self.headImgV.kf.setImage(with: url, placeholder: UIImage(named: "people_head_default"))
}
self.nameLabel.text = self.userModel.username
let city = self.userModel.address.city + "市"
self.cityLabel.text = city
let cityWidth = self.getWith(font: self.cityLabel.font, height: 20, string: city)
self.cityLabel.frame = CGRectMake(0, 0, cityWidth+8, 20)
self.zodiacLabel.text = self.userModel.zodiac
if self.userModel.address.city.isEmpty && self.userModel.zodiac.isEmpty {
self.nameTextView.attributed.text = """
\(self.userModel.username, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:18)))
"""
} else if self.userModel.zodiac.isEmpty {
self.nameTextView.attributed.text = """
\(self.userModel.username, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:18))) \(.view(self.cityLabel, .original(.center)))
"""
} else if self.userModel.address.city.isEmpty {
self.nameTextView.attributed.text = """
\(self.userModel.username, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:18))) \(.view(self.zodiacLabel, .original(.center)))
"""
} else {
self.nameTextView.attributed.text = """
\(self.userModel.username, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:18))) \(.view(self.cityLabel, .original(.center))) \(.view(self.zodiacLabel, .original(.center)))
"""
}
self.professionalLabel.text = self.userModel.position
self.detailLabel.text = self.userModel.signature
self.signImgV.isHidden = !self.userModel.isSigned
......@@ -60,12 +85,15 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
return btn
}()
lazy var nameLabel:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_B(ofSize:18)
return nameLabel
lazy var nameTextView:UITextView = {
let textView = UITextView()
textView.textColor = UIColor.mainTextColor
textView.backgroundColor = .clear
textView.font = UIFont.PFSC_B(ofSize:18)
textView.isScrollEnabled = false
textView.isEditable = false
textView.isSelectable = false
return textView
}()
lazy var cityLabel:UILabel = {
......@@ -76,7 +104,18 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
label.backgroundColor = .brandMainColor8
label.layer.cornerRadius = 3.0
label.clipsToBounds = true
label.text = "上海市"
return label
}()
lazy var zodiacLabel:UILabel = {
let label = UILabel()
label.textColor = UIColor.brandMainColor
label.textAlignment = .center
label.font = UIFont.PFSC_M(ofSize:12)
label.backgroundColor = .brandMainColor8
label.layer.cornerRadius = 3.0
label.clipsToBounds = true
label.frame = CGRect(x: 0, y: 0, width: 46, height: 20)
return label
}()
......@@ -117,15 +156,11 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
self.contentView.addSubview(self.headImgV)
self.contentView.addSubview(self.signImgV)
cardView.addSubview(self.nameLabel)
cardView.addSubview(self.nameTextView)
cardView.addSubview(self.cityLabel)
cardView.addSubview(self.professionalLabel)
cardView.addSubview(self.detailLabel)
cardView.addSubview(self.editBtn)
self.nameLabel.text = "啊防守打法胜多负少"
self.professionalLabel.text = "阿迪发沙发沙发撒发生大发三大发沙发沙发上1阿斯顿发双法防"
self.detailLabel.text = "阿凡达所发生的发顺丰大沙发沙发沙发沙发沙发沙发沙发沙发沙发沙发沙发沙发发沙发"
self.cardView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
......@@ -151,34 +186,38 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
make.centerX.equalTo(self.headImgV)
}
self.nameLabel.snp.makeConstraints { make in
self.nameTextView.snp.makeConstraints { make in
make.left.equalTo(16)
make.top.equalTo(headWidth/2.0+10.0)
make.height.equalTo(25)
}
self.cityLabel.snp.makeConstraints { make in
make.left.equalTo(self.nameLabel.snp.right).offset(10)
make.centerY.equalTo(self.nameLabel)
make.height.equalTo(21)
make.width.equalTo(44)
}
self.professionalLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(self.nameLabel.snp.bottom).offset(8)
make.height.greaterThanOrEqualTo(20)
make.height.equalTo(20)
make.top.equalTo(self.nameTextView.snp.bottom).offset(8)
}
self.detailLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(self.professionalLabel.snp.bottom).offset(8)
make.height.greaterThanOrEqualTo(18)
make.height.equalTo(18)
make.bottom.equalTo(-16)
}
self.professionalLabel.setContentCompressionResistancePriority(.required, for: .vertical)
self.professionalLabel.setContentHuggingPriority(.required, for: .vertical)
self.detailLabel.setContentCompressionResistancePriority(.required, for: .vertical)
self.detailLabel.setContentHuggingPriority(.required, for: .vertical)
}
func getWith(font: UIFont, height: CGFloat, string: String) -> CGFloat {
let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height)
let dic = [NSAttributedString.Key.font: font] // swift 4.2
var strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(ceil(strSize.width), strSize.height).width
}
@objc func edit() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment