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

// 名片

parent e8d86656
......@@ -126,7 +126,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.section && indexPath.section < self.cardInfoArr.count {
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() }
cell.userModel = cardInfo
cell.editBlock = { [weak self] in
......@@ -138,17 +138,17 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
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() }
introCell.userModel = cardInfo
introCell.editBlock = { [weak self] in
guard let self = self else { return }
if cardInfo.type == .honor {
if cardInfo.infoType == .honor {
let vc = YHEditHonorViewController()
vc.model = self.viewModel.nameCardInfo
self.navigationController?.pushViewController(vc)
} else if cardInfo.type == .introduce {
} else if cardInfo.infoType == .introduce {
let vc = YHEditPersonalProfileViewController()
vc.model = self.viewModel.nameCardInfo
self.navigationController?.pushViewController(vc)
......@@ -157,7 +157,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
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() }
eduCell.userModel = cardInfo
eduCell.hiddenBtnBlock = {
......@@ -174,7 +174,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
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() }
workCell.userModel = cardInfo
workCell.hiddenBtnBlock = {
......@@ -191,7 +191,7 @@ extension YHNameCardViewController: UITableViewDelegate, UITableViewDataSource {
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() }
topicCell.userModel = cardInfo
topicCell.editBlock = { [weak self] in
......@@ -261,7 +261,7 @@ extension YHNameCardViewController {
// 姓名头像信息
let model1 = YHUserNameCardInfo()
model1.type = .avatar
model1.infoType = .avatar
model1.isCurrentUser = self.isCurrentUser
model1.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model1)
......@@ -273,7 +273,7 @@ extension YHNameCardViewController {
}
if isShowIntroduce {
let model2 = YHUserNameCardInfo()
model2.type = .introduce
model2.infoType = .introduce
model2.isCurrentUser = self.isCurrentUser
model2.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model2)
......@@ -289,7 +289,7 @@ extension YHNameCardViewController {
}
if isShowEducation {
let model3 = YHUserNameCardInfo()
model3.type = .education
model3.infoType = .education
model3.isCurrentUser = self.isCurrentUser
model3.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model3)
......@@ -305,7 +305,7 @@ extension YHNameCardViewController {
}
if isShowWorkExperience {
let model4 = YHUserNameCardInfo()
model4.type = .workExperience
model4.infoType = .workExperience
model4.isCurrentUser = self.isCurrentUser
model4.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model4)
......@@ -318,7 +318,7 @@ extension YHNameCardViewController {
}
if isShowHonor {
let model5 = YHUserNameCardInfo()
model5.type = .honor
model5.infoType = .honor
model5.isCurrentUser = self.isCurrentUser
model5.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model5)
......@@ -331,7 +331,7 @@ extension YHNameCardViewController {
}
if isShowTopics {
let model6 = YHUserNameCardInfo()
model6.type = .topics
model6.infoType = .topics
model6.isCurrentUser = self.isCurrentUser
model6.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model6)
......
......@@ -36,7 +36,7 @@ class YHConnectListViewController: YHBaseViewController {
}()
lazy var noDataView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无数据", kEmptyCommonBgName)
let view = YHEmptyDataView.createView("暂无内容", kEmptyCommonBgName)
view.isHidden = true
return view
}()
......
......@@ -110,9 +110,10 @@ class YHUserNameCardInfo: SmartCodable {
var topics: [String] = []
var draftTopics: [String] = []
var authorization: YHAuthorizationModel = YHAuthorizationModel()
var type: Int = 1 // 人脉状态 1: 陌生人 3: 待验证 5: 好友
// 自定义属性
var type: YHNameCardInfoType = .unknown
var infoType: YHNameCardInfoType = .unknown
var isCurrentUser = false
var isHiddenEducation: Bool {
......@@ -160,7 +161,7 @@ class YHUserNameCardInfo: SmartCodable {
case isSigned = "is_signed"
case companyName = "company_name"
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 address
case authorization
......
......@@ -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 = {
let view = UIView()
......
......@@ -18,7 +18,7 @@ class YHMyIntroductionCell: UITableViewCell {
self.editBtn.isHidden = !self.userModel.isCurrentUser
if userModel.type == .introduce {
if userModel.infoType == .introduce {
self.titleLabel.text = "个人简介"
self.detailLabel.textColor = UIColor.mainTextColor70
if !self.userModel.bio.isEmpty {
......@@ -31,7 +31,7 @@ class YHMyIntroductionCell: UITableViewCell {
}
}
} else if userModel.type == .honor {
} else if userModel.infoType == .honor {
self.titleLabel.text = "荣誉奖项"
self.detailLabel.textColor = UIColor.mainTextColor70
if !self.userModel.honor.isEmpty {
......
......@@ -61,9 +61,7 @@ class YHNameCardContainerViewController: YHBaseViewController {
lazy var homePageVC: YHNameCardHomePageViewController = {
let vc = YHNameCardHomePageViewController()
if let userId = YHLoginManager.shared.userModel?.id {
vc.userId = userId
}
vc.userId = self.userId
return vc
}()
......
......@@ -40,6 +40,12 @@ class YHNameCardHomePageViewController: YHBaseViewController {
return tableView
}()
lazy var noDataView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无内容", kEmptyCommonBgName)
view.isHidden = true
return view
}()
deinit {
NotificationCenter.default.removeObserver(self)
}
......@@ -61,6 +67,13 @@ class YHNameCardHomePageViewController: YHBaseViewController {
make.bottom.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() {
......@@ -81,7 +94,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
}
if isShowIntroduce {
let model2 = YHUserNameCardInfo()
model2.type = .introduce
model2.infoType = .introduce
model2.isCurrentUser = self.isCurrentUser
model2.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model2)
......@@ -97,7 +110,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
}
if isShowEducation {
let model3 = YHUserNameCardInfo()
model3.type = .education
model3.infoType = .education
model3.isCurrentUser = self.isCurrentUser
model3.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model3)
......@@ -113,7 +126,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
}
if isShowWorkExperience {
let model4 = YHUserNameCardInfo()
model4.type = .workExperience
model4.infoType = .workExperience
model4.isCurrentUser = self.isCurrentUser
model4.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model4)
......@@ -126,7 +139,7 @@ class YHNameCardHomePageViewController: YHBaseViewController {
}
if isShowHonor {
let model5 = YHUserNameCardInfo()
model5.type = .honor
model5.infoType = .honor
model5.isCurrentUser = self.isCurrentUser
model5.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model5)
......@@ -139,12 +152,14 @@ class YHNameCardHomePageViewController: YHBaseViewController {
}
if isShowTopics {
let model6 = YHUserNameCardInfo()
model6.type = .topics
model6.infoType = .topics
model6.isCurrentUser = self.isCurrentUser
model6.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model6)
}
self.tableView.reloadData()
self.noDataView.isHidden = self.cardInfoArr.count > 0
}
}
}
......@@ -164,17 +179,17 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
if 0 <= indexPath.section && indexPath.section < self.cardInfoArr.count {
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() }
introCell.userModel = cardInfo
introCell.editBlock = { [weak self] in
guard let self = self else { return }
if cardInfo.type == .honor {
if cardInfo.infoType == .honor {
let vc = YHEditHonorViewController()
vc.model = self.viewModel.nameCardInfo
UIViewController.current?.navigationController?.pushViewController(vc)
} else if cardInfo.type == .introduce {
} else if cardInfo.infoType == .introduce {
let vc = YHEditPersonalProfileViewController()
vc.model = self.viewModel.nameCardInfo
UIViewController.current?.navigationController?.pushViewController(vc)
......@@ -183,7 +198,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
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() }
eduCell.userModel = cardInfo
eduCell.hiddenBtnBlock = {
......@@ -200,7 +215,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
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() }
workCell.userModel = cardInfo
workCell.hiddenBtnBlock = {
......@@ -217,7 +232,7 @@ extension YHNameCardHomePageViewController: UITableViewDelegate, UITableViewData
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() }
topicCell.userModel = cardInfo
topicCell.editBlock = { [weak self] in
......
......@@ -15,7 +15,7 @@ class YHNewNameCardViewController: YHBaseViewController {
var defaultIndex = 0
let viewModel = YHMatchUserViewModel()
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 isCurrentUser: Bool {
......@@ -155,7 +155,34 @@ class YHNewNameCardViewController: YHBaseViewController {
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)
btn.setTitle("发布动态", for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 13)
......@@ -163,9 +190,94 @@ class YHNewNameCardViewController: YHBaseViewController {
btn.backgroundColor = UIColor.brandGrayColor8
btn.layer.cornerRadius = 3.0
btn.masksToBounds = true
btn.isHidden = true
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 {
NotificationCenter.default.removeObserver(self)
}
......@@ -193,17 +305,76 @@ class YHNewNameCardViewController: YHBaseViewController {
func createUI() {
addObserver()
self.editBtn.isHidden = !self.isCurrentUser
view.backgroundColor = .white
view.addSubview(tableView)
view.addSubview(bottomBtn)
view.addSubview(bottomView)
tableView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.bottom.equalTo(bottomBtn.snp.top).offset(-8)
make.bottom.equalTo(bottomView.snp.top)
}
bottomView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.height.equalTo(64)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom())
}
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)
}
}
bottomBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(46)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom()-10)
}
}
......@@ -231,6 +402,7 @@ class YHNewNameCardViewController: YHBaseViewController {
_, _ in
self.updateModel()
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