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

// 人脉

parent 57b2d83b
......@@ -152,7 +152,11 @@ class YHMatchPeopleViewController: YHBaseViewController {
@objc func didMyCardBtnClicked() {
let vc = YHMyNameCardViewController()
if let userId = YHLoginManager.shared.userModel?.userid {
vc.userId = "\(userId)"
}
self.navigationController?.pushViewController(vc)
}
@objc func didRematchBtnClicked() {
......
......@@ -131,7 +131,9 @@ extension YHMyGoodFriendsVC: UITableViewDelegate, UITableViewDataSource {
if indexPath.section == 1 {
if 0 <= indexPath.row && indexPath.row < friendsArr.count {
let friend = self.friendsArr[indexPath.row]
let vc = YHMyNameCardViewController()
vc.userId = friend.yhId
self.navigationController?.pushViewController(vc)
}
}
......
......@@ -11,6 +11,7 @@ import UIKit
class YHMyNameCardViewController: YHBaseViewController {
var userId: String = ""
var cardInfoArr:[YHUserNameCardInfo] = []
let viewModel = YHMatchUserViewModel()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
......@@ -101,7 +102,7 @@ class YHMyNameCardViewController: YHBaseViewController {
extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 6
return self.cardInfoArr.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -110,62 +111,66 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyNameCardAvatarInfoCell.cellReuseIdentifier, for: indexPath) as! YHMyNameCardAvatarInfoCell
cell.editBlock = { [weak self] in
guard let self = self else { return }
let vc = YHEditBaseUserInfoViewController()
self.navigationController?.pushViewController(vc)
}
if indexPath.section == 1 {
if 0 <= self.cardInfoArr.count && self.cardInfoArr.count < indexPath.section {
let cardInfo = self.cardInfoArr[indexPath.section]
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as! YHMyIntroductionCell
cell.editBlock = { [weak self] in
if cardInfo.type == .honor || cardInfo.type == .introduce {
let introCell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as! YHMyIntroductionCell
introCell.userModel = self.viewModel.nameCardInfo
introCell.editBlock = { [weak self] in
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 cell
}
if indexPath.section == 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as! YHMyEducationCell
cell.editBlock = { [weak self] in
return introCell
}
if cardInfo.type == .education {
let eduCell = tableView.dequeueReusableCell(withIdentifier: YHMyEducationCell.cellReuseIdentifier, for: indexPath) as! YHMyEducationCell
eduCell.userModel = self.viewModel.nameCardInfo
eduCell.editBlock = { [weak self] in
guard let self = self else { return }
let vc = YHEditSchoolViewController()
self.navigationController?.pushViewController(vc)
}
return cell
return eduCell
}
if indexPath.section == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as! YHMyWorkExperienceCell
cell.editBlock = { [weak self] in
if cardInfo.type == .workExperience {
let workCell = tableView.dequeueReusableCell(withIdentifier: YHMyWorkExperienceCell.cellReuseIdentifier, for: indexPath) as! YHMyWorkExperienceCell
workCell.userModel = self.viewModel.nameCardInfo
workCell.editBlock = { [weak self] in
guard let self = self else { return }
let vc = YHEditWorkViewController()
self.navigationController?.pushViewController(vc)
}
return cell
return workCell
}
if indexPath.section == 4 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyIntroductionCell.cellReuseIdentifier, for: indexPath) as! YHMyIntroductionCell
cell.titleLabel.text = "荣誉奖项"
cell.editBlock = { [weak self] in
if cardInfo.type == .topics {
let topicCell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as! YHMyInterestTopicCell
topicCell.userModel = self.viewModel.nameCardInfo
topicCell.editBlock = { [weak self] in
guard let self = self else { return }
let vc = YHEditHonorViewController()
let vc = YHEditInterestViewController()
self.navigationController?.pushViewController(vc)
}
return cell
return topicCell
}
}
if indexPath.section == 5 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyInterestTopicCell.cellReuseIdentifier, for: indexPath) as! YHMyInterestTopicCell
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyNameCardAvatarInfoCell.cellReuseIdentifier, for: indexPath) as! YHMyNameCardAvatarInfoCell
cell.userModel = self.viewModel.nameCardInfo
cell.editBlock = { [weak self] in
guard let self = self else { return }
let vc = YHEditInterestViewController()
let vc = YHEditBaseUserInfoViewController()
self.navigationController?.pushViewController(vc)
}
return cell
}
return cell
}
......@@ -199,7 +204,40 @@ extension YHMyNameCardViewController {
self.viewModel.getUserNameCardInfo(uid: self.userId) {
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 {
}
}
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 {
var id: String = ""
var yhId: String = ""
......@@ -65,12 +75,38 @@ class YHUserNameCardInfo: SmartCodable {
var position: String = ""
var industry: String = ""
var honor: String = ""
let topics: [String] = []
var topics: [String] = []
// 自定义属性
var type:YHNameCardInfoType = .unknown
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 {
case id
case yhId = "yh_id"
......
......@@ -51,7 +51,16 @@ class YHMyInterestTopicCell: UITableViewCell {
var editBlock: EditBlock?
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 = {
let view = UIView()
......@@ -188,7 +197,7 @@ extension YHMyInterestTopicCell: UICollectionViewDelegate, UICollectionViewDataS
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
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 {
var userModel:YHUserNameCardInfo = YHUserNameCardInfo() {
didSet {
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 = {
......
......@@ -59,8 +59,27 @@ class YHMyWorkExperienceCell: UITableViewCell {
var userModel:YHUserNameCardInfo = YHUserNameCardInfo() {
didSet {
if !self.userModel.companyName.isEmpty {
self.companyView.detailLabel.text = ""
self.companyView.detailLabel.text = self.userModel.companyName
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 {
}
func getUserNameCardInfo(uid: String, callBack: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let params = ["uid" : uid]
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
guard let self = self else { return }
......@@ -128,4 +128,6 @@ class YHMatchUserViewModel: NSObject {
callBack(false, error)
}
}
}
......@@ -288,6 +288,9 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
switch item.type {
case .myCard://我的名片
let vc = YHMyNameCardViewController()
if let userId = YHLoginManager.shared.userModel?.userid {
vc.userId = "\(userId)"
}
self.navigationController?.pushViewController(vc)
case .myMessage://我的消息
printLog("我的消息")
......
......@@ -316,8 +316,10 @@ class YHAllApiName {
static let receiveFriendRequestApi = "super-app/community/process-friend-requests"
// 好友列表
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 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