Commit 026d733f authored by pete谢兆麟's avatar pete谢兆麟

修改bug

parent c8fa828f
......@@ -185,6 +185,7 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
self.viewModel.makePlanModel.toggleAddCartStatus(for: product)
self.updataPrice()
self.getScore()
self.tableView.reloadData()
}
return cell
}
......
......@@ -142,27 +142,27 @@ extension YHMakePlanModel {
}
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) {
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), mainModel.sub_product.count == 0 {
total += price
}
// Check sub products
for subModel in mainModel.sub_product {
if subModel.is_add_cart, let price = Double(subModel.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)"
}
return "\(total)"
}
}
extension YHMakePlanMainModel {
......
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