Commit 156243e0 authored by David黄金龙's avatar David黄金龙

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

* 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  //  首页资讯
  // 首页资讯
parents 0b28de6f 73df3ce1
......@@ -37,6 +37,7 @@
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 */; };
04213B332C4A084600797900 /* YHHomeInfoClassifyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B322C4A084600797900 /* YHHomeInfoClassifyModel.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 */; };
......@@ -634,6 +635,7 @@
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>"; };
04213B322C4A084600797900 /* YHHomeInfoClassifyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeInfoClassifyModel.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>"; };
......@@ -2581,6 +2583,7 @@
A567E5722BD7643D00D5D5A0 /* YHWebModel.swift */,
A5A89FD62C256B94005A71DD /* YHHomeLastMessageModel.swift */,
A5B6ED752C2593A1001B6732 /* YHSignerInfoModel.swift */,
04213B322C4A084600797900 /* YHHomeInfoClassifyModel.swift */,
);
path = M;
sourceTree = "<group>";
......@@ -3767,6 +3770,7 @@
045EEEB82B9F171A0022A143 /* YHWorkExampleMessageView.swift in Sources */,
04F4B76B2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift in Sources */,
045EEEA22B9F171A0022A143 /* YHWorkExperienceProjectModel.swift in Sources */,
04213B332C4A084600797900 /* YHHomeInfoClassifyModel.swift in Sources */,
04F316442C3568F000024164 /* YHAboutGalaxyViewController.swift in Sources */,
0435FA832BA2DEB100024EAE /* YHCardButton.swift in Sources */,
045EEECA2B9F171A0022A143 /* YHMyDocumentsListViewController.swift in Sources */,
......
......@@ -91,6 +91,7 @@ class YHHomeIdentityViewController: YHBaseViewController {
}
func createUI() {
gk_navigationBar.isHidden = true
self.view.addSubview(self.tableView)
self.view.addSubview(self.subTabBar)
self.subTabBar.snp.makeConstraints { make in
......
......@@ -12,6 +12,8 @@ import JXSegmentedView
class YHHomeInfoDetailContainerViewController: YHBaseViewController {
var customTitle:String = ""
var classifyId:Int = 0
var isHaveHot: Bool = true // 是否有精品
lazy var tabTitles: [String] = {
if isHaveHot {
......@@ -24,9 +26,12 @@ class YHHomeInfoDetailContainerViewController: YHBaseViewController {
let vc1 = YHHomeInfoDetailViewController()
vc1.isHot = false
vc1.isShowTab = self.isHaveHot
vc1.classifyId = self.classifyId
let vc2 = YHHomeInfoDetailViewController()
vc2.isHot = true
vc2.isShowTab = self.isHaveHot
vc2.classifyId = self.classifyId
if isHaveHot {
return [vc1, vc2]
......@@ -89,7 +94,7 @@ class YHHomeInfoDetailContainerViewController: YHBaseViewController {
make.height.equalTo(44)
}
self.listContainerView.snp.makeConstraints { make in
let gap = isHaveHot ? 44.0+19.0 : 0.0
let gap = isHaveHot ? 44.0+19.0 : 19.0
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+gap)
make.left.equalTo(0)
make.right.equalTo(0)
......
......@@ -12,6 +12,7 @@ import JXSegmentedView
class YHHomeInfoDetailViewController: YHBaseViewController {
var isHot:Bool = false // 是否是精品
var classifyId:Int = 0
var isShowTab: Bool = true
lazy var viewModel : YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
......@@ -40,6 +41,14 @@ class YHHomeInfoDetailViewController: YHBaseViewController {
return collectinoView
}()
lazy var emptyDataTipsView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无内容", kEmptyCommonBgName)
let topMargin = 310-k_Height_NavigationtBarAndStatuBar
view.topMargin = topMargin
view.isHidden = true
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.setupUI()
......@@ -50,12 +59,14 @@ class YHHomeInfoDetailViewController: YHBaseViewController {
gk_navigationBar.isHidden = true
self.view.backgroundColor = .white
self.view.addSubview(self.collectView)
self.view.addSubview(self.emptyDataTipsView)
self.collectView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.top.bottom.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)
}
self.emptyDataTipsView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}
......@@ -123,7 +134,8 @@ extension YHHomeInfoDetailViewController: JXSegmentedListContainerViewListDelega
extension YHHomeInfoDetailViewController {
// 获取最新资讯
func getTheNewestInfoList(isFirstPage: Bool) {
self.viewModel.getList(isFirsPage: isFirstPage, isHot: self.isHot) { success, error in
let haveHot = self.isHot ? self.isHot : nil
self.viewModel.getList(isFirsPage: isFirstPage, isHot: haveHot, classifyId: classifyId) { success, error in
self.collectView.reloadData()
self.collectView.es.stopPullToRefresh()
self.collectView.es.stopLoadingMore()
......@@ -131,6 +143,9 @@ extension YHHomeInfoDetailViewController {
self.collectView.es.noticeNoMoreData()
self.collectView.footer?.alpha = 1
}
let count = self.viewModel.arrHomeNewsData?.count ?? 0
self.emptyDataTipsView.isHidden = (count > 0)
self.collectView.isHidden = (count <= 0)
}
}
}
......
......@@ -16,7 +16,7 @@ class YHHomeInformationViewController: YHBaseViewController {
return viewModel
}()
var sectionItems:[String] = ["", "", "", ""]
var sectionItems:[YHHomeInfoClassifyModel?] = []
lazy var collectView = {
// 设置布局方向
......@@ -33,6 +33,7 @@ class YHHomeInformationViewController: YHBaseViewController {
collectinoView.alwaysBounceVertical = true
collectinoView.showsVerticalScrollIndicator = false
collectinoView.es.addYHPullToRefresh {
self.getClassifies()
self.getTheNewestInfoList(isFirstPage: true)
}
collectinoView.es.addInfiniteScrolling {
......@@ -43,6 +44,7 @@ class YHHomeInformationViewController: YHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
gk_navigationBar.isHidden = true
self.view.backgroundColor = .white
self.view.addSubview(self.collectView)
self.collectView.snp.makeConstraints { make in
......@@ -51,7 +53,7 @@ class YHHomeInformationViewController: YHBaseViewController {
make.left.equalTo(20)
make.right.equalTo(-20)
}
self.getClassifies()
self.getTheNewestInfoList(isFirstPage:true)
}
}
......@@ -121,6 +123,9 @@ extension YHHomeInformationViewController : CollectionViewWaterfallLayoutDelegat
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForHeaderInSection section: Int) -> Float {
if self.sectionItems.count <= 0 {
return 0.0
}
var row = self.sectionItems.count/3
if row%3 != 0 {
row = row + 1
......@@ -138,6 +143,15 @@ extension YHHomeInformationViewController: JXSegmentedListContainerViewListDeleg
}
extension YHHomeInformationViewController {
// 获取栏目
func getClassifies() {
self.viewModel.getHomeInfoClassifies { success, error in
self.sectionItems.removeAll()
self.sectionItems.append(contentsOf: self.viewModel.classifyArr)
self.collectView.reloadData()
}
}
// 获取最新资讯
func getTheNewestInfoList(isFirstPage: Bool) {
self.viewModel.getList(isFirsPage: isFirstPage) { success, error in
......
//
// YHHomeInfoClassifyModel.swift
// galaxy
//
// Created by edy on 2024/7/19.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHHomeInfoClassifyModel: SmartCodable {
var id: Int = 0
var type: Int = 0
var pid: Int = 0
var sort: Int = 0
var level: Int = 0
var isShow: Int = 0
var isMessage: Int = 0
var hotNum: Int = 0
var name: String = ""
var imgURL: String = ""
enum CodingKeys: String, CodingKey {
case id, type, pid, sort, level
case isShow = "is_show"
case isMessage = "is_message"
case hotNum = "hot_num"
case name
case imgURL = "img_url"
}
required init() {
}
}
......@@ -11,7 +11,7 @@ import UIKit
class YHHomeInfoSectionCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHHomeInfoSectionCell"
lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
......@@ -22,8 +22,8 @@ class YHHomeInfoSectionCell: UICollectionViewCell {
}()
lazy var imgView: UIImageView = {
let imgV = UIImageView()
imgV.backgroundColor = .red
let imgV = UIImageView(image: UIImage(named: "global_default_image"))
imgV.clipsToBounds = true
return imgV
}()
......@@ -35,7 +35,7 @@ class YHHomeInfoSectionCell: UICollectionViewCell {
super.init(frame: frame)
setupUI()
}
func setupUI() {
self.addSubview(self.imgView)
self.addSubview(self.titleLabel)
......@@ -49,4 +49,10 @@ class YHHomeInfoSectionCell: UICollectionViewCell {
make.height.equalTo(20)
}
}
func updateModel(_ model: YHHomeInfoClassifyModel) {
self.titleLabel.text = model.name
self.imgView.kf.setImage(with: URL(string: model.imgURL), placeholder: UIImage(named: "global_default_image"))
}
}
......@@ -16,17 +16,23 @@ class YHHomeInfoSectionHeadView: UICollectionReusableView {
static let reuseIdentifier = "YHHomeInfoSectionHeadView"
var items:[String] = [] {
var items:[YHHomeInfoClassifyModel?] = [] {
didSet {
self.collectView.reloadData()
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.bottomLineView.snp.updateConstraints { make in
make.top.equalTo(self.collectView.snp.bottom).offset(items.count > 0 ? 4.0 : 0.0)
}
self.collectView.isHidden = items.count <= 0
self.bottomLineView.isHidden = items.count <= 0
self.titleLabel.isHidden = items.count <= 0
self.setNeedsLayout()
self.layoutIfNeeded()
}
......@@ -104,16 +110,23 @@ extension YHHomeInfoSectionHeadView: UICollectionViewDelegate, UICollectionViewD
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeInfoSectionCell.cellReuseIdentifier, for: indexPath) as! YHHomeInfoSectionCell
if 0 <= indexPath.row, indexPath.row < self.items.count {
if let item = self.items[indexPath.row] {
cell.updateModel(item)
}
}
return cell
}
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)
if let item = self.items[indexPath.row] {
let vc = YHHomeInfoDetailContainerViewController()
vc.customTitle = item.name
vc.isHaveHot = item.hotNum > 0
vc.classifyId = item.id
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
}
......
......@@ -15,6 +15,7 @@ class YHHomePageViewModel : YHBaseViewModel {
var banners: [YHBannerModel]?
var classify: [YHHomeClassifyModel]?
var hkList: [YHHKEventModel]?
var classifyArr:[YHHomeInfoClassifyModel?] = []
//首页相关参数
private var curPageIndex : Int = 1
......@@ -319,7 +320,7 @@ extension YHHomePageViewModel {
}
}
func getList(isFirsPage : Bool, isHot:Bool? = nil, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
func getList(isFirsPage : Bool, isHot:Bool? = nil, classifyId: Int? = nil, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = ["page": curPageIndex,
"page_size": searchPageSize]
if isFirsPage {
......@@ -333,6 +334,10 @@ extension YHHomePageViewModel {
if let isHot = isHot {
params["is_hot"] = isHot ? 1 : 0
}
if let classifyId = classifyId {
params["classify_id[0]"] = classifyId
}
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 }
......@@ -376,6 +381,33 @@ extension YHHomePageViewModel {
}
}
func getHomeInfoClassifies(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["is_message": 1]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.homeInfoClassifies
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 = [YHHomeInfoClassifyModel].deserialize(array: dic as? [Any]) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
self.classifyArr = []
callBackBlock(false,err)
return
}
self.classifyArr = result
callBackBlock(true, nil)
} else {
self.classifyArr = []
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
self.classifyArr = []
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
......
......@@ -66,6 +66,8 @@ class YHAllApiName {
static let hklist = "infoflow/tool/list"
// 点赞、收藏、最近浏览数量
static let likeCollect = "infoflow/article/myArticleRecord"
// 首页资讯栏目
static let homeInfoClassifies = "infoflow/classify/classifies"
}
......
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