Commit 2acd8a02 authored by Steven杜宇's avatar Steven杜宇

// 人脉

parent 0d38fb52
...@@ -1259,6 +1259,7 @@ ...@@ -1259,6 +1259,7 @@
04B30B8C2E869717004E4B12 /* YHGrayCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B8B2E869717004E4B12 /* YHGrayCommonAlertView.swift */; }; 04B30B8C2E869717004E4B12 /* YHGrayCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B8B2E869717004E4B12 /* YHGrayCommonAlertView.swift */; };
04B30B8E2E88C837004E4B12 /* YHNameCardDynamicViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B8D2E88C837004E4B12 /* YHNameCardDynamicViewController.swift */; }; 04B30B8E2E88C837004E4B12 /* YHNameCardDynamicViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B8D2E88C837004E4B12 /* YHNameCardDynamicViewController.swift */; };
04B30B902E88CA0B004E4B12 /* YHNameCardDynamicCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B8F2E88CA0B004E4B12 /* YHNameCardDynamicCell.swift */; }; 04B30B902E88CA0B004E4B12 /* YHNameCardDynamicCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B8F2E88CA0B004E4B12 /* YHNameCardDynamicCell.swift */; };
04B30B982E891CF3004E4B12 /* YHContactViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B30B972E891CF3004E4B12 /* YHContactViewModel.swift */; };
04D4EC312E839C1000B0329B /* YHCircleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D4EC302E839C1000B0329B /* YHCircleViewController.swift */; }; 04D4EC312E839C1000B0329B /* YHCircleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D4EC302E839C1000B0329B /* YHCircleViewController.swift */; };
04D4EC332E839C2B00B0329B /* YHResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D4EC322E839C2B00B0329B /* YHResourceViewController.swift */; }; 04D4EC332E839C2B00B0329B /* YHResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D4EC322E839C2B00B0329B /* YHResourceViewController.swift */; };
04D4EC442E83D0D500B0329B /* YHCircleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D4EC432E83D0D500B0329B /* YHCircleViewModel.swift */; }; 04D4EC442E83D0D500B0329B /* YHCircleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D4EC432E83D0D500B0329B /* YHCircleViewModel.swift */; };
...@@ -2623,6 +2624,7 @@ ...@@ -2623,6 +2624,7 @@
04B30B8B2E869717004E4B12 /* YHGrayCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGrayCommonAlertView.swift; sourceTree = "<group>"; }; 04B30B8B2E869717004E4B12 /* YHGrayCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGrayCommonAlertView.swift; sourceTree = "<group>"; };
04B30B8D2E88C837004E4B12 /* YHNameCardDynamicViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNameCardDynamicViewController.swift; sourceTree = "<group>"; }; 04B30B8D2E88C837004E4B12 /* YHNameCardDynamicViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNameCardDynamicViewController.swift; sourceTree = "<group>"; };
04B30B8F2E88CA0B004E4B12 /* YHNameCardDynamicCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNameCardDynamicCell.swift; sourceTree = "<group>"; }; 04B30B8F2E88CA0B004E4B12 /* YHNameCardDynamicCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNameCardDynamicCell.swift; sourceTree = "<group>"; };
04B30B972E891CF3004E4B12 /* YHContactViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHContactViewModel.swift; sourceTree = "<group>"; };
04D4EC302E839C1000B0329B /* YHCircleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCircleViewController.swift; sourceTree = "<group>"; }; 04D4EC302E839C1000B0329B /* YHCircleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCircleViewController.swift; sourceTree = "<group>"; };
04D4EC322E839C2B00B0329B /* YHResourceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResourceViewController.swift; sourceTree = "<group>"; }; 04D4EC322E839C2B00B0329B /* YHResourceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResourceViewController.swift; sourceTree = "<group>"; };
04D4EC432E83D0D500B0329B /* YHCircleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCircleViewModel.swift; sourceTree = "<group>"; }; 04D4EC432E83D0D500B0329B /* YHCircleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCircleViewModel.swift; sourceTree = "<group>"; };
...@@ -6946,6 +6948,14 @@ ...@@ -6946,6 +6948,14 @@
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
04B30B962E891CCA004E4B12 /* VM */ = {
isa = PBXGroup;
children = (
04B30B972E891CF3004E4B12 /* YHContactViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
};
04D4EC262E839A0300B0329B /* Circle(下属社区) */ = { 04D4EC262E839A0300B0329B /* Circle(下属社区) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -7039,6 +7049,7 @@ ...@@ -7039,6 +7049,7 @@
04D640562E84DDBE000162AF /* Connections(人脉) */ = { 04D640562E84DDBE000162AF /* Connections(人脉) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
04B30B962E891CCA004E4B12 /* VM */,
0426E0982E84E8D3005C9F5D /* M */, 0426E0982E84E8D3005C9F5D /* M */,
04D6405C2E84E34A000162AF /* V */, 04D6405C2E84E34A000162AF /* V */,
04D6405B2E84E33E000162AF /* C */, 04D6405B2E84E33E000162AF /* C */,
...@@ -7725,6 +7736,7 @@ ...@@ -7725,6 +7736,7 @@
045C10362D12CA5F00BD2DC0 /* UIImage+Extension.swift in Sources */, 045C10362D12CA5F00BD2DC0 /* UIImage+Extension.swift in Sources */,
045C10372D12CA5F00BD2DC0 /* YHPreviewInfoCell.swift in Sources */, 045C10372D12CA5F00BD2DC0 /* YHPreviewInfoCell.swift in Sources */,
045C10382D12CA5F00BD2DC0 /* YHHKVisaRenewalPaymentViewModel.swift in Sources */, 045C10382D12CA5F00BD2DC0 /* YHHKVisaRenewalPaymentViewModel.swift in Sources */,
04B30B982E891CF3004E4B12 /* YHContactViewModel.swift in Sources */,
0411CEEB2D1512AF00644D35 /* YHGCWorkItemListViewModel.swift in Sources */, 0411CEEB2D1512AF00644D35 /* YHGCWorkItemListViewModel.swift in Sources */,
045C10392D12CA5F00BD2DC0 /* YHHKMemberModel.swift in Sources */, 045C10392D12CA5F00BD2DC0 /* YHHKMemberModel.swift in Sources */,
045C103A2D12CA5F00BD2DC0 /* YHCertificateUploadContentListVC.swift in Sources */, 045C103A2D12CA5F00BD2DC0 /* YHCertificateUploadContentListVC.swift in Sources */,
......
...@@ -10,8 +10,8 @@ import JXSegmentedView ...@@ -10,8 +10,8 @@ import JXSegmentedView
import UIKit import UIKit
class YHConnectListViewController: YHBaseViewController { class YHConnectListViewController: YHBaseViewController {
let viewModel = YHMatchUserViewModel() let viewModel = YHContactViewModel()
var arr: [String] = ["", "", ""] var arr: [YHContact] = []
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped) let tableView = UITableView(frame: .zero, style: .grouped)
...@@ -20,6 +20,9 @@ class YHConnectListViewController: YHBaseViewController { ...@@ -20,6 +20,9 @@ class YHConnectListViewController: YHBaseViewController {
tableView.delegate = self tableView.delegate = self
tableView.dataSource = self tableView.dataSource = self
tableView.register(YHConnectListCell.self, forCellReuseIdentifier: YHConnectListCell.cellReuseIdentifier) tableView.register(YHConnectListCell.self, forCellReuseIdentifier: YHConnectListCell.cellReuseIdentifier)
tableView.es.addInfiniteScrolling {
self.reguestData(false)
}
return tableView return tableView
}() }()
...@@ -46,6 +49,19 @@ class YHConnectListViewController: YHBaseViewController { ...@@ -46,6 +49,19 @@ class YHConnectListViewController: YHBaseViewController {
make.bottom.equalToSuperview() make.bottom.equalToSuperview()
make.top.equalToSuperview().offset(0) make.top.equalToSuperview().offset(0)
} }
reguestData(true)
}
func reguestData(_ isFirstPage: Bool) {
self.viewModel.getList(isFirstPage) { _, _ in
self.arr.append(contentsOf: (self.viewModel.contacts))
self.tableView.reloadData()
self.tableView.es.stopLoadingMore()
if !self.viewModel.hasMore {
self.tableView.es.noticeNoMoreData()
}
}
} }
} }
...@@ -56,6 +72,10 @@ extension YHConnectListViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -56,6 +72,10 @@ extension YHConnectListViewController: UITableViewDelegate, UITableViewDataSourc
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHConnectListCell.cellReuseIdentifier, for: indexPath) as? YHConnectListCell else { return UITableViewCell() } guard let cell = tableView.dequeueReusableCell(withIdentifier: YHConnectListCell.cellReuseIdentifier, for: indexPath) as? YHConnectListCell else { return UITableViewCell() }
if 0 <= indexPath.row, indexPath.row < arr.count {
let model = arr[indexPath.row]
cell.updateModel(model)
}
return cell return cell
} }
......
...@@ -9,52 +9,33 @@ ...@@ -9,52 +9,33 @@
import UIKit import UIKit
import SmartCodable import SmartCodable
// 联系人数据模型 class YHContactListModel: SmartCodable {
class YHContact: SmartCodable { var total: Int = 0
var list: [YHContact] = []
var name: String = ""
var title: String = ""
var industry: String = ""
var description: String = ""
var isVIP: Bool = false
// var relationship: ContactRelationship = ContactRelationship.none
required init() { required init() {
} }
} }
enum ContactRelationship { enum YHContactRelation: Int {
case none case stranger = 1
case friend case unvalidate = 3
case sentRequest case friend = 5
}
var buttonText: String {
switch self { // 联系人数据模型
case .none: class YHContact: SmartCodable {
return "添加好友" var id: String = ""
case .friend: var yh_id: String = ""
return "对方已是您的好友" var username: String = ""
case .sentRequest: var avatar: String = ""
return "已发送好友申请" var position: String = ""
} var industry: String = ""
} var signature: String = ""
var type: Int = 1 // 人脉状态 1: 陌生人 3: 待验证 5: 好友
var isInteractable: Bool {
switch self { required init() {
case .none:
return true
case .friend, .sentRequest:
return false
}
}
var buttonColor: UIColor {
switch self {
case .none:
return .systemBlue
case .friend, .sentRequest:
return .systemGray3
}
} }
} }
...@@ -25,29 +25,21 @@ class YHConnectListCell: UITableViewCell { ...@@ -25,29 +25,21 @@ class YHConnectListCell: UITableViewCell {
let label = UILabel() let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 15) label.font = UIFont.PFSC_B(ofSize: 15)
label.textColor = UIColor.brandGrayColor8 label.textColor = UIColor.brandGrayColor8
label.text = "XXXXXXXXXXXX"
return label return label
}() }()
private lazy var vipImgView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private lazy var titleLabel: UILabel = { private lazy var titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 13) label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = UIColor.brandGrayColor8 label.textColor = UIColor.brandGrayColor8
label.text = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
return label return label
}() }()
private lazy var descriptionLabel: UILabel = { private lazy var signatureLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 11) label.font = UIFont.PFSC_R(ofSize: 11)
label.textColor = UIColor.brandGrayColor6 label.textColor = UIColor.brandGrayColor6
label.numberOfLines = 2 label.numberOfLines = 2
label.text = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
return label return label
}() }()
...@@ -90,9 +82,8 @@ class YHConnectListCell: UITableViewCell { ...@@ -90,9 +82,8 @@ class YHConnectListCell: UITableViewCell {
// 添加所有子视图 // 添加所有子视图
contentView.addSubview(avatarImageView) contentView.addSubview(avatarImageView)
contentView.addSubview(nameLabel) contentView.addSubview(nameLabel)
contentView.addSubview(vipImgView)
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
contentView.addSubview(descriptionLabel) contentView.addSubview(signatureLabel)
contentView.addSubview(statusLabel) contentView.addSubview(statusLabel)
contentView.addSubview(addFriendButton) contentView.addSubview(addFriendButton)
contentView.addSubview(separatorLine) contentView.addSubview(separatorLine)
...@@ -109,13 +100,6 @@ class YHConnectListCell: UITableViewCell { ...@@ -109,13 +100,6 @@ class YHConnectListCell: UITableViewCell {
make.left.equalTo(avatarImageView.snp.right).offset(10) make.left.equalTo(avatarImageView.snp.right).offset(10)
make.height.equalTo(20) make.height.equalTo(20)
} }
vipImgView.snp.makeConstraints { make in
make.left.equalTo(nameLabel.snp.right).offset(4)
make.centerY.equalTo(nameLabel)
make.width.equalTo(43)
make.height.equalTo(16)
}
statusLabel.snp.makeConstraints { make in statusLabel.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-20) make.right.equalToSuperview().offset(-20)
...@@ -136,7 +120,7 @@ class YHConnectListCell: UITableViewCell { ...@@ -136,7 +120,7 @@ class YHConnectListCell: UITableViewCell {
make.right.equalToSuperview().offset(-20) make.right.equalToSuperview().offset(-20)
} }
descriptionLabel.snp.makeConstraints { make in signatureLabel.snp.makeConstraints { make in
make.left.equalTo(avatarImageView.snp.right).offset(10) make.left.equalTo(avatarImageView.snp.right).offset(10)
make.top.equalTo(titleLabel.snp.bottom).offset(4) make.top.equalTo(titleLabel.snp.bottom).offset(4)
make.right.equalToSuperview().offset(-20) make.right.equalToSuperview().offset(-20)
...@@ -152,19 +136,29 @@ class YHConnectListCell: UITableViewCell { ...@@ -152,19 +136,29 @@ class YHConnectListCell: UITableViewCell {
} }
func updateModel(_ contact: YHContact) { func updateModel(_ contact: YHContact) {
nameLabel.text = contact.name
titleLabel.text = "\(contact.title)\(contact.industry)" avatarImageView.sd_setImage(with: URL(string: contact.avatar), placeholderImage: UIImage(named: ""))
descriptionLabel.text = contact.description nameLabel.text = contact.username
titleLabel.text = "\(contact.position)\(contact.industry)"
// VIP标签显示 signatureLabel.text = contact.signature
vipImgView.isHidden = !contact.isVIP
if contact.type == YHContactRelation.stranger.rawValue {
// 按钮配置 addFriendButton.isHidden = false
// addFriendButton.setTitle(contact.relationship.buttonText, for: .normal) statusLabel.isHidden = true
// addFriendButton.isEnabled = contact.relationship.isInteractable
// addFriendButton.setTitleColor(contact.relationship.buttonColor, for: .normal) } else {
// addFriendButton.layer.borderColor = contact.relationship.buttonColor.cgColor addFriendButton.isHidden = true
statusLabel.isHidden = false
if contact.type == YHContactRelation.friend.rawValue {
statusLabel.text = "对方已是您的好友"
} else if contact.type == YHContactRelation.unvalidate.rawValue {
statusLabel.text = "已发送好友申请"
} else {
statusLabel.text = ""
}
}
// 头像占位符
} }
} }
//
// YHContactViewModel.swift
// galaxy
//
// Created by Dufet on 2025/9/28.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHContactViewModel: YHBaseViewModel {
var curPageIndex: Int = 1
var pageSize = 10
var totalCount: Int = 0
var contacts: [YHContact] = []
var hasMore: Bool = true
// super-app/business-card/list
// 最近浏览
func getList(_ firstFlag: Bool, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
var params: [String: Any] = ["page": curPageIndex,
"page_size": pageSize]
if firstFlag {
curPageIndex = 1
params = ["page": curPageIndex,
"page_size": pageSize]
} else {
params = ["page": curPageIndex + 1,
"page_size": pageSize]
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Contact.contactList
_ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, _ in
guard let self = self else { return }
// 1. json字符串 转 对象
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let result = YHContactListModel.deserialize(from: dic) else {
callBackBlock(false, nil)
return
}
if firstFlag {
self.totalCount = result.total
self.contacts.removeAll()
self.contacts = result.list
} else {
self.contacts.append(contentsOf: result.list)
curPageIndex += 1
}
if self.contacts.count >= self.totalCount {
self.hasMore = false
} else {
self.hasMore = true
}
callBackBlock(true, nil)
} else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
...@@ -148,9 +148,9 @@ class YHAddFriendCardCell: UITableViewCell { ...@@ -148,9 +148,9 @@ class YHAddFriendCardCell: UITableViewCell {
lazy var acceptBtn: UIButton = { lazy var acceptBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setTitle("接受", for: .normal) btn.setTitle("接受", for: .normal)
btn.backgroundColor = UIColor.brandMainColor btn.backgroundColor = UIColor.brandGrayColor8
btn.setTitleColor(UIColor.white, for: .normal) btn.setTitleColor(UIColor.white, for: .normal)
btn.titleLabel?.font = .PFSC_M(ofSize: 13.6) btn.titleLabel?.font = .PFSC_M(ofSize: 14)
btn.layer.cornerRadius = 2.75 btn.layer.cornerRadius = 2.75
btn.addTarget(self, action: #selector(didAcceptBtnClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(didAcceptBtnClicked), for: .touchUpInside)
return btn return btn
......
...@@ -27,10 +27,10 @@ class YHMyFriendsNoDataView: UIView { ...@@ -27,10 +27,10 @@ class YHMyFriendsNoDataView: UIView {
lazy var bottomBtn: UIButton = { lazy var bottomBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setTitle("返回人脉主页", for: .normal) btn.setTitle("去人脉寻找好友", for: .normal)
btn.backgroundColor = .brandMainColor btn.backgroundColor = .brandGrayColor2
btn.setTitleColor(.white, for: .normal) btn.setTitleColor(.brandGrayColor8, for: .normal)
btn.titleLabel?.font = .PFSC_M(ofSize: 13) btn.titleLabel?.font = .PFSC_M(ofSize: 12)
btn.layer.cornerRadius = 3 btn.layer.cornerRadius = 3
btn.addTarget(self, action: #selector(didBottomBtnClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(didBottomBtnClicked), for: .touchUpInside)
return btn return btn
...@@ -69,10 +69,10 @@ class YHMyFriendsNoDataView: UIView { ...@@ -69,10 +69,10 @@ class YHMyFriendsNoDataView: UIView {
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
} }
self.bottomBtn.snp.makeConstraints { make in self.bottomBtn.snp.makeConstraints { make in
make.width.equalTo(110) make.width.equalTo(112)
make.height.equalTo(38) make.height.equalTo(32)
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.top.equalTo(self.titleLabel.snp.bottom).offset(22) make.top.equalTo(self.titleLabel.snp.bottom).offset(24)
} }
} }
} }
...@@ -778,4 +778,9 @@ class YHAllApiName { ...@@ -778,4 +778,9 @@ class YHAllApiName {
// 获取用户鉴权 // 获取用户鉴权
static let getUsersig = "super-app/tencent/im/usersig" static let getUsersig = "super-app/tencent/im/usersig"
} }
//
struct Contact {
static let contactList = "super-app/business-card/list"
}
} }
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