Commit 6e33b255 authored by Steven杜宇's avatar Steven杜宇
parents b170e9c5 3058597b
...@@ -8497,7 +8497,7 @@ ...@@ -8497,7 +8497,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 2.2.0; MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy; PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
...@@ -8643,7 +8643,7 @@ ...@@ -8643,7 +8643,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 2.2.0; MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy; PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
...@@ -8851,7 +8851,7 @@ ...@@ -8851,7 +8851,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 2.2.0; MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy; PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
...@@ -8899,7 +8899,7 @@ ...@@ -8899,7 +8899,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 2.2.0; MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy; PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
......
...@@ -628,7 +628,6 @@ extension YHMyNewViewController { ...@@ -628,7 +628,6 @@ extension YHMyNewViewController {
} }
func clickItem(_ item: PersonalModuleItem) { func clickItem(_ item: PersonalModuleItem) {
if !checkLogin() { if !checkLogin() {
return return
} }
......
...@@ -121,9 +121,10 @@ class YHSurveyMatchingViewController: YHBaseViewController { ...@@ -121,9 +121,10 @@ class YHSurveyMatchingViewController: YHBaseViewController {
// 如果请求未完成,保持90%,等待请求完成 // 如果请求未完成,保持90%,等待请求完成
self.progressView.progress = 0.9 self.progressView.progress = 0.9
} }
self.requestState()
} }
}) })
requestState() // requestState()
} }
private func requestState() { private func requestState() {
......
...@@ -122,6 +122,12 @@ class YHMakePlanViewController: YHBaseViewController { ...@@ -122,6 +122,12 @@ class YHMakePlanViewController: YHBaseViewController {
} }
func addRightItems() { func addRightItems() {
let rightButtonItem = UIBarButtonItem(image: UIImage(named: "share_item_white")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(share))
gk_navRightBarButtonItem = rightButtonItem
gk_navItemRightSpace = 16
}
func addRightWhiteItems() {
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
gk_navItemRightSpace = 16 gk_navItemRightSpace = 16
...@@ -201,6 +207,9 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -201,6 +207,9 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
} else if indexPath.row == 3 { } else if indexPath.row == 3 {
count = viewModel.makePlanModel.invest.count count = viewModel.makePlanModel.invest.count
} }
if count == 0 {
return 68
}
return CGFloat(36 + 16 + 118 * count) return CGFloat(36 + 16 + 118 * count)
} }
...@@ -238,8 +247,8 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -238,8 +247,8 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
gk_navTitle = "续签至永居方案私人订制" gk_navTitle = "续签至永居方案私人订制"
gk_navTitleColor = .black gk_navTitleColor = .black
gk_backImage = UIImage(named: "nav_black_24") gk_backImage = UIImage(named: "nav_black_24")
gk_navRightBarButtonItem?.image = UIImage(named: "share_item") // gk_navRightBarButtonItem?.image = UIImage(named: "share_item")
addRightItems() addRightWhiteItems()
} else { } else {
gk_navBarAlpha = 0.0 gk_navBarAlpha = 0.0
gk_navBackgroundColor = .clear gk_navBackgroundColor = .clear
......
...@@ -82,65 +82,105 @@ extension String { ...@@ -82,65 +82,105 @@ extension String {
extension YHMakePlanModel { extension YHMakePlanModel {
mutating func toggleAddCartStatus(for productId: Int) { mutating func toggleAddCartStatus(for productId: Int) {
// Search and toggle in basic array var localBasic = basic
for i in 0..<basic.count { var localWork = work
if basic[i].product_id == productId { var localLive = live
basic[i].is_add_cart = !basic[i].is_add_cart var localInvest = invest
// If enabling, set all sub products to false except the first one
if basic[i].is_add_cart { for i in 0..<localBasic.count {
for j in 0..<basic[i].sub_product.count { if localBasic[i].product_id != 0 && localBasic[i].product_id == productId {
basic[i].sub_product[j].is_add_cart = (j == 0) 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 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 for i in 0..<localLive.count {
toggleInArray(&work, productId: productId) if localLive[i].product_id != 0 && localLive[i].product_id == productId {
toggleInArray(&live, productId: productId) localLive[i].is_add_cart = !localLive[i].is_add_cart
toggleInArray(&invest, productId: productId) 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) { private mutating func updateSubProducts(for mainModel: inout YHMakePlanMainModel) {
for i in 0..<array.count { if mainModel.is_add_cart {
if array[i].product_id == productId { // Find the subproduct with the lowest price
array[i].is_add_cart = !array[i].is_add_cart if let cheapestIndex = mainModel.sub_product.enumerated().min(by: {
// If enabling, set all sub products to false except the first one let price1 = Double($0.element.price) ?? 0
if array[i].is_add_cart { let price2 = Double($1.element.price) ?? 0
for j in 0..<array[i].sub_product.count { return price1 < price2
array[i].sub_product[j].is_add_cart = (j == 0) })?.offset {
} // Set only the cheapest to true, others to false
} for i in 0..<mainModel.sub_product.count {
return mainModel.sub_product[i].is_add_cart = (i == cheapestIndex)
} 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
}
} }
} }
} 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 { func calculateTotalPrice() -> String {
let allCategories = [basic, work, live, invest] let allCategories = [basic, work, live, invest]
var total: Double = 0 var total: Double = 0
......
...@@ -189,6 +189,8 @@ class YHMakePlanCardView: UIView { ...@@ -189,6 +189,8 @@ class YHMakePlanCardView: UIView {
for i in 0 ..< count { for i in 0 ..< count {
if tag == self.data?.sub_product[i].product_id { if tag == self.data?.sub_product[i].product_id {
self.data?.sub_product[i].is_add_cart = true 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()) self.configure(with: self.data ?? YHMakePlanMainModel())
...@@ -197,7 +199,20 @@ class YHMakePlanCardView: UIView { ...@@ -197,7 +199,20 @@ class YHMakePlanCardView: UIView {
@objc func handleAction() { @objc func handleAction() {
selectButton.isSelected = !selectButton.isSelected 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 // MARK: - Configuration
...@@ -238,7 +253,7 @@ class YHMakePlanCardView: UIView { ...@@ -238,7 +253,7 @@ class YHMakePlanCardView: UIView {
func configureSub(with data: YHMakePlanSubModel) { func configureSub(with data: YHMakePlanSubModel) {
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)"
selectButton.isHidden = true selectButton.isHidden = true
storeButton.isHidden = true storeButton.isHidden = true
if let url = URL(string: data.cover_img) { if let url = URL(string: data.cover_img) {
......
...@@ -39,6 +39,13 @@ class YHMakePlanPriceAlertView: UIView { ...@@ -39,6 +39,13 @@ class YHMakePlanPriceAlertView: UIView {
var dataSource: YHMakePlanModel = YHMakePlanModel() { var dataSource: YHMakePlanModel = YHMakePlanModel() {
didSet { didSet {
tableView.reloadData() tableView.reloadData()
let totalPrice = dataSource.calculateTotalPrice()
priceView.configure(price: totalPrice, actionText: "去办理") {
self.dismiss()
} nextHandler: {
self.block?(1)
}
} }
} }
...@@ -314,7 +321,6 @@ class YHMakePlanLabelCell: UITableViewCell { ...@@ -314,7 +321,6 @@ class YHMakePlanLabelCell: UITableViewCell {
} }
func updateAllViews() { func updateAllViews() {
titleLabel.text = "基础身份续签"
mainItemView.removeSubviews() mainItemView.removeSubviews()
let filteredModel = dataSource?.filteredByCartStatus() ?? [] let filteredModel = dataSource?.filteredByCartStatus() ?? []
...@@ -333,7 +339,7 @@ class YHMakePlanLabelCell: UITableViewCell { ...@@ -333,7 +339,7 @@ class YHMakePlanLabelCell: UITableViewCell {
valueLabel.font = UIFont.PFSC_M(ofSize: 14) valueLabel.font = UIFont.PFSC_M(ofSize: 14)
valueLabel.textColor = UIColor.mainTextColor valueLabel.textColor = UIColor.mainTextColor
valueLabel.textAlignment = .right valueLabel.textAlignment = .right
valueLabel.text = price valueLabel.text = "¥" + price
mainItemView.addSubview(valueLabel) mainItemView.addSubview(valueLabel)
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "share_item_white@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "share_item_white@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment