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
ba9cfe93
Commit
ba9cfe93
authored
Apr 11, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页的 获取更多 获取首页逻辑
parent
232ca251
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
37 deletions
+72
-37
YHHomePageViewController.swift
...Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
+36
-13
YHHomePageViewModel.swift
...axy/Classes/Modules/Home(首页)/VM/YHHomePageViewModel.swift
+31
-5
YHHomeCollectionViewCell.swift
...IntelligentService(服务中心)/V/YHHomeCollectionViewCell.swift
+2
-15
YHServiceTableFootView.swift
...s/IntelligentService(服务中心)/V/YHServiceTableFootView.swift
+0
-3
YhConstant.swift
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
+3
-1
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
View file @
ba9cfe93
...
@@ -32,7 +32,7 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -32,7 +32,7 @@ class YHHomePageViewController: YHBaseViewController {
collectinoView
.
register
(
YHHomeCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
YHHomeCollectionViewCell
.
cellReuseIdentifier
)
collectinoView
.
register
(
YHHomeCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
YHHomeCollectionViewCell
.
cellReuseIdentifier
)
collectinoView
.
delegate
=
self
collectinoView
.
delegate
=
self
collectinoView
.
dataSource
=
self
collectinoView
.
dataSource
=
self
collectinoView
.
bounces
=
false
//
collectinoView.bounces = false
collectinoView
.
translatesAutoresizingMaskIntoConstraints
=
false
collectinoView
.
translatesAutoresizingMaskIntoConstraints
=
false
collectinoView
.
alwaysBounceVertical
=
true
collectinoView
.
alwaysBounceVertical
=
true
return
collectinoView
return
collectinoView
...
@@ -55,30 +55,46 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -55,30 +55,46 @@ class YHHomePageViewController: YHBaseViewController {
let
view
=
YHHomeHeadView
()
let
view
=
YHHomeHeadView
()
return
view
return
view
}()
}()
}
private
extension
YHHomePageViewController
{
@objc
func
didSearchBarClicked
()
{
@objc
func
didSearchBarClicked
()
{
let
vc
=
YHSearchInfomationVC
()
let
vc
=
YHSearchInfomationVC
()
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
func
getData
()
{
func
getData
()
{
viewModel
.
getHomeNewsList
{[
weak
self
]
success
,
error
in
loadFirstData
()
viewModel
.
getHomeBanner
(
0
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
homeHeaderView
.
homeBannerView
.
dataArr
=
self
.
viewModel
.
banners
??
[]
}
}
func
loadMoreData
()
{
viewModel
.
getHomeNewsList
(
firstPageFlag
:
false
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
homeCollectView
.
es
.
stopLoadingMore
()
self
.
homeCollectView
.
reloadData
()
self
.
homeCollectView
.
reloadData
()
}
}
viewModel
.
getHomeBanner
(
0
)
{[
weak
self
]
success
,
error
in
}
func
loadFirstData
()
{
viewModel
.
getHomeNewsList
(
firstPageFlag
:
true
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
homeHeaderView
.
homeBannerView
.
dataArr
=
self
.
viewModel
.
banners
??
[]
homeCollectView
.
es
.
stopPullToRefresh
()
self
.
homeCollectView
.
reloadData
()
}
}
}
}
}
private
extension
YHHomePageViewController
{
func
setupUI
()
{
func
setupUI
()
{
gk_navigationBar
.
isHidden
=
true
gk_navigationBar
.
isHidden
=
true
view
.
backgroundColor
=
.
white
view
.
backgroundColor
=
.
white
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
homepageRefresh
)
,
name
:
YhConstant
.
YhNotification
.
refreshHomePageNotifiction
,
object
:
nil
)
view
.
addSubview
(
searchView
)
view
.
addSubview
(
searchView
)
searchView
.
snp
.
makeConstraints
{
make
in
searchView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
k_Height_safeAreaInsetsTop
()
+
6
)
make
.
top
.
equalTo
(
k_Height_safeAreaInsetsTop
()
+
6
)
...
@@ -97,15 +113,22 @@ private extension YHHomePageViewController {
...
@@ -97,15 +113,22 @@ private extension YHHomePageViewController {
homeCollectView
.
addSubview
(
homeHeaderView
)
homeCollectView
.
addSubview
(
homeHeaderView
)
homeCollectView
.
contentInset
=
UIEdgeInsets
(
top
:
YHHomeHeadView
.
viewH
,
left
:
0
,
bottom
:
20
,
right
:
0
)
homeCollectView
.
contentInset
=
UIEdgeInsets
(
top
:
YHHomeHeadView
.
viewH
,
left
:
0
,
bottom
:
20
,
right
:
0
)
let
tmpHeadView
=
homeCollectView
.
es
.
addPullToRefresh
{
self
.
loadFirstData
()
}
var
r
=
tmpHeadView
.
frame
r
.
origin
.
y
=
r
.
origin
.
y
-
YHHomeHeadView
.
viewH
tmpHeadView
.
frame
=
r
homeCollectView
.
es
.
addInfiniteScrolling
{
homeCollectView
.
es
.
addInfiniteScrolling
{
self
.
loadMoreData
()
}
}
homeCollectView
.
reloadData
()
}
}
func
loadFirstItem
()
{
@objc
func
homepageRefresh
()
{
loadFirstData
()
}
}
}
}
extension
YHHomePageViewController
:
UICollectionViewDelegate
,
UICollectionViewDataSource
{
extension
YHHomePageViewController
:
UICollectionViewDelegate
,
UICollectionViewDataSource
{
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/VM/YHHomePageViewModel.swift
View file @
ba9cfe93
...
@@ -10,8 +10,7 @@ import UIKit
...
@@ -10,8 +10,7 @@ import UIKit
class
YHHomePageViewModel
:
YHBaseViewModel
{
class
YHHomePageViewModel
:
YHBaseViewModel
{
//数据源
//数据源
var
configModel
:
YHConfigModel
?
var
configModel
:
YHConfigModel
?
//app相关配置
var
arrHomeNewsData
:
[
YHHomeListModel
]?
var
arrHomeNewsData
:
[
YHHomeListModel
]?
var
banners
:
[
YHBannerModel
]?
var
banners
:
[
YHBannerModel
]?
var
classify
:
[
YHHomeClassifyModel
]?
var
classify
:
[
YHHomeClassifyModel
]?
...
@@ -19,6 +18,7 @@ class YHHomePageViewModel : YHBaseViewModel {
...
@@ -19,6 +18,7 @@ class YHHomePageViewModel : YHBaseViewModel {
//首页相关参数
//首页相关参数
private
var
curPageIndex
:
Int
=
1
private
var
curPageIndex
:
Int
=
1
private
var
page_Size
:
Int
=
10
private
var
page_Size
:
Int
=
10
private
var
totalCount
:
Int
=
0
private
var
hasMoreForHomeNews
:
Bool
=
true
private
var
hasMoreForHomeNews
:
Bool
=
true
}
}
...
@@ -44,9 +44,20 @@ extension YHHomePageViewModel {
...
@@ -44,9 +44,20 @@ extension YHHomePageViewModel {
}
}
}
}
func
getHomeNewsList
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
/*
let
params
:
[
String
:
Any
]
=
[
"page"
:
curPageIndex
,
firstPageFlag true - 首页 false - 更多
*/
func
getHomeNewsList
(
firstPageFlag
:
Bool
,
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
var
params
:
[
String
:
Any
]
=
[
"page"
:
curPageIndex
,
"page_size"
:
page_Size
]
"page_size"
:
page_Size
]
if
firstPageFlag
{
params
=
[
"page"
:
curPageIndex
,
"page_size"
:
page_Size
]
}
else
{
params
=
[
"page"
:
curPageIndex
+
1
,
"page_size"
:
page_Size
]
}
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Common
.
consult
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Common
.
consult
let
_
=
YHNetRequest
.
getRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
let
_
=
YHNetRequest
.
getRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
...
@@ -62,7 +73,22 @@ extension YHHomePageViewModel {
...
@@ -62,7 +73,22 @@ extension YHHomePageViewModel {
for
item
in
result
.
data
{
for
item
in
result
.
data
{
item
.
calHeightParam
()
item
.
calHeightParam
()
}
}
self
.
arrHomeNewsData
=
result
.
data
if
firstPageFlag
{
self
.
totalCount
=
result
.
total
self
.
arrHomeNewsData
=
result
.
data
}
else
{
self
.
arrHomeNewsData
?
.
append
(
contentsOf
:
result
.
data
)
}
if
let
count
=
self
.
arrHomeNewsData
?
.
count
{
if
count
==
self
.
totalCount
{
self
.
hasMoreForHomeNews
=
false
}
else
{
self
.
hasMoreForHomeNews
=
true
}
}
callBackBlock
(
true
,
nil
)
callBackBlock
(
true
,
nil
)
}
else
{
}
else
{
self
.
arrHomeNewsData
=
[]
self
.
arrHomeNewsData
=
[]
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/V/YHHomeCollectionViewCell.swift
View file @
ba9cfe93
...
@@ -49,13 +49,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
...
@@ -49,13 +49,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
return
imageV
return
imageV
}()
}()
lazy
var
heartImageView
:
UIImageView
=
{
let
imageV
=
UIImageView
(
image
:
UIImage
(
named
:
"home_grey_heart"
))
imageV
.
contentMode
=
.
scaleAspectFill
return
imageV
}()
lazy
var
heartImageViewBtn
:
UIButton
=
{
lazy
var
heartImageViewBtn
:
UIButton
=
{
let
btn
:
UIButton
=
UIButton
(
type
:
.
custom
)
let
btn
:
UIButton
=
UIButton
(
type
:
.
custom
)
btn
.
setImage
(
UIImage
(
named
:
"home_grey_heart"
),
for
:
.
normal
)
btn
.
setImage
(
UIImage
(
named
:
"home_grey_heart"
),
for
:
.
normal
)
...
@@ -143,14 +136,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
...
@@ -143,14 +136,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
make
.
bottom
.
equalTo
(
-
36
)
make
.
bottom
.
equalTo
(
-
36
)
}
}
numLable
.
text
=
listModel
.
collect_count
.
string
numLable
.
text
=
listModel
.
collect_count
.
string
// if listModel.is_like {
// headImageView.image = UIImage(named: "home_red_heart")
// } else {
// headImageView.image = UIImage(named: "home_grey_heart")
// }
heartImageViewBtn
.
isSelected
=
listModel
.
is_like
heartImageViewBtn
.
isSelected
=
listModel
.
is_like
}
}
...
@@ -177,6 +162,8 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
...
@@ -177,6 +162,8 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
}
}
}
}
}
}
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
refreshHomePageNotifiction
,
object
:
nil
)
}
else
{
}
else
{
let
vc
=
UINavigationController
(
rootVC
:
YHPhoneLoginViewController
())
let
vc
=
UINavigationController
(
rootVC
:
YHPhoneLoginViewController
())
vc
.
modalPresentationStyle
=
.
custom
vc
.
modalPresentationStyle
=
.
custom
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/V/YHServiceTableFootView.swift
View file @
ba9cfe93
...
@@ -49,9 +49,6 @@ class YHServiceTableFootView: UIView {
...
@@ -49,9 +49,6 @@ class YHServiceTableFootView: UIView {
myCollectView
.
snp
.
makeConstraints
{
make
in
myCollectView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
top
.
left
.
right
.
bottom
.
equalToSuperview
()
}
}
// self.myCollectView.es.addInfiniteScrolling {
// self.loadFakeData()
// }
}
}
}
}
...
...
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
View file @
ba9cfe93
...
@@ -159,8 +159,10 @@ extension YhConstant {
...
@@ -159,8 +159,10 @@ extension YhConstant {
//退出成功
//退出成功
public
static
let
didLogoutSuccessNotifiction
=
Notification
.
Name
(
rawValue
:
"com.usleep.health.logout.success"
)
public
static
let
didLogoutSuccessNotifiction
=
Notification
.
Name
(
rawValue
:
"com.usleep.health.logout.success"
)
//token 过期
//token 过期
public
static
let
tokenInvalidateNotifiction
=
Notification
.
Name
(
rawValue
:
"com.usleep.health.token.invalidate"
)
public
static
let
tokenInvalidateNotifiction
=
Notification
.
Name
(
rawValue
:
"com.usleep.health.token.invalidate"
)
//首页刷新通知
public
static
let
refreshHomePageNotifiction
=
Notification
.
Name
(
rawValue
:
"com.yinhe.homePage.refresh"
)
}
}
}
}
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