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
659cf11f
Commit
659cf11f
authored
Apr 12, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner 跳转
parent
2f3c1e45
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
21 deletions
+79
-21
YHHomePageViewController.swift
...Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
+5
-0
YHBannerModel.swift
galaxy/galaxy/Classes/Modules/Home(首页)/M/YHBannerModel.swift
+1
-1
YHHomeBannerView.swift
.../galaxy/Classes/Modules/Home(首页)/V/YHHomeBannerView.swift
+41
-20
YhConstant.swift
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
+32
-0
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
View file @
659cf11f
...
@@ -39,6 +39,11 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -39,6 +39,11 @@ class YHHomePageViewController: YHBaseViewController {
getData
()
getData
()
}
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
loadFirstData
()
}
lazy
var
searchView
:
YHHomeSearchView
=
{
lazy
var
searchView
:
YHHomeSearchView
=
{
let
view
=
YHHomeSearchView
()
let
view
=
YHHomeSearchView
()
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
didSearchBarClicked
)
)
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
didSearchBarClicked
)
)
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/M/YHBannerModel.swift
View file @
659cf11f
...
@@ -12,7 +12,7 @@ class YHBannerModel: YHBaseModel {
...
@@ -12,7 +12,7 @@ class YHBannerModel: YHBaseModel {
var
name
:
String
=
""
var
name
:
String
=
""
var
skip_url
:
String
=
""
var
skip_url
:
String
=
""
var
img_url
:
String
=
""
var
img_url
:
String
=
""
var
type
:
Int
=
0
var
type
:
Int
=
0
//banner 跳转类型:0-不跳转,1-跳转H5,2-跳转APP内Tab,3-跳转资讯页
var
create_at
:
String
=
""
var
create_at
:
String
=
""
var
skip_type
:
Int
=
0
var
skip_type
:
Int
=
0
var
id
:
Int
=
0
var
id
:
Int
=
0
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHHomeBannerView.swift
View file @
659cf11f
...
@@ -11,12 +11,7 @@ import FSPagerView
...
@@ -11,12 +11,7 @@ import FSPagerView
import
Kingfisher
import
Kingfisher
class
YHHomeBannerView
:
UIView
{
class
YHHomeBannerView
:
UIView
{
// MARK: - constant 常量
static
let
viewH
:
CGFloat
=
KScreenWidth
-
20
*
2
static
let
viewH
:
CGFloat
=
KScreenWidth
-
20
*
2
// 位置、大小、图片、文本
var
dataArr
:
[
YHBannerModel
]
=
[]
{
var
dataArr
:
[
YHBannerModel
]
=
[]
{
didSet
{
didSet
{
self
.
pageControl
.
numberOfPages
=
self
.
dataArr
.
count
self
.
pageControl
.
numberOfPages
=
self
.
dataArr
.
count
...
@@ -40,7 +35,6 @@ class YHHomeBannerView: UIView {
...
@@ -40,7 +35,6 @@ class YHHomeBannerView: UIView {
view
.
automaticSlidingInterval
=
4
view
.
automaticSlidingInterval
=
4
view
.
register
(
FSPagerViewCell
.
self
,
forCellWithReuseIdentifier
:
"cell"
)
view
.
register
(
FSPagerViewCell
.
self
,
forCellWithReuseIdentifier
:
"cell"
)
view
.
itemSize
=
FSPagerView
.
automaticSize
view
.
itemSize
=
FSPagerView
.
automaticSize
// view.interitemSpacing = 10
return
view
return
view
}()
}()
...
@@ -83,6 +77,27 @@ private extension YHHomeBannerView {
...
@@ -83,6 +77,27 @@ private extension YHHomeBannerView {
self
.
pageControl
.
interitemSpacing
=
3
self
.
pageControl
.
interitemSpacing
=
3
}
}
func
goAppTab
(
tabBarName
:
String
)
{
if
!
tabBarName
.
isEmpty
{
if
tabBarName
.
contains
(
"tabBarHome"
,
caseSensitive
:
false
)
{
//首页
goTabBarBy
(
tabType
:
.
home
)
}
else
if
tabBarName
.
contains
(
"tabBarService"
,
caseSensitive
:
false
)
{
//服务中心
goTabBarBy
(
tabType
:
.
service
)
}
else
if
tabBarName
.
contains
(
"tabBarMsg"
,
caseSensitive
:
false
)
{
//消息
goTabBarBy
(
tabType
:
.
message
)
}
else
if
tabBarName
.
contains
(
"tabBarMine"
,
caseSensitive
:
false
)
{
//我的
goTabBarBy
(
tabType
:
.
mine
)
}
else
{
}
}
}
}
}
extension
YHHomeBannerView
:
FSPagerViewDataSource
,
FSPagerViewDelegate
{
extension
YHHomeBannerView
:
FSPagerViewDataSource
,
FSPagerViewDelegate
{
...
@@ -103,14 +118,13 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
...
@@ -103,14 +118,13 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
cell
.
textLabel
?
.
text
=
model
.
name
cell
.
textLabel
?
.
text
=
model
.
name
}
}
cell
.
imageView
?
.
contentMode
=
.
scaleAspectFill
cell
.
imageView
?
.
contentMode
=
.
scaleAspectFill
cell
.
backgroundColor
=
.
contentBkgColor
cell
.
backgroundColor
=
.
contentBkgColor
cell
.
contentView
.
layer
.
shadowColor
=
UIColor
.
clear
.
cgColor
cell
.
contentView
.
layer
.
shadowColor
=
UIColor
.
clear
.
cgColor
return
cell
return
cell
}
}
// MARK: - FSPagerView Delegate
// MARK: - FSPagerView Delegate
func
pagerView
(
_
pagerView
:
FSPagerView
,
didSelectItemAt
index
:
Int
)
{
func
pagerView
(
_
pagerView
:
FSPagerView
,
didSelectItemAt
index
:
Int
)
{
pagerView
.
deselectItem
(
at
:
index
,
animated
:
true
)
pagerView
.
deselectItem
(
at
:
index
,
animated
:
true
)
pagerView
.
scrollToItem
(
at
:
index
,
animated
:
true
)
pagerView
.
scrollToItem
(
at
:
index
,
animated
:
true
)
...
@@ -118,19 +132,26 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
...
@@ -118,19 +132,26 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
return
return
}
}
let
model
=
dataArr
[
index
]
let
model
=
dataArr
[
index
]
switch
model
.
type
{
if
model
.
skip_url
.
isEmpty
==
false
{
case
10
:
//跳转H5
switch
model
.
type
{
// let vc = BsWebViewController()
case
1
:
//跳转H5
// vc.urlString = model.link_url
let
vc
=
YHHomeWebViewController
()
// UIViewController.navTopViewController?.navigationController?.pushViewController(vc, animated: true)
vc
.
url
=
model
.
skip_url
break
self
.
parentViewController
?
.
navigationController
?
.
pushViewController
(
vc
)
case
20
:
//跳转原生页面
case
2
:
//跳转APP内Tab
if
let
vc
=
UIViewController
.
classFromString
(
model
.
skip_url
)
{
goAppTab
(
tabBarName
:
model
.
skip_url
)
UIViewController
.
navTopViewController
?
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
case
3
:
//3-跳转资讯页
let
vc
=
YHHomeWebViewController
()
vc
.
url
=
model
.
skip_url
self
.
parentViewController
?
.
navigationController
?
.
pushViewController
(
vc
)
case
0
:
//0 不需要跳转
printLog
(
"0 不需要跳转"
)
default
:
YHHUD
.
flash
(
message
:
"不需要处理的类型"
)
break
}
}
break
}
else
{
default
:
YHHUD
.
flash
(
message
:
"error:skip_url不能为空"
)
break
}
}
}
}
...
...
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
View file @
659cf11f
...
@@ -125,6 +125,38 @@ func isIphoneX() -> Bool {
...
@@ -125,6 +125,38 @@ func isIphoneX() -> Bool {
return
k_Height_safeAreaInsetsBottom
()
>
0.0
// 底部安全区 > 0 时,
return
k_Height_safeAreaInsetsBottom
()
>
0.0
// 底部安全区 > 0 时,
}
}
enum
tabBarPageType
:
Int
{
case
home
case
service
case
message
case
mine
}
func
goTabBarBy
(
tabType
:
tabBarPageType
)
{
var
tabIndex
:
Int
=
0
switch
tabType
{
case
.
home
:
tabIndex
=
0
case
.
service
:
tabIndex
=
1
case
.
message
:
tabIndex
=
2
case
.
mine
:
tabIndex
=
3
}
if
let
vc
=
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
as?
YHTabBarViewController
{
vc
.
selectedIndex
=
tabIndex
}
}
class
YhConstant
{
class
YhConstant
{
// MARK: - 登录信息
// MARK: - 登录信息
static
let
KLoginedInfoKey
=
"KLoginedInfoKey"
static
let
KLoginedInfoKey
=
"KLoginedInfoKey"
...
...
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