Commit 199c626f authored by pete谢兆麟's avatar pete谢兆麟

Merge branch 'plan' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into plan

# Conflicts:
#	galaxy/galaxy/Classes/Modules/Plan(方案)/MakePlan/VM/YHMakePlanViewModel.swift
parents 2e46eaed e768c063
...@@ -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,30 +17,35 @@ class YHPlanPolicyImageInfo { ...@@ -17,30 +17,35 @@ class YHPlanPolicyImageInfo {
class YHPlanPolicyDetailViewController: YHBaseViewController { class YHPlanPolicyDetailViewController: YHBaseViewController {
var urls: [String] = [] { var firstAppear: Bool = true
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)
} }
self.collectionView.reloadData()
} }
} }
var currentIndex: Int = 0
var imgs: [YHPlanPolicyImageInfo] = [] var imgs: [YHPlanPolicyImageInfo] = []
// lazy var scrollView: UIScrollView = { lazy var bgImgView: UIImageView = {
// let v = UIScrollView(frame: .zero) let v = UIImageView()
// return v v.clipsToBounds = true
// }() return v
}()
lazy var collectionView: UICollectionView = { lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout() let layout = UICollectionViewFlowLayout()
layout.minimumInteritemSpacing = 0.0 layout.minimumInteritemSpacing = 0.0
layout.minimumLineSpacing = 0.0 layout.minimumLineSpacing = 0.0
layout.scrollDirection = .horizontal layout.scrollDirection = .horizontal
let collectView = UICollectionView(frame: .zero, collectionViewLayout: layout) let collectView = UICollectionView(frame: CGRect(x: 0, y: k_Height_NavigationtBarAndStatuBar+24.0, width: KScreenWidth, height: 520), collectionViewLayout: layout)
collectView.backgroundColor = .clear collectView.backgroundColor = .clear
collectView.delegate = self collectView.delegate = self
collectView.dataSource = self collectView.dataSource = self
...@@ -49,6 +54,12 @@ class YHPlanPolicyDetailViewController: YHBaseViewController { ...@@ -49,6 +54,12 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
return collectView return collectView
}() }()
lazy var blurView: UIVisualEffectView = {
let blurEffect = UIBlurEffect(style: .light) // 可以选择不同的模糊样式
let blurEffectView = UIVisualEffectView(effect: blurEffect)
return blurEffectView
}()
lazy var shareBtn: UIButton = { lazy var shareBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.backgroundColor = .white btn.backgroundColor = .white
...@@ -56,20 +67,34 @@ class YHPlanPolicyDetailViewController: YHBaseViewController { ...@@ -56,20 +67,34 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
btn.setTitleColor(.mainTextColor, for: .normal) btn.setTitleColor(.mainTextColor, for: .normal)
btn.titleLabel?.font = .PFSC_M(ofSize: 16) btn.titleLabel?.font = .PFSC_M(ofSize: 16)
btn.layer.cornerRadius = 3.0 btn.layer.cornerRadius = 3.0
btn.addTarget(self, action: #selector(dismiss), for: .touchUpInside) btn.addTarget(self, action: #selector(didShareBtnClicked), for: .touchUpInside)
return btn return btn
}() }()
@objc func didShareBtnClicked() {
let view = YHPlanLinkShareView.alertView()
view.show()
}
override func viewDidLoad() { override func viewDidLoad() {
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(bgImgView)
view.addSubview(blurView)
view.addSubview(collectionView) view.addSubview(collectionView)
view.addSubview(shareBtn) view.addSubview(shareBtn)
bgImgView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
blurView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
collectionView.snp.makeConstraints { make in collectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+24.0) make.top.equalTo(k_Height_NavigationtBarAndStatuBar+24.0)
...@@ -82,18 +107,33 @@ class YHPlanPolicyDetailViewController: YHBaseViewController { ...@@ -82,18 +107,33 @@ 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",
"https://pic1.zhimg.com/v2-66b17db60d1c7c66096eaed9fe2bdb28_r.jpg",
"https://pics3.baidu.com/feed/2cf5e0fe9925bc3174f9833affbb97bcca137059.jpeg@f_auto?token=566818d4692ffdcc23b25f6391dbd061"
]
loadImgs() loadImgs()
showBgImage(index: currentIndex)
}
func showBgImage(index: Int) {
if 0 <= index, index < arr.count {
let model = arr[index]
if let url = URL(string: model.img_url) {
bgImgView.kf.setImage(with: url)
}
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if firstAppear {
collectionView.scrollToItem(at: IndexPath(row: currentIndex, section: 0), at: .top, animated: false)
firstAppear = false
}
} }
func loadImgs() { func loadImgs() {
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
...@@ -124,7 +164,7 @@ extension YHPlanPolicyDetailViewController: UICollectionViewDelegate, UICollecti ...@@ -124,7 +164,7 @@ extension YHPlanPolicyDetailViewController: UICollectionViewDelegate, UICollecti
// 返回每个单元格的大小 // 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: KScreenWidth, height: collectionView.height) return CGSize(width: KScreenWidth, height: 520)
} }
// 返回自定义单元格 // 返回自定义单元格
...@@ -150,7 +190,8 @@ extension YHPlanPolicyDetailViewController: UIScrollViewDelegate { ...@@ -150,7 +190,8 @@ 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)"
showBgImage(index: currentIndex)
} }
} }
...@@ -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,12 +269,18 @@ class YHPlanViewController: YHBaseViewController { ...@@ -249,12 +269,18 @@ 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
}() }()
@objc func didRevalueBtnClicked() { @objc func didRevalueBtnClicked() {
YHPlanLinkShareView.alertView().show()
} }
override func viewDidLoad() { override func viewDidLoad() {
...@@ -267,6 +293,7 @@ class YHPlanViewController: YHBaseViewController { ...@@ -267,6 +293,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 +311,12 @@ class YHPlanViewController: YHBaseViewController { ...@@ -284,6 +311,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 +378,15 @@ class YHPlanViewController: YHBaseViewController { ...@@ -345,13 +378,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 +424,14 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -389,6 +424,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 +517,53 @@ extension YHPlanViewController: UIScrollViewDelegate { ...@@ -474,45 +517,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 +581,7 @@ extension YHPlanViewController: UIScrollViewDelegate { ...@@ -530,6 +581,7 @@ extension YHPlanViewController: UIScrollViewDelegate {
self.segmented1View.defaultSelectedIndex = infoArr.count-1 self.segmented1View.defaultSelectedIndex = infoArr.count-1
self.segmented1View.reloadDataWithoutListContainer() self.segmented1View.reloadDataWithoutListContainer()
} }
} }
} }
...@@ -538,12 +590,8 @@ extension YHPlanViewController: JXSegmentedViewDelegate { ...@@ -538,12 +590,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