Commit 123191bf authored by Steven杜宇's avatar Steven杜宇

Merge branch 'dev_1013' into 'develop'

dev 1013合并到develop

See merge request !26
parents 130b4cde 89a0b3d6
......@@ -254,7 +254,8 @@ NSString *const TUILogoutFailNotification = @"TUILogoutFailNotification";
[NSNotificationCenter.defaultCenter postNotificationName:TUILoginSuccessNotification object:nil];
}
fail:^(int code, NSString *desc) {
self.loginWithInit = NO;
__strong __typeof(weakSelf) strongSelf = weakSelf;
strongSelf.loginWithInit = NO;
if (fail) {
fail(code, desc);
}
......
......@@ -48,10 +48,11 @@ platform :ios do
kjzf = "kjzf"
develop_fix_adopter = "develop_fix_adopter"
txim_add_card = "txim_add_card"
dev_1013 = "dev_1013"
#打包正使用的分支
myPack_branch = txim_add_card
myPack_branch = dev_1013
# 打adhoc包 执行命令 fastlane galaxyTest
......
This diff is collapsed.
......@@ -276,6 +276,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
vc.url = tUrl
UIViewController.current?.navigationController?.pushViewController(vc)
}
} else if iType == 10 {
// 多主体订单二维码跳转
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
if !YHLoginManager.shared.isLogin() {
printLog("需要登录")
return
}
// - 获取它对应的参数
if let orderId = arrItems["orderId"] as? String, !orderId.isEmpty {
var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/order/detail?id=\(orderId)"
if YHLoginManager.shared.isLogin() {
let token = YHLoginManager.shared.h5Token
url = url + "&param=" + token
}
var tUrl = url
if !url.contains("navigationH=") {
tUrl = url + "?navigationH=\(k_Height_NavigationtBarAndStatuBar)"
if url.contains("?") {
tUrl = url + "&navigationH=\(k_Height_NavigationtBarAndStatuBar)"
}
}
let vc = YHH5WebViewVC()
vc.url = tUrl
vc.isHideNavigationBar = false
UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
}
}
} else {
printLog("未处理的类型 \(iType)")
}
......
......@@ -39,7 +39,7 @@ class YHNavigationController: UINavigationController {
if let lastVC = viewControllers.last {
let className = String(describing: type(of: lastVC))
if !className.hasPrefix("TUI") { // 模糊匹配类名,使得腾讯IM页面不用隐藏NavigationBar
var needAnimated = false
var needAnimated = animated
let lastSecondCount = viewControllers.count - 2
if lastSecondCount >= 0 {
let lastSecondVC = viewControllers[lastSecondCount]
......
// YHIMMessageHandler.swift
import UIKit
import SafariServices
import TUIConversation
import TUIChat
import IQKeyboardManagerSwift
class YHIMMessageHandler: NSObject {
weak var viewController: UIViewController?
weak var navigationController: UINavigationController?
private lazy var previewFileTool: YHFilePreviewTool = {
guard let vc = viewController else { fatalError("ViewController不能为空") }
return YHFilePreviewTool(targetVC: vc)
}()
init(viewController: UIViewController,
navigationController: UINavigationController?) {
self.viewController = viewController
self.navigationController = navigationController
super.init()
}
}
// MARK: - TUIYHCustomCellClickDelegate
extension YHIMMessageHandler: TUIYHCustomCellClickDelegate {
func didTap(inFileCell cellData: TUIFileMessageCellData) {
var isExist: ObjCBool = false
let path = cellData.getFilePath(&isExist)
if isExist.boolValue {
let url = URL(fileURLWithPath: path)
previewFileTool.openXLSXFile(at: url, fileName: cellData.fileName)
} else {
cellData.downloadFile()
}
}
func didTapCustomOrderCell(_ cellData: TUIOrderCellData) {
let linkAddress = cellData.link ?? ""
// 处理普通URL
if linkAddress.count > 0,
linkAddress.isValidHttpUrl || linkAddress.isValidHttpsUrl || linkAddress.isValidFileUrl,
let url = URL(string: linkAddress) {
showSafari(url: url)
return
}
// 处理自定义消息
handleCustomMessage(linkAddress)
}
private func handleCustomMessage(_ content: String?) {
guard let dicData = content,
!dicData.isEmpty,
let data = dicData.data(using: .utf8),
let jsonObject = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
!jsonObject.isEmpty else {
printLog("消息解析失败")
return
}
let msgType = jsonObject["msg_type"] as? String ?? ""
let navH5Url = jsonObject["nav_h5_url"] as? String ?? ""
let orderID = jsonObject["order_id"] as? Int ?? -1
let type = jsonObject["type"] as? Int ?? -1
let batchId = jsonObject["batch_id"] as? Int ?? 0
if msgType == "card_msg", navH5Url.count > 0 {
let title = jsonObject["title"] as? String ?? ""
showH5Page(baseUrl: navH5Url, title: title)
} else if orderID > -1, type > -1 {
showOrderMessage(type: type, orderId: orderID, batchId: batchId)
}
}
}
// MARK: - 公开方法
extension YHIMMessageHandler {
/// 处理IM消息点击
/// - Parameter conversationData: 会话数据
@MainActor func handleIMMessageTap(conversationData: TUIConversationCellData) {
updateNavigateBarBeforeEnterChatVC()
let params: [String: Any] = [
TUICore_TUIChatObjectFactory_ChatViewController_Title: conversationData.title,
TUICore_TUIChatObjectFactory_ChatViewController_UserID: conversationData.userID,
TUICore_TUIChatObjectFactory_ChatViewController_GroupID: conversationData.groupID,
TUICore_TUIChatObjectFactory_ChatViewController_AvatarImage: conversationData.avatarImage,
TUICore_TUIChatObjectFactory_ChatViewController_AvatarUrl: conversationData.faceUrl,
TUICore_TUIChatObjectFactory_ChatViewController_ConversationID: conversationData.conversationID,
TUICore_TUIChatObjectFactory_ChatViewController_AtTipsStr: conversationData.atTipsStr,
TUICore_TUIChatObjectFactory_ChatViewController_AtMsgSeqs: conversationData.atMsgSeqs,
TUICore_TUIChatObjectFactory_ChatViewController_Draft: conversationData.draftText
]
pushToChatViewController(with: params)
}
/// 处理远程通知
/// - Parameter userInfo: 通知数据
@MainActor func handleRemoteNotification(_ userInfo: [AnyHashable: Any]) {
let extString = userInfo["ext"] as? String ?? "{}"
let extData = extString.data(using: .utf8) ?? Data()
let ext = (try? JSONSerialization.jsonObject(with: extData, options: [])) as? [String: Any] ?? [:]
let entity = ext["entity"] as? [String: Any] ?? [:]
let chatType = entity["chatType"] as? Int ?? 0
let senderID = entity["sender"] as? String ?? ""
let nickName = entity["nickname"] as? String ?? ""
let aps = userInfo["aps"] as? [String: Any] ?? [:]
let alert = aps["alert"] as? [String: Any] ?? [:]
let title = alert["title"] as? String ?? nickName
guard senderID.count > 0 else { return }
updateNavigateBarBeforeEnterChatVC()
var param: [String: Any] = [
TUICore_TUIChatObjectFactory_ChatViewController_Title: title,
TUICore_TUIChatObjectFactory_ChatViewController_AvatarUrl: "",
TUICore_TUIChatObjectFactory_ChatViewController_AtTipsStr: "",
TUICore_TUIChatObjectFactory_ChatViewController_AtMsgSeqs: [],
TUICore_TUIChatObjectFactory_ChatViewController_Draft: ""
]
if chatType == 2 { // 群聊
param[TUICore_TUIChatObjectFactory_ChatViewController_GroupID] = senderID
param[TUICore_TUIChatObjectFactory_ChatViewController_ConversationID] = "group_\(senderID)"
} else { // 单聊
param[TUICore_TUIChatObjectFactory_ChatViewController_UserID] = senderID
param[TUICore_TUIChatObjectFactory_ChatViewController_ConversationID] = "c2c_\(senderID)"
}
pushToChatViewController(with: param)
}
@MainActor func gotoChatVC(senderID: String, isGroupChat: Bool = false) {
guard senderID.count > 0 else { return }
updateNavigateBarBeforeEnterChatVC()
var param: [String: Any] = [
TUICore_TUIChatObjectFactory_ChatViewController_Title: "",
TUICore_TUIChatObjectFactory_ChatViewController_AvatarUrl: "",
TUICore_TUIChatObjectFactory_ChatViewController_AtTipsStr: "",
TUICore_TUIChatObjectFactory_ChatViewController_AtMsgSeqs: [],
TUICore_TUIChatObjectFactory_ChatViewController_Draft: ""
]
if isGroupChat { // 群聊
param[TUICore_TUIChatObjectFactory_ChatViewController_GroupID] = senderID
param[TUICore_TUIChatObjectFactory_ChatViewController_ConversationID] = "group_\(senderID)"
} else { // 单聊
param[TUICore_TUIChatObjectFactory_ChatViewController_UserID] = senderID
param[TUICore_TUIChatObjectFactory_ChatViewController_ConversationID] = "c2c_\(senderID)"
}
pushToChatViewController(with: param)
}
}
// MARK: - 私有方法
extension YHIMMessageHandler {
/// 跳转到聊天页面(统一方法)
private func pushToChatViewController(with params: [String: Any]) {
let vc = navigationController?.push(
TUICore_TUIChatObjectFactory_ChatViewController_Classic,
param: params,
forResult: nil
)
if let chatVC = vc as? TUIBaseChatViewController {
chatVC.navigationItem.rightBarButtonItem = nil
chatVC.navigationItem.rightBarButtonItems = nil
chatVC.yhCustomCellClickDelegate = self
}
}
/// 更新导航栏配置
@MainActor private func updateNavigateBarBeforeEnterChatVC() {
IQKeyboardManager.shared.isEnabled = false
navigationController?.gk_hideNavigationBar = false
navigationController?.isNavigationBarHidden = false
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .white
appearance.shadowImage = UIImage()
appearance.shadowColor = .clear
navigationController?.navigationBar.tintColor = .black
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance
}
/// 显示Safari浏览器
private func showSafari(url: URL) {
let safariVC = SFSafariViewController(url: url)
safariVC.dismissButtonStyle = .close
safariVC.modalPresentationStyle = .fullScreen
viewController?.present(safariVC, animated: true)
}
/// 显示H5页面(带Token)
private func showH5Page(baseUrl: String, title: String) {
var finalUrl = baseUrl
if YHLoginManager.shared.isLogin() {
let token = YHLoginManager.shared.h5Token
let separator = baseUrl.contains("?") ? "&" : "?"
finalUrl = baseUrl + separator + "param=" + token
}
let webVC = YHH5WebViewVC()
webVC.isFullScreenFlag = false
webVC.navTitle = title
webVC.url = finalUrl
navigationController?.pushViewController(webVC)
}
/// 显示订单消息页面
private func showOrderMessage(type: Int, orderId: Int, batchId: Int) {
YHServiceOrderListViewController.jumpToMessageController(
type: type,
orderId: orderId,
batchId
)
}
}
......@@ -126,8 +126,23 @@ class YHActivityListViewController: YHBaseViewController {
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHActivityListCell.self, forCellReuseIdentifier: YHActivityListCell.cellReuseIdentifier)
tableView.backgroundView = self.emptyDataTipsView
tableView.tableHeaderView = self.headerView
return tableView
}()
lazy var headerView: UIView = {
let radio = 88.0/335.0
let imgWidth = KScreenWidth - 20.0 * 2
let imgHeight = imgWidth * radio
var height = imgHeight + 16.0
let view = UIView(frame: CGRect(x: 20, y: 0, width: imgWidth, height: height))
let imgV = UIImageView(frame: CGRect(x: 0, y: 16, width: imgWidth, height: imgHeight))
imgV.image = UIImage(named: "activity_header_img")
view.addSubview(imgV)
let tap = UITapGestureRecognizer(target: self, action: #selector(didHeaderClicked))
view.addGestureRecognizer(tap)
return view
}()
lazy var emptyDataTipsView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无活动", kEmptyCommonBgName)
......@@ -135,6 +150,13 @@ class YHActivityListViewController: YHBaseViewController {
view.isHidden = true
return view
}()
lazy var messageHandler: YHIMMessageHandler = {
return YHIMMessageHandler(
viewController: self,
navigationController: navigationController
)
}()
// MARK: - 生命周期方法
......@@ -185,6 +207,26 @@ class YHActivityListViewController: YHBaseViewController {
}
extension YHActivityListViewController {
@objc func didHeaderClicked() {
YHGrayCommonAlertView.show("联系银河管家", "银河可为您组织线下活动,快来与我们聊聊您的需求吧~", "取消", "前往联系", fullGuestureEnable: false) {
} callBack: { [weak self] in
guard let self = self else {
return
}
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.getActiticyYhId { id in
YHHUD.hide()
if id.isEmpty {
YHHUD.flash(message: "获取银河ID失败")
return
}
self.messageHandler.gotoChatVC(senderID: id)
}
}
}
func loadMoreData() {
viewModel.getActivityList(firstFlag: false, type: type) { [weak self] _, _ in
guard let self = self else { return }
......@@ -300,20 +342,11 @@ extension YHActivityListViewController: UITableViewDelegate, UITableViewDataSour
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
var height: CGFloat = 16.0
if section != 0 {
height = 20.0
}
return height
return 20.0
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
var height: CGFloat = 16.0
if section != 0 {
height = 20.0
}
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth - 16.0 * 2, height: height))
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth - 16.0 * 2, height: 20))
view.backgroundColor = .clear
return view
}
......
......@@ -19,6 +19,13 @@ class YHActivityHelpModel: SmartCodable {
}
}
class ActiticyIdModel: SmartCodable {
var yh_id: String = ""
required init() {
}
}
class YHActivityViewModel: YHBaseViewModel {
// 1、活动列表 、 我的报名活动列表
var hasMoreForActivityList: Bool = true
......@@ -258,4 +265,22 @@ extension YHActivityViewModel {
callBackBlock(false, err)
}
}
func getActiticyYhId(callback: @escaping (String) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Resource.yhManagerId + "?mode=2"
_ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, _ in
guard let self = self else { return }
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let result = ActiticyIdModel.deserialize(from: dic) else {
return
}
callback(result.yh_id)
} else {
callback("")
}
} failBlock: { _ in
callback("")
}
}
}
......@@ -36,10 +36,10 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
self.photoImageView.kf.setImage(with: url)
if self.viewModel.isCanNext() {
nextButton.isEnabled = true
nextButton.backgroundColor = UIColor.brandMainColor
nextButton.backgroundColor = UIColor.brandGrayColor8
} else {
nextButton.isEnabled = false
nextButton.backgroundColor = UIColor.brandMainColor.withAlphaComponent(0.4)
nextButton.backgroundColor = UIColor.brandGrayColor4
}
}
}
......@@ -51,7 +51,7 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
stepOneView = {
let view = UIView()
view.backgroundColor = UIColor.brandMainColor
view.backgroundColor = UIColor.brandGrayColor8
return view
}()
view.addSubview(stepOneView)
......@@ -64,7 +64,7 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
stepTwoView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0xf4f6fa)
view.backgroundColor = UIColor.brandGrayColor2
return view
}()
view.addSubview(stepTwoView)
......@@ -122,10 +122,10 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
nextButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandMainColor.withAlphaComponent(0.4)
button.backgroundColor = UIColor.brandGrayColor4
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.contentHorizontalAlignment = .center
button.setTitle("提交", for: .normal)
button.setTitle("确定", for: .normal)
button.setTitleColor( UIColor(hex: 0xffffff), for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(nextStep), for: .touchUpInside)
......@@ -161,9 +161,9 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
promptView = {
let view = YHFailPromptView()
view.titleLable.text = "温馨提示:请填写真实信息,AI人脉匹配更精准"
view.backgroundColor = UIColor(hex: 0xf0f4fb)
view.titleLable.textColor = UIColor.brandMainColor
view.titleLable.text = "温馨提示:请填写真实信息,便于资源互换"
view.backgroundColor = UIColor.brandGrayColor2
view.titleLable.textColor = UIColor.brandGrayColor8
view.alertImageView.image = UIImage(named: "user_prompt_image")
return view
}()
......@@ -209,6 +209,7 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
guard let self = self else { return }
let vc = YHInformationAuthorizationStepTwoViewController()
vc.name = self.viewModel.model.username
vc.popToRoot = true
self.navigationController?.pushViewController(vc)
}
}
......@@ -227,10 +228,10 @@ extension YHInformationAuthorizationStepOneViewController: UITableViewDelegate,
self.viewModel.updateModel(model)
if self.viewModel.isCanNext() {
nextButton.isEnabled = true
nextButton.backgroundColor = UIColor.brandMainColor
nextButton.backgroundColor = UIColor.brandGrayColor8
} else {
nextButton.isEnabled = false
nextButton.backgroundColor = UIColor.brandMainColor.withAlphaComponent(0.4)
nextButton.backgroundColor = UIColor.brandGrayColor4
}
if model.id != .id1 && model.id != .id3 && model.id != .id5 {
self.items = viewModel.getBaseDataSource()
......
......@@ -9,6 +9,7 @@
import UIKit
class YHInformationAuthorizationStepTwoViewController: YHBaseViewController {
var popToRoot: Bool = false
var stepOneView: UIView!
var stepTwoView: UIView!
var nextButton: UIButton!
......@@ -24,16 +25,16 @@ class YHInformationAuthorizationStepTwoViewController: YHBaseViewController {
}
func getData() {
if stepFlag {
items = viewModel.getBaseSetDataSource()
tableView.reloadData()
} else {
// if stepFlag {
// items = viewModel.getBaseSetDataSource()
// tableView.reloadData()
// } else {
viewModel.requestUserAuthorization {[weak self] _, _ in
guard let self = self else { return }
items = viewModel.getBaseSetDataSource()
tableView.reloadData()
}
}
// }
}
func setView() {
......@@ -42,7 +43,7 @@ class YHInformationAuthorizationStepTwoViewController: YHBaseViewController {
stepOneView = {
let view = UIView()
view.backgroundColor = UIColor.brandMainColor
view.backgroundColor = UIColor.brandGrayColor8
return view
}()
view.addSubview(stepOneView)
......@@ -55,7 +56,7 @@ class YHInformationAuthorizationStepTwoViewController: YHBaseViewController {
stepTwoView = {
let view = UIView()
view.backgroundColor = UIColor.brandMainColor
view.backgroundColor = UIColor.brandGrayColor8
return view
}()
view.addSubview(stepTwoView)
......@@ -68,7 +69,7 @@ class YHInformationAuthorizationStepTwoViewController: YHBaseViewController {
nextButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandMainColor
button.backgroundColor = UIColor.brandGrayColor8
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.contentHorizontalAlignment = .center
button.setTitle("完成", for: .normal)
......@@ -117,15 +118,19 @@ class YHInformationAuthorizationStepTwoViewController: YHBaseViewController {
@objc func nextStep() {
viewModel.requestAuthorizationSubmit {[weak self] _, _ in
guard let self = self else { return }
if self.stepFlag {
// if self.stepFlag {
// self.navigationController?.popToRootViewController(animated: true)
// let view = YHPeopleSuccessView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
// view.titleLabel.text = "Hi,\(self.name)\n您的人脉网络已激活"
// let window = UIApplication.shared.yhKeyWindow()
// window?.addSubview(view)
// } else {
if popToRoot {
self.navigationController?.popToRootViewController(animated: true)
let view = YHPeopleSuccessView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.titleLabel.text = "Hi,\(self.name)\n您的人脉网络已激活"
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
} else {
self.navigationController?.popViewController(animated: true)
}
// }
}
}
}
......
......@@ -178,7 +178,7 @@ class YHMatchResultListViewController: YHBaseViewController {
}
if let userId = YHLoginManager.shared.userModel?.id, !userId.isEmpty {
let vc = YHNameCardViewController()
let vc = YHNewNameCardViewController()
vc.userId = userId
self.navigationController?.pushViewController(vc)
} else {
......@@ -189,7 +189,7 @@ class YHMatchResultListViewController: YHBaseViewController {
guard let self = self else { return }
if !uid.isEmpty {
YHLoginManager.shared.userModel?.id = uid
let vc = YHNameCardViewController()
let vc = YHNewNameCardViewController()
vc.userId = uid
self.navigationController?.pushViewController(vc)
}
......
......@@ -31,7 +31,11 @@ class YHMyGoodFriendsVC: YHBaseViewController {
view.bottomBtnClick = {
[weak self] in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
goTabBarBy(tabType: .community)
UIViewController.current?.navigationController?.popToRootViewController(animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
NotificationCenter.default.post(name: YhConstant.YhNotification.goConnectionVCNotifiction, object: nil)
}
}
view.isHidden = true
return view
......@@ -144,7 +148,7 @@ extension YHMyGoodFriendsVC: UITableViewDelegate, UITableViewDataSource {
if indexPath.section == 1 {
if 0 <= indexPath.row && indexPath.row < friendsArr.count {
let friend = self.friendsArr[indexPath.row]
let vc = YHNameCardViewController()
let vc = YHNewNameCardViewController()
vc.userId = friend.yhId
self.navigationController?.pushViewController(vc)
}
......
//
// YHCircleAddPhotoCell.swift
// galaxy
//
// Created by alexzzw on 2025/9/26.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHCircleAddPhotoCell: UICollectionViewCell {
private lazy var containerView: UIView = {
let view = UIView()
view.backgroundColor = UIColor.systemGray6
return view
}()
private lazy var plusImageView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "circle_plus_icon")
return imageView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
contentView.addSubview(containerView)
containerView.addSubview(plusImageView)
containerView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
plusImageView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(40)
}
}
}
//
// YHCircleHeaderButtonsView.swift
// galaxy
//
// Created by alexzzw on 2025/9/24.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHeaderButtonItemView: UIControl {
private lazy var iconView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private lazy var contentLabel: UILabel = {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = UIColor.brandGrayColor8
return label
}()
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.brandGrayColor1
addSubview(iconView)
addSubview(contentLabel)
contentLabel.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-14)
make.left.right.equalToSuperview()
}
iconView.snp.makeConstraints { make in
make.bottom.equalTo(contentLabel.snp.top).offset(-6)
make.width.height.equalTo(24)
make.centerX.equalToSuperview()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup(text: String, iconString: String) {
contentLabel.text = text
iconView.image = UIImage(named: iconString)
}
}
// 按钮点击回调协议
protocol YHCircleHeaderButtonsViewDelegate: AnyObject {
func headerButtonsView(_ view: YHCircleHeaderButtonsView, didTapButtonAt index: Int)
}
class YHCircleHeaderButtonsView: UIView {
weak var delegate: YHCircleHeaderButtonsViewDelegate?
// 按钮数据模型
private let buttonData: [(title: String, imageName: String)] = [
("找客户", "icon_find_customer"),
("找服务", "icon_find_service"),
("拓人脉", "icon_expand_network"),
("办活动", "icon_organize_event")
]
// 按钮数组
private var buttons: [UIControl] = []
// 容器栈视图
private lazy var stackView: UIStackView = {
let stack = UIStackView()
stack.axis = .horizontal
stack.distribution = .fillEqually
stack.alignment = .fill
stack.spacing = 10
stack.translatesAutoresizingMaskIntoConstraints = false
return stack
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupUI()
}
private func setupUI() {
backgroundColor = .white
addSubview(stackView)
// 设置约束
stackView.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(20)
make.top.equalToSuperview().offset(16)
make.bottom.equalToSuperview().offset(-20)
}
// 创建按钮
createButtons()
}
private func createButtons() {
for (index, data) in buttonData.enumerated() {
let button = createButton(title: data.title, imageName: data.imageName, tag: index)
buttons.append(button)
stackView.addArrangedSubview(button)
}
}
private func createButton(title: String, imageName: String, tag: Int) -> UIControl {
let button = YHHeaderButtonItemView()
button.setup(text: title, iconString: imageName)
button.tag = tag
// 添加点击事件
button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)
return button
}
@objc private func buttonTapped(_ sender: UIControl) {
// 调用代理方法
delegate?.headerButtonsView(self, didTapButtonAt: sender.tag)
}
}
// MARK: - UICollectionReusableView 版本(用于 CollectionView Header)
class YHCircleHeaderReusableView: UICollectionReusableView {
static let reuseIdentifier = "YHCircleHeaderReusableView"
weak var delegate: YHCircleHeaderButtonsViewDelegate?
private lazy var headerButtonsView: YHCircleHeaderButtonsView = {
let view = YHCircleHeaderButtonsView()
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupUI()
}
private func setupUI() {
backgroundColor = .white
addSubview(headerButtonsView)
headerButtonsView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
headerButtonsView.delegate = self
}
}
// MARK: - YHCircleHeaderButtonsViewDelegate
extension YHCircleHeaderReusableView: YHCircleHeaderButtonsViewDelegate {
func headerButtonsView(_ view: YHCircleHeaderButtonsView, didTapButtonAt index: Int) {
delegate?.headerButtonsView(view, didTapButtonAt: index)
}
}
//
// YHCircleMediaCell.swift
// galaxy
//
// Created by alexzzw on 2025/9/27.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AVFoundation
class YHCircleMediaCell: UICollectionViewCell {
var deleteCallback: (() -> Void)?
// MARK: - UI Components
private lazy var imageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.backgroundColor = UIColor.brandGrayColor2
return imageView
}()
private lazy var deleteButton: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal)
button.tintColor = .white
button.backgroundColor = UIColor.black.withAlphaComponent(0.5)
button.layer.cornerRadius = 10
button.addTarget(self, action: #selector(deleteButtonTapped), for: .touchUpInside)
button.isHidden = true
return button
}()
private lazy var playIcon: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "circle_play_icon")
imageView.isHidden = true
return imageView
}()
private lazy var durationLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 12, weight: .medium)
label.textColor = .white
label.backgroundColor = UIColor.black.withAlphaComponent(0.5)
label.textAlignment = .center
label.layer.cornerRadius = 8
label.clipsToBounds = true
label.isHidden = true
return label
}()
// MARK: - Initialization
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Setup UI
private func setupUI() {
contentView.addSubview(imageView)
contentView.addSubview(playIcon)
contentView.addSubview(durationLabel)
contentView.addSubview(deleteButton)
imageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
playIcon.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(40)
}
durationLabel.snp.makeConstraints { make in
make.bottom.right.equalToSuperview().inset(8)
make.height.equalTo(20)
make.width.greaterThanOrEqualTo(35)
}
deleteButton.snp.makeConstraints { make in
make.top.right.equalToSuperview().inset(4)
make.width.height.equalTo(20)
}
}
// MARK: - Configure Cell
func configure(with mediaItem: YHSelectMediaItem) {
resetCell()
switch mediaItem.type {
case .image:
configureForImage(mediaItem)
case .video:
configureForVideo(mediaItem)
}
}
private func resetCell() {
imageView.image = nil
playIcon.isHidden = true
durationLabel.isHidden = true
durationLabel.text = nil
}
private func configureForImage(_ mediaItem: YHSelectMediaItem) {
if let url = mediaItem.imageURL {
imageView.sd_setImage(with: url, placeholderImage: UIImage(named: "global_default_image"), context: nil)
} else {
imageView.image = mediaItem.image
}
playIcon.isHidden = true
durationLabel.isHidden = true
}
private func configureForVideo(_ mediaItem: YHSelectMediaItem) {
// 显示视频相关UI
playIcon.isHidden = false
// 生成视频缩略图
if let videoURL = mediaItem.videoURL {
generateVideoThumbnail(from: videoURL) { [weak self] thumbnail in
DispatchQueue.main.async {
self?.imageView.image = thumbnail
}
}
}
// 显示视频时长
// if let duration = mediaItem.duration {
// durationLabel.text = formatDuration(duration)
// durationLabel.isHidden = false
// } else if let videoURL = mediaItem.videoURL {
// // 如果没有时长信息,尝试获取
// getVideoDuration(from: videoURL) { [weak self] duration in
// DispatchQueue.main.async {
// if duration > 0 {
// self?.durationLabel.text = self?.formatDuration(duration)
// self?.durationLabel.isHidden = false
// }
// }
// }
// }
}
// MARK: - Video Helpers
private func generateVideoThumbnail(from url: URL, completion: @escaping (UIImage?) -> Void) {
DispatchQueue.global(qos: .userInitiated).async {
let asset = AVAsset(url: url)
let imageGenerator = AVAssetImageGenerator(asset: asset)
imageGenerator.appliesPreferredTrackTransform = true
imageGenerator.maximumSize = CGSize(width: 300, height: 300)
let time = CMTime(seconds: 0.0, preferredTimescale: 600)
do {
let cgImage = try imageGenerator.copyCGImage(at: time, actualTime: nil)
let thumbnail = UIImage(cgImage: cgImage)
completion(thumbnail)
} catch {
print("生成视频缩略图失败: \(error)")
completion(nil)
}
}
}
private func getVideoDuration(from url: URL, completion: @escaping (TimeInterval) -> Void) {
DispatchQueue.global(qos: .userInitiated).async {
let asset = AVAsset(url: url)
let duration = CMTimeGetSeconds(asset.duration)
completion(duration.isNaN ? 0 : duration)
}
}
private func formatDuration(_ duration: TimeInterval) -> String {
let totalSeconds = Int(duration)
let minutes = totalSeconds / 60
let seconds = totalSeconds % 60
if minutes > 0 {
return String(format: "%d:%02d", minutes, seconds)
} else {
return String(format: "0:%02d", seconds)
}
}
// MARK: - Actions
@objc private func deleteButtonTapped() {
deleteCallback?()
}
}
//
// YHCirclePhotoCell.swift
// galaxy
//
// Created by alexzzw on 2025/9/26.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
// MARK: - Custom Cells
class YHCirclePhotoCell: UICollectionViewCell {
var deleteCallback: (() -> Void)?
private lazy var imageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
return imageView
}()
private lazy var deleteButton: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal)
button.tintColor = .white
button.backgroundColor = UIColor.black.withAlphaComponent(0.5)
button.layer.cornerRadius = 10
button.addTarget(self, action: #selector(deleteButtonTapped), for: .touchUpInside)
button.isHidden = true
return button
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
contentView.addSubview(imageView)
contentView.addSubview(deleteButton)
imageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
deleteButton.snp.makeConstraints { make in
make.top.right.equalToSuperview().inset(4)
make.width.height.equalTo(20)
}
}
func configure(with image: UIImage) {
imageView.image = image
}
@objc private func deleteButtonTapped() {
deleteCallback?()
}
}
//
// YHConnectListViewController.swift
// galaxy
//
// Created by Dufet on 2025/9/25.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import JXSegmentedView
import UIKit
class YHConnectListViewController: YHBaseViewController {
let viewModel = YHContactViewModel()
let matchViewModel = YHMatchUserViewModel()
var arr: [YHContact] = []
lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.showsVerticalScrollIndicator = false
tableView.contentInsetAdjustmentBehavior = .never
tableView.estimatedSectionHeaderHeight = 1.0
tableView.estimatedSectionFooterHeight = 1.0
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor.white
tableView.register(YHConnectListCell.self, forCellReuseIdentifier: YHConnectListCell.cellReuseIdentifier)
tableView.es.addYHPullToRefresh {
self.reguestData(true)
}
tableView.es.addInfiniteScrolling {
self.reguestData(false)
}
return tableView
}()
lazy var noDataView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无内容", kEmptyCommonBgName)
view.isHidden = true
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
gk_navigationBar.isHidden = true
view.backgroundColor = UIColor.white
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalToSuperview()
make.top.equalToSuperview().offset(0)
}
view.addSubview(noDataView)
noDataView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(KScreenWidth)
make.height.equalTo(150)
}
reguestData(true)
}
func reguestData(_ isFirstPage: Bool) {
self.viewModel.getList(isFirstPage) { _, _ in
self.arr.removeAll()
self.arr.append(contentsOf: (self.viewModel.contacts))
self.noDataView.isHidden = self.arr.count > 0
self.tableView.reloadData()
self.tableView.es.stopLoadingMore()
self.tableView.es.stopPullToRefresh()
if !self.viewModel.hasMore {
self.tableView.es.noticeNoMoreData()
}
}
}
}
extension YHConnectListViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> 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)
cell.addFriendBlock = {[weak self] text in
guard let self = self else { return }
YHHUD.show(.progress(message: "加载中..."))
self.matchViewModel.addFriendWithText(text!, yhId: model.yh_id) {
success, error in
YHHUD.hide()
if success {
model.type = YHContactRelation.unvalidate.rawValue
self.tableView.reloadData()
} else {
var msg = "申请失败"
if let errMsg = error?.errorMsg, !errMsg.isEmpty {
msg = errMsg
}
YHHUD.flash(message: msg)
}
}
}
}
return cell
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 1.0
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 1.0
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < arr.count {
let contact = arr[indexPath.row]
let vc = YHNewNameCardViewController()
vc.userId = contact.yh_id
navigationController?.pushViewController(vc)
}
}
}
extension YHConnectListViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
//
// YHContact.swift
// galaxy
//
// Created by Dufet on 2025/9/25.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHContactListModel: SmartCodable {
var total: Int = 0
var list: [YHContact] = []
required init() {
}
}
enum YHContactRelation: Int {
case stranger = 1 // 陌生人
case unvalidate = 3 // 待验证
case friend = 5 // 好友
}
// 联系人数据模型
class YHContact: SmartCodable {
var id: String = ""
var yh_id: String = ""
var username: String = ""
var avatar: String = ""
var position: String = ""
var industry: String = ""
var signature: String = ""
var bio: String = ""
var type: Int = 1 // 人脉状态 1: 陌生人 3: 待验证 5: 好友
required init() {
}
}
//
// YHConnectListCellTableViewCell.swift
// galaxy
//
// Created by Dufet on 2025/9/25.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHConnectListCell: UITableViewCell {
static let cellReuseIdentifier = "YHConnectListCell"
var addFriendBlock: ((String?) -> Void) = { (_: String?) in }
var contact: YHContact = YHContact()
private lazy var avatarImageView: UIImageView = {
let imageView = UIImageView()
imageView.layer.borderWidth = 0.5
imageView.layer.borderColor = UIColor.brandGrayColor3.cgColor
imageView.layer.cornerRadius = 22
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
return imageView
}()
private lazy var nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 15)
label.textColor = UIColor.brandGrayColor8
return label
}()
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = UIColor.brandGrayColor8
return label
}()
private lazy var detailLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 11)
label.textColor = UIColor.brandGrayColor6
label.numberOfLines = 2
return label
}()
lazy var addFriendButton: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("添加好友", for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 11)
button.setTitleColor(UIColor.brandGrayColor8, for: .normal)
button.layer.borderWidth = 0.5
button.layer.borderColor = UIColor.brandGrayColor5.cgColor
button.addTarget(self, action: #selector(didAddFriendBtnClicked), for: .touchUpInside)
return button
}()
private lazy var statusLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 11)
label.textColor = UIColor.brandGrayColor6
label.text = "已发送好友申请"
return label
}()
private lazy var separatorLine: UIView = {
let view = UIView()
view.backgroundColor = UIColor.brandGrayColor3
return view
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
@objc func didAddFriendBtnClicked() {
let view = YHFriendRequestView.createView()
view.userModel = self.contact
view.sendBlock = {
[weak self] text in
guard let self = self else { return }
self.addFriendBlock(text)
}
view.show()
}
private func setupUI() {
selectionStyle = .none
// 添加所有子视图
contentView.addSubview(avatarImageView)
contentView.addSubview(nameLabel)
contentView.addSubview(titleLabel)
contentView.addSubview(detailLabel)
contentView.addSubview(statusLabel)
contentView.addSubview(addFriendButton)
contentView.addSubview(separatorLine)
// SnapKit 约束设置
avatarImageView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.top.equalToSuperview().offset(20)
make.width.height.equalTo(44)
make.bottom.lessThanOrEqualTo(-20)
}
nameLabel.snp.makeConstraints { make in
make.top.equalTo(avatarImageView.snp.top)
make.left.equalTo(avatarImageView.snp.right).offset(10)
make.right.equalTo(-120)
make.height.equalTo(20)
}
statusLabel.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-20)
make.centerY.equalTo(nameLabel)
make.height.equalTo(15)
}
addFriendButton.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-20)
make.bottom.equalTo(nameLabel.snp.bottom)
make.width.equalTo(68)
make.height.equalTo(25)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(avatarImageView.snp.right).offset(10)
make.top.equalTo(nameLabel.snp.bottom).offset(3)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(18)
}
detailLabel.snp.makeConstraints { make in
make.left.equalTo(avatarImageView.snp.right).offset(10)
make.top.equalTo(titleLabel.snp.bottom).offset(4)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(15)
make.bottom.lessThanOrEqualTo(-20)
}
separatorLine.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.bottom.equalToSuperview()
make.height.equalTo(0.5)
}
}
func updateModel(_ contact: YHContact) {
self.contact = contact
avatarImageView.sd_setImage(with: URL(string: contact.avatar), placeholderImage: UIImage(named: ""))
nameLabel.text = contact.username
detailLabel.text = contact.bio
var text1 = ""
var text1Arr: [String] = []
if !self.contact.position.isEmpty {
text1Arr.append(self.contact.position)
}
if !self.contact.industry.isEmpty {
text1Arr.append(self.contact.industry)
}
if text1Arr.count > 0 {
text1 = text1Arr.joined(separator: " | ")
}
titleLabel.text = text1
detailLabel.snp.updateConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(contact.bio.isEmpty ? 0 : 4)
make.height.equalTo(contact.bio.isEmpty ? 0 : 15)
}
if contact.type == YHContactRelation.stranger.rawValue {
addFriendButton.isHidden = false
statusLabel.isHidden = true
} else {
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)
}
}
}
......@@ -67,17 +67,14 @@ class YHMatchUserAddress: SmartCodable {
class YHAuthorizationModel: SmartCodable {
var educationExperience: Int = 0
var workExperience: Int = 0
var public_education_experience: Int = 0
var public_work_experience: Int = 0
var friend_education_experience: Int = 0
var friend_work_experience: Int = 0
required init() {
}
enum CodingKeys: String, CodingKey {
case educationExperience = "public_education_experience"
case workExperience = "public_work_experience"
}
}
enum YHNameCardInfoType: Int {
......@@ -110,19 +107,20 @@ 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 {
get {
return self.authorization.educationExperience != 2
return self.authorization.public_education_experience != 2 || self.authorization.friend_education_experience != 2
}
}
var isHiddenWorkExperience: Bool {
get {
return self.authorization.workExperience != 2
return self.authorization.public_work_experience != 2 || self.authorization.friend_work_experience != 2
}
}
......@@ -149,8 +147,10 @@ class YHUserNameCardInfo: SmartCodable {
self.position = model.position
self.industry = model.industry
self.honor = model.honor
self.authorization.educationExperience = model.authorization.educationExperience
self.authorization.workExperience = model.authorization.workExperience
self.authorization.public_education_experience = model.authorization.public_education_experience
self.authorization.public_work_experience = model.authorization.public_work_experience
self.authorization.friend_education_experience = model.authorization.friend_education_experience
self.authorization.friend_work_experience = model.authorization.friend_work_experience
self.topics.removeAll()
self.topics.append(contentsOf: model.topics)
}
......@@ -160,7 +160,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
......
......@@ -32,6 +32,8 @@ struct YHUserInformationModel {
var value: [String]?
var isNeed: Bool?
var country: String = ""
init(id: YHUserInformationID? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, type: YHItemSelectType? = nil, value: [String]? = nil, isNeed: Bool? = nil) {
self.id = id
self.title = title
......@@ -61,11 +63,14 @@ class YHMainUserInformationModel: SmartCodable {
}
class YHMainUserInformationSetModel: SmartCodable {
// 1: 关闭 2:开启
var uid: String = ""
var information_to_card: Int = 2
var information_to_card: Int = 2 // 弃用
var authorization_basic_information: Int = 2
var public_education_experience: Int = 2
var public_work_experience: Int = 2
var friend_education_experience: Int = 2
var friend_work_experience: Int = 2
var isclick_card: Int = 2
required init() {
}
......
//
// YHCompanyAuthorizationViewController.swift
// galaxy
//
// Created by alexzzw on 2025/10/11.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHCompanyAuthorizationViewController: YHBaseViewController {
// MARK: - Properties
var detailModel: YHResourceDetailModel? // 详情数据
var completionBlock: (() -> Void)?
private lazy var viewModel: YHResourceViewModel = {
return YHResourceViewModel()
}()
private var items: [YHSettingItem] = []
// MARK: - UI Components
private lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .white
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(cellWithClass: YHCompanyAuthSettingCell.self)
tableView.showsVerticalScrollIndicator = false
return tableView
}()
private lazy var completeButton: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandGrayColor8
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("完成", for: .normal)
button.setTitleColor(.white, for: .normal)
button.layer.cornerRadius = 3
button.addTarget(self, action: #selector(completeAction), for: .touchUpInside)
return button
}()
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
loadData()
}
// MARK: - Setup
private func setupUI() {
gk_navTitle = "信息授权"
view.backgroundColor = .white
view.addSubview(tableView)
view.addSubview(completeButton)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalToSuperview()
make.bottom.equalTo(completeButton.snp.top).offset(-12)
}
completeButton.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 12)
make.height.equalTo(48)
}
}
// MARK: - Data
private func loadData() {
guard let detailModel = detailModel else {
return
}
viewModel.isMyCompanyOpen = detailModel.isSettlement
let item = YHSettingItem.init(type: .companyToStrange, title: "允许公开您的公司信息", subTitle: "开启后,您的公司信息将展示在资源列表,包括企业服务与企业需求", isSelect: viewModel.isMyCompanyOpen, isShowAlert: true)
self.items = [item]
self.tableView.reloadData()
}
// MARK: - Actions
@objc private func completeAction() {
guard let detailModel = detailModel else {
return
}
// 2-开启,3-关闭
let status = detailModel.isSettlement ? 3 : 2
YHHUD.show(.progress(message: "加载中..."))
viewModel.companyAuthor(status: status) { [weak self] success, errorMsg in
guard let self = self else {
return
}
YHHUD.hide()
if success {
self.completionBlock?()
self.navigationController?.popViewController(animated: true)
} else {
YHHUD.flash(message: errorMsg ?? "授权失败,请重试")
}
}
}
@objc private func infoButtonTapped(_ sender: UIButton) {
guard sender.tag < items.count else { return }
let model = items[sender.tag]
showExplanationView(for: model)
}
// MARK: - Private Methods
private func handleSwitchToggle(at index: Int, isOn: Bool) {
guard index < items.count else { return }
let model = items[index]
switch model.type {
case .companyToStrange:
if !isOn {
YHGrayCommonAlertView.show(
"",
"关闭后,您的公司信息将不展示在资源列表",
"仍然关闭",
"保持开启",
fullGuestureEnable: false,
cancelCallBack: { [weak self] in
self?.updateModelState(at: index, isEnabled: false)
},
callBack: { [weak self] in
self?.revertSwitchState(at: index, to: true)
}
)
} else {
updateModelState(at: index, isEnabled: true)
}
default:
break
}
}
private func updateModelState(at index: Int, isEnabled: Bool) {
items[index].isSelect = isEnabled
viewModel.isMyCompanyOpen = isEnabled
tableView.reloadRows(at: [IndexPath(row: index, section: 0)], with: .none)
}
private func revertSwitchState(at index: Int, to value: Bool) {
items[index].isSelect = value
tableView.reloadRows(at: [IndexPath(row: index, section: 0)], with: .none)
}
private func showExplanationView(for model: YHSettingItem) {
let view = YHSetExplainView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.type = model.type
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
}
}
// MARK: - UITableViewDelegate & DataSource
extension YHCompanyAuthorizationViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHCompanyAuthSettingCell.self)
let model = items[indexPath.row]
cell.configure(with: model)
cell.infoButton.tag = indexPath.row
cell.infoButton.addTarget(self, action: #selector(infoButtonTapped(_:)), for: .touchUpInside)
cell.onSwitchToggle = { [weak self] isOn in
self?.handleSwitchToggle(at: indexPath.row, isOn: isOn)
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
}
......@@ -11,15 +11,15 @@ import UIKit
class YHAddFriendCardCell: UITableViewCell {
static let cellReuseIdentifier = "YHAddFriendCardCell"
let secondCardColor = UIColor(hex: 0xF0F4FB)
let thirdCardColor = UIColor(hex: 0xBBBBBB, alpha: 0.1)
let secondCardColor = UIColor.brandGrayColor4
let thirdCardColor = UIColor.brandGrayColor3
var acceptBlock: ((Bool) -> Void)?
var cardCount: Int = 1 {
didSet {
var firstCardBottomMargin = 0.0
var secondCardBottomMargin = 0.0
if self.cardCount <= 1 {
} else if self.cardCount == 2 {
firstCardBottomMargin = -6.0
......@@ -47,7 +47,7 @@ class YHAddFriendCardCell: UITableViewCell {
}
self.nameLabel.text = self.friendModel.username
self.msgLabel.text = self.friendModel.verifyInfo
self.signImgV.isHidden = !self.friendModel.isSign
// self.signImgV.isHidden = !self.friendModel.isSign
var text1 = ""
var text1Arr: [String] = []
......@@ -80,6 +80,7 @@ class YHAddFriendCardCell: UITableViewCell {
lazy var bgImageView: UIImageView = {
let bgImgView = UIImageView(image: UIImage(named: "people_add_friend_bg"))
bgImgView.isHidden = true
return bgImgView
}()
......@@ -102,6 +103,7 @@ class YHAddFriendCardCell: UITableViewCell {
lazy var signImgV: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "people_sign")
view.isHidden = true
return view
}()
......@@ -148,9 +150,9 @@ class YHAddFriendCardCell: UITableViewCell {
lazy var acceptBtn: UIButton = {
let btn = UIButton()
btn.setTitle("接受", for: .normal)
btn.backgroundColor = UIColor.brandMainColor
btn.backgroundColor = UIColor.brandGrayColor8
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.addTarget(self, action: #selector(didAcceptBtnClicked), for: .touchUpInside)
return btn
......@@ -191,6 +193,7 @@ class YHAddFriendCardCell: UITableViewCell {
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
self.selectionStyle = .none
self.contentView.addSubview(thirdCardView)
self.contentView.addSubview(secondCardView)
self.contentView.addSubview(cardView)
......@@ -280,7 +283,7 @@ class YHAddFriendCardCell: UITableViewCell {
self.secondCardView.snp.makeConstraints { make in
make.left.equalTo(self.cardView).offset(5)
make.right.equalTo(self.cardView).offset(-5)
make.height.equalTo(6)
make.height.equalTo(30)
make.bottom.equalTo(self.thirdCardView).offset(-6)
}
......@@ -288,7 +291,7 @@ class YHAddFriendCardCell: UITableViewCell {
make.left.equalTo(self.cardView).offset(10)
make.right.equalTo(self.cardView).offset(-10)
make.bottom.equalToSuperview()
make.height.equalTo(6)
make.height.equalTo(30)
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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