Commit 3828bdb0 authored by Steven杜宇's avatar Steven杜宇

// 人脉

parent 57b2d83b
...@@ -152,7 +152,11 @@ class YHMatchPeopleViewController: YHBaseViewController { ...@@ -152,7 +152,11 @@ class YHMatchPeopleViewController: YHBaseViewController {
@objc func didMyCardBtnClicked() { @objc func didMyCardBtnClicked() {
let vc = YHMyNameCardViewController() let vc = YHMyNameCardViewController()
if let userId = YHLoginManager.shared.userModel?.userid {
vc.userId = "\(userId)"
}
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
@objc func didRematchBtnClicked() { @objc func didRematchBtnClicked() {
......
...@@ -131,7 +131,9 @@ extension YHMyGoodFriendsVC: UITableViewDelegate, UITableViewDataSource { ...@@ -131,7 +131,9 @@ extension YHMyGoodFriendsVC: UITableViewDelegate, UITableViewDataSource {
if indexPath.section == 1 { if indexPath.section == 1 {
if 0 <= indexPath.row && indexPath.row < friendsArr.count { if 0 <= indexPath.row && indexPath.row < friendsArr.count {
let vc = YHMyNameCardViewController() let friend = self.friendsArr[indexPath.row]
let vc = YHMyNameCardViewController()
vc.userId = friend.yhId
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
} }
......
...@@ -11,6 +11,7 @@ import UIKit ...@@ -11,6 +11,7 @@ import UIKit
class YHMyNameCardViewController: YHBaseViewController { class YHMyNameCardViewController: YHBaseViewController {
var userId: String = "" var userId: String = ""
var cardInfoArr:[YHUserNameCardInfo] = []
let viewModel = YHMatchUserViewModel() let viewModel = YHMatchUserViewModel()
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped) let tableView = UITableView(frame:.zero, style:.grouped)
...@@ -101,7 +102,7 @@ class YHMyNameCardViewController: YHBaseViewController { ...@@ -101,7 +102,7 @@ class YHMyNameCardViewController: YHBaseViewController {
extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource { extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int { func numberOfSections(in tableView: UITableView) -> Int {
return 6 return self.cardInfoArr.count
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
...@@ -110,61 +111,65 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource ...@@ -110,61 +111,65 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyNameCardAvatarInfoCell.cellReuseIdentifier, for: indexPath) as! YHMyNameCardAvatarInfoCell if 0 <= self.cardInfoArr.count && self.cardInfoArr.count < indexPath.section {
cell.editBlock = { [weak self] in let cardInfo = self.cardInfoArr[indexPath.section]
guard let self = self else { return }
let vc = YHEditBaseUserInfoViewController()
self.navigationController?.pushViewController(vc)
}
if indexPath.section == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as! YHMyIntroductionCell if cardInfo.type == .honor || cardInfo.type == .introduce {
cell.editBlock = { [weak self] in let introCell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as! YHMyIntroductionCell
guard let self = self else { return } introCell.userModel = self.viewModel.nameCardInfo
let vc = YHEditPersonalProfileViewController() introCell.editBlock = { [weak self] in
self.navigationController?.pushViewController(vc) guard let self = self else { return }
if cardInfo.type == .honor {
let vc = YHEditHonorViewController()
self.navigationController?.pushViewController(vc)
} else if cardInfo.type == .introduce {
let vc = YHEditPersonalProfileViewController()
self.navigationController?.pushViewController(vc)
}
}
return introCell
} }
return cell
} if cardInfo.type == .education {
if indexPath.section == 2 { let eduCell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as! YHMyEducationCell
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as! YHMyEducationCell eduCell.userModel = self.viewModel.nameCardInfo
cell.editBlock = { [weak self] in eduCell.editBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
let vc = YHEditSchoolViewController() let vc = YHEditSchoolViewController()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
}
return eduCell
} }
return cell
} if cardInfo.type == .workExperience {
let workCell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as! YHMyWorkExperienceCell
if indexPath.section == 3 { workCell.userModel = self.viewModel.nameCardInfo
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as! YHMyWorkExperienceCell workCell.editBlock = { [weak self] in
cell.editBlock = { [weak self] in guard let self = self else { return }
guard let self = self else { return } let vc = YHEditWorkViewController()
let vc = YHEditWorkViewController() self.navigationController?.pushViewController(vc)
self.navigationController?.pushViewController(vc) }
return workCell
} }
return cell
} if cardInfo.type == .topics {
let topicCell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as! YHMyInterestTopicCell
if indexPath.section == 4 { topicCell.userModel = self.viewModel.nameCardInfo
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as! YHMyIntroductionCell topicCell.editBlock = { [weak self] in
cell.titleLabel.text = "荣誉奖项" guard let self = self else { return }
cell.editBlock = { [weak self] in let vc = YHEditInterestViewController()
guard let self = self else { return } self.navigationController?.pushViewController(vc)
let vc = YHEditHonorViewController() }
self.navigationController?.pushViewController(vc) return topicCell
} }
return cell
} }
if indexPath.section == 5 { let cell = tableView.dequeueReusableCell(withIdentifier: YHMyNameCardAvatarInfoCell.cellReuseIdentifier, for: indexPath) as! YHMyNameCardAvatarInfoCell
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as! YHMyInterestTopicCell cell.userModel = self.viewModel.nameCardInfo
cell.editBlock = { [weak self] in cell.editBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
let vc = YHEditInterestViewController() let vc = YHEditBaseUserInfoViewController()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
}
return cell
} }
return cell return cell
...@@ -199,7 +204,40 @@ extension YHMyNameCardViewController { ...@@ -199,7 +204,40 @@ extension YHMyNameCardViewController {
self.viewModel.getUserNameCardInfo(uid: self.userId) { self.viewModel.getUserNameCardInfo(uid: self.userId) {
success, error in success, error in
self.viewModel.nameCardInfo self.cardInfoArr.removeAll()
var model1 = YHUserNameCardInfo()
model1.type = .avatar
model1.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model1)
var model2 = YHUserNameCardInfo()
model2.type = .introduce
model2.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model2)
var model3 = YHUserNameCardInfo()
model3.type = .education
model3.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model3)
var model4 = YHUserNameCardInfo()
model4.type = .workExperience
model4.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model4)
var model5 = YHUserNameCardInfo()
model5.type = .honor
model5.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model5)
var model6 = YHUserNameCardInfo()
model6.type = .topics
model6.updateModel(self.viewModel.nameCardInfo)
self.cardInfoArr.append(model6)
self.tableView.reloadData()
} }
} }
} }
...@@ -48,6 +48,16 @@ class YHMatchUserAddress: SmartCodable { ...@@ -48,6 +48,16 @@ class YHMatchUserAddress: SmartCodable {
} }
} }
enum YHNameCardInfoType:Int {
case unknown = -1
case avatar = 0
case introduce = 1
case education = 2
case workExperience = 3
case honor = 4
case topics = 5
}
class YHUserNameCardInfo: SmartCodable { class YHUserNameCardInfo: SmartCodable {
var id: String = "" var id: String = ""
var yhId: String = "" var yhId: String = ""
...@@ -65,11 +75,37 @@ class YHUserNameCardInfo: SmartCodable { ...@@ -65,11 +75,37 @@ class YHUserNameCardInfo: SmartCodable {
var position: String = "" var position: String = ""
var industry: String = "" var industry: String = ""
var honor: String = "" var honor: String = ""
let topics: [String] = [] var topics: [String] = []
// 自定义属性
var type:YHNameCardInfoType = .unknown
required init() { required init() {
} }
func updateModel(_ model: YHUserNameCardInfo) {
self.id = model.id
self.yhId = model.yhId
self.isSigned = model.isSigned
self.avatar = model.avatar
self.username = model.username
self.address.province = model.address.province
self.address.country = model.address.country
self.address.city = model.address.city
self.zodiac = model.zodiac
self.signature = model.signature
self.bio = model.bio
self.college = model.college
self.major = model.major
self.background = model.background
self.companyName = model.companyName
self.position = model.position
self.industry = model.industry
self.honor = model.honor
self.topics.removeAll()
self.topics.append(contentsOf: model.topics)
}
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case id case id
......
...@@ -51,7 +51,16 @@ class YHMyInterestTopicCell: UITableViewCell { ...@@ -51,7 +51,16 @@ class YHMyInterestTopicCell: UITableViewCell {
var editBlock: EditBlock? var editBlock: EditBlock?
static let cellReuseIdentifier = "YHMyInterestTopicCell" static let cellReuseIdentifier = "YHMyInterestTopicCell"
var topicArr:[String] = ["深度阅读爱好者", "皮划艇玩家", "创新主义", "茶道啊大法师额", "皮划艇玩家", "创新主义", "茶道", "深度阅读爱好者","玩家", "创主义", "茶道", "皮划艇玩家", "创新主义"] var topicArr:[String] = []
var userModel:YHUserNameCardInfo = YHUserNameCardInfo() {
didSet {
self.topicArr.removeAll()
if self.userModel.topics.count > 0 {
self.topicArr.append(contentsOf: self.userModel.topics)
}
self.collectionView.reloadData()
}
}
lazy var cardView: UIView = { lazy var cardView: UIView = {
let view = UIView() let view = UIView()
...@@ -188,7 +197,7 @@ extension YHMyInterestTopicCell: UICollectionViewDelegate, UICollectionViewDataS ...@@ -188,7 +197,7 @@ extension YHMyInterestTopicCell: UICollectionViewDelegate, UICollectionViewDataS
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < topicArr.count { if 0 <= indexPath.item && indexPath.item < topicArr.count {
let text = topicArr[indexPath.item] // let text = topicArr[indexPath.item]
} }
} }
......
...@@ -15,7 +15,14 @@ class YHMyIntroductionCell: UITableViewCell { ...@@ -15,7 +15,14 @@ class YHMyIntroductionCell: UITableViewCell {
var userModel:YHUserNameCardInfo = YHUserNameCardInfo() { var userModel:YHUserNameCardInfo = YHUserNameCardInfo() {
didSet { didSet {
self.detailLabel.text = self.userModel.bio if userModel.type == .introduce {
self.titleLabel.text = "个人简介"
self.detailLabel.text = self.userModel.bio
} else if userModel.type == .honor {
self.titleLabel.text = "荣誉奖项"
self.detailLabel.text = self.userModel.honor
}
} }
} }
lazy var cardView: UIView = { lazy var cardView: UIView = {
......
...@@ -59,8 +59,27 @@ class YHMyWorkExperienceCell: UITableViewCell { ...@@ -59,8 +59,27 @@ class YHMyWorkExperienceCell: UITableViewCell {
var userModel:YHUserNameCardInfo = YHUserNameCardInfo() { var userModel:YHUserNameCardInfo = YHUserNameCardInfo() {
didSet { didSet {
if !self.userModel.companyName.isEmpty { self.companyView.detailLabel.text = self.userModel.companyName
self.companyView.detailLabel.text = "" self.professionView.detailLabel.text = self.userModel.position
self.industryView.detailLabel.text = self.userModel.industry
self.companyView.isHidden = self.userModel.companyName.isEmpty
self.professionView.isHidden = self.userModel.position.isEmpty
self.industryView.isHidden = self.userModel.industry.isEmpty
let companyHeight = self.userModel.companyName.isEmpty ? 0.0 : 20
self.companyView.snp.updateConstraints { make in
make.height.equalTo(companyHeight)
}
let positionHeight = self.userModel.position.isEmpty ? 0.0 : 20
self.professionView.snp.updateConstraints { make in
make.height.equalTo(positionHeight)
}
let industryHeight = self.userModel.industry.isEmpty ? 0.0 : 20
self.industryView.snp.updateConstraints { make in
make.height.equalTo(industryHeight)
} }
} }
} }
......
...@@ -99,9 +99,9 @@ class YHMatchUserViewModel: NSObject { ...@@ -99,9 +99,9 @@ class YHMatchUserViewModel: NSObject {
} }
func getUserNameCardInfo(uid: String, callBack: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) { func getUserNameCardInfo(uid: String, callBack: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let params = ["uid" : uid]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.nameCardInfoApi let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.nameCardInfoApi
let _ = YHNetRequest.getRequest(url: strUrl) { let _ = YHNetRequest.getRequest(url: strUrl, params: params) {
[weak self] json, code in [weak self] json, code in
guard let self = self else { return } guard let self = self else { return }
...@@ -128,4 +128,6 @@ class YHMatchUserViewModel: NSObject { ...@@ -128,4 +128,6 @@ class YHMatchUserViewModel: NSObject {
callBack(false, error) callBack(false, error)
} }
} }
} }
...@@ -288,6 +288,9 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -288,6 +288,9 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
switch item.type { switch item.type {
case .myCard://我的名片 case .myCard://我的名片
let vc = YHMyNameCardViewController() let vc = YHMyNameCardViewController()
if let userId = YHLoginManager.shared.userModel?.userid {
vc.userId = "\(userId)"
}
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
case .myMessage://我的消息 case .myMessage://我的消息
printLog("我的消息") printLog("我的消息")
......
...@@ -316,8 +316,10 @@ class YHAllApiName { ...@@ -316,8 +316,10 @@ class YHAllApiName {
static let receiveFriendRequestApi = "super-app/community/process-friend-requests" static let receiveFriendRequestApi = "super-app/community/process-friend-requests"
// 好友列表 // 好友列表
static let friendListApi = "super-app/community/my-friends" static let friendListApi = "super-app/community/my-friends"
// 用户名片
static let nameCardInfoApi = "super-app/business-card/detail"
// 我的名片 // 我的名片
static let nameCardInfoApi = "super-app/business-card/my-detail" static let myNameCardInfoApi = "super-app/business-card/my-detail"
static let change = "super-app/avatar/change" static let change = "super-app/avatar/change"
static let userSubmit = "super-app/user-base/submit" static let userSubmit = "super-app/user-base/submit"
......
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