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
a1e323ca
Commit
a1e323ca
authored
Aug 23, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
周日、香港法定节日
parent
0e5bcd83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
5 deletions
+162
-5
YHSelectApplicantGroupCell.swift
...tCertificate(3 赴港办证预约)/V/YHSelectApplicantGroupCell.swift
+160
-3
YHRangeDatePickerView.swift
...Classes/Tools/RangeDatePicker/YHRangeDatePickerView.swift
+2
-2
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/CustomerService/Certificate(办证段)/AppointCertificate(3 赴港办证预约)/V/YHSelectApplicantGroupCell.swift
View file @
a1e323ca
...
...
@@ -368,9 +368,12 @@ private extension YHSelectApplicantGroupCell {
[
weak
self
]
dateStr
in
guard
let
self
=
self
else
{
return
}
timeSelectView
.
detail
=
dateStr
if
let
model
=
dataModel
?
.
model
{
model
.
detailDateStr
=
dateStr
if
!
showHKHolidayWarmTips
(
startDateStr
:
dateStr
,
endDateStr
:
nil
)
{
model
.
detailDateStr
=
dateStr
timeSelectView
.
detail
=
dateStr
}
}
}
}
...
...
@@ -398,8 +401,162 @@ private extension YHSelectApplicantGroupCell {
if
let
model
=
dataModel
?
.
model
{
model
.
startDateStr
=
startDateStr
model
.
endDateStr
=
endDateStr
let
_
=
showHKHolidayWarmTips
(
startDateStr
:
startDateStr
,
endDateStr
:
endDateStr
)
}
}
view
.
show
()
}
func
showHKHolidayWarmTips
(
startDateStr
:
String
?
,
endDateStr
:
String
?)
->
Bool
{
if
let
start
=
startDateStr
,
let
end
=
endDateStr
{
//时间段
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd"
if
let
startDate
=
dateFormatter
.
date
(
from
:
start
),
let
endDate
=
dateFormatter
.
date
(
from
:
end
)
{
let
(
arrString
,
allDates
)
=
getAllDates
(
from
:
startDate
,
to
:
endDate
)
if
let
model
=
dataModel
,
let
arr
=
model
.
arrHkHolidays
,
arr
.
count
>
0
{
//判断是否有交集
if
haveCommonElements
(
array1
:
arrString
,
array2
:
arr
)
{
YHHUD
.
flash
(
message
:
"周日或法定节假日不可预约"
)
return
true
}
}
//判断 周日
if
hasSunday
(
in
:
allDates
)
{
YHHUD
.
flash
(
message
:
"周日或法定节假日不可预约"
)
return
true
}
}
}
else
if
let
start
=
startDateStr
{
//时间点
//时间段
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd"
if
let
startDate
=
dateFormatter
.
date
(
from
:
start
)
{
let
(
arrString
,
allDates
)
=
getAllDates
(
from
:
startDate
,
to
:
startDate
)
if
let
model
=
dataModel
,
let
arr
=
model
.
arrHkHolidays
,
arr
.
count
>
0
{
//判断是否有交集
if
haveCommonElements
(
array1
:
arrString
,
array2
:
arr
)
{
YHHUD
.
flash
(
message
:
"周日或法定节假日不可预约"
)
return
true
}
}
//判断 周日
if
hasSunday
(
in
:
allDates
)
{
YHHUD
.
flash
(
message
:
"周日或法定节假日不可预约"
)
return
true
}
}
}
else
{
}
return
false
}
}
// MARK: - 提示逻辑 辅助函数
private
extension
YHSelectApplicantGroupCell
{
//获取两个日期直接的全部日期
/* 使用示例
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
if let startDate = dateFormatter.date(from: "2024-01-01"),
let endDate = dateFormatter.date(from: "2024-01-10") {
let allDates = getAllDates(from: startDate, to: endDate)
for date in allDates {
print(dateFormatter.string(from: date))
}
}
*/
func
getAllDates
(
from
startDate
:
Date
,
to
endDate
:
Date
)
->
([
String
],[
Date
])
{
var
arrStrings
:
[
String
]
=
[]
var
arrDates
:
[
Date
]
=
[]
var
currentDate
=
startDate
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd"
let
dateString
=
dateFormatter
.
string
(
from
:
currentDate
)
arrStrings
.
append
(
dateString
)
arrDates
.
append
(
currentDate
)
while
currentDate
<=
endDate
{
let
dateString
=
dateFormatter
.
string
(
from
:
currentDate
)
arrStrings
.
append
(
dateString
)
arrDates
.
append
(
currentDate
)
currentDate
=
Calendar
.
current
.
date
(
byAdding
:
.
day
,
value
:
1
,
to
:
currentDate
)
!
}
return
(
arrStrings
,
arrDates
)
}
//判断字符串是否有交集
/*
// 使用示例
let array1 = ["apple", "banana", "cherry"]
let array2 = ["banana", "kiwi", "mango"]
let haveCommon = haveCommonElements(array1: array1, array2: array2)
print(haveCommon) // 输出:true
*/
func
haveCommonElements
(
array1
:
[
String
],
array2
:
[
String
])
->
Bool
{
let
set1
=
Set
(
array1
)
let
set2
=
Set
(
array2
)
return
!
set1
.
isDisjoint
(
with
:
set2
)
}
//判断日期是否有周日
/*
// 使用示例
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
dateFormatter.locale = Locale(identifier: "zh_CN") // 设置 locale 以确保周日被正确识别为周末的开始
let dates = ["2024-01-01", "2024-01-07", "2024-01-08"].map { dateFormatter.date(from: $0)! }
let isSunday = isSunday(in: dates)
for (index, date) in dates.enumerated() {
print("\(dateFormatter.string(from: date)) is Sunday: \(isSunday[index])")
}
*/
func
hasSunday
(
in
dates
:
[
Date
])
->
Bool
{
if
dates
.
isEmpty
{
return
false
}
var
returnV
=
false
let
calendar
=
Calendar
.
current
for
(
index
,
date
)
in
dates
.
enumerated
()
{
returnV
=
calendar
.
isDateInWeekend
(
date
)
||
returnV
if
returnV
{
return
returnV
}
}
view
.
show
()
//for test hjl
return
returnV
}
}
galaxy/galaxy/Classes/Tools/RangeDatePicker/YHRangeDatePickerView.swift
View file @
a1e323ca
...
...
@@ -191,7 +191,7 @@ private extension YHRangeDatePickerView {
func
tapOneDate
(
_
date
:
Date
)
{
if
startDate
==
nil
{
startDate
=
date
YHHUD
.
flash
(
message
:
"
开始
选择结束日期"
)
YHHUD
.
flash
(
message
:
"选择结束日期"
)
}
else
if
endDate
==
nil
{
// 比较结果
let
comparisonResult
=
gregorian
.
compare
(
startDate
!
,
to
:
date
,
toGranularity
:
.
day
)
...
...
@@ -213,7 +213,7 @@ private extension YHRangeDatePickerView {
calendar
.
deselect
(
endDate
!
)
startDate
=
date
endDate
=
nil
YHHUD
.
flash
(
message
:
"
开始
选择结束日期"
)
YHHUD
.
flash
(
message
:
"选择结束日期"
)
}
}
...
...
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