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
2c34284e
Commit
2c34284e
authored
Apr 08, 2025
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
算法修改
parent
0818af1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
YHMakePlanModel.swift
...Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanModel.swift
+30
-2
YHMakePlanCardView.swift
...sses/Modules/Plan(方案)/MakePlan/V/YHMakePlanCardView.swift
+2
-2
No files found.
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanModel.swift
View file @
2c34284e
...
...
@@ -173,9 +173,26 @@ extension YHMakePlanModel {
private
mutating
func
checkSubProducts
(
in
models
:
inout
[
YHMakePlanMainModel
],
for
productId
:
Int
)
{
for
i
in
0
..<
models
.
count
{
if
models
[
i
]
.
product_id
==
0
{
var
hasFind
=
false
for
j
in
0
..<
models
[
i
]
.
sub_product
.
count
{
if
models
[
i
]
.
sub_product
[
j
]
.
product_id
==
productId
{
if
models
[
i
]
.
sub_product
[
j
]
.
is_add_cart
{
models
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
false
models
[
i
]
.
is_add_cart
=
false
}
else
{
models
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
true
models
[
i
]
.
is_add_cart
=
true
}
hasFind
=
true
}
}
if
hasFind
{
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
)
if
models
[
i
]
.
sub_product
[
j
]
.
product_id
==
productId
{
}
else
{
models
[
i
]
.
sub_product
[
j
]
.
is_add_cart
=
false
}
}
}
}
...
...
@@ -229,3 +246,14 @@ extension Array where Element == YHMakePlanSubModel {
self
.
filter
{
$0
.
is_add_cart
}
}
}
extension
Array
where
Element
==
YHMakePlanSubModel
{
func
indexOfLowestPrice
()
->
Int
?
{
return
self
.
enumerated
()
.
reduce
(
into
:
(
index
:
0
,
price
:
Double
.
infinity
))
{
result
,
current
in
let
(
currentIndex
,
model
)
=
current
if
let
currentPrice
=
Double
(
model
.
price
),
currentPrice
<
result
.
price
{
result
=
(
currentIndex
,
currentPrice
)
}
}
.
index
}
}
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanCardView.swift
View file @
2c34284e
...
...
@@ -202,7 +202,7 @@ class YHMakePlanCardView: UIView {
var
product
=
self
.
data
?
.
product_id
??
0
let
count
=
self
.
data
?
.
sub_product
.
count
??
0
if
count
!=
0
{
var
index
=
0
var
index
=
self
.
data
?
.
sub_product
.
indexOfLowestPrice
()
??
0
for
i
in
0
..<
count
{
let
flag
=
self
.
data
?
.
sub_product
[
i
]
.
is_add_cart
??
false
if
flag
{
...
...
@@ -224,7 +224,7 @@ class YHMakePlanCardView: UIView {
if
data
.
price
==
""
{
storeButton
.
isHidden
=
false
let
count
=
self
.
data
?
.
sub_product
.
count
??
0
var
index
=
0
var
index
=
self
.
data
?
.
sub_product
.
indexOfLowestPrice
()
??
0
for
i
in
0
..<
count
{
let
flag
=
self
.
data
?
.
sub_product
[
i
]
.
is_add_cart
??
false
if
flag
{
...
...
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