Commit 6e33b255 authored by Steven杜宇's avatar Steven杜宇
parents b170e9c5 3058597b
......@@ -8497,7 +8497,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
......@@ -8643,7 +8643,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
......@@ -8851,7 +8851,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
......@@ -8899,7 +8899,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
......
......@@ -628,7 +628,6 @@ extension YHMyNewViewController {
}
func clickItem(_ item: PersonalModuleItem) {
if !checkLogin() {
return
}
......
......@@ -121,9 +121,10 @@ class YHSurveyMatchingViewController: YHBaseViewController {
// 如果请求未完成,保持90%,等待请求完成
self.progressView.progress = 0.9
}
self.requestState()
}
})
requestState()
// requestState()
}
private func requestState() {
......
......@@ -122,6 +122,12 @@ class YHMakePlanViewController: YHBaseViewController {
}
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))
gk_navRightBarButtonItem = rightButtonItem
gk_navItemRightSpace = 16
......@@ -201,6 +207,9 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
} else if indexPath.row == 3 {
count = viewModel.makePlanModel.invest.count
}
if count == 0 {
return 68
}
return CGFloat(36 + 16 + 118 * count)
}
......@@ -238,8 +247,8 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
gk_navTitle = "续签至永居方案私人订制"
gk_navTitleColor = .black
gk_backImage = UIImage(named: "nav_black_24")
gk_navRightBarButtonItem?.image = UIImage(named: "share_item")
addRightItems()
// gk_navRightBarButtonItem?.image = UIImage(named: "share_item")
addRightWhiteItems()
} else {
gk_navBarAlpha = 0.0
gk_navBackgroundColor = .clear
......
......@@ -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
......
......@@ -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
......@@ -238,7 +253,7 @@ class YHMakePlanCardView: UIView {
func configureSub(with data: YHMakePlanSubModel) {
titleLabel.text = data.product_name
subtitleLabel.text = data.product_desc
priceTagView.text = data.price
priceTagView.text = \(data.price)"
selectButton.isHidden = true
storeButton.isHidden = true
if let url = URL(string: data.cover_img) {
......
......@@ -39,6 +39,13 @@ class YHMakePlanPriceAlertView: UIView {
var dataSource: YHMakePlanModel = YHMakePlanModel() {
didSet {
tableView.reloadData()
let totalPrice = dataSource.calculateTotalPrice()
priceView.configure(price: totalPrice, actionText: "去办理") {
self.dismiss()
} nextHandler: {
self.block?(1)
}
}
}
......@@ -314,7 +321,6 @@ class YHMakePlanLabelCell: UITableViewCell {
}
func updateAllViews() {
titleLabel.text = "基础身份续签"
mainItemView.removeSubviews()
let filteredModel = dataSource?.filteredByCartStatus() ?? []
......@@ -333,7 +339,7 @@ class YHMakePlanLabelCell: UITableViewCell {
valueLabel.font = UIFont.PFSC_M(ofSize: 14)
valueLabel.textColor = UIColor.mainTextColor
valueLabel.textAlignment = .right
valueLabel.text = price
valueLabel.text = "¥" + price
mainItemView.addSubview(valueLabel)
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