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
4bd95d9d
Commit
4bd95d9d
authored
Apr 02, 2025
by
Steven杜宇
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'plan' of
http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS
into plan
parents
d07e1e47
bd4e9eb2
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
466 additions
and
71 deletions
+466
-71
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+4
-0
YHMakePlanViewController.swift
...odules/Plan(方案)/MakePlan/C/YHMakePlanViewController.swift
+25
-8
YHMakePlanModel.swift
...Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanModel.swift
+155
-0
YHMakePlanScoreModel.swift
...es/Modules/Plan(方案)/MakePlan/M/YHMakePlanScoreModel.swift
+16
-0
YHMakePlanBottomView.swift
...es/Modules/Plan(方案)/MakePlan/V/YHMakePlanBottomView.swift
+8
-2
YHMakePlanCardView.swift
...sses/Modules/Plan(方案)/MakePlan/V/YHMakePlanCardView.swift
+52
-4
YHMakePlanCell.swift
.../Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanCell.swift
+4
-1
YHMakePlanPriceAlertView.swift
...odules/Plan(方案)/MakePlan/V/YHMakePlanPriceAlertView.swift
+63
-34
YHMakePlanSelectAlertView.swift
...dules/Plan(方案)/MakePlan/V/YHMakePlanSelectAlertView.swift
+47
-21
YHMakePlanViewModel.swift
...es/Modules/Plan(方案)/MakePlan/VM/YHMakePlanViewModel.swift
+91
-1
YHAllApiName.swift
galaxy/galaxy/Classes/Tools/NetWork/YHAllApiName.swift
+1
-0
No files found.
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
4bd95d9d
...
@@ -1171,6 +1171,7 @@
...
@@ -1171,6 +1171,7 @@
048D6AE32D6348F000BC6F4C
/* YHMemberCenterCurrentPrivilegeCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
048D6AE22D6348EF00BC6F4C
/* YHMemberCenterCurrentPrivilegeCell.swift */
;
};
048D6AE32D6348F000BC6F4C
/* YHMemberCenterCurrentPrivilegeCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
048D6AE22D6348EF00BC6F4C
/* YHMemberCenterCurrentPrivilegeCell.swift */
;
};
0497C7532D9BD21500A3E32A
/* YHMakePlanViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0497C7522D9BD21500A3E32A
/* YHMakePlanViewModel.swift */
;
};
0497C7532D9BD21500A3E32A
/* YHMakePlanViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0497C7522D9BD21500A3E32A
/* YHMakePlanViewModel.swift */
;
};
0497C7552D9BD36700A3E32A
/* YHMakePlanModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0497C7542D9BD36700A3E32A
/* YHMakePlanModel.swift */
;
};
0497C7552D9BD36700A3E32A
/* YHMakePlanModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0497C7542D9BD36700A3E32A
/* YHMakePlanModel.swift */
;
};
0497C7572D9D437B00A3E32A
/* YHMakePlanScoreModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0497C7562D9D437B00A3E32A
/* YHMakePlanScoreModel.swift */
;
};
04A750D02D925FD400974E5F
/* YHCustomerInformationQuestionnaireVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04A750CF2D925FD400974E5F
/* YHCustomerInformationQuestionnaireVC.swift */
;
};
04A750D02D925FD400974E5F
/* YHCustomerInformationQuestionnaireVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04A750CF2D925FD400974E5F
/* YHCustomerInformationQuestionnaireVC.swift */
;
};
04A750D22D93ABCE00974E5F
/* YHSurveyTableViewCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04A750D12D93ABCE00974E5F
/* YHSurveyTableViewCell.swift */
;
};
04A750D22D93ABCE00974E5F
/* YHSurveyTableViewCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04A750D12D93ABCE00974E5F
/* YHSurveyTableViewCell.swift */
;
};
04A750D42D93DFED00974E5F
/* YHSurveyQuestionType.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04A750D32D93DFED00974E5F
/* YHSurveyQuestionType.swift */
;
};
04A750D42D93DFED00974E5F
/* YHSurveyQuestionType.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04A750D32D93DFED00974E5F
/* YHSurveyQuestionType.swift */
;
};
...
@@ -2475,6 +2476,7 @@
...
@@ -2475,6 +2476,7 @@
048D6AE22D6348EF00BC6F4C
/* YHMemberCenterCurrentPrivilegeCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMemberCenterCurrentPrivilegeCell.swift
;
sourceTree
=
"<group>"
;
};
048D6AE22D6348EF00BC6F4C
/* YHMemberCenterCurrentPrivilegeCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMemberCenterCurrentPrivilegeCell.swift
;
sourceTree
=
"<group>"
;
};
0497C7522D9BD21500A3E32A
/* YHMakePlanViewModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanViewModel.swift
;
sourceTree
=
"<group>"
;
};
0497C7522D9BD21500A3E32A
/* YHMakePlanViewModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanViewModel.swift
;
sourceTree
=
"<group>"
;
};
0497C7542D9BD36700A3E32A
/* YHMakePlanModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanModel.swift
;
sourceTree
=
"<group>"
;
};
0497C7542D9BD36700A3E32A
/* YHMakePlanModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanModel.swift
;
sourceTree
=
"<group>"
;
};
0497C7562D9D437B00A3E32A
/* YHMakePlanScoreModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanScoreModel.swift
;
sourceTree
=
"<group>"
;
};
04A750CF2D925FD400974E5F
/* YHCustomerInformationQuestionnaireVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHCustomerInformationQuestionnaireVC.swift
;
sourceTree
=
"<group>"
;
};
04A750CF2D925FD400974E5F
/* YHCustomerInformationQuestionnaireVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHCustomerInformationQuestionnaireVC.swift
;
sourceTree
=
"<group>"
;
};
04A750D12D93ABCE00974E5F
/* YHSurveyTableViewCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSurveyTableViewCell.swift
;
sourceTree
=
"<group>"
;
};
04A750D12D93ABCE00974E5F
/* YHSurveyTableViewCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSurveyTableViewCell.swift
;
sourceTree
=
"<group>"
;
};
04A750D32D93DFED00974E5F
/* YHSurveyQuestionType.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSurveyQuestionType.swift
;
sourceTree
=
"<group>"
;
};
04A750D32D93DFED00974E5F
/* YHSurveyQuestionType.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSurveyQuestionType.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -6719,6 +6721,7 @@
...
@@ -6719,6 +6721,7 @@
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
0497C7542D9BD36700A3E32A
/* YHMakePlanModel.swift */
,
0497C7542D9BD36700A3E32A
/* YHMakePlanModel.swift */
,
0497C7562D9D437B00A3E32A
/* YHMakePlanScoreModel.swift */
,
);
);
path
=
M
;
path
=
M
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -7737,6 +7740,7 @@
...
@@ -7737,6 +7740,7 @@
045C119B2D12CA5F00BD2DC0
/* YHButlerServiceMessage.swift in Sources */
,
045C119B2D12CA5F00BD2DC0
/* YHButlerServiceMessage.swift in Sources */
,
045C119C2D12CA5F00BD2DC0
/* YHSubmitAllInfoCheckView.swift in Sources */
,
045C119C2D12CA5F00BD2DC0
/* YHSubmitAllInfoCheckView.swift in Sources */
,
045C119D2D12CA5F00BD2DC0
/* UIColor+Extension.swift in Sources */
,
045C119D2D12CA5F00BD2DC0
/* UIColor+Extension.swift in Sources */
,
0497C7572D9D437B00A3E32A
/* YHMakePlanScoreModel.swift in Sources */
,
045C119E2D12CA5F00BD2DC0
/* YHCustomTextView.swift in Sources */
,
045C119E2D12CA5F00BD2DC0
/* YHCustomTextView.swift in Sources */
,
04307BA52D1E54BD00ED8E8D
/* YHGCInformationFillTipsAlertView.swift in Sources */
,
04307BA52D1E54BD00ED8E8D
/* YHGCInformationFillTipsAlertView.swift in Sources */
,
045C119F2D12CA5F00BD2DC0
/* YHEditBaseUserInfoViewController.swift in Sources */
,
045C119F2D12CA5F00BD2DC0
/* YHEditBaseUserInfoViewController.swift in Sources */
,
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/C/YHMakePlanViewController.swift
View file @
4bd95d9d
...
@@ -57,14 +57,6 @@ class YHMakePlanViewController: YHBaseViewController {
...
@@ -57,14 +57,6 @@ class YHMakePlanViewController: YHBaseViewController {
make
.
bottom
.
left
.
right
.
equalToSuperview
()
make
.
bottom
.
left
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
98
)
make
.
height
.
equalTo
(
98
)
}
}
// Configure with data
priceView
.
configure
(
price
:
"489800"
)
{
print
(
"Action button tapped!"
)
YHMakePlanPriceAlertView
.
show
{
_
in
}
}
self
.
view
.
addSubview
(
tableView
)
self
.
view
.
addSubview
(
tableView
)
tableView
.
snp
.
makeConstraints
{
make
in
tableView
.
snp
.
makeConstraints
{
make
in
...
@@ -82,6 +74,19 @@ class YHMakePlanViewController: YHBaseViewController {
...
@@ -82,6 +74,19 @@ class YHMakePlanViewController: YHBaseViewController {
requestData
()
requestData
()
}
}
func
updataPrice
()
{
let
totalPrice
=
viewModel
.
makePlanModel
.
calculateTotalPrice
()
priceView
.
configure
(
price
:
totalPrice
,
actionText
:
"去办理"
)
{
YHMakePlanPriceAlertView
.
show
(
dataSource
:
self
.
viewModel
.
makePlanModel
)
{
_
in
}
}
nextHandler
:
{
YHMakePlanPriceAlertView
.
show
(
dataSource
:
self
.
viewModel
.
makePlanModel
)
{
_
in
}
}
}
func
addRightItems
()
{
func
addRightItems
()
{
let
rightButtonItem
=
UIBarButtonItem
(
image
:
UIImage
(
named
:
"share_item"
)?
.
withRenderingMode
(
.
alwaysOriginal
),
style
:
.
plain
,
target
:
self
,
action
:
#selector(
share
)
)
let
rightButtonItem
=
UIBarButtonItem
(
image
:
UIImage
(
named
:
"share_item"
)?
.
withRenderingMode
(
.
alwaysOriginal
),
style
:
.
plain
,
target
:
self
,
action
:
#selector(
share
)
)
gk_navRightBarButtonItem
=
rightButtonItem
gk_navRightBarButtonItem
=
rightButtonItem
...
@@ -96,6 +101,14 @@ class YHMakePlanViewController: YHBaseViewController {
...
@@ -96,6 +101,14 @@ class YHMakePlanViewController: YHBaseViewController {
viewModel
.
getProductList
{[
weak
self
]
_
,
_
in
viewModel
.
getProductList
{[
weak
self
]
_
,
_
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
tableView
.
reloadData
()
tableView
.
reloadData
()
getScore
()
}
}
func
getScore
()
{
viewModel
.
getRate
(
model
:
viewModel
.
makePlanModel
)
{[
weak
self
]
_
,
_
in
guard
let
self
=
self
else
{
return
}
}
}
}
}
...
@@ -126,6 +139,10 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
...
@@ -126,6 +139,10 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
dataSource
=
viewModel
.
makePlanModel
.
invest
dataSource
=
viewModel
.
makePlanModel
.
invest
}
}
cell
.
dataSource
=
dataSource
cell
.
dataSource
=
dataSource
cell
.
actionHandler
=
{
product
in
self
.
viewModel
.
makePlanModel
.
toggleAddCartStatus
(
for
:
product
)
self
.
updataPrice
()
}
return
cell
return
cell
}
}
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanModel.swift
View file @
4bd95d9d
...
@@ -14,6 +14,14 @@ struct YHMakePlanModel: SmartCodable {
...
@@ -14,6 +14,14 @@ struct YHMakePlanModel: SmartCodable {
var
work
:
[
YHMakePlanMainModel
]
=
[]
var
work
:
[
YHMakePlanMainModel
]
=
[]
var
live
:
[
YHMakePlanMainModel
]
=
[]
var
live
:
[
YHMakePlanMainModel
]
=
[]
var
invest
:
[
YHMakePlanMainModel
]
=
[]
var
invest
:
[
YHMakePlanMainModel
]
=
[]
// 修改所有子元素的 is_add_cart 值
mutating
func
updateAddCartStatus
()
{
basic
=
basic
.
map
{
$0
.
updatedModel
()
}
work
=
work
.
map
{
$0
.
updatedModel
()
}
live
=
live
.
map
{
$0
.
updatedModel
()
}
invest
=
invest
.
map
{
$0
.
updatedModel
()
}
}
}
}
struct
YHMakePlanMainModel
:
SmartCodable
{
struct
YHMakePlanMainModel
:
SmartCodable
{
...
@@ -24,6 +32,29 @@ struct YHMakePlanMainModel: SmartCodable {
...
@@ -24,6 +32,29 @@ struct YHMakePlanMainModel: SmartCodable {
var
price
:
String
=
""
var
price
:
String
=
""
var
is_add_cart
:
Bool
=
true
var
is_add_cart
:
Bool
=
true
var
sub_product
:
[
YHMakePlanSubModel
]
=
[]
var
sub_product
:
[
YHMakePlanSubModel
]
=
[]
// 更新当前模型及其子模型的 is_add_cart 状态
func
updatedModel
()
->
YHMakePlanMainModel
{
var
updatedModel
=
self
updatedModel
.
is_add_cart
=
true
// 处理子产品,找到最便宜的一个
if
!
sub_product
.
isEmpty
{
// 找到最便宜的子产品
let
cheapestSubProduct
=
sub_product
.
sorted
{
(
$0
.
price
.
toDouble
()
??
0
)
<
(
$1
.
price
.
toDouble
()
??
0
)
}
.
first
// 更新所有子产品的 is_add_cart 状态
updatedModel
.
sub_product
=
sub_product
.
map
{
var
sub
=
$0
sub
.
is_add_cart
=
(
$0
.
product_id
==
cheapestSubProduct
?
.
product_id
)
return
sub
}
}
return
updatedModel
}
}
}
struct
YHMakePlanSubModel
:
SmartCodable
{
struct
YHMakePlanSubModel
:
SmartCodable
{
...
@@ -34,3 +65,127 @@ struct YHMakePlanSubModel: SmartCodable {
...
@@ -34,3 +65,127 @@ struct YHMakePlanSubModel: SmartCodable {
var
price
:
String
=
""
var
price
:
String
=
""
var
is_add_cart
:
Bool
=
true
var
is_add_cart
:
Bool
=
true
}
}
// 扩展 String 用于价格转换
extension
String
{
func
toDouble
()
->
Double
?
{
// 移除可能存在的货币符号、千位分隔符等
let
numericString
=
self
.
replacingOccurrences
(
of
:
"$"
,
with
:
""
)
.
replacingOccurrences
(
of
:
","
,
with
:
""
)
.
trimmingCharacters
(
in
:
.
whitespacesAndNewlines
)
return
Double
(
numericString
)
}
}
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
)
}
}
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
)
}
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
}
}
}
}
}
func
calculateTotalPrice
()
->
String
{
let
allCategories
=
[
basic
,
work
,
live
,
invest
]
var
total
:
Double
=
0
for
category
in
allCategories
{
for
mainModel
in
category
{
// Check main product
if
mainModel
.
is_add_cart
,
let
price
=
Double
(
mainModel
.
price
)
{
total
+=
price
}
// Check sub products
for
subModel
in
mainModel
.
sub_product
{
if
subModel
.
is_add_cart
,
let
price
=
Double
(
subModel
.
price
)
{
total
+=
price
}
}
}
}
return
"
\(
total
)
"
}
}
extension
YHMakePlanMainModel
{
/// Returns a filtered version of the model, keeping only `is_add_cart == true` for itself and its sub-products.
func
filteredByCartStatus
()
->
YHMakePlanMainModel
?
{
guard
is_add_cart
else
{
return
nil
}
var
filteredModel
=
self
filteredModel
.
sub_product
=
sub_product
.
filter
{
$0
.
is_add_cart
}
return
filteredModel
}
}
extension
Array
where
Element
==
YHMakePlanMainModel
{
/// Filters out models where `is_add_cart == false` and also filters their sub-products.
func
filteredByCartStatus
()
->
[
YHMakePlanMainModel
]
{
self
.
compactMap
{
$0
.
filteredByCartStatus
()
}
}
}
extension
Array
where
Element
==
YHMakePlanSubModel
{
/// Filters out sub-models where `is_add_cart == false`.
func
filteredByCartStatus
()
->
[
YHMakePlanSubModel
]
{
self
.
filter
{
$0
.
is_add_cart
}
}
}
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/M/YHMakePlanScoreModel.swift
0 → 100644
View file @
4bd95d9d
//
// YHMakePlanScoreModel.swift
// galaxy
//
// Created by EDY on 2025/4/2.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
import
SmartCodable
struct
YHMakePlanScoreModel
:
SmartCodable
{
var
year
:
Int
=
-
1
var
pass_rate
:
String
=
""
var
url
:
String
=
""
}
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanBottomView.swift
View file @
4bd95d9d
...
@@ -33,6 +33,7 @@ class YHMakePlanBottomView: UIView {
...
@@ -33,6 +33,7 @@ class YHMakePlanBottomView: UIView {
button
.
titleLabel
?
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
16
)
button
.
titleLabel
?
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
16
)
button
.
layer
.
cornerRadius
=
2
button
.
layer
.
cornerRadius
=
2
button
.
backgroundColor
=
UIColor
.
mainTextColor
button
.
backgroundColor
=
UIColor
.
mainTextColor
button
.
addTarget
(
self
,
action
:
#selector(
nextAction
)
,
for
:
.
touchUpInside
)
return
button
return
button
}()
}()
...
@@ -47,7 +48,8 @@ class YHMakePlanBottomView: UIView {
...
@@ -47,7 +48,8 @@ class YHMakePlanBottomView: UIView {
}
}
var
actionHandler
:
(()
->
Void
)?
var
actionHandler
:
(()
->
Void
)?
var
nextHandler
:
(()
->
Void
)?
// MARK: - Initialization
// MARK: - Initialization
override
init
(
frame
:
CGRect
)
{
override
init
(
frame
:
CGRect
)
{
...
@@ -96,13 +98,17 @@ class YHMakePlanBottomView: UIView {
...
@@ -96,13 +98,17 @@ class YHMakePlanBottomView: UIView {
actionHandler
?()
actionHandler
?()
}
}
@objc
private
func
nextAction
()
{
nextHandler
?()
}
// MARK: - Configuration
// MARK: - Configuration
func
configure
(
price
:
String
,
actionText
:
String
?
=
nil
,
actionHandler
:
(()
->
Void
)?
=
nil
)
{
func
configure
(
price
:
String
,
actionText
:
String
?
=
nil
,
actionHandler
:
(()
->
Void
)?
=
nil
,
nextHandler
:
(()
->
Void
)?
=
nil
)
{
self
.
price
=
price
self
.
price
=
price
if
let
actionText
=
actionText
{
if
let
actionText
=
actionText
{
actionButton
.
setTitle
(
actionText
,
for
:
.
normal
)
actionButton
.
setTitle
(
actionText
,
for
:
.
normal
)
}
}
self
.
actionHandler
=
actionHandler
self
.
actionHandler
=
actionHandler
self
.
nextHandler
=
nextHandler
}
}
}
}
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanCardView.swift
View file @
4bd95d9d
...
@@ -10,8 +10,10 @@ import UIKit
...
@@ -10,8 +10,10 @@ import UIKit
import
AttributedString
import
AttributedString
class
YHMakePlanCardView
:
UIView
{
class
YHMakePlanCardView
:
UIView
{
var
actionHandler
:
((
Int
)
->
Void
)?
// MARK: - UI Elements
// MARK: - UI Elements
var
data
:
YHMakePlanMainModel
?
private
lazy
var
containerView
:
UIView
=
{
private
lazy
var
containerView
:
UIView
=
{
let
view
=
UIView
()
let
view
=
UIView
()
...
@@ -45,7 +47,7 @@ class YHMakePlanCardView: UIView {
...
@@ -45,7 +47,7 @@ class YHMakePlanCardView: UIView {
let
button
=
YHImageTextButton
(
title
:
"星企航(7年)"
,
image
:
UIImage
(
named
:
"make_plan_down"
))
let
button
=
YHImageTextButton
(
title
:
"星企航(7年)"
,
image
:
UIImage
(
named
:
"make_plan_down"
))
button
.
layer
.
cornerRadius
=
2
button
.
layer
.
cornerRadius
=
2
button
.
backgroundColor
=
UIColor
(
hex
:
0xf5f6f8
)
button
.
backgroundColor
=
UIColor
(
hex
:
0xf5f6f8
)
// button.addTarget(self, action: #selector(handle
Action), for: .touchUpInside)
button
.
addTarget
(
self
,
action
:
#selector(
select
Action
)
,
for
:
.
touchUpInside
)
return
button
return
button
}()
}()
...
@@ -62,7 +64,7 @@ class YHMakePlanCardView: UIView {
...
@@ -62,7 +64,7 @@ class YHMakePlanCardView: UIView {
button
.
setImage
(
UIImage
(
named
:
"make_plan_select"
),
for
:
.
selected
)
button
.
setImage
(
UIImage
(
named
:
"make_plan_select"
),
for
:
.
selected
)
button
.
setImage
(
UIImage
(
named
:
"make_plan_normal"
),
for
:
.
normal
)
button
.
setImage
(
UIImage
(
named
:
"make_plan_normal"
),
for
:
.
normal
)
//
button.addTarget(self, action: #selector(handleAction), for: .touchUpInside)
button
.
addTarget
(
self
,
action
:
#selector(
handleAction
)
,
for
:
.
touchUpInside
)
return
button
return
button
}()
}()
...
@@ -134,15 +136,42 @@ class YHMakePlanCardView: UIView {
...
@@ -134,15 +136,42 @@ class YHMakePlanCardView: UIView {
}
}
@objc
func
selectAction
()
{
YHMakePlanSelectAlertView
.
show
(
dataSource
:
data
??
YHMakePlanMainModel
())
{
tag
in
self
.
actionHandler
?(
tag
)
self
.
selectButton
.
isSelected
=
true
let
count
=
self
.
data
?
.
sub_product
.
count
??
0
for
i
in
0
..<
count
{
if
tag
==
self
.
data
?
.
sub_product
[
i
]
.
product_id
{
self
.
data
?
.
sub_product
[
i
]
.
is_add_cart
=
true
}
}
self
.
configure
(
with
:
self
.
data
??
YHMakePlanMainModel
())
}
}
@objc
func
handleAction
()
{
selectButton
.
isSelected
=
!
selectButton
.
isSelected
self
.
actionHandler
?(
self
.
data
?
.
product_id
??
0
)
}
// MARK: - Configuration
// MARK: - Configuration
func
configure
(
with
data
:
YHMakePlanMainModel
)
{
func
configure
(
with
data
:
YHMakePlanMainModel
)
{
self
.
data
=
data
titleLabel
.
text
=
data
.
product_name
titleLabel
.
text
=
data
.
product_name
subtitleLabel
.
text
=
data
.
product_desc
subtitleLabel
.
text
=
data
.
product_desc
priceTagView
.
text
=
data
.
price
priceTagView
.
text
=
data
.
price
if
data
.
price
==
""
{
if
data
.
price
==
""
{
storeButton
.
isHidden
=
false
storeButton
.
isHidden
=
false
let
subModel
=
data
.
sub_product
[
0
]
let
count
=
self
.
data
?
.
sub_product
.
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
]
priceTagView
.
text
=
subModel
.
price
priceTagView
.
text
=
subModel
.
price
storeButton
.
setTitle
(
subModel
.
product_name
,
for
:
.
normal
)
storeButton
.
setTitle
(
subModel
.
product_name
,
for
:
.
normal
)
}
else
{
}
else
{
...
@@ -151,6 +180,25 @@ class YHMakePlanCardView: UIView {
...
@@ -151,6 +180,25 @@ class YHMakePlanCardView: UIView {
if
let
url
=
URL
(
string
:
data
.
cover_img
)
{
if
let
url
=
URL
(
string
:
data
.
cover_img
)
{
companyImageView
.
kf
.
setImage
(
with
:
url
,
placeholder
:
UIImage
(
named
:
"global_default_image"
))
companyImageView
.
kf
.
setImage
(
with
:
url
,
placeholder
:
UIImage
(
named
:
"global_default_image"
))
}
}
if
data
.
is_add_cart
{
selectButton
.
isSelected
=
true
}
else
{
selectButton
.
isSelected
=
false
}
storeButton
.
updateContent
()
}
func
configureSub
(
with
data
:
YHMakePlanSubModel
)
{
titleLabel
.
text
=
data
.
product_name
subtitleLabel
.
text
=
data
.
product_desc
priceTagView
.
text
=
data
.
price
selectButton
.
isHidden
=
true
storeButton
.
isHidden
=
true
if
let
url
=
URL
(
string
:
data
.
cover_img
)
{
companyImageView
.
kf
.
setImage
(
with
:
url
,
placeholder
:
UIImage
(
named
:
"global_default_image"
))
}
storeButton
.
updateContent
()
storeButton
.
updateContent
()
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanCell.swift
View file @
4bd95d9d
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
import
UIKit
import
UIKit
class
YHMakePlanCell
:
UITableViewCell
{
class
YHMakePlanCell
:
UITableViewCell
{
// typealias InformationBlock = (_ model: YHItemModel) -> Void
var
actionHandler
:
((
Int
)
->
Void
)?
var
centerView
:
UIView
!
var
centerView
:
UIView
!
var
titleLabel
:
UILabel
!
var
titleLabel
:
UILabel
!
var
mainItemView
:
UIView
!
var
mainItemView
:
UIView
!
...
@@ -94,6 +94,9 @@ class YHMakePlanCell: UITableViewCell {
...
@@ -94,6 +94,9 @@ class YHMakePlanCell: UITableViewCell {
}
}
var
h
=
121
var
h
=
121
let
itemView
=
YHMakePlanCardView
()
let
itemView
=
YHMakePlanCardView
()
itemView
.
actionHandler
=
{
product
in
self
.
actionHandler
?(
product
)
}
itemView
.
configure
(
with
:
dataSource
?[
i
]
??
YHMakePlanMainModel
())
itemView
.
configure
(
with
:
dataSource
?[
i
]
??
YHMakePlanMainModel
())
mainItemView
.
addSubview
(
itemView
)
mainItemView
.
addSubview
(
itemView
)
itemView
.
snp
.
makeConstraints
{
make
in
itemView
.
snp
.
makeConstraints
{
make
in
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanPriceAlertView.swift
View file @
4bd95d9d
...
@@ -25,6 +25,8 @@ class YHMakePlanPriceAlertView: UIView {
...
@@ -25,6 +25,8 @@ class YHMakePlanPriceAlertView: UIView {
if
#available(iOS 11.0, *)
{
if
#available(iOS 11.0, *)
{
tableView
.
contentInsetAdjustmentBehavior
=
.
never
tableView
.
contentInsetAdjustmentBehavior
=
.
never
}
}
tableView
.
rowHeight
=
UITableView
.
automaticDimension
tableView
.
estimatedRowHeight
=
50
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
backgroundColor
=
.
clear
tableView
.
backgroundColor
=
.
clear
tableView
.
separatorStyle
=
.
none
tableView
.
separatorStyle
=
.
none
...
@@ -34,9 +36,16 @@ class YHMakePlanPriceAlertView: UIView {
...
@@ -34,9 +36,16 @@ class YHMakePlanPriceAlertView: UIView {
return
tableView
return
tableView
}()
}()
static
func
show
(
callBack
:
@escaping
((
Int
)
->
Void
))
{
var
dataSource
:
YHMakePlanModel
=
YHMakePlanModel
()
{
didSet
{
tableView
.
reloadData
()
}
}
static
func
show
(
dataSource
:
YHMakePlanModel
,
callBack
:
@escaping
((
Int
)
->
Void
))
{
let
view
=
YHMakePlanPriceAlertView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
KScreenHeight
))
let
view
=
YHMakePlanPriceAlertView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
KScreenHeight
))
view
.
block
=
callBack
view
.
block
=
callBack
view
.
dataSource
=
dataSource
let
window
=
UIApplication
.
shared
.
yhKeyWindow
()
let
window
=
UIApplication
.
shared
.
yhKeyWindow
()
window
?
.
addSubview
(
view
)
window
?
.
addSubview
(
view
)
}
}
...
@@ -118,10 +127,10 @@ class YHMakePlanPriceAlertView: UIView {
...
@@ -118,10 +127,10 @@ class YHMakePlanPriceAlertView: UIView {
make
.
height
.
equalTo
(
98
)
make
.
height
.
equalTo
(
98
)
}
}
// Configure with data
priceView
.
configure
(
price
:
"489800"
,
actionText
:
"去办理"
)
{
priceView
.
configure
(
price
:
"489800"
)
{
self
.
dismiss
()
print
(
"Action button tapped!"
)
}
nextHandler
:
{
// Handle the "去办理" action here
self
.
block
?(
1
)
}
}
centerView
.
addSubview
(
tableView
)
centerView
.
addSubview
(
tableView
)
...
@@ -174,12 +183,22 @@ extension YHMakePlanPriceAlertView: UITableViewDelegate, UITableViewDataSource {
...
@@ -174,12 +183,22 @@ extension YHMakePlanPriceAlertView: UITableViewDelegate, UITableViewDataSource {
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withClass
:
YHMakePlanLabelCell
.
self
)
as?
YHMakePlanLabelCell
else
{
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withClass
:
YHMakePlanLabelCell
.
self
)
as?
YHMakePlanLabelCell
else
{
return
UITableViewCell
()
return
UITableViewCell
()
}
}
// cell.dataSource = [CompanyPackageData(title: "香港身份申请至永居删除", subtitle: "香港高才入境计划申请到永居全流程", companyName: "", priceTag: "", price: "¥20000.00", showCheckmark: true)]
var
data
:
[
YHMakePlanMainModel
]
=
[]
if
indexPath
.
row
==
0
{
data
=
dataSource
.
basic
}
else
if
indexPath
.
row
==
1
{
data
=
dataSource
.
work
}
else
if
indexPath
.
row
==
2
{
data
=
dataSource
.
live
}
else
if
indexPath
.
row
==
3
{
data
=
dataSource
.
invest
}
cell
.
dataSource
=
data
return
cell
return
cell
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
96
return
UITableView
.
automaticDimension
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
...
@@ -293,40 +312,50 @@ class YHMakePlanLabelCell: UITableViewCell {
...
@@ -293,40 +312,50 @@ class YHMakePlanLabelCell: UITableViewCell {
func
updateAllViews
()
{
func
updateAllViews
()
{
titleLabel
.
text
=
"基础身份续签"
titleLabel
.
text
=
"基础身份续签"
mainItemView
.
removeSubviews
()
mainItemView
.
removeSubviews
()
var
y
=
0
let
filteredModel
=
dataSource
?
.
filteredByCartStatus
()
??
[]
for
i
in
0
..<
(
dataSource
?
.
count
??
0
)
{
y
+=
12
var
lastView
:
UIView
?
var
h
=
20
let
titleLabel
=
{
for
(
i
,
model
)
in
filteredModel
.
enumerated
()
{
let
label
=
UILabel
()
let
titleLabel
=
UILabel
()
label
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
14
)
titleLabel
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
14
)
label
.
textColor
=
UIColor
.
mainTextColor
titleLabel
.
textColor
=
UIColor
.
mainTextColor
label
.
text
=
"香港身份申请至永居"
titleLabel
.
text
=
model
.
product_name
return
label
titleLabel
.
numberOfLines
=
0
}()
mainItemView
.
addSubview
(
titleLabel
)
mainItemView
.
addSubview
(
titleLabel
)
let
price
=
model
.
sub_product
.
first
?
.
price
??
model
.
price
let
valueLabel
=
UILabel
()
valueLabel
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
14
)
valueLabel
.
textColor
=
UIColor
.
mainTextColor
valueLabel
.
textAlignment
=
.
right
valueLabel
.
text
=
price
mainItemView
.
addSubview
(
valueLabel
)
titleLabel
.
snp
.
makeConstraints
{
make
in
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
make
.
top
.
equalTo
(
y
)
make
.
right
.
equalTo
(
valueLabel
.
snp
.
left
)
.
offset
(
-
8
)
make
.
height
.
equalTo
(
h
)
if
let
lastView
=
lastView
{
make
.
top
.
equalTo
(
lastView
.
snp
.
bottom
)
.
offset
(
12
)
}
else
{
make
.
top
.
equalToSuperview
()
.
offset
(
12
)
}
}
}
let
valueLabel
=
{
let
label
=
UILabel
()
label
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
14
)
label
.
textColor
=
UIColor
.
mainTextColor
label
.
textAlignment
=
.
right
label
.
text
=
"¥58999"
return
label
}()
mainItemView
.
addSubview
(
valueLabel
)
valueLabel
.
snp
.
makeConstraints
{
make
in
valueLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
y
)
make
.
width
.
equalTo
(
100
)
make
.
height
.
equalTo
(
h
)
make
.
top
.
equalTo
(
titleLabel
)
}
}
y
+=
h
lastView
=
titleLabel
// 如果是最后一个元素,连接到底部
if
i
==
filteredModel
.
count
-
1
{
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
12
)
}
}
}
}
}
}
}
}
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/V/YHMakePlanSelectAlertView.swift
View file @
4bd95d9d
...
@@ -18,6 +18,12 @@ class YHMakePlanSelectAlertView: UIView {
...
@@ -18,6 +18,12 @@ class YHMakePlanSelectAlertView: UIView {
var
hasSelectLabel
:
UILabel
!
var
hasSelectLabel
:
UILabel
!
var
cardView
:
YHMakePlanCardView
!
var
cardView
:
YHMakePlanCardView
!
var
lineView
:
UIView
!
var
lineView
:
UIView
!
var
selectIndex
:
Int
=
0
var
dataSource
:
YHMakePlanMainModel
?
{
didSet
{
updata
()
}
}
lazy
var
tableView
:
UITableView
=
{
lazy
var
tableView
:
UITableView
=
{
let
tableView
=
UITableView
(
frame
:
.
zero
,
style
:
.
grouped
)
let
tableView
=
UITableView
(
frame
:
.
zero
,
style
:
.
grouped
)
...
@@ -39,8 +45,9 @@ class YHMakePlanSelectAlertView: UIView {
...
@@ -39,8 +45,9 @@ class YHMakePlanSelectAlertView: UIView {
return
tableView
return
tableView
}()
}()
static
func
show
(
callBack
:
@escaping
((
Int
)
->
Void
))
{
static
func
show
(
dataSource
:
YHMakePlanMainModel
,
callBack
:
@escaping
((
Int
)
->
Void
))
{
let
view
=
YHMakePlanSelectAlertView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
KScreenHeight
))
let
view
=
YHMakePlanSelectAlertView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
KScreenHeight
))
view
.
dataSource
=
dataSource
view
.
block
=
callBack
view
.
block
=
callBack
let
window
=
UIApplication
.
shared
.
yhKeyWindow
()
let
window
=
UIApplication
.
shared
.
yhKeyWindow
()
window
?
.
addSubview
(
view
)
window
?
.
addSubview
(
view
)
...
@@ -162,7 +169,7 @@ class YHMakePlanSelectAlertView: UIView {
...
@@ -162,7 +169,7 @@ class YHMakePlanSelectAlertView: UIView {
button
.
setTitleColor
(
UIColor
(
hex
:
0xffffff
),
for
:
.
normal
)
button
.
setTitleColor
(
UIColor
(
hex
:
0xffffff
),
for
:
.
normal
)
button
.
setTitle
(
"确认"
,
for
:
.
normal
)
button
.
setTitle
(
"确认"
,
for
:
.
normal
)
button
.
layer
.
cornerRadius
=
4
button
.
layer
.
cornerRadius
=
4
button
.
addTarget
(
self
,
action
:
#selector(
dismiss
)
,
for
:
.
touchUpInside
)
button
.
addTarget
(
self
,
action
:
#selector(
orderButtonClick
)
,
for
:
.
touchUpInside
)
return
button
return
button
}()
}()
centerView
.
addSubview
(
sureButton
)
centerView
.
addSubview
(
sureButton
)
...
@@ -181,6 +188,17 @@ class YHMakePlanSelectAlertView: UIView {
...
@@ -181,6 +188,17 @@ class YHMakePlanSelectAlertView: UIView {
}
}
}
}
func
updata
()
{
guard
let
data
=
dataSource
else
{
return
}
for
i
in
0
..<
data
.
sub_product
.
count
{
if
data
.
sub_product
[
i
]
.
is_add_cart
==
true
{
selectIndex
=
i
}
}
cardView
.
configureSub
(
with
:
data
.
sub_product
[
selectIndex
])
tableView
.
reloadData
()
}
@objc
private
func
handleTap
(
_
sender
:
AnyObject
?)
{
@objc
private
func
handleTap
(
_
sender
:
AnyObject
?)
{
dismiss
()
dismiss
()
}
}
...
@@ -191,17 +209,11 @@ class YHMakePlanSelectAlertView: UIView {
...
@@ -191,17 +209,11 @@ class YHMakePlanSelectAlertView: UIView {
@objc
func
orderButtonClick
()
{
@objc
func
orderButtonClick
()
{
if
let
block
=
block
{
if
let
block
=
block
{
block
(
1
)
block
(
dataSource
?
.
sub_product
[
selectIndex
]
.
product_id
??
0
)
}
}
dismiss
()
dismiss
()
}
}
@objc
func
guideButtonClick
()
{
if
let
block
=
block
{
block
(
2
)
}
dismiss
()
}
}
}
extension
YHMakePlanSelectAlertView
:
UIGestureRecognizerDelegate
{
extension
YHMakePlanSelectAlertView
:
UIGestureRecognizerDelegate
{
...
@@ -216,14 +228,15 @@ extension YHMakePlanSelectAlertView: UIGestureRecognizerDelegate {
...
@@ -216,14 +228,15 @@ extension YHMakePlanSelectAlertView: UIGestureRecognizerDelegate {
extension
YHMakePlanSelectAlertView
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHMakePlanSelectAlertView
:
UITableViewDelegate
,
UITableViewDataSource
{
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
// return items.count
// return items.count
return
4
return
dataSource
?
.
sub_product
.
count
??
0
}
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withClass
:
YHMakePlanCardCell
.
self
)
as?
YHMakePlanCardCell
else
{
guard
let
cell
=
tableView
.
dequeueReusableCell
(
withClass
:
YHMakePlanCardCell
.
self
)
as?
YHMakePlanCardCell
else
{
return
UITableViewCell
()
return
UITableViewCell
()
}
}
cell
.
configure
(
with
:
ServiceModel
(
title
:
"星企航7年服务"
,
price
:
18900
))
guard
let
model
=
dataSource
?
.
sub_product
[
indexPath
.
row
]
else
{
return
UITableViewCell
()}
cell
.
configure
(
with
:
model
)
return
cell
return
cell
}
}
...
@@ -232,7 +245,18 @@ extension YHMakePlanSelectAlertView: UITableViewDelegate, UITableViewDataSource
...
@@ -232,7 +245,18 @@ extension YHMakePlanSelectAlertView: UITableViewDelegate, UITableViewDataSource
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
selectIndex
=
indexPath
.
row
let
count
=
dataSource
?
.
sub_product
.
count
??
0
for
i
in
0
..<
count
{
if
i
==
indexPath
.
row
{
dataSource
?
.
sub_product
[
i
]
.
is_add_cart
=
true
guard
let
model
=
dataSource
?
.
sub_product
[
i
]
else
{
return
}
cardView
.
configureSub
(
with
:
model
)
}
else
{
dataSource
?
.
sub_product
[
i
]
.
is_add_cart
=
false
}
}
tableView
.
reloadData
()
}
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
...
@@ -339,14 +363,16 @@ class YHMakePlanCardCell: UITableViewCell {
...
@@ -339,14 +363,16 @@ class YHMakePlanCardCell: UITableViewCell {
}
}
// MARK: - Configuration
// MARK: - Configuration
func
configure
(
with
service
:
ServiceModel
)
{
func
configure
(
with
service
:
YHMakePlanSubModel
)
{
titleLabel
.
text
=
service
.
title
titleLabel
.
text
=
service
.
product_name
priceLabel
.
text
=
"¥
\(
service
.
price
)
"
priceLabel
.
text
=
service
.
price
if
service
.
is_add_cart
{
containerView
.
layer
.
borderWidth
=
1
}
else
{
containerView
.
layer
.
borderWidth
=
0
}
if
let
url
=
URL
(
string
:
service
.
cover_img
)
{
bgImageView
.
kf
.
setImage
(
with
:
url
,
placeholder
:
UIImage
(
named
:
"global_default_image"
))
}
}
}
}
}
// Example model for configuration
struct
ServiceModel
{
let
title
:
String
let
price
:
Int
}
galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/VM/YHMakePlanViewModel.swift
View file @
4bd95d9d
...
@@ -10,7 +10,7 @@ import UIKit
...
@@ -10,7 +10,7 @@ import UIKit
class
YHMakePlanViewModel
:
YHBaseViewModel
{
class
YHMakePlanViewModel
:
YHBaseViewModel
{
var
makePlanModel
:
YHMakePlanModel
=
YHMakePlanModel
()
var
makePlanModel
:
YHMakePlanModel
=
YHMakePlanModel
()
var
score
:
YHMakePlanScoreModel
=
YHMakePlanScoreModel
()
// 请求产品列表
// 请求产品列表
func
getProductList
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
Void
)
{
func
getProductList
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
Void
)
{
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
ResignPlan
.
productListApi
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
ResignPlan
.
productListApi
...
@@ -23,6 +23,7 @@ class YHMakePlanViewModel: YHBaseViewModel {
...
@@ -23,6 +23,7 @@ class YHMakePlanViewModel: YHBaseViewModel {
return
return
}
}
self
?
.
makePlanModel
=
result
self
?
.
makePlanModel
=
result
self
?
.
makePlanModel
.
updateAddCartStatus
()
callBackBlock
(
true
,
nil
)
callBackBlock
(
true
,
nil
)
}
else
{
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
.
count
>
0
?
json
.
msg
:
"数据错误"
)
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
.
count
>
0
?
json
.
msg
:
"数据错误"
)
...
@@ -33,4 +34,93 @@ class YHMakePlanViewModel: YHBaseViewModel {
...
@@ -33,4 +34,93 @@ class YHMakePlanViewModel: YHBaseViewModel {
}
}
}
}
// 请求产品列表
func
getRate
(
model
:
YHMakePlanModel
,
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
Void
)
{
var
basic
:
[
Int
]
=
[]
var
work
:
[
Int
]
=
[]
var
live
:
[
Int
]
=
[]
var
invest
:
[
Int
]
=
[]
let
basicArray
=
makePlanModel
.
basic
let
workArray
=
makePlanModel
.
work
let
liveArray
=
makePlanModel
.
live
let
investArray
=
makePlanModel
.
invest
for
item
in
basicArray
{
if
item
.
is_add_cart
==
true
{
if
item
.
sub_product
.
count
>
0
{
for
subItem
in
item
.
sub_product
{
if
subItem
.
is_add_cart
==
true
{
basic
.
append
(
subItem
.
product_id
)
}
}
}
else
{
basic
.
append
(
item
.
product_id
)
}
}
}
for
item
in
workArray
{
if
item
.
is_add_cart
==
true
{
if
item
.
sub_product
.
count
>
0
{
for
subItem
in
item
.
sub_product
{
if
subItem
.
is_add_cart
==
true
{
work
.
append
(
subItem
.
product_id
)
}
}
}
else
{
work
.
append
(
item
.
product_id
)
}
}
}
for
item
in
liveArray
{
if
item
.
is_add_cart
==
true
{
if
item
.
sub_product
.
count
>
0
{
for
subItem
in
item
.
sub_product
{
if
subItem
.
is_add_cart
==
true
{
live
.
append
(
subItem
.
product_id
)
}
}
}
else
{
live
.
append
(
item
.
product_id
)
}
}
}
for
item
in
investArray
{
if
item
.
is_add_cart
==
true
{
if
item
.
sub_product
.
count
>
0
{
for
subItem
in
item
.
sub_product
{
if
subItem
.
is_add_cart
==
true
{
invest
.
append
(
subItem
.
product_id
)
}
}
}
else
{
invest
.
append
(
item
.
product_id
)
}
}
}
var
params
:
[
String
:
Any
]
=
[
"work_product_ids"
:
work
,
"live_product_ids"
:
live
,
"invest_product_ids"
:
invest
,
"basic_product_ids"
:
basic
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
ResignPlan
.
getRate
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
_
in
// 1. json字符串 转 对象
guard
self
!=
nil
else
{
return
}
if
json
.
code
==
200
{
guard
let
dic
=
json
.
data
?
.
peel
as?
[
String
:
Any
],
let
result
=
YHMakePlanScoreModel
.
deserialize
(
from
:
dic
)
else
{
callBackBlock
(
false
,
nil
)
return
}
self
?
.
score
=
result
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
.
count
>
0
?
json
.
msg
:
"数据错误"
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
}
}
galaxy/galaxy/Classes/Tools/NetWork/YHAllApiName.swift
View file @
4bd95d9d
...
@@ -756,6 +756,7 @@ class YHAllApiName {
...
@@ -756,6 +756,7 @@ class YHAllApiName {
struct
ResignPlan
{
struct
ResignPlan
{
static
let
planlistApi
=
"super-app/renewal/advice/get-renewal-plan"
static
let
planlistApi
=
"super-app/renewal/advice/get-renewal-plan"
static
let
productListApi
=
"super-app/renewal/advice/get-renewal-product-list"
static
let
productListApi
=
"super-app/renewal/advice/get-renewal-product-list"
static
let
getRate
=
"super-app/renewal/advice/get-year-and-pass-rate"
}
}
// 问卷
// 问卷
...
...
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