Commit 73e743f8 authored by Steven杜宇's avatar Steven杜宇

// plan

parent be9872eb
......@@ -11,13 +11,15 @@ import JXSegmentedView
class YHPlanViewController: YHBaseViewController {
let viewModel = YHPlanViewModel()
var infoArr: [String] = ["", "", "", "", "", ""]
var cases: [String] = ["水电费噶事多发结石冷风机拉萨反垃圾算法逻辑的山卡拉飞机啊索拉卡飞机啊拉卡萨",
"阿斯顿发发", "阿斯顿发生大法师懂法守法说法大萨达法司法发沙发是打发三大发实达防擦是打发",
"啊所发生的发生的放假啦苏卡达飞机拉萨开发机阿萨拉法基阿萨拉开发",
"双法防",
"沙发上",
"啊防守打法"]
var analyzeArr: [YHPlanAnalyzeModel] = [YHPlanAnalyzeModel(),
YHPlanAnalyzeModel(),
YHPlanAnalyzeModel(),
YHPlanAnalyzeModel()]
var policyArr: [YHPlanCaseModel] = []
var caseArr: [YHPlanCaseModel] = []
let headerViewHeight = 146.0
let topScrollHeight = 146.0-44.0
......@@ -247,7 +249,6 @@ class YHPlanViewController: YHBaseViewController {
lazy var policyVieiw: YHPlanPolicyCarouselView = {
let v = YHPlanPolicyCarouselView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 268))
v.bannerArr = ["", "", "", ""]
return v
}()
......@@ -305,6 +306,53 @@ class YHPlanViewController: YHBaseViewController {
make.top.equalTo(10+k_Height_statusBar())
make.width.height.equalTo(24)
}
requestData()
}
func requestData() {
viewModel.requetResignPlanInfo {
[weak self] _, _ in
guard let self = self else { return }
var workModel = YHPlanAnalyzeModel()
workModel.name = "work"
var liveModel = YHPlanAnalyzeModel()
liveModel.name = "live"
var investModel = YHPlanAnalyzeModel()
investModel.name = "invest"
var stayModel = YHPlanAnalyzeModel()
stayModel.name = "stay"
for item in self.viewModel.planListModel.list {
if item.name == "work" {
workModel = item
} else if item.name == "live" {
liveModel = item
} else if item.name == "invest" {
investModel = item
} else if item.name == "stay" {
stayModel = item
}
}
workModel.score = self.viewModel.planListModel.basic.work_score
liveModel.score = self.viewModel.planListModel.basic.live_score
investModel.score = self.viewModel.planListModel.basic.invest_score
stayModel.score = self.viewModel.planListModel.basic.stay_time_score
analyzeArr.removeAll()
analyzeArr.append(contentsOf: [workModel, liveModel, investModel, stayModel])
policyVieiw.bannerArr = policyArr
caseArr.removeAll()
caseArr.append(contentsOf: self.viewModel.planListModel.plan_article_case)
self.tableView.reloadData()
}
}
}
......@@ -325,30 +373,39 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
guard let cell1 = tableView.dequeueReusableCell(withIdentifier: YHPlanScoreCell.cellReuseIdentifier, for: indexPath) as? YHPlanScoreCell else {
return UITableViewCell()
}
cell1.model = self.viewModel.planListModel.basic
return cell1
} else if indexPath.section < 5 {
guard let cell2 = tableView.dequeueReusableCell(withIdentifier: YHPlanAnalyzeInfoCell.cellReuseIdentifier, for: indexPath) as? YHPlanAnalyzeInfoCell else {
return UITableViewCell()
}
cell2.products = ["", ""]
cell2.model = analyzeArr[indexPath.section-1]
return cell2
} else if indexPath.section == 5 {
guard let cell3 = tableView.dequeueReusableCell(withIdentifier: YHPlanCustomerCaseListCell.cellReuseIdentifier, for: indexPath) as? YHPlanCustomerCaseListCell else {
return UITableViewCell()
if caseArr.count > 0 {
guard let cell3 = tableView.dequeueReusableCell(withIdentifier: YHPlanCustomerCaseListCell.cellReuseIdentifier, for: indexPath) as? YHPlanCustomerCaseListCell else {
return UITableViewCell()
}
cell3.cases = self.caseArr
return cell3
}
cell3.cases = self.cases
return cell3
}
}
let defaultCell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath)
defaultCell.backgroundColor = .clear
defaultCell.contentView.backgroundColor = .clear
return defaultCell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 5 {
return getCaseListHeight()
if caseArr.count > 0 {
return getCaseListHeight()
}
return 1.0
}
return UITableView.automaticDimension
}
......@@ -360,14 +417,19 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 4 {
return 268.0
if policyArr.count > 0 {
return 268.0
}
return 1.0
}
return 1.0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == 4 {
return self.policyVieiw
if policyArr.count > 0 {
return self.policyVieiw
}
}
let view = UIView()
return view
......@@ -391,8 +453,8 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
var yOffset1 = 0.0
var yOffset2 = 0.0
for (index, _) in cases.enumerated() {
let textHeight = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth-8.0*2.0, string: cases[index])
for (index, item) in caseArr.enumerated() {
let textHeight = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth-8.0*2.0, string: item.title)
let caseCellHeight = textHeight + (cellWidth*(200.0/166.0) + 8.0+12.0+10.0)
if index % 2 == 0 {
......@@ -435,7 +497,6 @@ extension YHPlanViewController: UIScrollViewDelegate {
tableView.setContentOffset(CGPoint(x: 0, y: headerViewHeight), animated: false)
}
}
}
if scrollView.contentOffset.y < headerViewHeight {
......
......@@ -7,7 +7,91 @@
//
import UIKit
import SmartCodable
class YHPlanModel: NSObject {
class YHPlanListModel: SmartCodable {
var basic: YHPlanValueChartInfo = YHPlanValueChartInfo()
var list: [YHPlanAnalyzeModel] = []
var plan_article_case: [YHPlanCaseModel] = []
var plan_article_policy: [YHPlanCaseModel] = []
var code: String = ""
var url: String = ""
required init() {
}
}
class YHPlanCaseModel: SmartCodable {
var title: String = ""
var img_url: String = ""
var image_poster: String = ""
required init() {
}
}
class YHPlanValueChartInfo: SmartCodable {
var work_score: String = ""
var live_score: String = ""
var invest_score: String = ""
var stay_time_score: String = ""
var result: String = ""
var level_name: String = ""
required init() {
}
}
class YHPlanProductModel: SmartCodable {
var title: String = ""
var description: String = ""
var img_url: String = ""
var recommend_product_ids: [Int] = []
required init() {
}
}
class YHPlanAnalyzeModel: SmartCodable {
var name: String = ""
var score: String = "0.0"
var current_state: String = ""
var suggest: String = ""
var hong_kong_policy: String = ""
var solution_plan: [YHPlanProductModel] = []
func getTitle() -> String {
if name == "work" {
return "工作"
}
if name == "live" {
return "生活"
}
if name == "invest" {
return "投资"
}
if name == "stay" {
return "逗留"
}
return ""
}
required init() {
}
}
......@@ -26,7 +26,6 @@ class YHPlanAnalyzeInfoView: UIView {
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize: 13)
lable.numberOfLines = 0
lable.text = "您目前尚未在香港搭建生活关联,基本无法提供在港生活相关证明资料"
return lable
}()
......@@ -64,7 +63,23 @@ class YHPlanAnalyzeInfoCell: UITableViewCell {
static let cellReuseIdentifier = "YHPlanAnalyzeInfoCell"
var products: [String] = [] {
var model = YHPlanAnalyzeModel() {
didSet {
titleLabel.text = "\(model.getTitle())分析"
let aa: ASAttributedString = .init("\(model.score)", .font(UIFont(name: "DINAlternate-Bold", size: 24)!), .foreground(UIColor.mainTextColor))
let bb: ASAttributedString = .init("/5.0", .font(UIFont(name: "DINAlternate-Bold", size: 14)!), .foreground(UIColor.init(hex: 0x8993A2)))
scoreLabel.attributed.text = aa+bb
currentStateVeiw.descLabel.text = model.current_state
requireVeiw.descLabel.text = model.hong_kong_policy
suggestVeiw.descLabel.text = model.suggest
products = model.solution_plan
}
}
var products: [YHPlanProductModel] = [] {
didSet {
let isShowList = products.count > 0
productListView.isHidden = !isShowList
......@@ -104,7 +119,7 @@ class YHPlanAnalyzeInfoCell: UITableViewCell {
let lable = UILabel()
lable.textAlignment = .right
lable.font = UIFont.PFSC_M(ofSize: 15)
let aa: ASAttributedString = .init("3.0", .font(UIFont(name: "DINAlternate-Bold", size: 24)!), .foreground(UIColor.mainTextColor))
let aa: ASAttributedString = .init("0.0", .font(UIFont(name: "DINAlternate-Bold", size: 24)!), .foreground(UIColor.mainTextColor))
let bb: ASAttributedString = .init("/5.0", .font(UIFont(name: "DINAlternate-Bold", size: 14)!), .foreground(UIColor.init(hex: 0x8993A2)))
lable.attributed.text = aa+bb
return lable
......
......@@ -12,6 +12,18 @@ class YHPlanCustomerCaseCollectionCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHPlanCustomerCaseCollectionCell"
var model = YHPlanCaseModel() {
didSet {
descLabel.text = model.title
if let url = URL(string: model.img_url) {
iconImgV.sd_setImage(with: url, placeholderImage: UIImage(named: "global_default_image"))
} else {
iconImgV.image = UIImage(named: "global_default_image")
}
}
}
lazy var whiteContentView: UIView = {
let v = UIView()
v.backgroundColor = .white
......
......@@ -12,7 +12,7 @@ class YHPlanCustomerCaseListCell: UITableViewCell {
static let cellReuseIdentifier = "YHPlanCustomerCaseListCell"
var cases: [String] = [] {
var cases: [YHPlanCaseModel] = [] {
didSet {
collectionView.reloadData()
}
......@@ -105,7 +105,12 @@ extension YHPlanCustomerCaseListCell: UICollectionViewDelegate, UICollectionView
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let cellWidth = floor((KScreenWidth-16.0*2.0-10.0)/2.0)
var height = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth-8.0*2.0, string: cases[indexPath.item])
var height = 0.0
if indexPath.item < cases.count {
let model = cases[indexPath.item]
height = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth-8.0*2.0, string: model.title)
}
height += (cellWidth*(200.0/166.0) + 8.0+12.0+10.0)
return CGSize(width: cellWidth, height: height)
}
......@@ -116,7 +121,8 @@ extension YHPlanCustomerCaseListCell: UICollectionViewDelegate, UICollectionView
return UICollectionViewCell()
}
if 0 <= indexPath.item && indexPath.item < cases.count {
cell.descLabel.text = cases[indexPath.item]
let model = cases[indexPath.item]
cell.model = model
}
return cell
}
......
......@@ -13,6 +13,16 @@ class YHPlanPolicyCarouselImageCell: FSPagerViewCell {
static let cellReuseIdentifier = "YHPlanPolicyCarouselImageCell"
var model = YHPlanCaseModel() {
didSet {
if let url = URL(string: model.img_url) {
imageV.sd_setImage(with: url, placeholderImage: UIImage(named: "global_default_image"))
} else {
imageV.image = UIImage(named: "global_default_image")
}
}
}
lazy var imageV: UIImageView = {
let v = UIImageView()
return v
......
......@@ -11,7 +11,7 @@ import FSPagerView
class YHPlanPolicyCarouselView: UIView {
var bannerArr: [String] = [] {
var bannerArr: [YHPlanCaseModel] = [] {
didSet {
// 设置为0是先停掉自动滑动定时器
bannerView.automaticSlidingInterval = 0
......@@ -128,7 +128,7 @@ extension YHPlanPolicyCarouselView: FSPagerViewDataSource, FSPagerViewDelegate {
}
if index < bannerArr.count {
let model = bannerArr[index]
cell.imageV.backgroundColor = .randomColor()
cell.model = model
}
return cell
}
......
......@@ -85,12 +85,20 @@ class YHPlanProductItemView: UIView {
class YHPlanProductListView: UIView {
var products: [String] = [] {
var products: [YHPlanProductModel] = [] {
didSet {
listView.removeSubviews()
var lastItemView: YHPlanProductItemView?
for (index, item) in products.enumerated() {
let v = YHPlanProductItemView(frame: .zero)
v.titleLabel.text = item.title
v.descLabel.text = item.description
if let url = URL(string: item.img_url) {
v.iconImgV.sd_setImage(with: url, placeholderImage: UIImage(named: "global_default_image"))
} else {
v.iconImgV.image = UIImage(named: "global_default_image")
}
listView.addSubview(v)
v.snp.makeConstraints { make in
make.left.right.equalToSuperview()
......
......@@ -11,6 +11,12 @@ import UIKit
class YHPlanScoreCell: UITableViewCell {
static let cellReuseIdentifier = "YHPlanScoreCell"
var model = YHPlanValueChartInfo() {
didSet {
scoreView.model = model
}
}
lazy var scoreView: YHPlanScoreView = {
let v = YHPlanScoreView(frame: .zero)
......@@ -35,6 +41,5 @@ class YHPlanScoreCell: UITableViewCell {
scoreView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
scoreView.chartView.updateScores([5.0, 5.0, 5.0, 5.0])
}
}
......@@ -9,6 +9,19 @@
import UIKit
class YHPlanScoreView: UIView {
var model = YHPlanValueChartInfo() {
didSet {
let score1 = CGFloat(Double(model.work_score) ?? 0.0)
let score2 = CGFloat(Double(model.live_score) ?? 0.0)
let score3 = CGFloat(Double(model.invest_score) ?? 0.0)
let score4 = CGFloat(Double(model.stay_time_score) ?? 0.0)
chartView.updateScores([score1, score2, score3, score4])
statusLabel.text = model.level_name
descLabel.text = model.result
}
}
lazy var whiteContentView: UIView = {
let v = UIView()
......@@ -40,7 +53,7 @@ class YHPlanScoreView: UIView {
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .center
lable.font = UIFont(name: "AlibabaPuHuiTi_3_95_ExtraBold", size: 24)
lable.text = ""
lable.text = ""
return lable
}()
......@@ -61,7 +74,6 @@ class YHPlanScoreView: UIView {
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize: 13)
lable.numberOfLines = 0
lable.text = "您已获得香港居民身份,办理项目为高才计划,根据您得情况综合分析结果如下:这是一段文字描述"
return lable
}()
......
......@@ -8,6 +8,34 @@
import UIKit
class YHPlanViewModel: NSObject {
class YHPlanViewModel: YHBaseViewModel {
var planListModel: YHPlanListModel = YHPlanListModel()
func requetResignPlanInfo(callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.ResignPlan.planlistApi
_ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, _ in
guard let self = self else { return }
// 1. json字符串 转 对象
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let result = YHPlanListModel.deserialize(from: dic) else {
callBackBlock(false, nil)
return
}
self.planListModel = result
callBackBlock(true, nil)
} else {
// self.activityTravelModel = nil
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
// self.activityTravelModel = nil
callBackBlock(false, err)
}
}
}
......@@ -752,4 +752,10 @@ class YHAllApiName {
}
// 续签方案
struct ResignPlan {
static let planlistApi = "super-app/renewal/advice/get-renewal-plan"
}
}
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