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

// 名片

parent e8d86656
...@@ -126,7 +126,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -126,7 +126,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.section && indexPath.section < self.cardInfoArr.count { if 0 <= indexPath.section && indexPath.section < self.cardInfoArr.count {
let cardInfo = self.cardInfoArr[indexPath.section] let cardInfo = self.cardInfoArr[indexPath.section]
if cardInfo.type == .avatar { if cardInfo.infoType == .avatar {
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMyNameCardAvatarInfoCell.cellReuseIdentifier, for: indexPath) as? YHMyNameCardAvatarInfoCell else { return UITableViewCell() } guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMyNameCardAvatarInfoCell.cellReuseIdentifier, for: indexPath) as? YHMyNameCardAvatarInfoCell else { return UITableViewCell() }
cell.userModel = cardInfo cell.userModel = cardInfo
cell.editBlock = { [weak self] in cell.editBlock = { [weak self] in
...@@ -138,17 +138,17 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -138,17 +138,17 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
return cell return cell
} }
if cardInfo.type == .honor || cardInfo.type == .introduce { if cardInfo.infoType == .honor || cardInfo.infoType == .introduce {
guard let introCell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as? YHMyIntroductionCell else { return UITableViewCell() } guard let introCell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as? YHMyIntroductionCell else { return UITableViewCell() }
introCell.userModel = cardInfo introCell.userModel = cardInfo
introCell.editBlock = { [weak self] in introCell.editBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
if cardInfo.type == .honor { if cardInfo.infoType == .honor {
let vc = YHEditHonorViewController() let vc = YHEditHonorViewController()
vc.model = self.viewModel.nameCardInfo vc.model = self.viewModel.nameCardInfo
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} else if cardInfo.type == .introduce { } else if cardInfo.infoType == .introduce {
let vc = YHEditPersonalProfileViewController() let vc = YHEditPersonalProfileViewController()
vc.model = self.viewModel.nameCardInfo vc.model = self.viewModel.nameCardInfo
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
...@@ -157,7 +157,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -157,7 +157,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
return introCell return introCell
} }
if cardInfo.type == .education { if cardInfo.infoType == .education {
guard let eduCell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as? YHMyEducationCell else { return UITableViewCell() } guard let eduCell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as? YHMyEducationCell else { return UITableViewCell() }
eduCell.userModel = cardInfo eduCell.userModel = cardInfo
eduCell.hiddenBtnBlock = { eduCell.hiddenBtnBlock = {
...@@ -174,7 +174,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -174,7 +174,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
return eduCell return eduCell
} }
if cardInfo.type == .workExperience { if cardInfo.infoType == .workExperience {
guard let workCell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as? YHMyWorkExperienceCell else { return UITableViewCell() } guard let workCell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as? YHMyWorkExperienceCell else { return UITableViewCell() }
workCell.userModel = cardInfo workCell.userModel = cardInfo
workCell.hiddenBtnBlock = { workCell.hiddenBtnBlock = {
...@@ -191,7 +191,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -191,7 +191,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
return workCell return workCell
} }
if cardInfo.type == .topics { if cardInfo.infoType == .topics {
guard let topicCell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as? YHMyInterestTopicCell else { return UITableViewCell() } guard let topicCell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as? YHMyInterestTopicCell else { return UITableViewCell() }
topicCell.userModel = cardInfo topicCell.userModel = cardInfo
topicCell.editBlock = { [weak self] in topicCell.editBlock = { [weak self] in
...@@ -261,7 +261,7 @@ extension YHNameCardViewController { ...@@ -261,7 +261,7 @@ extension YHNameCardViewController {
// 姓名头像信息 // 姓名头像信息
let model1 = YHUserNameCardInfo() let model1 = YHUserNameCardInfo()
model1.type = .avatar model1.infoType = .avatar
model1.isCurrentUser = self.isCurrentUser model1.isCurrentUser = self.isCurrentUser
model1.updateModel(self.viewModel.nameCardInfo) model1.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model1) self.cardInfoArr.append(model1)
...@@ -273,7 +273,7 @@ extension YHNameCardViewController { ...@@ -273,7 +273,7 @@ extension YHNameCardViewController {
} }
if isShowIntroduce { if isShowIntroduce {
let model2 = YHUserNameCardInfo() let model2 = YHUserNameCardInfo()
model2.type = .introduce model2.infoType = .introduce
model2.isCurrentUser = self.isCurrentUser model2.isCurrentUser = self.isCurrentUser
model2.updateModel(self.viewModel.nameCardInfo) model2.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model2) self.cardInfoArr.append(model2)
...@@ -289,7 +289,7 @@ extension YHNameCardViewController { ...@@ -289,7 +289,7 @@ extension YHNameCardViewController {
} }
if isShowEducation { if isShowEducation {
let model3 = YHUserNameCardInfo() let model3 = YHUserNameCardInfo()
model3.type = .education model3.infoType = .education
model3.isCurrentUser = self.isCurrentUser model3.isCurrentUser = self.isCurrentUser
model3.updateModel(self.viewModel.nameCardInfo) model3.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model3) self.cardInfoArr.append(model3)
...@@ -305,7 +305,7 @@ extension YHNameCardViewController { ...@@ -305,7 +305,7 @@ extension YHNameCardViewController {
} }
if isShowWorkExperience { if isShowWorkExperience {
let model4 = YHUserNameCardInfo() let model4 = YHUserNameCardInfo()
model4.type = .workExperience model4.infoType = .workExperience
model4.isCurrentUser = self.isCurrentUser model4.isCurrentUser = self.isCurrentUser
model4.updateModel(self.viewModel.nameCardInfo) model4.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model4) self.cardInfoArr.append(model4)
...@@ -318,7 +318,7 @@ extension YHNameCardViewController { ...@@ -318,7 +318,7 @@ extension YHNameCardViewController {
} }
if isShowHonor { if isShowHonor {
let model5 = YHUserNameCardInfo() let model5 = YHUserNameCardInfo()
model5.type = .honor model5.infoType = .honor
model5.isCurrentUser = self.isCurrentUser model5.isCurrentUser = self.isCurrentUser
model5.updateModel(self.viewModel.nameCardInfo) model5.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model5) self.cardInfoArr.append(model5)
...@@ -331,7 +331,7 @@ extension YHNameCardViewController { ...@@ -331,7 +331,7 @@ extension YHNameCardViewController {
} }
if isShowTopics { if isShowTopics {
let model6 = YHUserNameCardInfo() let model6 = YHUserNameCardInfo()
model6.type = .topics model6.infoType = .topics
model6.isCurrentUser = self.isCurrentUser model6.isCurrentUser = self.isCurrentUser
model6.updateModel(self.viewModel.nameCardInfo) model6.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model6) self.cardInfoArr.append(model6)
......
...@@ -36,7 +36,7 @@ class YHConnectListViewController: YHBaseViewController { ...@@ -36,7 +36,7 @@ class YHConnectListViewController: YHBaseViewController {
}() }()
lazy var noDataView: YHEmptyDataView = { lazy var noDataView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无数据", kEmptyCommonBgName) let view = YHEmptyDataView.createView("暂无内容", kEmptyCommonBgName)
view.isHidden = true view.isHidden = true
return view return view
}() }()
......
...@@ -110,9 +110,10 @@ class YHUserNameCardInfo: SmartCodable { ...@@ -110,9 +110,10 @@ class YHUserNameCardInfo: SmartCodable {
var topics: [String] = [] var topics: [String] = []
var draftTopics: [String] = [] var draftTopics: [String] = []
var authorization: YHAuthorizationModel = YHAuthorizationModel() var authorization: YHAuthorizationModel = YHAuthorizationModel()
var type: Int = 1 // 人脉状态 1: 陌生人 3: 待验证 5: 好友
// 自定义属性 // 自定义属性
var type: YHNameCardInfoType = .unknown var infoType: YHNameCardInfoType = .unknown
var isCurrentUser = false var isCurrentUser = false
var isHiddenEducation: Bool { var isHiddenEducation: Bool {
...@@ -160,7 +161,7 @@ class YHUserNameCardInfo: SmartCodable { ...@@ -160,7 +161,7 @@ class YHUserNameCardInfo: SmartCodable {
case isSigned = "is_signed" case isSigned = "is_signed"
case companyName = "company_name" case companyName = "company_name"
case draftTopics = "draft_topics" case draftTopics = "draft_topics"
case id, avatar, username, zodiac, signature, bio, college, major, background, position, industry, honor case id, avatar, username, zodiac, signature, bio, college, major, background, position, industry, honor, type
case topics case topics
case address case address
case authorization case authorization
......
...@@ -39,6 +39,31 @@ class YHFriendRequestView: UIView { ...@@ -39,6 +39,31 @@ class YHFriendRequestView: UIView {
} }
} }
var userModel2: YHUserNameCardInfo = YHUserNameCardInfo() {
didSet {
if let url = URL(string: self.userModel2.avatar) {
self.headImgV.kf.setImage(with: url, placeholder: UIImage(named: "people_head_default"))
} else {
self.headImgV.image = UIImage(named: "people_head_default")
}
self.nameLabel.text = self.userModel2.username
// self.signImgV.isHidden = !self.userModel.isSign
var text1 = ""
var text1Arr: [String] = []
if !self.userModel2.position.isEmpty {
text1Arr.append(self.userModel2.position)
}
if !self.userModel2.industry.isEmpty {
text1Arr.append(self.userModel2.industry)
}
if text1Arr.count > 0 {
text1 = text1Arr.joined(separator: " | ")
}
self.professionalLabel.text = text1
}
}
// 底层蒙版 // 底层蒙版
lazy var blackMaskView: UIView = { lazy var blackMaskView: UIView = {
let view = UIView() let view = UIView()
......
...@@ -18,7 +18,7 @@ class YHMyIntroductionCell: UITableViewCell { ...@@ -18,7 +18,7 @@ class YHMyIntroductionCell: UITableViewCell {
self.editBtn.isHidden = !self.userModel.isCurrentUser self.editBtn.isHidden = !self.userModel.isCurrentUser
if userModel.type == .introduce { if userModel.infoType == .introduce {
self.titleLabel.text = "个人简介" self.titleLabel.text = "个人简介"
self.detailLabel.textColor = UIColor.mainTextColor70 self.detailLabel.textColor = UIColor.mainTextColor70
if !self.userModel.bio.isEmpty { if !self.userModel.bio.isEmpty {
...@@ -31,7 +31,7 @@ class YHMyIntroductionCell: UITableViewCell { ...@@ -31,7 +31,7 @@ class YHMyIntroductionCell: UITableViewCell {
} }
} }
} else if userModel.type == .honor { } else if userModel.infoType == .honor {
self.titleLabel.text = "荣誉奖项" self.titleLabel.text = "荣誉奖项"
self.detailLabel.textColor = UIColor.mainTextColor70 self.detailLabel.textColor = UIColor.mainTextColor70
if !self.userModel.honor.isEmpty { if !self.userModel.honor.isEmpty {
......
...@@ -61,9 +61,7 @@ class YHNameCardContainerViewController: YHBaseViewController { ...@@ -61,9 +61,7 @@ class YHNameCardContainerViewController: YHBaseViewController {
lazy var homePageVC: YHNameCardHomePageViewController = { lazy var homePageVC: YHNameCardHomePageViewController = {
let vc = YHNameCardHomePageViewController() let vc = YHNameCardHomePageViewController()
if let userId = YHLoginManager.shared.userModel?.id { vc.userId = self.userId
vc.userId = userId
}
return vc return vc
}() }()
......
...@@ -40,6 +40,12 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -40,6 +40,12 @@ class YHNameCardHomePageViewController: YHBaseViewController {
return tableView return tableView
}() }()
lazy var noDataView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无内容", kEmptyCommonBgName)
view.isHidden = true
return view
}()
deinit { deinit {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
} }
...@@ -61,6 +67,13 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -61,6 +67,13 @@ class YHNameCardHomePageViewController: YHBaseViewController {
make.bottom.equalToSuperview() make.bottom.equalToSuperview()
make.top.equalToSuperview() make.top.equalToSuperview()
} }
view.addSubview(noDataView)
noDataView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(72)
make.width.equalTo(KScreenWidth)
make.height.equalTo(164)
}
} }
func addObserver() { func addObserver() {
...@@ -81,7 +94,7 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -81,7 +94,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
} }
if isShowIntroduce { if isShowIntroduce {
let model2 = YHUserNameCardInfo() let model2 = YHUserNameCardInfo()
model2.type = .introduce model2.infoType = .introduce
model2.isCurrentUser = self.isCurrentUser model2.isCurrentUser = self.isCurrentUser
model2.updateModel(self.viewModel.nameCardInfo) model2.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model2) self.cardInfoArr.append(model2)
...@@ -97,7 +110,7 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -97,7 +110,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
} }
if isShowEducation { if isShowEducation {
let model3 = YHUserNameCardInfo() let model3 = YHUserNameCardInfo()
model3.type = .education model3.infoType = .education
model3.isCurrentUser = self.isCurrentUser model3.isCurrentUser = self.isCurrentUser
model3.updateModel(self.viewModel.nameCardInfo) model3.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model3) self.cardInfoArr.append(model3)
...@@ -113,7 +126,7 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -113,7 +126,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
} }
if isShowWorkExperience { if isShowWorkExperience {
let model4 = YHUserNameCardInfo() let model4 = YHUserNameCardInfo()
model4.type = .workExperience model4.infoType = .workExperience
model4.isCurrentUser = self.isCurrentUser model4.isCurrentUser = self.isCurrentUser
model4.updateModel(self.viewModel.nameCardInfo) model4.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model4) self.cardInfoArr.append(model4)
...@@ -126,7 +139,7 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -126,7 +139,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
} }
if isShowHonor { if isShowHonor {
let model5 = YHUserNameCardInfo() let model5 = YHUserNameCardInfo()
model5.type = .honor model5.infoType = .honor
model5.isCurrentUser = self.isCurrentUser model5.isCurrentUser = self.isCurrentUser
model5.updateModel(self.viewModel.nameCardInfo) model5.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model5) self.cardInfoArr.append(model5)
...@@ -139,12 +152,14 @@ class YHNameCardHomePageViewController: YHBaseViewController { ...@@ -139,12 +152,14 @@ class YHNameCardHomePageViewController: YHBaseViewController {
} }
if isShowTopics { if isShowTopics {
let model6 = YHUserNameCardInfo() let model6 = YHUserNameCardInfo()
model6.type = .topics model6.infoType = .topics
model6.isCurrentUser = self.isCurrentUser model6.isCurrentUser = self.isCurrentUser
model6.updateModel(self.viewModel.nameCardInfo) model6.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model6) self.cardInfoArr.append(model6)
} }
self.tableView.reloadData() self.tableView.reloadData()
self.noDataView.isHidden = self.cardInfoArr.count > 0
} }
} }
} }
...@@ -164,17 +179,17 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData ...@@ -164,17 +179,17 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
if 0 <= indexPath.section && indexPath.section < self.cardInfoArr.count { if 0 <= indexPath.section && indexPath.section < self.cardInfoArr.count {
let cardInfo = self.cardInfoArr[indexPath.section] let cardInfo = self.cardInfoArr[indexPath.section]
if cardInfo.type == .honor || cardInfo.type == .introduce { if cardInfo.infoType == .honor || cardInfo.infoType == .introduce {
guard let introCell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as? YHMyIntroductionCell else { return UITableViewCell() } guard let introCell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as? YHMyIntroductionCell else { return UITableViewCell() }
introCell.userModel = cardInfo introCell.userModel = cardInfo
introCell.editBlock = { [weak self] in introCell.editBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
if cardInfo.type == .honor { if cardInfo.infoType == .honor {
let vc = YHEditHonorViewController() let vc = YHEditHonorViewController()
vc.model = self.viewModel.nameCardInfo vc.model = self.viewModel.nameCardInfo
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
} else if cardInfo.type == .introduce { } else if cardInfo.infoType == .introduce {
let vc = YHEditPersonalProfileViewController() let vc = YHEditPersonalProfileViewController()
vc.model = self.viewModel.nameCardInfo vc.model = self.viewModel.nameCardInfo
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
...@@ -183,7 +198,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData ...@@ -183,7 +198,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
return introCell return introCell
} }
if cardInfo.type == .education { if cardInfo.infoType == .education {
guard let eduCell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as? YHMyEducationCell else { return UITableViewCell() } guard let eduCell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as? YHMyEducationCell else { return UITableViewCell() }
eduCell.userModel = cardInfo eduCell.userModel = cardInfo
eduCell.hiddenBtnBlock = { eduCell.hiddenBtnBlock = {
...@@ -200,7 +215,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData ...@@ -200,7 +215,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
return eduCell return eduCell
} }
if cardInfo.type == .workExperience { if cardInfo.infoType == .workExperience {
guard let workCell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as? YHMyWorkExperienceCell else { return UITableViewCell() } guard let workCell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as? YHMyWorkExperienceCell else { return UITableViewCell() }
workCell.userModel = cardInfo workCell.userModel = cardInfo
workCell.hiddenBtnBlock = { workCell.hiddenBtnBlock = {
...@@ -217,7 +232,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData ...@@ -217,7 +232,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
return workCell return workCell
} }
if cardInfo.type == .topics { if cardInfo.infoType == .topics {
guard let topicCell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as? YHMyInterestTopicCell else { return UITableViewCell() } guard let topicCell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as? YHMyInterestTopicCell else { return UITableViewCell() }
topicCell.userModel = cardInfo topicCell.userModel = cardInfo
topicCell.editBlock = { [weak self] in topicCell.editBlock = { [weak self] in
......
...@@ -15,7 +15,7 @@ class YHNewNameCardViewController: YHBaseViewController { ...@@ -15,7 +15,7 @@ class YHNewNameCardViewController: YHBaseViewController {
var defaultIndex = 0 var defaultIndex = 0
let viewModel = YHMatchUserViewModel() let viewModel = YHMatchUserViewModel()
var headerHeight: CGFloat = 300.0 var headerHeight: CGFloat = 300.0
let containerCellHeight = KScreenHeight-k_Height_NavigationtBarAndStatuBar-k_Height_safeAreaInsetsBottom()-46-10-8 let containerCellHeight = KScreenHeight-k_Height_NavigationtBarAndStatuBar-k_Height_safeAreaInsetsBottom()-88
var canScroll: Bool = true var canScroll: Bool = true
var isCurrentUser: Bool { var isCurrentUser: Bool {
...@@ -155,7 +155,34 @@ class YHNewNameCardViewController: YHBaseViewController { ...@@ -155,7 +155,34 @@ class YHNewNameCardViewController: YHBaseViewController {
return label return label
}() }()
lazy var bottomBtn: UIButton = { lazy var bottomView: UIView = {
let view = UIView()
view.addSubview(buttonsContentV)
view.addSubview(sendLabel)
buttonsContentV.snp.makeConstraints { make in
make.left.right.bottom.equalTo(0)
make.height.equalTo(64)
}
sendLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(16)
make.top.equalTo(8)
}
return view
}()
lazy var sendLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.brandGrayColor6
label.textAlignment = .center
label.font = UIFont.PFSC_R(ofSize: 12)
label.text = "已为您发送好友申请"
label.isHidden = true
return label
}()
lazy var publishBtn: UIButton = {
let btn = UIButton(type: .custom) let btn = UIButton(type: .custom)
btn.setTitle("发布动态", for: .normal) btn.setTitle("发布动态", for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 13) btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 13)
...@@ -163,9 +190,94 @@ class YHNewNameCardViewController: YHBaseViewController { ...@@ -163,9 +190,94 @@ class YHNewNameCardViewController: YHBaseViewController {
btn.backgroundColor = UIColor.brandGrayColor8 btn.backgroundColor = UIColor.brandGrayColor8
btn.layer.cornerRadius = 3.0 btn.layer.cornerRadius = 3.0
btn.masksToBounds = true btn.masksToBounds = true
btn.isHidden = true
return btn return btn
}() }()
lazy var cooperationBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setTitle("联系合作", for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 13)
btn.setTitleColor(.white, for: .normal)
btn.backgroundColor = UIColor.brandGrayColor8
btn.layer.cornerRadius = 3.0
btn.masksToBounds = true
btn.isHidden = true
return btn
}()
lazy var addFriendBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setTitle("添加好友", for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 13)
btn.setTitleColor(.brandGrayColor8, for: .normal)
btn.backgroundColor = UIColor.brandGrayColor2
btn.addTarget(self, action: #selector(didAddFriendBtnClicked), for: .touchUpInside)
btn.layer.cornerRadius = 3.0
btn.masksToBounds = true
btn.isHidden = true
return btn
}()
@objc func didAddFriendBtnClicked() {
let view = YHFriendRequestView.createView()
view.userModel2 = self.viewModel.nameCardInfo
view.sendBlock = {
[weak self] text in
guard let self = self else { return }
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.addFriendWithText(text!, yhId: self.userId) {
success, error in
YHHUD.hide()
if success {
self.viewModel.nameCardInfo.type = YHContactRelation.unvalidate.rawValue
self.updateBottomButton()
} else {
var msg = "申请失败"
if let errMsg = error?.errorMsg, !errMsg.isEmpty {
msg = errMsg
}
YHHUD.flash(message: msg)
}
}
}
view.show()
}
lazy var buttonsContentV: UIView = {
let v = UIView()
v.addSubview(addFriendBtn)
v.addSubview(cooperationBtn)
v.addSubview(publishBtn)
publishBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(46)
make.top.equalTo(8)
make.bottom.equalTo(-10)
}
addFriendBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(cooperationBtn.snp.left).offset(-10)
make.width.equalTo(116)
make.height.equalTo(46)
make.top.equalTo(8)
make.bottom.equalTo(-10)
}
cooperationBtn.snp.makeConstraints { make in
make.right.equalTo(-16)
make.height.equalTo(46)
make.top.equalTo(8)
make.bottom.equalTo(-10)
}
return v
}()
deinit { deinit {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
} }
...@@ -193,17 +305,76 @@ class YHNewNameCardViewController: YHBaseViewController { ...@@ -193,17 +305,76 @@ class YHNewNameCardViewController: YHBaseViewController {
func createUI() { func createUI() {
addObserver() addObserver()
self.editBtn.isHidden = !self.isCurrentUser self.editBtn.isHidden = !self.isCurrentUser
view.backgroundColor = .white
view.addSubview(tableView) view.addSubview(tableView)
view.addSubview(bottomBtn) view.addSubview(bottomView)
tableView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview() make.left.right.top.equalToSuperview()
make.bottom.equalTo(bottomBtn.snp.top).offset(-8) make.bottom.equalTo(bottomView.snp.top)
} }
bottomBtn.snp.makeConstraints { make in bottomView.snp.makeConstraints { make in
make.left.equalTo(16) make.left.right.equalTo(0)
make.right.equalTo(-16) make.height.equalTo(64)
make.height.equalTo(46) make.bottom.equalTo(-k_Height_safeAreaInsetsBottom())
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom()-10) }
updateBottomButton()
}
func updateBottomButton() {
if isCurrentUser {
publishBtn.isHidden = false
addFriendBtn.isHidden = true
cooperationBtn.isHidden = true
sendLabel.isHidden = true
bottomView.snp.updateConstraints { make in
make.height.equalTo(64)
}
} else {
if self.viewModel.nameCardInfo.type == YHContactRelation.friend.rawValue { // 是好友
publishBtn.isHidden = true
addFriendBtn.isHidden = true
cooperationBtn.isHidden = false
sendLabel.isHidden = true
bottomView.snp.updateConstraints { make in
make.height.equalTo(64)
}
addFriendBtn.snp.updateConstraints { make in
make.width.equalTo(0)
make.right.equalTo(cooperationBtn.snp.left).offset(0)
}
} else if self.viewModel.nameCardInfo.type == YHContactRelation.unvalidate.rawValue { // 已发送好友请求
publishBtn.isHidden = true
addFriendBtn.isHidden = true
cooperationBtn.isHidden = false
sendLabel.isHidden = false
bottomView.snp.updateConstraints { make in
make.height.equalTo(88)
}
addFriendBtn.snp.updateConstraints { make in
make.width.equalTo(0)
make.right.equalTo(cooperationBtn.snp.left).offset(0)
}
} else if self.viewModel.nameCardInfo.type == YHContactRelation.stranger.rawValue { // 非好友
publishBtn.isHidden = true
addFriendBtn.isHidden = false
cooperationBtn.isHidden = false
sendLabel.isHidden = true
bottomView.snp.updateConstraints { make in
make.height.equalTo(64)
}
addFriendBtn.snp.updateConstraints { make in
make.width.equalTo(116)
make.right.equalTo(cooperationBtn.snp.left).offset(-10)
}
}
} }
} }
...@@ -231,6 +402,7 @@ class YHNewNameCardViewController: YHBaseViewController { ...@@ -231,6 +402,7 @@ class YHNewNameCardViewController: YHBaseViewController {
_, _ in _, _ in
self.updateModel() self.updateModel()
self.tableView.reloadData() self.tableView.reloadData()
self.updateBottomButton()
} }
} }
......
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