Commit 2e46eaed authored by pete谢兆麟's avatar pete谢兆麟

首页接口

parent 38d25f0d
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHMakePlanViewController: YHBaseViewController { class YHMakePlanViewController: YHBaseViewController {
var items: [[Int]] = [] var items: [[Int]] = []
let viewModel = YHSchemeViewModel() let viewModel = YHMakePlanViewModel()
private var lastContentOffset: CGFloat = 0 private var lastContentOffset: CGFloat = 0
private let scrollThreshold: CGFloat = 100 // 滑动100点显示导航栏 private let scrollThreshold: CGFloat = 100 // 滑动100点显示导航栏
private var isNavigationBarHidden = false private var isNavigationBarHidden = false
...@@ -93,7 +93,10 @@ class YHMakePlanViewController: YHBaseViewController { ...@@ -93,7 +93,10 @@ class YHMakePlanViewController: YHBaseViewController {
} }
func requestData() { func requestData() {
tableView.reloadData() viewModel.getProductList {[weak self] _, _ in
guard let self = self else { return }
tableView.reloadData()
}
} }
func submitTargets() { func submitTargets() {
...@@ -112,12 +115,32 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -112,12 +115,32 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
guard let cell = tableView.dequeueReusableCell(withClass: YHMakePlanCell.self) as? YHMakePlanCell else { guard let cell = tableView.dequeueReusableCell(withClass: YHMakePlanCell.self) as? YHMakePlanCell else {
return UITableViewCell() return UITableViewCell()
} }
cell.dataSource = [CompanyPackageData(title: "香港身份申请至永居删除", subtitle: "香港高才入境计划申请到永居全流程", companyName: "", priceTag: "", price: "¥20000.00", showCheckmark: true)] var dataSource: [YHMakePlanMainModel] = []
if indexPath.row == 0 {
dataSource = viewModel.makePlanModel.basic
} else if indexPath.row == 1 {
dataSource = viewModel.makePlanModel.work
} else if indexPath.row == 2 {
dataSource = viewModel.makePlanModel.live
} else if indexPath.row == 3 {
dataSource = viewModel.makePlanModel.invest
}
cell.dataSource = dataSource
return cell return cell
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 158 + 16 var count = 0
if indexPath.row == 0 {
count = viewModel.makePlanModel.basic.count
} else if indexPath.row == 1 {
count = viewModel.makePlanModel.work.count
} else if indexPath.row == 2 {
count = viewModel.makePlanModel.live.count
} else if indexPath.row == 3 {
count = viewModel.makePlanModel.invest.count
}
return CGFloat(36 + 16 + 118 * count)
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......
...@@ -31,7 +31,7 @@ class YHMakePlanCardView: UIView { ...@@ -31,7 +31,7 @@ class YHMakePlanCardView: UIView {
let label = UILabel() let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 12) label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = UIColor(hex: 0x8993a2) label.textColor = UIColor(hex: 0x8993a2)
label.numberOfLines = 2 label.numberOfLines = 1
return label return label
}() }()
...@@ -136,23 +136,25 @@ class YHMakePlanCardView: UIView { ...@@ -136,23 +136,25 @@ class YHMakePlanCardView: UIView {
// MARK: - Configuration // MARK: - Configuration
func configure(with data: CompanyPackageData) { func configure(with data: YHMakePlanMainModel) {
titleLabel.text = data.title titleLabel.text = data.product_name
subtitleLabel.text = data.subtitle subtitleLabel.text = data.product_desc
priceTagView.text = data.price priceTagView.text = data.price
if data.price == "" {
storeButton.isHidden = false
let subModel = data.sub_product[0]
priceTagView.text = subModel.price
storeButton.setTitle(subModel.product_name, for: .normal)
} else {
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()
} }
} }
struct CompanyPackageData {
let title: String
let subtitle: String
let companyName: String
let priceTag: String
let price: String
let showCheckmark: Bool
}
class YHImageTextButton: UIButton { class YHImageTextButton: UIButton {
var spacing: CGFloat = 4 // 文字和图片之间的间距 var spacing: CGFloat = 4 // 文字和图片之间的间距
......
...@@ -14,7 +14,7 @@ class YHMakePlanCell: UITableViewCell { ...@@ -14,7 +14,7 @@ class YHMakePlanCell: UITableViewCell {
var titleLabel: UILabel! var titleLabel: UILabel!
var mainItemView: UIView! var mainItemView: UIView!
var country: String = "" var country: String = ""
var dataSource: [CompanyPackageData]? { var dataSource: [YHMakePlanMainModel]? {
didSet { didSet {
updateAllViews() updateAllViews()
} }
...@@ -94,7 +94,7 @@ class YHMakePlanCell: UITableViewCell { ...@@ -94,7 +94,7 @@ class YHMakePlanCell: UITableViewCell {
} }
var h = 121 var h = 121
let itemView = YHMakePlanCardView() let itemView = YHMakePlanCardView()
itemView.configure(with: CompanyPackageData(title: "香港身份申请至永居删除", subtitle: "香港高才入境计划申请到永居全流程", companyName: "", priceTag: "", price: "¥20000.00", showCheckmark: true)) itemView.configure(with: dataSource?[i] ?? YHMakePlanMainModel())
mainItemView.addSubview(itemView) mainItemView.addSubview(itemView)
itemView.snp.makeConstraints { make in itemView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
......
...@@ -174,7 +174,7 @@ extension YHMakePlanPriceAlertView: UITableViewDelegate, UITableViewDataSource { ...@@ -174,7 +174,7 @@ 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)] // cell.dataSource = [CompanyPackageData(title: "香港身份申请至永居删除", subtitle: "香港高才入境计划申请到永居全流程", companyName: "", priceTag: "", price: "¥20000.00", showCheckmark: true)]
return cell return cell
} }
...@@ -212,7 +212,7 @@ class YHMakePlanLabelCell: UITableViewCell { ...@@ -212,7 +212,7 @@ class YHMakePlanLabelCell: UITableViewCell {
var titleLabel: UILabel! var titleLabel: UILabel!
var mainItemView: UIView! var mainItemView: UIView!
var country: String = "" var country: String = ""
var dataSource: [CompanyPackageData]? { var dataSource: [YHMakePlanMainModel]? {
didSet { didSet {
updateAllViews() updateAllViews()
} }
......
...@@ -18,7 +18,7 @@ class YHMakePlanViewModel: YHBaseViewModel { ...@@ -18,7 +18,7 @@ class YHMakePlanViewModel: YHBaseViewModel {
// 1. json字符串 转 对象 // 1. json字符串 转 对象
guard self != nil else { return } guard self != nil else { return }
if json.code == 200 { if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let data = dic["Data"] as? [String : Any], let result = YHMakePlanModel.deserialize(from: data) else { guard let dic = json.data?.peel as? [String: Any], let result = YHMakePlanModel.deserialize(from: dic) else {
callBackBlock(false, nil) callBackBlock(false, nil)
return return
} }
......
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