Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
4fa16fab
Commit
4fa16fab
authored
Oct 10, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资源相关
parent
051ce9c5
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
242 additions
and
301 deletions
+242
-301
YHResourceDetailViewController.swift
...y(社区)/Resource(资源)/C/YHResourceDetailViewController.swift
+47
-56
YHResourceViewController.swift
...mmunity(社区)/Resource(资源)/C/YHResourceViewController.swift
+67
-53
YHResourceListModel.swift
...es/Community(社区)/Resource(资源)/M/YHResourceListModel.swift
+0
-0
YHResourceCategoryView.swift
...Community(社区)/Resource(资源)/V/YHResourceCategoryView.swift
+66
-107
YHResourceDetailBaseInfoCell.swift
...ity(社区)/Resource(资源)/V/YHResourceDetailBaseInfoCell.swift
+13
-7
YHResourceDetailDemandCell.swift
...unity(社区)/Resource(资源)/V/YHResourceDetailDemandCell.swift
+6
-5
YHResourceDetailDocumentsCell.swift
...ty(社区)/Resource(资源)/V/YHResourceDetailDocumentsCell.swift
+1
-1
YHResourceDetailHeaderCell.swift
...unity(社区)/Resource(资源)/V/YHResourceDetailHeaderCell.swift
+24
-6
YHResourceTableViewCell.swift
...ommunity(社区)/Resource(资源)/V/YHResourceTableViewCell.swift
+18
-66
YHResourceViewModel.swift
...s/Community(社区)/Resource(资源)/VM/YHResourceViewModel.swift
+0
-0
No files found.
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/C/YHResourceDetailViewController.swift
View file @
4fa16fab
...
...
@@ -12,7 +12,8 @@ import SnapKit
class
YHResourceDetailViewController
:
YHBaseViewController
{
// MARK: - Properties
var
resourceModel
:
YHResourceListModel
?
var
companyId
:
Int
=
0
// 只需要传入公司ID
var
detailModel
:
YHResourceDetailModel
?
// 详情数据
var
isMyCompany
:
Bool
=
false
{
didSet
{
...
...
@@ -20,6 +21,10 @@ class YHResourceDetailViewController: YHBaseViewController {
}
}
private
lazy
var
viewModel
:
YHResourceViewModel
=
{
return
YHResourceViewModel
()
}()
private
lazy
var
messageHandler
:
YHIMMessageHandler
=
{
return
YHIMMessageHandler
(
viewController
:
self
,
...
...
@@ -29,7 +34,7 @@ class YHResourceDetailViewController: YHBaseViewController {
// MARK: - UI Components
// 背景图
- 改为在tableView后面
// 背景图
private
lazy
var
bgIcon
:
UIImageView
=
{
let
view
=
UIImageView
()
view
.
image
=
UIImage
(
named
:
"resource_detail_bg"
)
...
...
@@ -87,7 +92,6 @@ class YHResourceDetailViewController: YHBaseViewController {
gk_backImage
=
UIImage
(
named
:
"nav_black_24"
)
view
.
addSubview
(
bgIcon
)
view
.
addSubview
(
tableView
)
// 添加底部操作栏
view
.
addSubview
(
bottomActionView
)
bottomActionView
.
addSubview
(
contactButton
)
setupConstraints
()
...
...
@@ -96,21 +100,15 @@ class YHResourceDetailViewController: YHBaseViewController {
private
func
updateViewIsMine
()
{
gk_navTitle
=
isMyCompany
?
"我的企业"
:
"企业详情"
if
isMyCompany
{
bottomActionView
.
isHidden
=
true
}
else
{
bottomActionView
.
isHidden
=
false
}
bottomActionView
.
isHidden
=
isMyCompany
updateRightBarButtonItem
()
}
private
func
setupConstraints
()
{
// 背景图约束 - 参照YHMemberCenterViewController
bgIcon
.
snp
.
makeConstraints
{
make
in
make
.
top
.
left
.
right
.
bottom
.
equalToSuperview
()
}
// tableView约束
tableView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
k_Height_NavigationtBarAndStatuBar
)
...
...
@@ -130,7 +128,6 @@ class YHResourceDetailViewController: YHBaseViewController {
make
.
height
.
equalTo
(
46
)
}
// 不需要设置contentInset,让内容从导航栏下方开始
tableView
.
tableFooterView
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
0.01
))
}
...
...
@@ -154,29 +151,42 @@ class YHResourceDetailViewController: YHBaseViewController {
gk_navRightBarButtonItem
=
rightButtonItem
gk_navItemRightSpace
=
16
}
}
// MARK: - Data
private
func
loadData
()
{
guard
let
_
=
resourceModel
else
{
return
}
tableView
.
reloadData
()
incrementViewCount
()
}
private
func
incrementViewCount
()
{
resourceModel
?
.
incrementViewCount
()
guard
companyId
>
0
else
{
YHHUD
.
flash
(
message
:
"公司ID无效"
)
return
}
// 直接调用详情接口
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
viewModel
.
getCompanyDetail
(
companyId
:
companyId
)
{
[
weak
self
]
detail
,
error
in
guard
let
self
=
self
else
{
return
}
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
if
let
detail
=
detail
{
self
.
detailModel
=
detail
self
.
tableView
.
reloadData
()
}
else
if
let
error
=
error
{
YHHUD
.
flash
(
message
:
error
)
}
}
}
}
// MARK: - Actions
@objc
private
func
shareButtonClicked
()
{
//
//
分享功能
}
@objc
private
func
moreButtonClicked
()
{
//
//
更多操作
}
@objc
private
func
contactButtonClicked
()
{
...
...
@@ -184,9 +194,10 @@ class YHResourceDetailViewController: YHBaseViewController {
YHOneKeyLoginManager
.
shared
.
oneKeyLogin
()
return
}
messageHandler
.
gotoChatVC
(
senderID
:
""
)
if
let
detailModel
=
detailModel
,
!
detailModel
.
yh_id
.
isEmpty
{
messageHandler
.
gotoChatVC
(
senderID
:
detailModel
.
yh_id
)
}
}
}
// MARK: - UITableViewDataSource & UITableViewDelegate
...
...
@@ -202,12 +213,10 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
guard
let
model
=
resource
Model
else
{
guard
let
model
=
detail
Model
else
{
return
UITableViewCell
()
}
let
hasDocuments
=
!
model
.
images
.
isEmpty
switch
indexPath
.
section
{
case
0
:
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"HeaderCell"
,
for
:
indexPath
)
as?
YHResourceDetailHeaderCell
else
{
...
...
@@ -224,37 +233,23 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
return
cell
case
2
:
if
hasDocuments
{
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"DemandCell"
,
for
:
indexPath
)
as?
YHResourceDetailDemandCell
else
{
return
UITableViewCell
()
}
cell
.
configure
(
with
:
model
)
return
cell
}
else
{
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"DemandCell"
,
for
:
indexPath
)
as?
YHResourceDetailDemandCell
else
{
return
UITableViewCell
()
}
cell
.
configure
(
with
:
model
)
return
cell
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"DemandCell"
,
for
:
indexPath
)
as?
YHResourceDetailDemandCell
else
{
return
UITableViewCell
()
}
cell
.
configure
(
with
:
model
)
return
cell
case
3
:
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"DocumentsCell"
,
for
:
indexPath
)
as?
YHResourceDetailDocumentsCell
else
{
return
UITableViewCell
()
}
cell
.
configure
(
with
:
model
.
images
)
let
images
=
model
.
company_information
.
map
{
$0
.
url
}
cell
.
configure
(
with
:
images
)
cell
.
onImageTapped
=
{
[
weak
self
]
index
in
self
?
.
showImageBrowser
(
at
:
index
)
}
cell
.
onImageHeightChanged
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
// NSObject.cancelPreviousPerformRequests(
// withTarget: self,
// selector: #selector(self.performBatchReload),
// object: nil
// )
// self.perform(#selector(self.performBatchReload), with: indexPath, afterDelay: 0.01)
// // 使用 performBatchUpdates 避免动画跳动
UIView
.
performWithoutAnimation
{
self
.
tableView
.
reloadRows
(
at
:
[
indexPath
],
with
:
.
none
)
}
...
...
@@ -266,12 +261,6 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
}
}
@objc
private
func
performBatchReload
(
indexPath
:
IndexPath
)
{
UIView
.
performWithoutAnimation
{
self
.
tableView
.
reloadRows
(
at
:
[
indexPath
],
with
:
.
none
)
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
UITableView
.
automaticDimension
}
...
...
@@ -292,10 +281,8 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
return
0.01
}
// 关键改动:参照YHMemberCenterViewController的scrollViewDidScroll实现
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
if
scrollView
.
contentOffset
.
y
>
0
{
// 向上滚动
var
alpha
=
scrollView
.
contentOffset
.
y
/
k_Height_NavigationtBarAndStatuBar
if
alpha
>
1.0
{
alpha
=
1.0
...
...
@@ -311,7 +298,11 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
}
private
func
showImageBrowser
(
at
index
:
Int
)
{
guard
let
images
=
resourceModel
?
.
images
else
{
return
}
print
(
"显示图片浏览器,索引:
\(
index
)
,共
\(
images
.
count
)
张"
)
guard
let
companyInformation
=
detailModel
?
.
company_information
else
{
return
}
let
images
=
companyInformation
.
map
{
$0
.
url
}
if
images
.
count
>
index
,
images
.
count
>
0
{
printLog
(
"显示图片浏览器,索引:
\(
index
)
,共
\(
images
.
count
)
张"
)
YHPictureReviewManager
.
shared
.
showNetWorkPicturs
(
curIndex
:
index
,
arrPicturs
:
images
)
}
}
}
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/C/YHResourceViewController.swift
View file @
4fa16fab
...
...
@@ -3,7 +3,7 @@
// galaxy
//
// Created by alexzzw on 2025/9/24.
// Copyright
Â
© 2025 https://www.galaxy-immi.com. All rights reserved.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
...
...
@@ -33,6 +33,9 @@ class YHResourceViewController: YHBaseViewController {
// 筛选条件
var
selectedCategories
:
[
YHResourceCategory
]
=
[]
// 行业分类数据
var
allCategories
:
[
YHResourceCategory
]
=
[]
// MARK: - UI Components
// 自定义搜索视图
...
...
@@ -121,7 +124,6 @@ class YHResourceViewController: YHBaseViewController {
}()
// 空状态视图
private
lazy
var
noDataView
:
YHEmptyDataView
=
{
let
view
=
YHEmptyDataView
.
createView
(
"暂无内容"
,
kEmptyOrderBgName
)
view
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
164
)
...
...
@@ -146,7 +148,8 @@ class YHResourceViewController: YHBaseViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
setupUI
()
addDefaultData
()
loadCategories
()
// 先加载分类数据
// addDefaultData()
getData
()
}
...
...
@@ -162,7 +165,8 @@ class YHResourceViewController: YHBaseViewController {
}
func
handleTypeChangeNotification
(
_
userInfo
:
[
AnyHashable
:
Any
])
{
guard
let
selectTypeKey
=
userInfo
[
YHResourceViewController
.
selectTypeKey
]
as?
String
,
let
type
=
YHResourceFilterType
(
rawValue
:
selectTypeKey
)
else
{
guard
let
selectTypeKey
=
userInfo
[
YHResourceViewController
.
selectTypeKey
]
as?
String
,
let
type
=
YHResourceFilterType
(
rawValue
:
selectTypeKey
)
else
{
return
}
setResourceType
(
type
)
...
...
@@ -186,7 +190,7 @@ private extension YHResourceViewController {
view
.
addSubview
(
noDataView
)
view
.
addSubview
(
publishButton
)
// 分类视图要最后添加
,
确保在最上层
// 分类视图要最后添加
,
确保在最上层
view
.
addSubview
(
maskView
)
view
.
addSubview
(
categoryView
)
...
...
@@ -206,6 +210,7 @@ private extension YHResourceViewController {
make
.
left
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
44
)
}
serviceButton
.
setContentCompressionResistancePriority
(
.
required
,
for
:
.
horizontal
)
demandButton
.
setContentCompressionResistancePriority
(
.
required
,
for
:
.
horizontal
)
industryButton
.
setContentCompressionResistancePriority
(
.
defaultLow
,
for
:
.
horizontal
)
...
...
@@ -235,7 +240,6 @@ private extension YHResourceViewController {
categoryView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
filterContainerView
.
snp
.
bottom
)
// 使用变量保存高度约束的引用
self
.
categoryViewHeightConstraint
=
make
.
height
.
equalTo
(
0
)
.
constraint
}
...
...
@@ -303,6 +307,20 @@ private extension YHResourceViewController {
}
}
/// 加载行业分类数据
func
loadCategories
()
{
viewModel
.
getResourceCategories
{
[
weak
self
]
categories
,
error
in
guard
let
self
=
self
else
{
return
}
if
let
categories
=
categories
{
self
.
allCategories
=
categories
self
.
categoryView
.
setCategories
(
categories
)
}
else
if
let
error
=
error
{
print
(
"加载分类失败:
\(
error
)
"
)
}
}
}
func
getData
()
{
loadFirstData
()
}
...
...
@@ -313,49 +331,47 @@ private extension YHResourceViewController {
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
}
DispatchQueue
.
global
()
.
async
{
self
.
viewModel
.
getResourceList
(
firstFlag
:
true
)
{
[
weak
self
]
success
,
message
in
guard
let
self
=
self
else
{
return
}
viewModel
.
getResourceList
(
firstFlag
:
true
)
{
[
weak
self
]
success
,
message
in
guard
let
self
=
self
else
{
return
}
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
// if success, let arrData = self.viewModel.arrResourceData, arrData.count > 0 {
// let arrString = arrData.toJSONString()
// UserDefaults.standard.set(arrString, forKey: "resourceFirstPageData")
// UserDefaults.standard.synchronize()
// } else if !success, let errorMessage = message {
// YHHUD.flash(message: errorMessage)
// }
if
!
success
,
let
errorMessage
=
message
{
YHHUD
.
flash
(
message
:
errorMessage
)
}
self
.
resourceTableView
.
es
.
stopPullToRefresh
()
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
if
success
,
let
arrData
=
self
.
viewModel
.
arrResourceData
,
arrData
.
count
>
0
{
let
arrString
=
arrData
.
toJSONString
()
UserDefaults
.
standard
.
set
(
arrString
,
forKey
:
"resourceFirstPageData"
)
UserDefaults
.
standard
.
synchronize
()
}
else
if
!
success
,
let
errorMessage
=
message
{
YHHUD
.
flash
(
message
:
errorMessage
)
}
self
.
resourceTableView
.
es
.
stopPullToRefresh
()
if
self
.
viewModel
.
hasMoreForResource
==
false
{
self
.
resourceTableView
.
es
.
noticeNoMoreData
()
self
.
resourceTableView
.
footer
?
.
alpha
=
1
}
self
.
updateUI
()
if
self
.
viewModel
.
hasMoreForResource
==
false
{
self
.
resourceTableView
.
es
.
noticeNoMoreData
()
self
.
resourceTableView
.
footer
?
.
alpha
=
1
}
self
.
updateUI
()
}
}
}
func
loadMoreData
()
{
DispatchQueue
.
global
()
.
async
{
self
.
viewModel
.
getResourceList
(
firstFlag
:
false
)
{
[
weak
self
]
_
,
_
in
guard
let
self
=
self
else
{
return
}
viewModel
.
getResourceList
(
firstFlag
:
false
)
{
[
weak
self
]
_
,
_
in
guard
let
self
=
self
else
{
return
}
DispatchQueue
.
main
.
asyncAfter
(
wallDeadline
:
.
now
()
+
0.35
,
execute
:
{
self
.
resourceTableView
.
reloadData
()
DispatchQueue
.
main
.
asyncAfter
(
wallDeadline
:
.
now
()
+
0.35
,
execute
:
{
self
.
resourceTableView
.
reloadData
()
self
.
resourceTableView
.
es
.
stopLoadingMore
()
if
self
.
viewModel
.
hasMoreForResource
==
false
{
self
.
resourceTableView
.
es
.
noticeNoMoreData
()
self
.
resourceTableView
.
footer
?
.
alpha
=
1
}
})
}
self
.
resourceTableView
.
es
.
stopLoadingMore
()
if
self
.
viewModel
.
hasMoreForResource
==
false
{
self
.
resourceTableView
.
es
.
noticeNoMoreData
()
self
.
resourceTableView
.
footer
?
.
alpha
=
1
}
})
}
}
...
...
@@ -454,7 +470,6 @@ private extension YHResourceViewController {
industryButton
.
setImage
(
UIImage
(
named
:
"resource_filter_up"
),
for
:
.
normal
)
}
// 修改隐藏动画方法
@objc
func
hideCategoryView
()
{
// 高度约束动画
UIView
.
animate
(
withDuration
:
0.3
,
delay
:
0
,
options
:
.
curveEaseIn
,
animations
:
{
...
...
@@ -510,9 +525,7 @@ extension YHResourceViewController: YHCustomSearchViewDelegate {
func
searchView
(
_
searchView
:
YHCustomSearchView
,
didSearchWithText
text
:
String
?)
{
viewModel
.
searchKeyword
=
text
if
text
?
.
isEmpty
==
true
{
getData
()
}
getData
()
}
func
searchViewDidBeginEditing
(
_
searchView
:
YHCustomSearchView
)
{
...
...
@@ -521,7 +534,6 @@ extension YHResourceViewController: YHCustomSearchViewDelegate {
func
searchViewDidEndEditing
(
_
searchView
:
YHCustomSearchView
)
{
// 搜索结束编辑时的处理
getData
()
}
}
...
...
@@ -538,8 +550,9 @@ extension YHResourceViewController: UITableViewDelegate, UITableViewDataSource {
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHResourceTableViewCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as?
YHResourceTableViewCell
else
{
return
UITableViewCell
()
}
cell
.
resourceModel
=
datas
[
indexPath
.
row
]
let
model
=
datas
[
indexPath
.
row
]
model
.
isService
=
viewModel
.
currentType
==
.
service
cell
.
resourceModel
=
model
return
cell
}
...
...
@@ -552,8 +565,10 @@ extension YHResourceViewController: UITableViewDelegate, UITableViewDataSource {
tableView
.
deselectRow
(
at
:
indexPath
,
animated
:
true
)
guard
let
model
=
viewModel
.
arrResourceData
?[
indexPath
.
row
]
else
{
return
}
// 跳转到详情页
let
vc
=
YHResourceDetailViewController
()
vc
.
resourceModel
=
model
vc
.
companyId
=
model
.
id
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
}
...
...
@@ -586,15 +601,14 @@ extension YHResourceViewController: YHResourceCategoryViewDelegate {
selectedCategories
=
categories
viewModel
.
selectedCategories
=
categories
updateIndustryButtonTitle
()
if
isSet
{
// 隐藏分类视图
hideCategoryView
()
// 重新加载数据
getData
()
}
// 重新加载数据
getData
()
}
}
// MARK: - 枚举定义
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/M/YHResourceListModel.swift
View file @
4fa16fab
This diff is collapsed.
Click to expand it.
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceCategoryView.swift
View file @
4fa16fab
...
...
@@ -40,6 +40,11 @@ class YHResourceCategoryView: UIView {
private
lazy
var
bottomButtonContainer
:
UIView
=
{
let
view
=
UIView
()
view
.
backgroundColor
=
.
white
// 添加顶部阴影
view
.
layer
.
shadowColor
=
UIColor
.
black
.
cgColor
view
.
layer
.
shadowOffset
=
CGSize
(
width
:
0
,
height
:
-
2
)
view
.
layer
.
shadowOpacity
=
0.05
view
.
layer
.
shadowRadius
=
4
return
view
}()
...
...
@@ -81,13 +86,11 @@ class YHResourceCategoryView: UIView {
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
setupUI
()
loadCategories
()
}
required
init
?(
coder
:
NSCoder
)
{
super
.
init
(
coder
:
coder
)
setupUI
()
loadCategories
()
}
// MARK: - Setup
...
...
@@ -130,87 +133,17 @@ class YHResourceCategoryView: UIView {
}
}
private
func
loadCategories
()
{
// 模拟数据,实际使用时从接口获取
let
allCategory
=
YHResourceCategory
()
allCategory
.
id
=
"0"
allCategory
.
name
=
"全部行业"
let
category1
=
YHResourceCategory
()
category1
.
id
=
"1"
category1
.
name
=
"金融会计"
let
category2
=
YHResourceCategory
()
category2
.
id
=
"2"
category2
.
name
=
"资讯科技"
let
category3
=
YHResourceCategory
()
category3
.
id
=
"3"
category3
.
name
=
"业务支持"
let
category4
=
YHResourceCategory
()
category4
.
id
=
"4"
category4
.
name
=
"工业制造"
let
category5
=
YHResourceCategory
()
category5
.
id
=
"5"
category5
.
name
=
"建筑工程"
let
category6
=
YHResourceCategory
()
category6
.
id
=
"6"
category6
.
name
=
"地产开发"
let
category7
=
YHResourceCategory
()
category7
.
id
=
"7"
category7
.
name
=
"法律服务"
let
category8
=
YHResourceCategory
()
category8
.
id
=
"8"
category8
.
name
=
"商业贸易"
let
category9
=
YHResourceCategory
()
category9
.
id
=
"9"
category9
.
name
=
"物流运输"
let
category10
=
YHResourceCategory
()
category10
.
id
=
"10"
category10
.
name
=
"餐饮旅游"
let
category11
=
YHResourceCategory
()
category11
.
id
=
"11"
category11
.
name
=
"广播娱乐"
let
category12
=
YHResourceCategory
()
category12
.
id
=
"12"
category12
.
name
=
"艺术文化"
let
category13
=
YHResourceCategory
()
category13
.
id
=
"13"
category13
.
name
=
"体育运动"
let
category14
=
YHResourceCategory
()
category14
.
id
=
"14"
category14
.
name
=
"医疗健康"
let
category15
=
YHResourceCategory
()
category15
.
id
=
"15"
category15
.
name
=
"学术教育"
let
category16
=
YHResourceCategory
()
category16
.
id
=
"16"
category16
.
name
=
"其他"
categories
=
[
allCategory
,
category1
,
category2
,
category3
,
category4
,
category5
,
category6
,
category7
,
category8
,
category9
,
category10
,
category11
,
category12
,
category13
,
category14
,
category15
,
category16
]
// MARK: - Public Methods
/// 设置分类数据(从外部传入,通常来自API)
/// - Parameter categories: 分类数组
func
setCategories
(
_
categories
:
[
YHResourceCategory
])
{
self
.
categories
=
categories
collectionView
.
reloadData
()
}
//
MARK: - Public Methods
//
/ 设置已选中的分类
/// - Parameter categories: 已选中的分类数组
func
setSelectedCategories
(
_
categories
:
[
YHResourceCategory
])
{
selectedCategories
=
categories
collectionView
.
reloadData
()
...
...
@@ -219,7 +152,7 @@ class YHResourceCategoryView: UIView {
// MARK: - Actions
@objc
private
func
resetButtonClicked
()
{
// 重置
为"全部行业"
// 重置
:清空所有选择
selectedCategories
.
removeAll
()
collectionView
.
reloadData
()
delegate
?
.
categoryView
(
self
,
didSelectCategories
:
selectedCategories
,
isSet
:
false
)
...
...
@@ -238,7 +171,8 @@ extension YHResourceCategoryView: UICollectionViewDataSource, UICollectionViewDe
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
guard
categories
.
count
>
indexPath
.
item
,
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"YHResourceCategoryCell"
,
for
:
indexPath
)
as?
YHResourceCategoryCell
else
{
guard
categories
.
count
>
indexPath
.
item
,
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"YHResourceCategoryCell"
,
for
:
indexPath
)
as?
YHResourceCategoryCell
else
{
return
UICollectionViewCell
()
}
...
...
@@ -252,28 +186,20 @@ extension YHResourceCategoryView: UICollectionViewDataSource, UICollectionViewDe
func
collectionView
(
_
collectionView
:
UICollectionView
,
didSelectItemAt
indexPath
:
IndexPath
)
{
let
category
=
categories
[
indexPath
.
item
]
//
如果是"全部行业",清空其他选择
if
category
.
id
==
"0"
{
selectedCategories
.
removeAll
()
selectedCategories
.
append
(
category
)
//
切换选中状态(支持多选)
if
let
index
=
selectedCategories
.
firstIndex
(
where
:
{
$0
.
id
==
category
.
id
})
{
// 如果已选中,则取消选中
selectedCategories
.
remove
(
at
:
index
)
}
else
{
// 移除"全部行业"选项
selectedCategories
.
removeAll
{
$0
.
id
==
"0"
}
// 切换选中状态
if
let
index
=
selectedCategories
.
firstIndex
(
where
:
{
$0
.
id
==
category
.
id
})
{
selectedCategories
.
remove
(
at
:
index
)
}
else
{
selectedCategories
.
append
(
category
)
}
// // 如果没有选中任何分类,自动选中"全部行业"
// if selectedCategories.isEmpty {
// selectedCategories.append(categories.first!)
// }
// 如果未选中,则添加到选中列表
selectedCategories
.
append
(
category
)
}
// 刷新UI
collectionView
.
reloadData
()
// 通知代理(不自动关闭,用户需要点击"筛选"按钮)
delegate
?
.
categoryView
(
self
,
didSelectCategories
:
selectedCategories
,
isSet
:
false
)
}
}
...
...
@@ -295,9 +221,16 @@ extension YHResourceCategoryView: UICollectionViewDelegateFlowLayout {
// MARK: - YHResourceCategoryCell
class
YHResourceCategoryCell
:
UICollectionViewCell
{
private
lazy
var
iconLabel
:
UILabel
=
{
let
label
=
UILabel
()
label
.
font
=
UIFont
.
systemFont
(
ofSize
:
18
)
label
.
textAlignment
=
.
center
return
label
}()
private
lazy
var
titleLabel
:
UILabel
=
{
let
label
=
UILabel
()
label
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
1
4
)
label
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
1
3
)
label
.
textAlignment
=
.
center
label
.
textColor
=
.
brandGrayColor8
label
.
numberOfLines
=
1
...
...
@@ -306,6 +239,15 @@ class YHResourceCategoryCell: UICollectionViewCell {
return
label
}()
private
lazy
var
containerStackView
:
UIStackView
=
{
let
stack
=
UIStackView
()
stack
.
axis
=
.
horizontal
stack
.
spacing
=
4
stack
.
alignment
=
.
center
stack
.
distribution
=
.
fill
return
stack
}()
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
setupUI
()
...
...
@@ -318,26 +260,43 @@ class YHResourceCategoryCell: UICollectionViewCell {
private
func
setupUI
()
{
backgroundColor
=
UIColor
.
brandGrayColor2
layer
.
cornerRadius
=
2
// 调整圆角以适应新高度
layer
.
cornerRadius
=
2
layer
.
borderWidth
=
1
layer
.
borderColor
=
UIColor
.
clear
.
cgColor
contentView
.
addSubview
(
titleLabel
)
contentView
.
addSubview
(
containerStackView
)
containerStackView
.
addArrangedSubview
(
iconLabel
)
containerStackView
.
addArrangedSubview
(
titleLabel
)
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
.
inset
(
UIEdgeInsets
(
top
:
12
,
left
:
4
,
bottom
:
12
,
right
:
4
))
containerStackView
.
snp
.
makeConstraints
{
make
in
make
.
center
.
equalToSuperview
()
make
.
left
.
greaterThanOrEqualToSuperview
()
.
offset
(
8
)
make
.
right
.
lessThanOrEqualToSuperview
()
.
offset
(
-
8
)
}
iconLabel
.
setContentHuggingPriority
(
.
required
,
for
:
.
horizontal
)
titleLabel
.
setContentCompressionResistancePriority
(
.
defaultLow
,
for
:
.
horizontal
)
}
func
configure
(
with
category
:
YHResourceCategory
,
isSelected
:
Bool
)
{
// 设置图标(如果有)
if
!
category
.
icon
.
isEmpty
{
iconLabel
.
text
=
category
.
icon
iconLabel
.
isHidden
=
false
}
else
{
iconLabel
.
isHidden
=
true
}
titleLabel
.
text
=
category
.
name
if
isSelected
{
layer
.
borderColor
=
UIColor
.
brandGrayColor8
.
cgColor
titleLabel
.
font
=
UIFont
.
PFSC_B
(
ofSize
:
14
)
titleLabel
.
font
=
UIFont
.
PFSC_B
(
ofSize
:
13
)
titleLabel
.
textColor
=
UIColor
.
brandGrayColor8
}
else
{
layer
.
borderColor
=
UIColor
.
clear
.
cgColor
titleLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
14
)
titleLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
titleLabel
.
textColor
=
UIColor
.
brandGrayColor7
}
}
}
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceDetailBaseInfoCell.swift
View file @
4fa16fab
...
...
@@ -70,13 +70,19 @@ class YHResourceDetailBaseInfoCell: UITableViewCell {
}
}
func
configure
(
with
model
:
YHResource
List
Model
)
{
func
configure
(
with
model
:
YHResource
Detail
Model
)
{
stackView
.
arrangedSubviews
.
forEach
{
$0
.
removeFromSuperview
()
}
addInfoRow
(
title
:
"企业介绍"
,
content
:
model
.
content
.
isEmpty
?
"未填写"
:
model
.
content
)
addInfoRow
(
title
:
"主营业务"
,
content
:
model
.
category_name
.
isEmpty
?
"未填写"
:
model
.
category_name
)
addInfoRow
(
title
:
"提供服务"
,
content
:
model
.
service_duration
.
isEmpty
?
"未填写"
:
model
.
service_duration
)
addInfoRow
(
title
:
"行业类型"
,
content
:
model
.
category_name
.
isEmpty
?
"未填写"
:
model
.
category_name
)
// 使用详情接口的字段
addInfoRow
(
title
:
"企业介绍"
,
content
:
model
.
company_introduction
.
isEmpty
?
"未填写"
:
model
.
company_introduction
)
addInfoRow
(
title
:
"主营业务"
,
content
:
model
.
company_business
.
isEmpty
?
"未填写"
:
model
.
company_business
)
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
)
if
!
model
.
settlement_status_str
.
isEmpty
{
addInfoRow
(
title
:
"入驻状态"
,
content
:
model
.
settlement_status_str
)
}
}
private
func
addInfoRow
(
title
:
String
,
content
:
String
)
{
...
...
@@ -98,7 +104,7 @@ class YHResourceDetailBaseInfoCell: UITableViewCell {
contentLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
contentLabel
.
textColor
=
UIColor
.
brandGrayColor8
contentLabel
.
text
=
content
contentLabel
.
numberOfLines
=
4
contentLabel
.
numberOfLines
=
0
contentLabel
.
textAlignment
=
.
left
container
.
addSubview
(
titleLabel
)
...
...
@@ -110,7 +116,7 @@ class YHResourceDetailBaseInfoCell: UITableViewCell {
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
make
.
top
.
equalToSuperview
()
make
.
bottom
.
lessThanOrEqualToSuperview
(
)
make
.
width
.
equalTo
(
70
)
}
contentLabel
.
snp
.
makeConstraints
{
make
in
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceDetailDemandCell.swift
View file @
4fa16fab
...
...
@@ -36,7 +36,7 @@ class YHResourceDetailDemandCell: UITableViewCell {
let
label
=
UILabel
()
label
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
label
.
textColor
=
UIColor
.
brandGrayColor8
label
.
numberOfLines
=
4
label
.
numberOfLines
=
0
return
label
}()
...
...
@@ -66,15 +66,15 @@ class YHResourceDetailDemandCell: UITableViewCell {
}
demandTitleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
offset
(
16
)
make
.
left
.
equalToSuperview
()
.
offset
(
20
)
make
.
top
.
equalTo
(
titleLabel
.
snp
.
bottom
)
.
offset
(
16
)
make
.
width
.
equalTo
(
70
)
}
demandContentLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
demandTitleLabel
.
snp
.
right
)
.
offset
(
12
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
20
)
make
.
top
.
equalTo
(
demandTitleLabel
)
}
dividerView
.
snp
.
makeConstraints
{
make
in
...
...
@@ -85,7 +85,8 @@ class YHResourceDetailDemandCell: UITableViewCell {
}
}
func
configure
(
with
model
:
YHResourceListModel
)
{
demandContentLabel
.
text
=
model
.
title
.
isEmpty
?
"未填写"
:
model
.
title
func
configure
(
with
model
:
YHResourceDetailModel
)
{
// 使用详情接口的 demand_published 字段
demandContentLabel
.
text
=
model
.
demand_published
.
isEmpty
?
"未填写"
:
model
.
demand_published
}
}
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceDetailDocumentsCell.swift
View file @
4fa16fab
...
...
@@ -133,7 +133,7 @@ class YHResourceDetailDocumentsCell: UITableViewCell {
}
let
imageWidth
=
KScreenWidth
-
20
*
2
// 左右各16的padding
let
imageHeight
=
imageWidth
*
1.
4
// A4纸张比例
let
imageHeight
=
imageWidth
*
1.
0
// A4纸张比例
for
(
index
,
imageUrl
)
in
images
.
enumerated
()
{
let
imageView
=
UIImageView
()
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceDetailHeaderCell.swift
View file @
4fa16fab
...
...
@@ -7,15 +7,18 @@
//
import
UIKit
import
Kingfisher
class
YHResourceDetailHeaderCell
:
UITableViewCell
{
private
lazy
var
logoImageView
:
UIImageView
=
{
let
imageView
=
UIImageView
()
imageView
.
contentMode
=
.
scaleAspectFi
t
imageView
.
contentMode
=
.
scaleAspectFi
ll
imageView
.
clipsToBounds
=
true
imageView
.
layer
.
cornerRadius
=
4
imageView
.
backgroundColor
=
.
white
imageView
.
layer
.
borderWidth
=
1
imageView
.
layer
.
borderColor
=
UIColor
.
brandGrayColor3
.
cgColor
return
imageView
}()
...
...
@@ -72,11 +75,26 @@ class YHResourceDetailHeaderCell: UITableViewCell {
}
}
func
configure
(
with
model
:
YHResourceListModel
)
{
if
let
url
=
URL
(
string
:
model
.
company_logo
)
{
logoImageView
.
sd_setImage
(
with
:
url
,
placeholderImage
:
UIImage
(
named
:
"people_head_default"
))
func
configure
(
with
model
:
YHResourceDetailModel
)
{
// 设置Logo
if
!
model
.
companyLogoUrl
.
isEmpty
{
logoImageView
.
kf
.
setImage
(
with
:
URL
(
string
:
model
.
companyLogoUrl
),
placeholder
:
UIImage
(
named
:
"global_default_image"
)
)
}
else
{
logoImageView
.
image
=
UIImage
(
named
:
"global_default_image"
)
}
// 设置公司名称
companyNameLabel
.
text
=
model
.
displayName
// 设置英文名称
if
!
model
.
company_english_name
.
isEmpty
{
companyEnglishNameLabel
.
text
=
model
.
company_english_name
companyEnglishNameLabel
.
isHidden
=
false
}
else
{
companyEnglishNameLabel
.
isHidden
=
true
}
companyNameLabel
.
text
=
model
.
company_name
companyEnglishNameLabel
.
text
=
"JUXIN CERTIFIED PUBLIC ACCOUNTANTS FIRM"
}
}
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceTableViewCell.swift
View file @
4fa16fab
...
...
@@ -191,83 +191,35 @@ extension YHResourceTableViewCell {
private
func
updateUI
()
{
guard
let
model
=
resourceModel
else
{
return
}
// 设置基本信息
let
title
=
model
.
title
.
count
>
0
?
model
.
title
:
"-"
let
company
=
model
.
company_name
.
count
>
0
?
model
.
company_name
:
"-"
let
categoryName
=
model
.
category_name
.
count
>
0
?
model
.
category_name
:
"-"
titleLabel
.
text
=
title
companyLabel
.
text
=
company
industryLabel
.
text
=
categoryName
var
needNext
=
false
if
let
needNewLine
=
model
.
needNewLine
{
needNext
=
needNewLine
}
else
{
let
needNewLine
=
model
.
calculateNeedNewLine
()
model
.
needNewLine
=
needNewLine
needNext
=
needNewLine
}
if
!
needNext
{
companyLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
titleLabel
)
make
.
top
.
equalTo
(
titleLabel
.
snp
.
bottom
)
.
offset
(
4
)
}
vSeparatorLine
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
companyLabel
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
centerY
.
equalTo
(
companyLabel
)
make
.
width
.
equalTo
(
1
)
make
.
height
.
equalTo
(
8
)
}
// 行业标签约束
industryLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
right
.
lessThanOrEqualTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
companyLabel
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
32
)
}
}
else
{
companyLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
titleLabel
)
make
.
right
.
lessThanOrEqualTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
titleLabel
.
snp
.
bottom
)
.
offset
(
4
)
}
vSeparatorLine
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
companyLabel
.
snp
.
left
)
make
.
centerY
.
equalTo
(
industryLabel
)
make
.
width
.
equalTo
(
1
)
make
.
height
.
equalTo
(
8
)
}
// 行业标签约束
industryLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
right
.
lessThanOrEqualTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
companyLabel
.
snp
.
bottom
)
.
offset
(
4
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
32
)
}
}
// 设置基本信息 - 使用新的API字段
titleLabel
.
text
=
getServiceOrDemandText
(
model
:
model
)
// 显示服务或需求信息
companyLabel
.
text
=
model
.
displayName
// 使用 company_name
industryLabel
.
text
=
model
.
industryDisplayText
// 使用 industry_type_str
// 设置Logo
if
!
model
.
company
_logo
.
isEmpty
{
// 设置Logo
- 使用新的API字段
if
!
model
.
company
LogoUrl
.
isEmpty
{
logoImageView
.
kf
.
setImage
(
with
:
URL
(
string
:
model
.
company
_logo
),
with
:
URL
(
string
:
model
.
company
LogoUrl
),
placeholder
:
UIImage
(
named
:
"global_default_image"
)
)
}
else
{
logoImageView
.
image
=
UIImage
(
named
:
"global_default_image"
)
}
// 设置类型标签
if
model
.
type
==
"service"
{
// 设置类型标签
- 根据是服务还是需求
if
model
.
isService
{
typeTagIcon
.
image
=
UIImage
(
named
:
"resource_flag_service"
)
}
else
if
model
.
type
==
"demand"
{
typeTagIcon
.
image
=
UIImage
(
named
:
"resource_flag_demand"
)
}
else
{
typeTagIcon
.
image
=
nil
typeTagIcon
.
image
=
UIImage
(
named
:
"resource_flag_demand"
)
}
}
/// 获取服务或需求文本
private
func
getServiceOrDemandText
(
model
:
YHResourceListModel
)
->
String
{
if
model
.
isService
{
return
model
.
resource_provided
.
isEmpty
?
"-"
:
model
.
resource_provided
}
else
{
return
model
.
demand_published
.
isEmpty
?
"-"
:
model
.
demand_published
}
}
}
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/VM/YHResourceViewModel.swift
View file @
4fa16fab
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment