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
0a9f5bf2
Commit
0a9f5bf2
authored
May 31, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 搜索相关
parent
292298db
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
10 deletions
+87
-10
YHHomePageViewController.swift
...Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
+11
-0
YHSearchInfomationVC.swift
...axy/Classes/Modules/Home(首页)/C/YHSearchInfomationVC.swift
+33
-3
YHHomeSearchView.swift
.../galaxy/Classes/Modules/Home(首页)/V/YHHomeSearchView.swift
+15
-7
YHServerHKLifeViewController.swift
...lligentService(服务中心)/C/YHServerHKLifeViewController.swift
+11
-0
YHServiceListViewController.swift
...elligentService(服务中心)/C/YHServiceListViewController.swift
+12
-0
YHServerTableHeadView.swift
...es/IntelligentService(服务中心)/V/YHServerTableHeadView.swift
+5
-0
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
View file @
0a9f5bf2
...
...
@@ -46,6 +46,7 @@ class YHHomePageViewController: YHBaseViewController {
requestAppNewVersion
()
//获取OSS密钥
YHOSSManager
.
share
.
getOSSID
()
updateDefaultSearchKeyWord
()
}
lazy
var
searchView
:
YHHomeSearchView
=
{
...
...
@@ -60,6 +61,16 @@ class YHHomePageViewController: YHBaseViewController {
return
view
}()
func
updateDefaultSearchKeyWord
()
{
var
placeHolder
=
"香港生活"
if
isHaveLocalSearchRecords
()
{
let
latestValidSearchWord
=
getLatestValidSearchWord
()
if
!
latestValidSearchWord
.
isEmpty
{
placeHolder
=
latestValidSearchWord
}
}
searchView
.
placeHolder
=
placeHolder
}
var
tapTimestamp
:
CFAbsoluteTime
=
-
10.0
}
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHSearchInfomationVC.swift
View file @
0a9f5bf2
...
...
@@ -10,10 +10,30 @@ import UIKit
import
AVFoundation
import
AVKit
// 搜索文字集合本地存储key
let
searchInfoHistoryKey
=
"searchInfoHistoryKey"
// 最近一条有效搜索本地存储key
let
kLatestValidSearchKey
=
"kLatestValidSearchKey"
// 本地是否有搜索记录
func
isHaveLocalSearchRecords
()
->
Bool
{
if
let
arr
=
UserDefaults
.
standard
.
array
(
forKey
:
searchInfoHistoryKey
)
as?
[
String
],
arr
.
count
>
0
{
return
true
}
return
false
}
// 获取最新有效搜索记录
func
getLatestValidSearchWord
()
->
String
{
if
let
text
=
UserDefaults
.
standard
.
string
(
forKey
:
kLatestValidSearchKey
),
!
text
.
isEmpty
{
return
text
}
return
""
}
class
YHSearchInfomationVC
:
YHBaseViewController
{
static
let
searchInfoHistoryKey
=
"searchInfoHistoryKey"
static
let
searchHistoryMaxCount
=
10
var
searchStr
=
""
var
items
:[
YHHomeListModel
]
=
[]
...
...
@@ -169,6 +189,11 @@ class YHSearchInfomationVC: YHBaseViewController {
if
let
arr
=
self
.
viewModel
.
arrHomeNewsData
{
items
.
append
(
contentsOf
:
arr
)
}
if
items
.
count
>
0
,
!
self
.
searchStr
.
isEmpty
{
self
.
saveLatestValidSearchKewWord
(
self
.
searchStr
)
}
emptyDataTipsView
.
isHidden
=
(
items
.
count
>
0
)
searchHistoryView
.
isHidden
=
true
self
.
tableView
.
reloadData
()
...
...
@@ -239,7 +264,7 @@ class YHSearchInfomationVC: YHBaseViewController {
}
func
getSearchHistoryList
()
->
[
String
]
{
if
let
arr
=
UserDefaults
.
standard
.
array
(
forKey
:
Self
.
searchInfoHistoryKey
)
as?
[
String
]
{
if
let
arr
=
UserDefaults
.
standard
.
array
(
forKey
:
searchInfoHistoryKey
)
as?
[
String
]
{
return
arr
}
return
[]
...
...
@@ -273,7 +298,7 @@ class YHSearchInfomationVC: YHBaseViewController {
arr
.
insert
(
targetText
,
at
:
0
)
arr
.
removeLast
()
}
UserDefaults
.
standard
.
set
(
arr
,
forKey
:
Self
.
searchInfoHistoryKey
)
UserDefaults
.
standard
.
set
(
arr
,
forKey
:
searchInfoHistoryKey
)
UserDefaults
.
standard
.
synchronize
()
}
...
...
@@ -287,6 +312,11 @@ class YHSearchInfomationVC: YHBaseViewController {
searchBar
.
textField
.
becomeFirstResponder
()
}
}
func
saveLatestValidSearchKewWord
(
_
keyWord
:
String
)
{
UserDefaults
.
standard
.
set
(
keyWord
,
forKey
:
kLatestValidSearchKey
)
UserDefaults
.
standard
.
synchronize
()
}
}
extension
YHSearchInfomationVC
:
UITableViewDelegate
,
UITableViewDataSource
{
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHHomeSearchView.swift
View file @
0a9f5bf2
...
...
@@ -9,6 +9,19 @@
import
UIKit
class
YHHomeSearchView
:
UIView
{
static
let
viewH
:
CGFloat
=
36.0
lazy
var
placeHolderLabel
:
UILabel
=
{
let
lable
=
UILabel
()
lable
.
text
=
"香港身份"
lable
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
lable
.
textColor
=
UIColor
(
hex
:
0x94A3B8
,
alpha
:
1.0
)
return
lable
}()
var
placeHolder
:
String
=
""
{
didSet
{
self
.
placeHolderLabel
.
text
=
placeHolder
}
}
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
...
...
@@ -34,13 +47,8 @@ private extension YHHomeSearchView {
make
.
width
.
height
.
equalTo
(
16
)
}
let
lable
=
UILabel
()
lable
.
text
=
"香港身份"
lable
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
lable
.
textColor
=
UIColor
(
hex
:
0x94A3B8
,
alpha
:
1.0
)
addSubview
(
lable
)
lable
.
snp
.
makeConstraints
{
make
in
addSubview
(
placeHolderLabel
)
placeHolderLabel
.
snp
.
makeConstraints
{
make
in
make
.
centerY
.
equalToSuperview
()
make
.
left
.
equalTo
(
imageV
.
snp
.
right
)
.
offset
(
8
)
make
.
height
.
equalTo
(
18
)
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/C/YHServerHKLifeViewController.swift
View file @
0a9f5bf2
...
...
@@ -47,8 +47,19 @@ class YHServerHKLifeViewController: YHBaseViewController {
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
loadData
()
updateDefaultSearchKeyWord
()
}
func
updateDefaultSearchKeyWord
()
{
var
placeHolder
=
"香港生活"
if
isHaveLocalSearchRecords
()
{
let
latestValidSearchWord
=
getLatestValidSearchWord
()
if
!
latestValidSearchWord
.
isEmpty
{
placeHolder
=
latestValidSearchWord
}
}
tableHeadView
.
searchPlaceHolder
=
placeHolder
}
}
extension
YHServerHKLifeViewController
{
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/C/YHServiceListViewController.swift
View file @
0a9f5bf2
...
...
@@ -47,6 +47,18 @@ class YHServiceListViewController: YHBaseViewController {
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
loadData
()
updateDefaultSearchKeyWord
()
}
func
updateDefaultSearchKeyWord
()
{
var
placeHolder
=
"香港身份"
if
isHaveLocalSearchRecords
()
{
let
latestValidSearchWord
=
getLatestValidSearchWord
()
if
!
latestValidSearchWord
.
isEmpty
{
placeHolder
=
latestValidSearchWord
}
}
tableHeadView
.
searchPlaceHolder
=
placeHolder
}
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/V/YHServerTableHeadView.swift
View file @
0a9f5bf2
...
...
@@ -18,6 +18,11 @@ class YHServerTableHeadView: UIView {
updateAllViews
()
}
}
var
searchPlaceHolder
:
String
=
""
{
didSet
{
search
.
placeHolder
=
searchPlaceHolder
}
}
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
backgroundColor
=
.
white
...
...
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