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
3058597b
Commit
3058597b
authored
Apr 07, 2025
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
算法修改
parent
c7dec44f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
51 deletions
+105
-51
YHSurveyMatchingViewController.swift
...s/Modules/Plan(方案)/C/YHSurveyMatchingViewController.swift
+1
-1
YHMakePlanModel.swift
...Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanModel.swift
+88
-48
YHMakePlanCardView.swift
...sses/Modules/Plan(方案)/MakePlan/V/YHMakePlanCardView.swift
+16
-1
YHMakePlanPriceAlertView.swift
...odules/Plan(方案)/MakePlan/V/YHMakePlanPriceAlertView.swift
+0
-1
No files found.
galaxy/galaxy/Classes/Modules/Plan(方案)/C/YHSurveyMatchingViewController.swift
View file @
3058597b
...
...
@@ -124,7 +124,7 @@ class YHSurveyMatchingViewController: YHBaseViewController {
self
.
requestState
()
}
})
//requestState()
//
requestState()
}
private
func
requestState
()
{
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanModel.swift
View file @
3058597b
...
...
@@ -82,65 +82,105 @@ extension String {
extension
YHMakePlanModel
{
mutating
func
toggleAddCartStatus
(
for
productId
:
Int
)
{
// Search and toggle in basic array
for
i
in
0
..<
basic
.
count
{
if
basic
[
i
]
.
product_id
==
productId
{
basic
[
i
]
.
is_add_cart
=
!
basic
[
i
]
.
is_add_cart
// If enabling, set all sub products to false except the first one
if
basic
[
i
]
.
is_add_cart
{
for
j
in
0
..<
basic
[
i
]
.
sub_product
.
count
{
basic
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
(
j
==
0
)
}
}
var
localBasic
=
basic
var
localWork
=
work
var
localLive
=
live
var
localInvest
=
invest
for
i
in
0
..<
localBasic
.
count
{
if
localBasic
[
i
]
.
product_id
!=
0
&&
localBasic
[
i
]
.
product_id
==
productId
{
localBasic
[
i
]
.
is_add_cart
=
!
localBasic
[
i
]
.
is_add_cart
updateSubProducts
(
for
:
&
localBasic
[
i
])
// Update the original arrays and return
basic
=
localBasic
work
=
localWork
live
=
localLive
invest
=
localInvest
return
}
}
for
i
in
0
..<
localWork
.
count
{
if
localWork
[
i
]
.
product_id
!=
0
&&
localWork
[
i
]
.
product_id
==
productId
{
localWork
[
i
]
.
is_add_cart
=
!
localWork
[
i
]
.
is_add_cart
updateSubProducts
(
for
:
&
localWork
[
i
])
// Update the original arrays and return
basic
=
localBasic
work
=
localWork
live
=
localLive
invest
=
localInvest
return
}
else
{
// Search in sub products
for
j
in
0
..<
basic
[
i
]
.
sub_product
.
count
{
if
basic
[
i
]
.
sub_product
[
j
]
.
product_id
==
productId
{
basic
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
!
basic
[
i
]
.
sub_product
[
j
]
.
is_add_cart
// When a sub product is selected, set its parent to true
if
basic
[
i
]
.
sub_product
[
j
]
.
is_add_cart
{
basic
[
i
]
.
is_add_cart
=
true
}
return
}
}
}
}
// Repeat the same logic for work, live, and invest arrays
toggleInArray
(
&
work
,
productId
:
productId
)
toggleInArray
(
&
live
,
productId
:
productId
)
toggleInArray
(
&
invest
,
productId
:
productId
)
for
i
in
0
..<
localLive
.
count
{
if
localLive
[
i
]
.
product_id
!=
0
&&
localLive
[
i
]
.
product_id
==
productId
{
localLive
[
i
]
.
is_add_cart
=
!
localLive
[
i
]
.
is_add_cart
updateSubProducts
(
for
:
&
localLive
[
i
])
// Update the original arrays and return
basic
=
localBasic
work
=
localWork
live
=
localLive
invest
=
localInvest
return
}
}
for
i
in
0
..<
localInvest
.
count
{
if
localInvest
[
i
]
.
product_id
!=
0
&&
localInvest
[
i
]
.
product_id
==
productId
{
localInvest
[
i
]
.
is_add_cart
=
!
localInvest
[
i
]
.
is_add_cart
updateSubProducts
(
for
:
&
localInvest
[
i
])
// Update the original arrays and return
basic
=
localBasic
work
=
localWork
live
=
localLive
invest
=
localInvest
return
}
}
// If we get here, we need to check sub_products (product_id == 0 cases)
checkSubProducts
(
in
:
&
localBasic
,
for
:
productId
)
checkSubProducts
(
in
:
&
localWork
,
for
:
productId
)
checkSubProducts
(
in
:
&
localLive
,
for
:
productId
)
checkSubProducts
(
in
:
&
localInvest
,
for
:
productId
)
basic
=
localBasic
work
=
localWork
live
=
localLive
invest
=
localInvest
}
private
func
toggleInArray
(
_
array
:
inout
[
YHMakePlanMainModel
],
productId
:
Int
)
{
for
i
in
0
..<
array
.
count
{
if
array
[
i
]
.
product_id
==
productId
{
array
[
i
]
.
is_add_cart
=
!
array
[
i
]
.
is_add_cart
// If enabling, set all sub products to false except the first one
if
array
[
i
]
.
is_add_cart
{
for
j
in
0
..<
array
[
i
]
.
sub_product
.
count
{
array
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
(
j
==
0
)
}
}
return
}
else
{
// Search in sub products
for
j
in
0
..<
array
[
i
]
.
sub_product
.
count
{
if
array
[
i
]
.
sub_product
[
j
]
.
product_id
==
productId
{
array
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
!
array
[
i
]
.
sub_product
[
j
]
.
is_add_cart
// When a sub product is selected, set its parent to true
if
array
[
i
]
.
sub_product
[
j
]
.
is_add_cart
{
array
[
i
]
.
is_add_cart
=
true
}
return
}
private
mutating
func
updateSubProducts
(
for
mainModel
:
inout
YHMakePlanMainModel
)
{
if
mainModel
.
is_add_cart
{
// Find the subproduct with the lowest price
if
let
cheapestIndex
=
mainModel
.
sub_product
.
enumerated
()
.
min
(
by
:
{
let
price1
=
Double
(
$0
.
element
.
price
)
??
0
let
price2
=
Double
(
$1
.
element
.
price
)
??
0
return
price1
<
price2
})?
.
offset
{
// Set only the cheapest to true, others to false
for
i
in
0
..<
mainModel
.
sub_product
.
count
{
mainModel
.
sub_product
[
i
]
.
is_add_cart
=
(
i
==
cheapestIndex
)
}
}
}
else
{
// If main model is not in cart, set all subproducts to false
for
i
in
0
..<
mainModel
.
sub_product
.
count
{
mainModel
.
sub_product
[
i
]
.
is_add_cart
=
false
}
}
}
private
mutating
func
checkSubProducts
(
in
models
:
inout
[
YHMakePlanMainModel
],
for
productId
:
Int
)
{
for
i
in
0
..<
models
.
count
{
if
models
[
i
]
.
product_id
==
0
{
for
j
in
0
..<
models
[
i
]
.
sub_product
.
count
{
models
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
(
models
[
i
]
.
sub_product
[
j
]
.
product_id
==
productId
)
}
}
}
}
func
calculateTotalPrice
()
->
String
{
let
allCategories
=
[
basic
,
work
,
live
,
invest
]
var
total
:
Double
=
0
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanCardView.swift
View file @
3058597b
...
...
@@ -189,6 +189,8 @@ class YHMakePlanCardView: UIView {
for
i
in
0
..<
count
{
if
tag
==
self
.
data
?
.
sub_product
[
i
]
.
product_id
{
self
.
data
?
.
sub_product
[
i
]
.
is_add_cart
=
true
}
else
{
self
.
data
?
.
sub_product
[
i
]
.
is_add_cart
=
false
}
}
self
.
configure
(
with
:
self
.
data
??
YHMakePlanMainModel
())
...
...
@@ -197,7 +199,20 @@ class YHMakePlanCardView: UIView {
@objc
func
handleAction
()
{
selectButton
.
isSelected
=
!
selectButton
.
isSelected
self
.
actionHandler
?(
self
.
data
?
.
product_id
??
0
)
var
product
=
self
.
data
?
.
product_id
??
0
let
count
=
self
.
data
?
.
sub_product
.
count
??
0
if
count
!=
0
{
var
index
=
0
for
i
in
0
..<
count
{
let
flag
=
self
.
data
?
.
sub_product
[
i
]
.
is_add_cart
??
false
if
flag
{
index
=
i
}
}
let
subModel
=
data
?
.
sub_product
[
index
]
product
=
subModel
?
.
product_id
??
0
}
self
.
actionHandler
?(
product
)
}
// MARK: - Configuration
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanPriceAlertView.swift
View file @
3058597b
...
...
@@ -321,7 +321,6 @@ class YHMakePlanLabelCell: UITableViewCell {
}
func
updateAllViews
()
{
titleLabel
.
text
=
"基础身份续签"
mainItemView
.
removeSubviews
()
let
filteredModel
=
dataSource
?
.
filteredByCartStatus
()
??
[]
...
...
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