Commit cbd9f3e5 authored by Steven杜宇's avatar Steven杜宇

// 资讯

parent bff7e6d5
......@@ -26,6 +26,9 @@
04213B232C48B7F700797900 /* YHIdentityTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B222C48B7F700797900 /* YHIdentityTabBar.swift */; };
04213B252C48C15400797900 /* YHHomeIdentityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */; };
04213B272C48C95E00797900 /* YHHomeIdentityCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B262C48C95E00797900 /* YHHomeIdentityCell.swift */; };
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 */; };
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 */; };
......@@ -608,6 +611,9 @@
04213B222C48B7F700797900 /* YHIdentityTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHIdentityTabBar.swift; sourceTree = "<group>"; };
04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeIdentityViewController.swift; sourceTree = "<group>"; };
04213B262C48C95E00797900 /* YHHomeIdentityCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeIdentityCell.swift; sourceTree = "<group>"; };
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>"; };
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>"; };
......@@ -2531,6 +2537,8 @@
A567E5762BD7643D00D5D5A0 /* YHHomePageViewController.swift */,
A5000F502C3BC28B00843452 /* YHHomeHoldViewPageViewController.swift */,
04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */,
04213B282C48EF5200797900 /* YHHomeInformationViewController.swift */,
04213B2C2C48FEB000797900 /* YHHomeInfoSectionHeadView.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2568,6 +2576,7 @@
04C85DE02C3677CB008B20D6 /* YHConsultantQRCodeView.swift */,
04213B222C48B7F700797900 /* YHIdentityTabBar.swift */,
04213B262C48C95E00797900 /* YHHomeIdentityCell.swift */,
04213B2A2C48F1BE00797900 /* YHHomeInfoSectionCell.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -3266,6 +3275,7 @@
A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */,
A5ACE9452B4564F7002C94D2 /* YHHUDContainerView.swift in Sources */,
045EEEFD2B9F171A0022A143 /* YHSheetPickerViewType.swift in Sources */,
04213B2B2C48F1BE00797900 /* YHHomeInfoSectionCell.swift in Sources */,
045EEEC72B9F171A0022A143 /* YHOtherYesOrNoItemView.swift in Sources */,
A5FF0F3E2C32F2590069852B /* YHActivityDetailCell2.swift in Sources */,
04FD85702C21646200BEF9C5 /* YHMyInterestTopicCell.swift in Sources */,
......@@ -3400,6 +3410,7 @@
0499E3002C056EE30037E646 /* YHOneKeyLoginView.swift in Sources */,
043D2C8C2C0F037B00172438 /* YHServiceOrderSearchViewModel.swift in Sources */,
0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */,
04213B292C48EF5300797900 /* YHHomeInformationViewController.swift in Sources */,
048B2A4D2BC7DAE800A93BF0 /* YHMyLikeViewModel.swift in Sources */,
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */,
045EEECD2B9F171A0022A143 /* YHScoreDataModel.swift in Sources */,
......@@ -3507,6 +3518,7 @@
045EEE932B9F171A0022A143 /* YHPreviewInfoSingleLineTitleView.swift in Sources */,
045EEF1D2B9F171A0022A143 /* YHAddressPickView.swift in Sources */,
A58AC0A12BAC0B2900A30FA9 /* YHFileListItemView.swift in Sources */,
04213B2D2C48FEB000797900 /* YHHomeInfoSectionHeadView.swift in Sources */,
045EEED12B9F171A0022A143 /* YHScorePersonInfoCell.swift in Sources */,
044CF8D42BB6BCF700008CE8 /* YHSignatureUploadTableViewCell.swift in Sources */,
A567E5B02BD7643D00D5D5A0 /* YHHomeWebBottomView.swift in Sources */,
......
......@@ -50,7 +50,8 @@ class YHHomeIdentityViewController: YHBaseViewController {
self.segmentedView.dataSource = segmentedDataSource
view.addSubview(self.segmentedView)
segmentedView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(44)
make.top.equalTo(imgView.snp.bottom).offset(8.0)
}
......
//
// YHHomeInfoSectionHeadView.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
let kHomeGap = 15.0
let kHomeItemWidth = floor((KScreenWidth-20.0*2.0-kHomeGap*2.0)/3.0)
let kHomeItemHeight = kHomeItemWidth+10.0+20.0+26.0
class YHHomeInfoSectionHeadView: UICollectionReusableView {
static let reuseIdentifier = "YHHomeInfoSectionHeadView"
var items:[String] = [] {
didSet {
var row = items.count/3
if row%3 != 0 {
row = row + 1
}
let totalHeight = Double(row) * kHomeItemHeight
self.collectView.reloadData()
self.collectView.snp.updateConstraints { make in
make.height.equalTo(totalHeight)
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var collectView = {
// 设置布局方向
let flowLayout = UICollectionViewFlowLayout()
flowLayout.minimumInteritemSpacing = kHomeGap
flowLayout.minimumLineSpacing = 0.0
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.register(YHHomeInfoSectionCell.self, forCellWithReuseIdentifier:YHHomeInfoSectionCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.isScrollEnabled = false
collectinoView.showsVerticalScrollIndicator = false
return collectinoView
}()
lazy var bottomLineView:UIView = {
let view = UIView()
view.backgroundColor = UIColor.init(hex: 0xF0F3F7)
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_M(ofSize: 18)
label.textAlignment = .left
label.textColor = UIColor.mainTextColor
label.text = "最新资讯"
return label
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
func createUI() {
self.backgroundColor = .white
self.addSubview(collectView)
self.addSubview(bottomLineView)
self.addSubview(titleLabel)
collectView.snp.makeConstraints { make in
make.top.equalTo(10)
make.left.right.equalToSuperview()
make.height.equalTo(0)
}
bottomLineView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(collectView.snp.bottom).offset(4.0)
make.height.equalTo(0.5)
}
titleLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(65)
make.top.equalTo(bottomLineView.snp.bottom)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension YHHomeInfoSectionHeadView: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// 最新资讯
return self.items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeInfoSectionCell.cellReuseIdentifier, for: indexPath) as! YHHomeInfoSectionCell
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: kHomeItemWidth, height: kHomeItemHeight)
}
}
//
// YHHomeInformationViewController.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeInformationViewController: YHBaseViewController {
lazy var viewModel : YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
return viewModel
}()
var sectionItems:[String] = ["", "", "", ""]
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.register(YHHomeInfoSectionCell.self, forCellWithReuseIdentifier:YHHomeInfoSectionCell.cellReuseIdentifier)
collectinoView.register(YHHomeInfoSectionHeadView.self, forSupplementaryViewOfKind: CollectionViewWaterfallElementKindSectionHeader, withReuseIdentifier: YHHomeInfoSectionHeadView.reuseIdentifier)
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.view.backgroundColor = .white
self.view.addSubview(self.collectView)
self.collectView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+44)
make.bottom.equalToSuperview()
make.left.equalTo(20)
make.right.equalTo(-20)
}
self.getTheNewestInfoList(isFirstPage:true)
}
}
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource
extension YHHomeInformationViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// 最新资讯
return self.viewModel.arrHomeNewsData?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == CollectionViewWaterfallElementKindSectionHeader {
let headerView: YHHomeInfoSectionHeadView = collectionView.dequeueReusableSupplementaryView(ofKind: CollectionViewWaterfallElementKindSectionHeader, withReuseIdentifier: YHHomeInfoSectionHeadView.reuseIdentifier, for: indexPath) as! YHHomeInfoSectionHeadView
headerView.items = sectionItems
return headerView
}
return UICollectionReusableView()
}
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 YHHomeInformationViewController : 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)
}
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForHeaderInSection section: Int) -> Float {
var row = self.sectionItems.count/3
if row%3 != 0 {
row = row + 1
}
let listHeight = Float(Double(row) * kHomeItemHeight)
let totalHeight = 10.0 + listHeight + 4.0 + 0.5 + 65.0
return totalHeight
}
}
extension YHHomeInformationViewController {
// 获取最新资讯
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
}
}
}
}
//
// YHHomeInfoSectionCell.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeInfoSectionCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHHomeInfoSectionCell"
lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textAlignment = .left
label.textColor = UIColor.mainTextColor70
label.text = "身份福利"
return label
}()
lazy var imgView: UIImageView = {
let imgV = UIImageView()
imgV.backgroundColor = .red
return imgV
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
func setupUI() {
self.addSubview(self.imgView)
self.addSubview(self.titleLabel)
self.imgView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(self.imgView.snp.width)
}
self.titleLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(self.imgView.snp.bottom).offset(10)
make.height.equalTo(20)
}
}
}
......@@ -319,6 +319,59 @@ extension YHHomePageViewModel {
}
}
func getList(isFirsPage firstFlag : Bool, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = ["page": curPageIndex,
"page_size": searchPageSize]
if firstFlag {
params = ["page": 1,
"page_size": searchPageSize]
} else {
params = ["page": curPageIndex + 1,
"page_size": searchPageSize]
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHHomeListTotalModel.deserialize(from: dic as? Dictionary) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
for item in result.data {
item.calHeightParam()
}
if firstFlag {
self.curPageIndex = 1
self.totalCount = result.total
self.arrHomeNewsData = result.data
} else {
self.curPageIndex = self.curPageIndex + 1
self.arrHomeNewsData?.append(contentsOf: result.data)
}
if let count = self.arrHomeNewsData?.count {
if count == self.totalCount {
self.hasMoreForHomeNews = false
} else {
self.hasMoreForHomeNews = true
}
}
callBackBlock(true, nil)
} else {
self.arrHomeNewsData = []
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func getHKEvent(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.hklist
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
......
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