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
0af4620b
Commit
0af4620b
authored
Apr 10, 2024
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
15fb8b14
' into xiezhaolin
parents
65988f57
15fb8b14
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
43 deletions
+83
-43
YHHomePageViewController.swift
...Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
+0
-0
YHHomeListModel.swift
...y/galaxy/Classes/Modules/Home(首页)/M/YHHomeListModel.swift
+52
-2
YHHomePageViewModel.swift
...axy/Classes/Modules/Home(首页)/VM/YHHomePageViewModel.swift
+3
-3
YHHomeCollectionViewCell.swift
...IntelligentService(服务中心)/V/YHHomeCollectionViewCell.swift
+28
-38
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
View file @
0af4620b
This diff is collapsed.
Click to expand it.
galaxy/galaxy/Classes/Modules/Home(首页)/M/YHHomeListModel.swift
View file @
0af4620b
...
...
@@ -16,6 +16,56 @@ class YHHomeListModel: YHBaseModel {
var
view_count
:
Int
=
0
var
img_url
:
String
=
""
var
type
:
Int
=
0
var
img_width
:
Int
=
0
var
img_height
:
Int
=
0
//网络返回的图片宽高
var
img_width
:
CGFloat
=
0
var
img_height
:
CGFloat
=
0
//实际使用的图片宽高
var
img_width_use
:
CGFloat
=
0
var
img_height_use
:
CGFloat
=
0
//cell的宽高
var
img_width_cell
:
CGFloat
=
0
var
img_height_cell
:
CGFloat
=
0
func
calHeightParam
()
{
let
text
=
self
.
title
let
width
=
(
KScreenWidth
-
47
)
/
2
let
font
=
UIFont
.
PFSC_R
(
ofSize
:
14
)
// 字体大小
let
maxWidth
=
width
-
16
// 最大宽度限制
// 创建NSAttributedString对象并设置属性
let
attributes
=
[
NSAttributedString
.
Key
.
font
:
font
]
as
[
NSAttributedString
.
Key
:
Any
]
_
=
NSMutableAttributedString
(
string
:
text
,
attributes
:
attributes
)
// 根据指定的最大宽度和字体大小计算文本的高度
let
size
=
(
text
as
NSString
)
.
boundingRect
(
with
:
CGSize
(
width
:
maxWidth
,
height
:
.
greatestFiniteMagnitude
),
options
:
.
usesLineFragmentOrigin
,
attributes
:
attributes
,
context
:
nil
)
.
size
var
textHeight
=
size
.
height
if
textHeight
>
40
{
textHeight
=
40
}
else
if
textHeight
<
20
{
textHeight
=
20
}
let
imageSize
=
CGSizeMake
(
CGFloat
(
self
.
img_width
),
CGFloat
(
self
.
img_height
))
var
imageHeight
=
0.0
if
imageSize
.
width
==
0
{
imageHeight
=
width
}
else
{
imageHeight
=
width
*
imageSize
.
height
/
imageSize
.
width
if
imageHeight
>
280
{
imageHeight
=
280
}
}
let
totalHeight
=
imageHeight
+
textHeight
+
30
self
.
img_width_use
=
width
self
.
img_height_use
=
imageHeight
self
.
img_width_cell
=
width
self
.
img_height_cell
=
totalHeight
}
}
galaxy/galaxy/Classes/Modules/Home(首页)/VM/YHHomePageViewModel.swift
View file @
0af4620b
...
...
@@ -11,7 +11,7 @@ import UIKit
class
YHHomePageViewModel
:
YHBaseViewModel
{
//数据源
var
configModel
:
YHHomeCofigMode
?
var
lists
:
[
YHHomeListModel
]?
var
arrHomeNewsData
:
[
YHHomeListModel
?]
=
[]
var
banners
:
[
YHBannerModel
]?
var
classify
:
[
YHHomeClassifyModel
]?
}
...
...
@@ -38,7 +38,7 @@ extension YHHomePageViewModel {
}
}
func
getHomeList
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
func
getHome
News
List
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
params
:
[
String
:
Any
]
=
[
"page"
:
1
,
"page_size"
:
10
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Common
.
consult
...
...
@@ -51,7 +51,7 @@ extension YHHomePageViewModel {
callBackBlock
(
false
,
nil
)
return
}
self
.
lists
=
result
as?
[
YHHomeListModel
]
self
.
arrHomeNewsData
=
result
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/V/YHHomeCollectionViewCell.swift
View file @
0af4620b
...
...
@@ -12,11 +12,11 @@ import Kingfisher
class
YHHomeCollectionViewCell
:
UICollectionViewCell
{
static
let
cellReuseIdentifier
=
"YHHomeCollectionViewCell"
var
dataSource
:
AboutAdvantageItem
?
{
didSet
{
updataAllSubViews
()
}
}
//
var dataSource: AboutAdvantageItem? {
//
didSet {
//
updataAllSubViews()
//
}
//
}
var
listModel
:
YHHomeListModel
?
{
didSet
{
...
...
@@ -138,48 +138,38 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
}
func
updataAllSubViews
()
{
guard
let
dataSource
=
dataSource
else
{
return
}
let
imageSize
=
getImageSize
(
dataSource
.
url
)
var
imageHeight
=
0.0
if
imageSize
.
width
==
0
{
imageHeight
=
width
}
else
{
imageHeight
=
width
*
imageSize
.
height
/
imageSize
.
width
if
imageHeight
>
280
{
imageHeight
=
280
}
}
titleImageView
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
right
.
top
.
equalToSuperview
()
make
.
height
.
equalTo
(
imageHeight
)
}
if
let
url
=
URL
(
string
:
dataSource
.
url
)
{
titleImageView
.
kf
.
setImage
(
with
:
url
)
}
descripeLable
.
text
=
dataSource
.
title
}
//
func updataAllSubViews() {
// guard let dataSource = listModel
else { return }
//
let imageSize = getImageSize(dataSource.url)
//
var imageHeight = 0.0
//
if imageSize.width == 0 {
//
imageHeight = width
//
} else {
//
imageHeight = width * imageSize.height/imageSize.width
//
if imageHeight > 280 {
//
imageHeight = 280
//
}
//
}
//
titleImageView.snp.remakeConstraints { make in
//
make.left.right.top.equalToSuperview()
//
make.height.equalTo(imageHeight)
//
}
//
if let url = URL(string: dataSource.url) {
//
titleImageView.kf.setImage(with: url)
//
}
//
descripeLable.text = dataSource.title
//
}
func
updataSubViews
()
{
guard
let
listModel
=
listModel
else
{
return
}
let
imageSize
=
getImageSize
(
listModel
.
img_url
)
var
imageHeight
=
0.0
if
imageSize
.
width
==
0
{
imageHeight
=
width
}
else
{
imageHeight
=
width
*
imageSize
.
height
/
imageSize
.
width
if
imageHeight
>
280
{
imageHeight
=
280
}
}
titleImageView
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
right
.
top
.
equalToSuperview
()
make
.
height
.
equalTo
(
imageHeight
)
make
.
height
.
equalTo
(
listModel
.
img_height_use
)
}
if
let
url
=
URL
(
string
:
listModel
.
img_url
)
{
titleImageView
.
kf
.
setImage
(
with
:
url
)
}
descripeLable
.
text
=
listModel
.
title
descripeLable
.
text
=
listModel
.
title
.
defaultStringIfEmpty
(
detaultValue
:
"***"
)
//for test hjl
}
...
...
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