Commit 8e2b46ff authored by Steven杜宇's avatar Steven杜宇

// 方案

parent 2face72e
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import UIKit import UIKit
class YHPlanPolicyImageInfo { class YHPlanPolicyImageInfo {
var url: String = "" var model: YHPlanCaseModel = YHPlanCaseModel()
var imgView: UIImageView = UIImageView() var imgView: UIImageView = UIImageView()
let height: CGFloat = 520.0 let height: CGFloat = 520.0
var width: CGFloat = 520.0 var width: CGFloat = 520.0
...@@ -17,17 +17,19 @@ class YHPlanPolicyImageInfo { ...@@ -17,17 +17,19 @@ class YHPlanPolicyImageInfo {
class YHPlanPolicyDetailViewController: YHBaseViewController { class YHPlanPolicyDetailViewController: YHBaseViewController {
var urls: [String] = [] { var arr: [YHPlanCaseModel] = [] {
didSet { didSet {
imgs.removeAll() imgs.removeAll()
for url in urls { for item in arr {
let model = YHPlanPolicyImageInfo() let model = YHPlanPolicyImageInfo()
model.url = url model.model = item
imgs.append(model) imgs.append(model)
} }
} }
} }
var currentIndex: Int = 0
var imgs: [YHPlanPolicyImageInfo] = [] var imgs: [YHPlanPolicyImageInfo] = []
// lazy var scrollView: UIScrollView = { // lazy var scrollView: UIScrollView = {
...@@ -64,7 +66,7 @@ class YHPlanPolicyDetailViewController: YHBaseViewController { ...@@ -64,7 +66,7 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
super.viewDidLoad() super.viewDidLoad()
gk_backImage = UIImage(named: "nav_back_white") gk_backImage = UIImage(named: "nav_back_white")
gk_navTitle = "1/\(urls.count)" gk_navTitle = "\(currentIndex+1)/\(arr.count)"
gk_navTitleColor = .white gk_navTitleColor = .white
view.backgroundColor = .init(hex: 0x000000, alpha: 1.0) view.backgroundColor = .init(hex: 0x000000, alpha: 1.0)
view.addSubview(collectionView) view.addSubview(collectionView)
...@@ -82,10 +84,7 @@ class YHPlanPolicyDetailViewController: YHBaseViewController { ...@@ -82,10 +84,7 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
make.height.equalTo(46) make.height.equalTo(46)
make.top.equalTo(collectionView.snp.bottom).offset(32) make.top.equalTo(collectionView.snp.bottom).offset(32)
} }
urls = ["https://img0.baidu.com/it/u=10464961,1462197942&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667", collectionView.setContentOffset(CGPoint(x: KScreenWidth * Double(currentIndex), y: 0.0), animated: true)
"https://pic1.zhimg.com/v2-66b17db60d1c7c66096eaed9fe2bdb28_r.jpg",
"https://pics3.baidu.com/feed/2cf5e0fe9925bc3174f9833affbb97bcca137059.jpeg@f_auto?token=566818d4692ffdcc23b25f6391dbd061"
]
loadImgs() loadImgs()
} }
...@@ -93,7 +92,7 @@ class YHPlanPolicyDetailViewController: YHBaseViewController { ...@@ -93,7 +92,7 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
let ossGroup = DispatchGroup() let ossGroup = DispatchGroup()
for item in imgs { for item in imgs {
ossGroup.enter() ossGroup.enter()
item.imgView.kf.setImage(with: URL(string: item.url)) { result in item.imgView.kf.setImage(with: URL(string: item.model.img_url)) { result in
switch result { switch result {
case let .success(value): case let .success(value):
let size = value.image.size let size = value.image.size
...@@ -150,7 +149,7 @@ extension YHPlanPolicyDetailViewController: UIScrollViewDelegate { ...@@ -150,7 +149,7 @@ extension YHPlanPolicyDetailViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
let currentIndex = Int(scrollView.contentOffset.x/KScreenWidth) let currentIndex = Int(scrollView.contentOffset.x/KScreenWidth)
gk_navTitle = "\(currentIndex+1)/\(urls.count)" gk_navTitle = "\(currentIndex+1)/\(arr.count)"
} }
} }
...@@ -48,6 +48,27 @@ class YHPlanViewController: YHBaseViewController { ...@@ -48,6 +48,27 @@ class YHPlanViewController: YHBaseViewController {
return tableView return tableView
}() }()
lazy var fakeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.isHidden = true
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.showsVerticalScrollIndicator = false
tableView.estimatedSectionHeaderHeight = 1.0
tableView.estimatedSectionFooterHeight = 1.0
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(YHPlanAnalyzeInfoCell.self, forCellReuseIdentifier: YHPlanAnalyzeInfoCell.cellReuseIdentifier)
tableView.register(YHPlanScoreCell.self, forCellReuseIdentifier: YHPlanScoreCell.cellReuseIdentifier)
tableView.register(YHPlanCustomerCaseListCell.self, forCellReuseIdentifier: YHPlanCustomerCaseListCell.cellReuseIdentifier)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
return tableView
}()
lazy var whiteBackBtn: UIButton = { lazy var whiteBackBtn: UIButton = {
let v = UIButton() let v = UIButton()
v.setImage(UIImage(named: "nav_back_white"), for: .normal) v.setImage(UIImage(named: "nav_back_white"), for: .normal)
...@@ -63,8 +84,7 @@ class YHPlanViewController: YHBaseViewController { ...@@ -63,8 +84,7 @@ class YHPlanViewController: YHBaseViewController {
}() }()
@objc func didShareBtnClicked() { @objc func didShareBtnClicked() {
// let vc = YHPlanShareViewController() let vc = YHPlanShareViewController()
let vc = YHPlanPolicyDetailViewController()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
...@@ -249,6 +269,14 @@ class YHPlanViewController: YHBaseViewController { ...@@ -249,6 +269,14 @@ class YHPlanViewController: YHBaseViewController {
lazy var policyVieiw: YHPlanPolicyCarouselView = { lazy var policyVieiw: YHPlanPolicyCarouselView = {
let v = YHPlanPolicyCarouselView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 268)) let v = YHPlanPolicyCarouselView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 268))
v.clickBlock = {
[weak self] arr, index in
guard let self = self else { return }
let vc = YHPlanPolicyDetailViewController()
vc.arr = arr
vc.currentIndex = index
self.navigationController?.pushViewController(vc, animated: true)
}
return v return v
}() }()
...@@ -267,6 +295,7 @@ class YHPlanViewController: YHBaseViewController { ...@@ -267,6 +295,7 @@ class YHPlanViewController: YHBaseViewController {
self.view.backgroundColor = .init(hex: 0xF8F9FB) self.view.backgroundColor = .init(hex: 0xF8F9FB)
self.view.addSubview(bgImgView) self.view.addSubview(bgImgView)
self.view.addSubview(fakeTableView)
self.view.addSubview(tableView) self.view.addSubview(tableView)
self.view.addSubview(fixedSegmentView) self.view.addSubview(fixedSegmentView)
self.view.addSubview(bottomView) self.view.addSubview(bottomView)
...@@ -284,6 +313,12 @@ class YHPlanViewController: YHBaseViewController { ...@@ -284,6 +313,12 @@ class YHPlanViewController: YHBaseViewController {
make.bottom.equalTo(bottomView.snp.top) make.bottom.equalTo(bottomView.snp.top)
} }
fakeTableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+44.0)
make.bottom.equalTo(bottomView.snp.top)
}
fixedSegmentView.snp.makeConstraints { make in fixedSegmentView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
...@@ -345,13 +380,15 @@ class YHPlanViewController: YHBaseViewController { ...@@ -345,13 +380,15 @@ class YHPlanViewController: YHBaseViewController {
analyzeArr.removeAll() analyzeArr.removeAll()
analyzeArr.append(contentsOf: [workModel, liveModel, investModel, stayModel]) analyzeArr.append(contentsOf: [workModel, liveModel, investModel, stayModel])
policyVieiw.bannerArr = policyArr policyArr.removeAll()
policyArr.append(contentsOf: self.viewModel.planListModel.plan_article_policy)
caseArr.removeAll() caseArr.removeAll()
caseArr.append(contentsOf: self.viewModel.planListModel.plan_article_case) caseArr.append(contentsOf: self.viewModel.planListModel.plan_article_case)
self.tableView.reloadData() policyVieiw.bannerArr = policyArr
self.tableView.reloadData()
self.fakeTableView.reloadData()
} }
} }
} }
...@@ -389,6 +426,14 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -389,6 +426,14 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
return UITableViewCell() return UITableViewCell()
} }
cell3.cases = self.caseArr cell3.cases = self.caseArr
cell3.clickBlock = {
[weak self] arr, index in
guard let self = self else { return }
let vc = YHPlanPolicyDetailViewController()
vc.arr = arr
vc.currentIndex = index
self.navigationController?.pushViewController(vc, animated: true)
}
return cell3 return cell3
} }
} }
...@@ -474,45 +519,53 @@ extension YHPlanViewController: UIScrollViewDelegate { ...@@ -474,45 +519,53 @@ extension YHPlanViewController: UIScrollViewDelegate {
printLog("\(scrollView.contentOffset.y)") printLog("\(scrollView.contentOffset.y)")
bgImgView.y = scrollView.contentOffset.y > 0.0 ? -scrollView.contentOffset.y : 0.0 if scrollView == tableView {
if scrollView.contentOffset.y >= topScrollHeight {
tableView.contentOffset.y = topScrollHeight
}
var percent = scrollView.contentOffset.y/20.0
if percent > 1.0 {
percent = 1.0
} else if percent < 0.0 {
percent = 0.0
}
fixedSegmentView.alpha = scrollView.contentOffset.y >= topScrollHeight ? 1.0 : 0.0
gk_navigationBar.alpha = percent
whiteBackBtn.isHidden = percent >= 1.0
shareBtn.isHidden = percent >= 1.0
}
var percent = scrollView.contentOffset.y/20.0 if fakeTableView.contentOffset.y > 0 {
if percent > 1.0 { bgImgView.y = -scrollView.contentOffset.y-fakeTableView.contentOffset.y
percent = 1.0 } else {
} else if percent < 0.0 { bgImgView.y = -scrollView.contentOffset.y
percent = 0.0
} }
fixedSegmentView.alpha = scrollView.contentOffset.y >= topScrollHeight ? 1.0 : 0.0
gk_navigationBar.alpha = percent
whiteBackBtn.isHidden = percent >= 1.0
shareBtn.isHidden = percent >= 1.0
if scrollView.contentOffset.y > topScrollHeight { fakeTableView.isHidden = tableView.contentOffset.y <= topScrollHeight-1
if topScrollHeight <= scrollView.contentOffset.y, scrollView.contentOffset.y <= topScrollHeight+10 {
if !contentOffSetChangeBig { if tableView.contentOffset.y >= topScrollHeight, fakeTableView.contentOffset.y >= 0 {
contentOffSetChangeBig = true tableView.isHidden = true
tableView.y = k_Height_NavigationtBarAndStatuBar+44.0 fakeTableView.isHidden = false
printLog("BBBBBBBBB") } else {
tableView.setContentOffset(CGPoint(x: 0, y: headerViewHeight), animated: false) tableView.isHidden = false
} fakeTableView.isHidden = true
}
} }
if scrollView.contentOffset.y < headerViewHeight { printLog("fakeTableView: \(fakeTableView.contentOffset.y) tableView: \(tableView.contentOffset.y)")
if contentOffSetChangeBig {
contentOffSetChangeBig = false }
tableView.y = k_Height_NavigationtBarAndStatuBar
printLog("AAAAAAAAAA") func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
tableView.setContentOffset(CGPoint(x: 0, y: topScrollHeight), animated: false)
}
}
var find = false var find = false
for index in 0...infoArr.count-1 { for index in 0...infoArr.count-1 {
let rect = self.tableView.rectForRow(at: IndexPath(row: 0, section: index)) let rect = self.fakeTableView.rectForRow(at: IndexPath(row: 0, section: index))
let conditon = index == 0 ? scrollView.contentOffset.y <= rect.origin.y : scrollView.contentOffset.y < rect.origin.y-5 let conditon = index == 0 ? fakeTableView.contentOffset.y <= rect.origin.y : fakeTableView.contentOffset.y < rect.origin.y-5
if conditon { if conditon {
find = true find = true
let targetIndex = index-1 >= 0 ? index-1 : 0 let targetIndex = index-1 >= 0 ? index-1 : 0
...@@ -530,6 +583,7 @@ extension YHPlanViewController: UIScrollViewDelegate { ...@@ -530,6 +583,7 @@ extension YHPlanViewController: UIScrollViewDelegate {
self.segmented1View.defaultSelectedIndex = infoArr.count-1 self.segmented1View.defaultSelectedIndex = infoArr.count-1
self.segmented1View.reloadDataWithoutListContainer() self.segmented1View.reloadDataWithoutListContainer()
} }
} }
} }
...@@ -538,12 +592,8 @@ extension YHPlanViewController: JXSegmentedViewDelegate { ...@@ -538,12 +592,8 @@ extension YHPlanViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) { func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
let index = segmentedView.selectedIndex let index = segmentedView.selectedIndex
if index > 0 { self.tableView.setContentOffset(CGPoint(x: 0, y: topScrollHeight), animated: true)
if self.tableView.contentOffset.y < topScrollHeight { self.fakeTableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top, animated: true)
self.tableView.setContentOffset(CGPoint(x: 0, y: topScrollHeight+2), animated: false)
}
}
self.tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top, animated: true)
if segmentedView == segmented1View { if segmentedView == segmented1View {
self.segmented2View.defaultSelectedIndex = index self.segmented2View.defaultSelectedIndex = index
......
...@@ -12,6 +12,7 @@ class YHPlanCustomerCaseListCell: UITableViewCell { ...@@ -12,6 +12,7 @@ class YHPlanCustomerCaseListCell: UITableViewCell {
static let cellReuseIdentifier = "YHPlanCustomerCaseListCell" static let cellReuseIdentifier = "YHPlanCustomerCaseListCell"
var clickBlock: (([YHPlanCaseModel], Int) -> Void)?
var cases: [YHPlanCaseModel] = [] { var cases: [YHPlanCaseModel] = [] {
didSet { didSet {
collectionView.reloadData() collectionView.reloadData()
...@@ -130,6 +131,7 @@ extension YHPlanCustomerCaseListCell: UICollectionViewDelegate, UICollectionView ...@@ -130,6 +131,7 @@ extension YHPlanCustomerCaseListCell: UICollectionViewDelegate, UICollectionView
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < cases.count { if 0 <= indexPath.item && indexPath.item < cases.count {
// let text = topicArr[indexPath.item] // let text = topicArr[indexPath.item]
clickBlock?(cases, indexPath.item)
} }
} }
......
...@@ -11,6 +11,8 @@ import FSPagerView ...@@ -11,6 +11,8 @@ import FSPagerView
class YHPlanPolicyCarouselView: UIView { class YHPlanPolicyCarouselView: UIView {
var clickBlock: (([YHPlanCaseModel], Int) -> Void)?
var bannerArr: [YHPlanCaseModel] = [] { var bannerArr: [YHPlanCaseModel] = [] {
didSet { didSet {
// 设置为0是先停掉自动滑动定时器 // 设置为0是先停掉自动滑动定时器
...@@ -139,7 +141,7 @@ extension YHPlanPolicyCarouselView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -139,7 +141,7 @@ extension YHPlanPolicyCarouselView: FSPagerViewDataSource, FSPagerViewDelegate {
pagerView.scrollToItem(at: index, animated: true) pagerView.scrollToItem(at: index, animated: true)
if 0 <= index, index < bannerArr.count { if 0 <= index, index < bannerArr.count {
let model = bannerArr[index] let model = bannerArr[index]
// selectBannerItemBlock?(model) clickBlock?(bannerArr, index)
return return
} }
} }
......
...@@ -15,13 +15,13 @@ class YHPlanShareImageCell: UICollectionViewCell { ...@@ -15,13 +15,13 @@ class YHPlanShareImageCell: UICollectionViewCell {
var model: YHPlanPolicyImageInfo = YHPlanPolicyImageInfo() { var model: YHPlanPolicyImageInfo = YHPlanPolicyImageInfo() {
didSet { didSet {
if let url = URL(string: model.url) { if let url = URL(string: model.model.img_url) {
imgView.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image")) imgView.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
} else { } else {
imgView.image = UIImage(named: "global_default_image") imgView.image = UIImage(named: "global_default_image")
} }
imgView.snp.remakeConstraints { make in imgView.snp.updateConstraints { make in
make.top.bottom.equalToSuperview() make.top.bottom.equalToSuperview()
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.width.equalTo(imgView.snp.height).multipliedBy(model.width/model.height) make.width.equalTo(imgView.snp.height).multipliedBy(model.width/model.height)
......
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