Commit 6c81304b authored by Steven杜宇's avatar Steven杜宇

// 首页资讯

parent ee2214c0
......@@ -29,6 +29,8 @@
04213B292C48EF5300797900 /* YHHomeInformationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B282C48EF5200797900 /* YHHomeInformationViewController.swift */; };
04213B2B2C48F1BE00797900 /* YHHomeInfoSectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B2A2C48F1BE00797900 /* YHHomeInfoSectionCell.swift */; };
04213B2D2C48FEB000797900 /* YHHomeInfoSectionHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B2C2C48FEB000797900 /* YHHomeInfoSectionHeadView.swift */; };
04213B2F2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B2E2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift */; };
04213B312C4917BD00797900 /* YHHomeInfoDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B302C4917BD00797900 /* YHHomeInfoDetailViewController.swift */; };
0425E63D2BA9345200A5E763 /* YHSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */; };
0425E6402BA9357D00A5E763 /* YHScemeItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */; };
0425E6422BA95B1B00A5E763 /* YHSchemeTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */; };
......@@ -614,6 +616,8 @@
04213B282C48EF5200797900 /* YHHomeInformationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeInformationViewController.swift; sourceTree = "<group>"; };
04213B2A2C48F1BE00797900 /* YHHomeInfoSectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeInfoSectionCell.swift; sourceTree = "<group>"; };
04213B2C2C48FEB000797900 /* YHHomeInfoSectionHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeInfoSectionHeadView.swift; sourceTree = "<group>"; };
04213B2E2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeInfoDetailContainerViewController.swift; sourceTree = "<group>"; };
04213B302C4917BD00797900 /* YHHomeInfoDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeInfoDetailViewController.swift; sourceTree = "<group>"; };
0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableViewCell.swift; sourceTree = "<group>"; };
0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHScemeItemModel.swift; sourceTree = "<group>"; };
0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableFooterView.swift; sourceTree = "<group>"; };
......@@ -2538,6 +2542,8 @@
A5000F502C3BC28B00843452 /* YHHomeHoldViewPageViewController.swift */,
04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */,
04213B282C48EF5200797900 /* YHHomeInformationViewController.swift */,
04213B2E2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift */,
04213B302C4917BD00797900 /* YHHomeInfoDetailViewController.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -3514,6 +3520,7 @@
045EEEE42B9F171A0022A143 /* YHMySignatureDetailModel.swift in Sources */,
A58A8C8F2BA6978100632765 /* YHMineCertificateEntryViewController.swift in Sources */,
045EEF1B2B9F171A0022A143 /* YHAddressPickViewTableViewCell.swift in Sources */,
04213B2F2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift in Sources */,
A567E5A42BD7643D00D5D5A0 /* YHSearchInfoCell.swift in Sources */,
045EEE932B9F171A0022A143 /* YHPreviewInfoSingleLineTitleView.swift in Sources */,
045EEF1D2B9F171A0022A143 /* YHAddressPickView.swift in Sources */,
......@@ -3584,6 +3591,7 @@
045A08C22C37EB8B00BCBABA /* YHMyFileListNoneCell.swift in Sources */,
04FD85682C21277800BEF9C5 /* YHMyNameCardAvatarInfoCell.swift in Sources */,
A566A79A2C219FA400980D06 /* YHHomeSalonAreaView.swift in Sources */,
04213B312C4917BD00797900 /* YHHomeInfoDetailViewController.swift in Sources */,
A5ACE9432B4564F7002C94D2 /* UILable+Extension.swift in Sources */,
0414BDB22BCCC0A500225367 /* YHCollectionModel.swift in Sources */,
045EEE882B9F171A0022A143 /* YHPreviewAcademicAndProfessionalQualificationViewController.swift in Sources */,
......
//
// YHHomeInfoDetailViewController.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHomeInfoDetailContainerViewController: YHBaseViewController {
var customTitle:String = ""
var isHaveHot: Bool = true // 是否有精品
lazy var tabTitles: [String] = {
if isHaveHot {
return ["最新", "精品"]
}
return ["最新"]
}()
lazy var arrItemVCs : [YHBaseViewController] = {
let vc1 = YHHomeInfoDetailViewController()
vc1.isHot = false
vc1.isShowTab = self.isHaveHot
let vc2 = YHHomeInfoDetailViewController()
vc2.isHot = true
vc2.isShowTab = self.isHaveHot
if isHaveHot {
return [vc1, vc2]
}
return [vc1]
}()
lazy var segmentedView : JXSegmentedView = {
let segmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 44))
segmentedView.delegate = self
segmentedView.dataSource = segmentedDataSource
segmentedView.listContainer = listContainerView
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorHeight = 2
indicator.indicatorCornerRadius = 0.0
indicator.indicatorColor = .brandMainColor
segmentedView.indicators = [indicator]
segmentedView.defaultSelectedIndex = 0
return segmentedView
}()
lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.isItemSpacingAverageEnabled = false
dataSource.titles = self.tabTitles
dataSource.titleNormalFont = UIFont.PFSC_R(ofSize: 16)
dataSource.titleNormalColor = UIColor.init(hex: 0x94A3B8)
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 16)
dataSource.titleSelectedColor = .mainTextColor
dataSource.itemWidth = 32.0
dataSource.itemSpacing = 22.0
return dataSource
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
let view = JXSegmentedListContainerView(dataSource: self, type: .scrollView)
view.backgroundColor = .clear
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.setupUI()
}
func setupUI() {
gk_navTitle = customTitle
self.view.backgroundColor = .white
self.view.addSubview(self.segmentedView)
self.view.addSubview(self.listContainerView)
self.segmentedView.isHidden = !self.isHaveHot
self.segmentedView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(0)
make.height.equalTo(44)
}
self.listContainerView.snp.makeConstraints { make in
let gap = isHaveHot ? 44.0+19.0 : 0.0
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+gap)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalToSuperview()
}
}
}
extension YHHomeInfoDetailContainerViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
}
}
extension YHHomeInfoDetailContainerViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
return titleDataSource.dataSource.count
}
return 0
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
}
}
//
// YHHomeInfoDetailViewController.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHomeInfoDetailViewController: YHBaseViewController {
var isHot:Bool = false // 是否是精品
var isShowTab: Bool = true
lazy var viewModel : YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
return viewModel
}()
lazy var collectView = {
// 设置布局方向
let flowLayout = YHHomeCollectionLayout()
flowLayout.minimumInteritemSpacing = 7.0
flowLayout.minimumColumnSpacing = 7.0
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
collectinoView.showsVerticalScrollIndicator = false
collectinoView.es.addYHPullToRefresh {
self.getTheNewestInfoList(isFirstPage: true)
}
collectinoView.es.addInfiniteScrolling {
self.getTheNewestInfoList(isFirstPage: false)
}
return collectinoView
}()
override func viewDidLoad() {
super.viewDidLoad()
self.setupUI()
self.getTheNewestInfoList(isFirstPage:true)
}
func setupUI() {
gk_navigationBar.isHidden = true
self.view.backgroundColor = .white
self.view.addSubview(self.collectView)
self.collectView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(20)
make.right.equalTo(-20)
let gap = isShowTab ? 44.0+19.0 : 0.0
make.height.equalTo(KScreenHeight-k_Height_NavigationtBarAndStatuBar-gap)
}
}
}
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource
extension YHHomeInfoDetailViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// 最新资讯
return self.viewModel.arrHomeNewsData?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHHomeCollectionViewCell
cell.listModel = self.viewModel.arrHomeNewsData?[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let model = self.viewModel.arrHomeNewsData?[indexPath.row] else { return }
if model.type == 2 {
let vc = YHHomeWebViewController()
vc.url = YHBaseUrlManager.shared.curH5URL() + "articleDetail.html" + "?id=\(model.id)"
vc.id = model.id
vc.block = { item in
if let arr = self.viewModel.arrHomeNewsData {
for (index,targetItem) in arr.enumerated() {
if targetItem.id == item.id {
targetItem.is_like = item.is_like
targetItem.like_count = item.like_count
self.collectView.reloadItems(at: [IndexPath.SubSequence(item: index, section: 0)])
}
}
}
}
self.navigationController?.pushViewController(vc)
} else if model.type == 1 {
printLog("直接播放视频")
}
}
}
//MARK: - CollectionViewWaterfallLayoutDelegate
extension YHHomeInfoDetailViewController : CollectionViewWaterfallLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let count = self.viewModel.arrHomeNewsData?.count ?? 0
if indexPath.row < count {
guard let model = self.viewModel.arrHomeNewsData?[indexPath.row] else { return CGSize.zero }
return CGSize(width: model.img_width_cell, height: model.img_height_cell)
}
let width = (KScreenWidth - 47) / 2
return CGSize(width: width, height: 140.0)
}
}
extension YHHomeInfoDetailViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
extension YHHomeInfoDetailViewController {
// 获取最新资讯
func getTheNewestInfoList(isFirstPage: Bool) {
self.viewModel.getList(isFirsPage: isFirstPage) { success, error in
self.collectView.reloadData()
self.collectView.es.stopPullToRefresh()
self.collectView.es.stopLoadingMore()
if self.viewModel.hasMoreForHomeNews == false {
self.collectView.es.noticeNoMoreData()
self.collectView.footer?.alpha = 1
}
}
}
}
......@@ -25,7 +25,6 @@ class YHHomeInformationViewController: YHBaseViewController {
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.register(YHHomeInfoSectionCell.self, forCellWithReuseIdentifier:YHHomeInfoSectionCell.cellReuseIdentifier)
collectinoView.register(YHHomeInfoSectionHeadView.self, forSupplementaryViewOfKind: CollectionViewWaterfallElementKindSectionHeader, withReuseIdentifier: YHHomeInfoSectionHeadView.reuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
......
......@@ -108,7 +108,13 @@ extension YHHomeInfoSectionHeadView: UICollectionViewDelegate, UICollectionViewD
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.row, indexPath.row < self.items.count {
let item = self.items[indexPath.row]
let vc = YHHomeInfoDetailContainerViewController()
vc.customTitle = item
vc.isHaveHot = true
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
......
......@@ -280,11 +280,11 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
return
}
if true {
let vc = YHHomeInformationViewController()
self.navigationController?.pushViewController(vc)
return
}
// if true {
// let vc = YHHomeInformationViewController()
// self.navigationController?.pushViewController(vc)
// return
// }
let item: PersonalModuleItem = items[indexPath.row]
switch item.type {
......
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