Commit 20d7d958 authored by Alex朱枝文's avatar Alex朱枝文

我的公司相关

parent 604ef0b7
...@@ -1187,6 +1187,8 @@ ...@@ -1187,6 +1187,8 @@
0487C1E02E8BCCDD00CE6472 /* YHResourceDetailDemandCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1DF2E8BCCDD00CE6472 /* YHResourceDetailDemandCell.swift */; }; 0487C1E02E8BCCDD00CE6472 /* YHResourceDetailDemandCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1DF2E8BCCDD00CE6472 /* YHResourceDetailDemandCell.swift */; };
0487C1E22E8BCD0200CE6472 /* YHResourceDetailDocumentsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1E12E8BCD0200CE6472 /* YHResourceDetailDocumentsCell.swift */; }; 0487C1E22E8BCD0200CE6472 /* YHResourceDetailDocumentsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1E12E8BCD0200CE6472 /* YHResourceDetailDocumentsCell.swift */; };
0487C1FD2E99F8E800CE6472 /* YHKingfisherUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1FC2E99F8E800CE6472 /* YHKingfisherUtils.swift */; }; 0487C1FD2E99F8E800CE6472 /* YHKingfisherUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1FC2E99F8E800CE6472 /* YHKingfisherUtils.swift */; };
0487C1FF2E9A54A600CE6472 /* YHCompanyAuthorizationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C1FE2E9A54A600CE6472 /* YHCompanyAuthorizationViewController.swift */; };
0487C2012E9A55A400CE6472 /* YHCompanyAuthSettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0487C2002E9A55A400CE6472 /* YHCompanyAuthSettingCell.swift */; };
048D6ADB2D5E00DE00BC6F4C /* YHMemberCenterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048D6ADA2D5E00DE00BC6F4C /* YHMemberCenterViewController.swift */; }; 048D6ADB2D5E00DE00BC6F4C /* YHMemberCenterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048D6ADA2D5E00DE00BC6F4C /* YHMemberCenterViewController.swift */; };
048D6ADD2D5EF0A900BC6F4C /* YHMemberCenterHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048D6ADC2D5EF0A900BC6F4C /* YHMemberCenterHeaderView.swift */; }; 048D6ADD2D5EF0A900BC6F4C /* YHMemberCenterHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048D6ADC2D5EF0A900BC6F4C /* YHMemberCenterHeaderView.swift */; };
048D6ADF2D5F0FBE00BC6F4C /* YHMemberCenterHeaderBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048D6ADE2D5F0FBE00BC6F4C /* YHMemberCenterHeaderBannerCell.swift */; }; 048D6ADF2D5F0FBE00BC6F4C /* YHMemberCenterHeaderBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048D6ADE2D5F0FBE00BC6F4C /* YHMemberCenterHeaderBannerCell.swift */; };
...@@ -2567,6 +2569,8 @@ ...@@ -2567,6 +2569,8 @@
0487C1DF2E8BCCDD00CE6472 /* YHResourceDetailDemandCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResourceDetailDemandCell.swift; sourceTree = "<group>"; }; 0487C1DF2E8BCCDD00CE6472 /* YHResourceDetailDemandCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResourceDetailDemandCell.swift; sourceTree = "<group>"; };
0487C1E12E8BCD0200CE6472 /* YHResourceDetailDocumentsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResourceDetailDocumentsCell.swift; sourceTree = "<group>"; }; 0487C1E12E8BCD0200CE6472 /* YHResourceDetailDocumentsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResourceDetailDocumentsCell.swift; sourceTree = "<group>"; };
0487C1FC2E99F8E800CE6472 /* YHKingfisherUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHKingfisherUtils.swift; sourceTree = "<group>"; }; 0487C1FC2E99F8E800CE6472 /* YHKingfisherUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHKingfisherUtils.swift; sourceTree = "<group>"; };
0487C1FE2E9A54A600CE6472 /* YHCompanyAuthorizationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCompanyAuthorizationViewController.swift; sourceTree = "<group>"; };
0487C2002E9A55A400CE6472 /* YHCompanyAuthSettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCompanyAuthSettingCell.swift; sourceTree = "<group>"; };
048D6ADA2D5E00DE00BC6F4C /* YHMemberCenterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMemberCenterViewController.swift; sourceTree = "<group>"; }; 048D6ADA2D5E00DE00BC6F4C /* YHMemberCenterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMemberCenterViewController.swift; sourceTree = "<group>"; };
048D6ADC2D5EF0A900BC6F4C /* YHMemberCenterHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMemberCenterHeaderView.swift; sourceTree = "<group>"; }; 048D6ADC2D5EF0A900BC6F4C /* YHMemberCenterHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMemberCenterHeaderView.swift; sourceTree = "<group>"; };
048D6ADE2D5F0FBE00BC6F4C /* YHMemberCenterHeaderBannerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMemberCenterHeaderBannerCell.swift; sourceTree = "<group>"; }; 048D6ADE2D5F0FBE00BC6F4C /* YHMemberCenterHeaderBannerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMemberCenterHeaderBannerCell.swift; sourceTree = "<group>"; };
...@@ -7060,6 +7064,7 @@ ...@@ -7060,6 +7064,7 @@
children = ( children = (
04D4EC322E839C2B00B0329B /* YHResourceViewController.swift */, 04D4EC322E839C2B00B0329B /* YHResourceViewController.swift */,
0487C1D92E8BB58300CE6472 /* YHResourceDetailViewController.swift */, 0487C1D92E8BB58300CE6472 /* YHResourceDetailViewController.swift */,
0487C1FE2E9A54A600CE6472 /* YHCompanyAuthorizationViewController.swift */,
); );
path = C; path = C;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -7082,6 +7087,7 @@ ...@@ -7082,6 +7087,7 @@
0487C1DB2E8BCC8200CE6472 /* YHResourceDetailHeaderCell.swift */, 0487C1DB2E8BCC8200CE6472 /* YHResourceDetailHeaderCell.swift */,
04355C922E8912490083BE91 /* YHResourceTableViewCell.swift */, 04355C922E8912490083BE91 /* YHResourceTableViewCell.swift */,
04355C8F2E890E020083BE91 /* YHResourceCategoryView.swift */, 04355C8F2E890E020083BE91 /* YHResourceCategoryView.swift */,
0487C2002E9A55A400CE6472 /* YHCompanyAuthSettingCell.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -8316,6 +8322,7 @@ ...@@ -8316,6 +8322,7 @@
045C11DD2D12CA5F00BD2DC0 /* YHScoreDataModel.swift in Sources */, 045C11DD2D12CA5F00BD2DC0 /* YHScoreDataModel.swift in Sources */,
045C11DE2D12CA5F00BD2DC0 /* YHCertificateTemplateCell.swift in Sources */, 045C11DE2D12CA5F00BD2DC0 /* YHCertificateTemplateCell.swift in Sources */,
045C11DF2D12CA5F00BD2DC0 /* YHCollegeSearchViewController.swift in Sources */, 045C11DF2D12CA5F00BD2DC0 /* YHCollegeSearchViewController.swift in Sources */,
0487C1FF2E9A54A600CE6472 /* YHCompanyAuthorizationViewController.swift in Sources */,
045C11E02D12CA5F00BD2DC0 /* YHResignInfoConfirmInfoListModel.swift in Sources */, 045C11E02D12CA5F00BD2DC0 /* YHResignInfoConfirmInfoListModel.swift in Sources */,
045C11E12D12CA5F00BD2DC0 /* YHFileListContentView.swift in Sources */, 045C11E12D12CA5F00BD2DC0 /* YHFileListContentView.swift in Sources */,
045C11E22D12CA5F00BD2DC0 /* YHFamilyMemberViewModel.swift in Sources */, 045C11E22D12CA5F00BD2DC0 /* YHFamilyMemberViewModel.swift in Sources */,
...@@ -8646,6 +8653,7 @@ ...@@ -8646,6 +8653,7 @@
045C12E32D12CA5F00BD2DC0 /* YHServiceTableFootView.swift in Sources */, 045C12E32D12CA5F00BD2DC0 /* YHServiceTableFootView.swift in Sources */,
045C12E42D12CA5F00BD2DC0 /* YHMsgViewModel.swift in Sources */, 045C12E42D12CA5F00BD2DC0 /* YHMsgViewModel.swift in Sources */,
045C12E52D12CA5F00BD2DC0 /* YHJsApi.swift in Sources */, 045C12E52D12CA5F00BD2DC0 /* YHJsApi.swift in Sources */,
0487C2012E9A55A400CE6472 /* YHCompanyAuthSettingCell.swift in Sources */,
045C12E62D12CA5F00BD2DC0 /* YHScoreResultView.swift in Sources */, 045C12E62D12CA5F00BD2DC0 /* YHScoreResultView.swift in Sources */,
04AFEF492D5DDE180007A011 /* YHMyFunctionGroupItem2Cell.swift in Sources */, 04AFEF492D5DDE180007A011 /* YHMyFunctionGroupItem2Cell.swift in Sources */,
045C12E72D12CA5F00BD2DC0 /* YHAIChatShadowView.swift in Sources */, 045C12E72D12CA5F00BD2DC0 /* YHAIChatShadowView.swift in Sources */,
......
//
// 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
}
}
...@@ -12,15 +12,11 @@ import SnapKit ...@@ -12,15 +12,11 @@ import SnapKit
class YHResourceDetailViewController: YHBaseViewController { class YHResourceDetailViewController: YHBaseViewController {
// MARK: - Properties // MARK: - Properties
/// 如果true,对应传入detailModel,否则,必传companyId
var isMyCompany: Bool = false
var companyId: Int = 0 // 只需要传入公司ID var companyId: Int = 0 // 只需要传入公司ID
var detailModel: YHResourceDetailModel? // 详情数据 var detailModel: YHResourceDetailModel? // 详情数据
var isMyCompany: Bool = false {
didSet {
updateViewIsMine()
}
}
private lazy var viewModel: YHResourceViewModel = { private lazy var viewModel: YHResourceViewModel = {
return YHResourceViewModel() return YHResourceViewModel()
}() }()
...@@ -60,6 +56,12 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -60,6 +56,12 @@ class YHResourceDetailViewController: YHBaseViewController {
return view return view
}() }()
private lazy var bottomBarView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var bottomActionView: UIView = { private lazy var bottomActionView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .white view.backgroundColor = .white
...@@ -81,7 +83,15 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -81,7 +83,15 @@ class YHResourceDetailViewController: YHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
loadData() if isMyCompany {
if detailModel != nil {
tableView.reloadData()
} else {
loadData(true)
}
} else {
loadData(false)
}
} }
// MARK: - Setup // MARK: - Setup
...@@ -92,6 +102,7 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -92,6 +102,7 @@ class YHResourceDetailViewController: YHBaseViewController {
gk_backImage = UIImage(named: "nav_black_24") gk_backImage = UIImage(named: "nav_black_24")
view.addSubview(bgIcon) view.addSubview(bgIcon)
view.addSubview(tableView) view.addSubview(tableView)
view.addSubview(bottomBarView)
view.addSubview(bottomActionView) view.addSubview(bottomActionView)
bottomActionView.addSubview(contactButton) bottomActionView.addSubview(contactButton)
setupConstraints() setupConstraints()
...@@ -109,16 +120,30 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -109,16 +120,30 @@ class YHResourceDetailViewController: YHBaseViewController {
make.top.left.right.bottom.equalToSuperview() make.top.left.right.bottom.equalToSuperview()
} }
tableView.snp.makeConstraints { make in bottomBarView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) make.bottom.equalToSuperview()
make.bottom.equalTo(bottomActionView.snp.top) make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom)
} }
bottomActionView.snp.makeConstraints { make in bottomActionView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.bottom.equalToSuperview() make.bottom.equalTo(bottomBarView.snp.top)
make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-64) make.height.equalTo(64)
}
if isMyCompany {
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomBarView.snp.top)
}
} else {
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomActionView.snp.top)
}
} }
contactButton.snp.makeConstraints { make in contactButton.snp.makeConstraints { make in
...@@ -133,8 +158,13 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -133,8 +158,13 @@ class YHResourceDetailViewController: YHBaseViewController {
private func updateRightBarButtonItem() { private func updateRightBarButtonItem() {
if isMyCompany { if isMyCompany {
/*
let rightButtonItem = UIBarButtonItem(image: UIImage(named: "name_card_authorize")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(authorizeBtnClicked))
gk_navRightBarButtonItem = rightButtonItem
gk_navItemRightSpace = 16
*/
let rightButtonItem = UIBarButtonItem( let rightButtonItem = UIBarButtonItem(
image: UIImage(named: "service_center_more")?.withRenderingMode(.alwaysOriginal), image: UIImage(named: "name_card_authorize")?.withRenderingMode(.alwaysOriginal),
style: .plain, style: .plain,
target: self, target: self,
action: #selector(moreButtonClicked) action: #selector(moreButtonClicked)
...@@ -142,6 +172,8 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -142,6 +172,8 @@ class YHResourceDetailViewController: YHBaseViewController {
gk_navRightBarButtonItem = rightButtonItem gk_navRightBarButtonItem = rightButtonItem
gk_navItemRightSpace = 16 gk_navItemRightSpace = 16
} else { } else {
// 不显示按钮了
/*
let rightButtonItem = UIBarButtonItem( let rightButtonItem = UIBarButtonItem(
image: UIImage(named: "share_item")?.withRenderingMode(.alwaysOriginal), image: UIImage(named: "share_item")?.withRenderingMode(.alwaysOriginal),
style: .plain, style: .plain,
...@@ -150,33 +182,54 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -150,33 +182,54 @@ class YHResourceDetailViewController: YHBaseViewController {
) )
gk_navRightBarButtonItem = rightButtonItem gk_navRightBarButtonItem = rightButtonItem
gk_navItemRightSpace = 16 gk_navItemRightSpace = 16
*/
} }
} }
// MARK: - Data // MARK: - Data
private func loadData() { private func loadData(_ isMine: Bool = false) {
guard companyId > 0 else { if isMine {
YHHUD.flash(message: "公司ID无效") // 直接调用详情接口
return YHHUD.show(.progress(message: "加载中..."))
} viewModel.getMyCompanyDetail { [weak self] detail, error in
guard let self = self else { return }
// 直接调用详情接口
YHHUD.show(.progress(message: "加载中...")) DispatchQueue.main.async {
viewModel.getCompanyDetail(companyId: companyId) { [weak self] detail, error in YHHUD.hide()
guard let self = self else { return }
if let detail = detail {
self.detailModel = detail
self.tableView.reloadData()
} else {
YHHUD.flash(message: error?.errorMsg ?? "获取信息异常,请重试")
}
}
}
} else {
guard companyId > 0 else {
YHHUD.flash(message: "公司ID无效")
return
}
DispatchQueue.main.async { // 直接调用详情接口
YHHUD.hide() YHHUD.show(.progress(message: "加载中..."))
viewModel.getCompanyDetail(companyId: companyId) { [weak self] detail, error in
guard let self = self else { return }
if let detail = detail { DispatchQueue.main.async {
self.detailModel = detail YHHUD.hide()
self.tableView.reloadData() if let detail = detail {
} else if let error = error { self.companyId = detail.id
YHHUD.flash(message: error) self.detailModel = detail
self.tableView.reloadData()
} else if let error = error {
YHHUD.flash(message: error)
}
} }
} }
} }
} }
// MARK: - Actions // MARK: - Actions
...@@ -186,7 +239,17 @@ class YHResourceDetailViewController: YHBaseViewController { ...@@ -186,7 +239,17 @@ class YHResourceDetailViewController: YHBaseViewController {
} }
@objc private func moreButtonClicked() { @objc private func moreButtonClicked() {
// 更多操作 // 更多操作,直接跳授权页
guard let detailModel = detailModel else {
YHHUD.flash(message: "请稍候")
return
}
let ctl = YHCompanyAuthorizationViewController()
ctl.detailModel = detailModel
ctl.completionBlock = { [weak self] in
self?.loadData(true)
}
navigationController?.pushViewController(ctl, animated: true)
} }
@objc private func contactButtonClicked() { @objc private func contactButtonClicked() {
......
...@@ -277,11 +277,14 @@ private extension YHResourceViewController { ...@@ -277,11 +277,14 @@ private extension YHResourceViewController {
} }
func setupPullToRefresh() { func setupPullToRefresh() {
resourceTableView.es.addYHPullToRefresh { resourceTableView.es.addYHPullToRefresh { [weak self] in
guard let self = self else { return }
self.loadCategories()
self.getData() self.getData()
} }
resourceTableView.es.addInfiniteScrolling { resourceTableView.es.addInfiniteScrolling { [weak self] in
guard let self = self else { return }
self.loadMoreData() self.loadMoreData()
} }
...@@ -316,7 +319,7 @@ private extension YHResourceViewController { ...@@ -316,7 +319,7 @@ private extension YHResourceViewController {
self.allCategories = categories self.allCategories = categories
self.categoryView.setCategories(categories) self.categoryView.setCategories(categories)
} else if let error = error { } else if let error = error {
print("加载分类失败: \(error)") printLog("加载分类失败: \(error)")
} }
} }
} }
...@@ -579,7 +582,14 @@ extension YHResourceViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -579,7 +582,14 @@ extension YHResourceViewController: UITableViewDelegate, UITableViewDataSource {
// 跳转到详情页 // 跳转到详情页
let vc = YHResourceDetailViewController() let vc = YHResourceDetailViewController()
vc.companyId = model.id if model.is_owner == 1 {
vc.isMyCompany = true
vc.companyId = model.id
} else {
vc.isMyCompany = false
vc.companyId = model.id
}
navigationController?.pushViewController(vc, animated: true) navigationController?.pushViewController(vc, animated: true)
} }
} }
......
...@@ -37,7 +37,7 @@ class YHCompanyDocument: SmartCodable { ...@@ -37,7 +37,7 @@ class YHCompanyDocument: SmartCodable {
class YHResourceDetailModel: SmartCodable { class YHResourceDetailModel: SmartCodable {
required init() {} required init() {}
var contract_avatar: YHCompanyAvatar? var company_avatar: YHCompanyAvatar?
var id: Int = 0 var id: Int = 0
var company_name: String = "" var company_name: String = ""
var company_english_name: String = "" var company_english_name: String = ""
...@@ -46,7 +46,7 @@ class YHResourceDetailModel: SmartCodable { ...@@ -46,7 +46,7 @@ class YHResourceDetailModel: SmartCodable {
var last_processed_time: String = "" var last_processed_time: String = ""
var processor_id: Int = 0 var processor_id: Int = 0
var processor: String = "" var processor: String = ""
var settlement_status: Int = 0 var settlement_status: Int = 0 // 1,2 已授权 3.未授权
var settlement_status_str: String = "" var settlement_status_str: String = ""
var resource_provided: String = "" var resource_provided: String = ""
var demand_published: String = "" var demand_published: String = ""
...@@ -62,12 +62,16 @@ class YHResourceDetailModel: SmartCodable { ...@@ -62,12 +62,16 @@ class YHResourceDetailModel: SmartCodable {
// 计算属性 // 计算属性
var companyLogoUrl: String { var companyLogoUrl: String {
return contract_avatar?.url ?? "" return company_avatar?.url ?? ""
} }
var displayName: String { var displayName: String {
return company_name.isEmpty ? company_english_name : company_name return company_name.isEmpty ? company_english_name : company_name
} }
var isSettlement: Bool {
return settlement_status != 3 && settlement_status != 0
}
} }
// MARK: - 资源列表模型(公司信息) // MARK: - 资源列表模型(公司信息)
...@@ -77,6 +81,7 @@ class YHResourceListModel: SmartCodable { ...@@ -77,6 +81,7 @@ class YHResourceListModel: SmartCodable {
var isService = true var isService = true
// MARK: - 基本信息(匹配列表API) // MARK: - 基本信息(匹配列表API)
var is_owner: Int = 0 // 0-非所属公司,1-所属公司
var id: Int = 0 var id: Int = 0
var company_avatar: YHCompanyAvatar? var company_avatar: YHCompanyAvatar?
var company_name: String = "" var company_name: String = ""
...@@ -90,7 +95,7 @@ class YHResourceListModel: SmartCodable { ...@@ -90,7 +95,7 @@ class YHResourceListModel: SmartCodable {
var company_introduction: String = "" // 公司介绍 var company_introduction: String = "" // 公司介绍
var company_business: String = "" // 主营业务 var company_business: String = "" // 主营业务
var company_information: [YHCompanyDocument] = [] // 公司资料 var company_information: [YHCompanyDocument] = [] // 公司资料
var settlement_status: Int = 0 var settlement_status: Int = 0 // 1,2 已授权 3.未授权
var settlement_status_str: String = "" var settlement_status_str: String = ""
// MARK: - 计算属性 // MARK: - 计算属性
...@@ -188,12 +193,6 @@ class YHResourceListModel: SmartCodable { ...@@ -188,12 +193,6 @@ class YHResourceListModel: SmartCodable {
self.demand_published = detail.demand_published self.demand_published = detail.demand_published
} }
} }
/// 增加浏览量(兼容方法)
func incrementViewCount() {
// 如果需要调用接口增加浏览量,在这里实现
print("增加浏览量")
}
} }
// MARK: - 资源分类模型 // MARK: - 资源分类模型
......
//
// YHCompanyAuthSettingCell.swift
// galaxy
//
// Created by alexzzw on 2025/10/11.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHCompanyAuthSettingCell: UITableViewCell {
// MARK: - Callback
var onSwitchToggle: ((Bool) -> Void)?
// MARK: - UI Components
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 16)
label.textColor = UIColor.brandGrayColor8
return label
}()
lazy var infoButton: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "my_card_set_alert"), for: .normal)
button.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
return button
}()
private lazy var descriptionLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = UIColor.brandGrayColor5
label.numberOfLines = 0
return label
}()
private lazy var toggleSwitch: UISwitch = {
let switchView = UISwitch()
switchView.onTintColor = UIColor.brandGrayColor8
switchView.transform = CGAffineTransform(scaleX: 0.77, y: 0.77)
switchView.addTarget(self, action: #selector(switchValueChanged(_:)), for: .valueChanged)
return switchView
}()
// MARK: - Initialization
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Setup UI
private func setupUI() {
selectionStyle = .none
contentView.backgroundColor = .white
backgroundColor = .white
contentView.addSubview(titleLabel)
contentView.addSubview(infoButton)
contentView.addSubview(descriptionLabel)
contentView.addSubview(toggleSwitch)
toggleSwitch.snp.makeConstraints { make in
make.right.equalTo(-21)
make.centerY.equalToSuperview()
make.width.equalTo(40)
make.height.equalTo(22)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(21)
make.top.equalTo(16)
make.right.lessThanOrEqualTo(toggleSwitch.snp.left).offset(-12)
}
infoButton.snp.makeConstraints { make in
make.left.equalTo(titleLabel.snp.right).offset(4)
make.centerY.equalTo(titleLabel)
make.width.height.equalTo(18)
}
descriptionLabel.snp.makeConstraints { make in
make.left.equalTo(21)
make.right.equalTo(toggleSwitch.snp.left).offset(-26)
make.top.equalTo(titleLabel.snp.bottom).offset(8)
make.bottom.equalTo(-16).priority(.high)
}
}
// MARK: - Actions
@objc private func switchValueChanged(_ sender: UISwitch) {
onSwitchToggle?(sender.isOn)
}
// MARK: - Public Methods
func configure(with model: YHSettingItem) {
titleLabel.text = model.title
descriptionLabel.text = model.subTitle
toggleSwitch.isOn = model.isSelect
infoButton.isHidden = !model.isShowAlert
}
// MARK: - Reuse
override func prepareForReuse() {
super.prepareForReuse()
onSwitchToggle = nil
infoButton.removeTarget(nil, action: nil, for: .allEvents)
titleLabel.text = nil
descriptionLabel.text = nil
toggleSwitch.isOn = false
infoButton.isHidden = true
}
}
...@@ -74,15 +74,10 @@ class YHResourceDetailBaseInfoCell: UITableViewCell { ...@@ -74,15 +74,10 @@ class YHResourceDetailBaseInfoCell: UITableViewCell {
stackView.arrangedSubviews.forEach { $0.removeFromSuperview() } stackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
// 使用详情接口的字段 // 使用详情接口的字段
addInfoRow(title: "企业介绍", content: model.company_introduction.isEmpty ? "未填写" : model.company_introduction) addInfoRow(title: "企业介绍", content: model.company_introduction.isEmpty ? "-" : model.company_introduction)
addInfoRow(title: "主营业务", content: model.company_business.isEmpty ? "未填写" : model.company_business) addInfoRow(title: "主营业务", content: model.company_business.isEmpty ? "-" : model.company_business)
addInfoRow(title: "提供服务", content: model.resource_provided.isEmpty ? "未填写" : model.resource_provided) addInfoRow(title: "提供服务", content: model.resource_provided.isEmpty ? "-" : model.resource_provided)
addInfoRow(title: "发布需求", content: model.demand_published.isEmpty ? "未填写" : model.demand_published) addInfoRow(title: "行业类型", content: model.industry_type_str.isEmpty ? "-" : model.industry_type_str)
addInfoRow(title: "行业类型", content: model.industry_type_str.isEmpty ? "未填写" : model.industry_type_str)
if !model.settlement_status_str.isEmpty {
addInfoRow(title: "入驻状态", content: model.settlement_status_str)
}
} }
private func addInfoRow(title: String, content: String) { private func addInfoRow(title: String, content: String) {
......
...@@ -87,6 +87,6 @@ class YHResourceDetailDemandCell: UITableViewCell { ...@@ -87,6 +87,6 @@ class YHResourceDetailDemandCell: UITableViewCell {
func configure(with model: YHResourceDetailModel) { func configure(with model: YHResourceDetailModel) {
// 使用详情接口的 demand_published 字段 // 使用详情接口的 demand_published 字段
demandContentLabel.text = model.demand_published.isEmpty ? "未填写" : model.demand_published demandContentLabel.text = model.demand_published.isEmpty ? "-" : model.demand_published
} }
} }
...@@ -138,7 +138,6 @@ class YHResourceDetailDocumentsCell: UITableViewCell { ...@@ -138,7 +138,6 @@ class YHResourceDetailDocumentsCell: UITableViewCell {
for (index, imageUrl) in images.enumerated() { for (index, imageUrl) in images.enumerated() {
let imageView = UIImageView() let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit imageView.contentMode = .scaleAspectFit
imageView.backgroundColor = UIColor.systemGray6
imageView.isUserInteractionEnabled = true imageView.isUserInteractionEnabled = true
if let url = URL(string: imageUrl) { if let url = URL(string: imageUrl) {
......
...@@ -23,6 +23,8 @@ class YHResourceViewModel: NSObject { ...@@ -23,6 +23,8 @@ class YHResourceViewModel: NSObject {
var selectedCategories: [YHResourceCategory] = [] var selectedCategories: [YHResourceCategory] = []
var searchKeyword: String? var searchKeyword: String?
var isMyCompanyOpen: Bool = false
override init() { override init() {
super.init() super.init()
} }
...@@ -177,4 +179,51 @@ class YHResourceViewModel: NSObject { ...@@ -177,4 +179,51 @@ class YHResourceViewModel: NSObject {
} }
} }
/// 获取公司详情
/// - Parameters:
/// - completion: 完成回调 // 错误码10005表示客户未注册公司
func getMyCompanyDetail(completion: @escaping (YHResourceDetailModel?, YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Resource.myCompany
_ = YHNetRequest.getRequest(url: strUrl, params: [:]) { json, _ in
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any],
let result = YHResourceDetailModel.deserialize(from: dic) else {
let errorModel: YHErrorModel = YHErrorModel(errorCode: -10001, errorMsg: "数据解析失败")
completion(nil, errorModel)
return
}
completion(result, nil)
} else {
let errorMsg = json.msg.isEmpty ? "获取详情失败" : json.msg
let errorModel: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: errorMsg)
completion(nil, errorModel)
}
} failBlock: { err in
completion(nil, err)
}
}
/// 授权公司公开
/// - Parameters:
/// - status: 2-开启,3-关闭
/// - completion: 完成回调
func companyAuthor(status: Int, completion: @escaping (Bool, String?) -> Void) {
let params: [String: Any] = ["status": status]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Resource.author
_ = YHNetRequest.putRequest(url: strUrl, params: params) { json, _ in
if json.code == 200 {
completion(true, nil)
} else {
let errorMsg = json.msg.isEmpty ? "授权失败" : json.msg
completion(false, errorMsg)
}
} failBlock: { err in
let errorMsg = err.errorMsg
completion(false, errorMsg)
}
}
} }
...@@ -42,7 +42,10 @@ class YHSetExplainView: UIView { ...@@ -42,7 +42,10 @@ class YHSetExplainView: UIView {
titleLabel.text = "允许向陌生人公开您的工作经历" titleLabel.text = "允许向陌生人公开您的工作经历"
messageLabel.text = "授权开启后,您的个人主页将展示最新工作信息,仅对非好友人脉开放查看权限,保护您的隐私安全" messageLabel.text = "授权开启后,您的个人主页将展示最新工作信息,仅对非好友人脉开放查看权限,保护您的隐私安全"
topImageView.image = UIImage(named: "set_example_work") topImageView.image = UIImage(named: "set_example_work")
case .companyToStrange:
titleLabel.text = "允许公开您的公司信息"
messageLabel.text = "授权开启后,您的公司信息将展示在资源列表,包括企业服务与企业需求"
topImageView.image = UIImage(named: "set_example_company")
} }
} }
} }
......
...@@ -106,7 +106,7 @@ class YHInformationAuthorizeViewModel: YHBaseViewModel { ...@@ -106,7 +106,7 @@ class YHInformationAuthorizeViewModel: YHBaseViewModel {
func updateSetModel(_ item: YHSettingItem) { func updateSetModel(_ item: YHSettingItem) {
switch item.type { switch item.type {
case .normal: break case .normal, .companyToStrange: break
case .people: case .people:
setModel.authorization_basic_information = item.isSelect ? 2 : 1 setModel.authorization_basic_information = item.isSelect ? 2 : 1
case .schoolToFriend: case .schoolToFriend:
......
...@@ -15,6 +15,7 @@ enum YHSettingType: Int { ...@@ -15,6 +15,7 @@ enum YHSettingType: Int {
case workToStranger case workToStranger
case schoolToFriend case schoolToFriend
case workToFriend case workToFriend
case companyToStrange
} }
class YHSettingItem: NSObject { class YHSettingItem: NSObject {
......
...@@ -104,7 +104,7 @@ class YHAllowSettingTableViewCell: UITableViewCell { ...@@ -104,7 +104,7 @@ class YHAllowSettingTableViewCell: UITableViewCell {
@objc func switchViewChange() { @objc func switchViewChange() {
guard let model = item else { return } guard let model = item else { return }
switch model.type { switch model.type {
case .normal: case .normal, .companyToStrange:
model.isSelect = detailSwitch.isOn model.isSelect = detailSwitch.isOn
if let block = block { if let block = block {
block(model) block(model)
......
...@@ -43,6 +43,17 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -43,6 +43,17 @@ class YHMyNewViewController: YHBaseViewController {
let vm = YHPrincleViewModel() let vm = YHPrincleViewModel()
return vm return vm
}() }()
private lazy var resourceViewModel: YHResourceViewModel = {
return YHResourceViewModel()
}()
private lazy var messageHandler: YHIMMessageHandler = {
return YHIMMessageHandler(
viewController: self,
navigationController: navigationController
)
}()
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame: CGRect.zero, style: .grouped) let tableView = UITableView(frame: CGRect.zero, style: .grouped)
...@@ -825,9 +836,53 @@ extension YHMyNewViewController { ...@@ -825,9 +836,53 @@ extension YHMyNewViewController {
let vc = YHMyGoodFriendsVC() let vc = YHMyGoodFriendsVC()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
case .myEnterprise: case .myEnterprise:
print("") YHHUD.show(.progress(message: ""))
resourceViewModel.getMyCompanyDetail { [weak self] resourceDetailModel, errorModel in
guard let self = self else {
return
}
YHHUD.hide()
guard let resourceDetailModel = resourceDetailModel else {
if let errorModel = errorModel, errorModel.errorCode == 10005 {
self.showContactManagerDialog()
} else {
YHHUD.flash(message: errorModel?.errorMsg ?? "请稍候")
}
return
}
self.gotoMyCompany(resourceDetailModel)
}
default: default:
printLog("不需要响应") printLog("不需要响应")
} }
} }
private func gotoMyCompany(_ detailModel: YHResourceDetailModel) {
// 跳转到详情页
let vc = YHResourceDetailViewController()
vc.isMyCompany = true
vc.detailModel = detailModel
navigationController?.pushViewController(vc, animated: true)
}
private func showContactManagerDialog() {
YHGrayCommonAlertView.show("暂未绑定企业", "请您联系银河管家进行企业绑定,快来与我们联系吧~", "返回", "去联系", fullGuestureEnable: false) {
} callBack: { [weak self] in
guard let self = self else {
return
}
YHHUD.show(.progress(message: ""))
self.resourceViewModel.getDemandYhId { [weak self] id in
guard let self = self else {
return
}
YHHUD.hide()
if id.isEmpty {
YHHUD.flash(message: "获取银河ID失败")
return
}
self.messageHandler.gotoChatVC(senderID: id)
}
}
}
} }
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "set_example_company@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "set_example_company@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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