Commit bcfaed22 authored by pete谢兆麟's avatar pete谢兆麟

服务首页接口添加

parent 7f5bfda3
...@@ -240,6 +240,7 @@ ...@@ -240,6 +240,7 @@
049AC4C82BC513AB00F857F4 /* YHOrderListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */; }; 049AC4C82BC513AB00F857F4 /* YHOrderListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */; };
049AC4CA2BC5141600F857F4 /* YHServerNoOrderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */; }; 049AC4CA2BC5141600F857F4 /* YHServerNoOrderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */; };
049AC4CC2BC6615500F857F4 /* YHHomeListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */; }; 049AC4CC2BC6615500F857F4 /* YHHomeListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */; };
049AC4CE2BC674A700F857F4 /* YHHomeClassifyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */; };
04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */; }; 04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */; };
04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */; }; 04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */; };
04A671592B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A671582B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift */; }; 04A671592B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A671582B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift */; };
...@@ -674,6 +675,7 @@ ...@@ -674,6 +675,7 @@
049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOrderListView.swift; sourceTree = "<group>"; }; 049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOrderListView.swift; sourceTree = "<group>"; };
049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServerNoOrderView.swift; sourceTree = "<group>"; }; 049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServerNoOrderView.swift; sourceTree = "<group>"; };
049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeListModel.swift; sourceTree = "<group>"; }; 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeListModel.swift; sourceTree = "<group>"; };
049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeClassifyModel.swift; sourceTree = "<group>"; };
04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadTypeCell.swift; sourceTree = "<group>"; }; 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadTypeCell.swift; sourceTree = "<group>"; };
04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFilePreviewTool.swift; sourceTree = "<group>"; }; 04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFilePreviewTool.swift; sourceTree = "<group>"; };
04A671582B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadSheetView.swift; sourceTree = "<group>"; }; 04A671582B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadSheetView.swift; sourceTree = "<group>"; };
...@@ -2145,6 +2147,7 @@ ...@@ -2145,6 +2147,7 @@
A5C5B2E92B4ECA4D00A7C5D1 /* YHDavidModel0.swift */, A5C5B2E92B4ECA4D00A7C5D1 /* YHDavidModel0.swift */,
A53F42B82BC3DCA9009CAC70 /* YHHomeKingKongBlockModel.swift */, A53F42B82BC3DCA9009CAC70 /* YHHomeKingKongBlockModel.swift */,
049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */, 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */,
049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2763,6 +2766,7 @@ ...@@ -2763,6 +2766,7 @@
044CF8D62BBA57DC00008CE8 /* YHFailPromptView.swift in Sources */, 044CF8D62BBA57DC00008CE8 /* YHFailPromptView.swift in Sources */,
A5ACE9562B4564F7002C94D2 /* YHBouncesContentView.swift in Sources */, A5ACE9562B4564F7002C94D2 /* YHBouncesContentView.swift in Sources */,
A554A5122B99715000EA5973 /* YHConstantArrayData.swift in Sources */, A554A5122B99715000EA5973 /* YHConstantArrayData.swift in Sources */,
049AC4CE2BC674A700F857F4 /* YHHomeClassifyModel.swift in Sources */,
045EEE962B9F171A0022A143 /* YHPreviewInfoCertificatePictureItemsView.swift in Sources */, 045EEE962B9F171A0022A143 /* YHPreviewInfoCertificatePictureItemsView.swift in Sources */,
A53D381E2BC23794006AE6F7 /* YHMsgViewController.swift in Sources */, A53D381E2BC23794006AE6F7 /* YHMsgViewController.swift in Sources */,
A592FE912BA6CC010062FACA /* YHCertificateEntryHeadView.swift in Sources */, A592FE912BA6CC010062FACA /* YHCertificateEntryHeadView.swift in Sources */,
......
...@@ -90,6 +90,11 @@ class YHHomePageViewController: YHBaseViewController { ...@@ -90,6 +90,11 @@ class YHHomePageViewController: YHBaseViewController {
guard let self = self else { return } guard let self = self else { return }
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? [] self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? []
} }
viewModel.getHomeClassify {[weak self] success, error in
guard let self = self else { return }
}
} }
} }
......
//
// YHHomeClassifyModel.swift
// galaxy
//
// Created by EDY on 2024/4/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeClassifyModel: YHBaseModel {
var id: Int = 0
var name: String = ""
var pid: Int = 0
var type: Int = 0
var children: [YHClassifyModel] = []
}
class YHClassifyModel: YHBaseModel {
var children: [String] = []
var id: Int = 0
var name: String = ""
var pid: Int = 0
var type: Int = 0
}
...@@ -15,4 +15,7 @@ class YHHomeListModel: YHBaseModel { ...@@ -15,4 +15,7 @@ class YHHomeListModel: YHBaseModel {
var content: String = "" var content: String = ""
var view_count: Int = 0 var view_count: Int = 0
var img_url: String = "" var img_url: String = ""
var type: Int = 0
var img_width: Int = 0
var img_height: Int = 0
} }
...@@ -13,6 +13,7 @@ class YHHomePageViewModel : YHBaseViewModel { ...@@ -13,6 +13,7 @@ class YHHomePageViewModel : YHBaseViewModel {
var configModel:YHHomeCofigMode? var configModel:YHHomeCofigMode?
var lists: [YHHomeListModel]? var lists: [YHHomeListModel]?
var banners: [YHBannerModel]? var banners: [YHBannerModel]?
var classify: [YHHomeClassifyModel]?
} }
//接口 //接口
...@@ -66,7 +67,7 @@ extension YHHomePageViewModel { ...@@ -66,7 +67,7 @@ extension YHHomePageViewModel {
func getHomeBanner(_ type: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) { func getHomeBanner(_ type: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["type": type] let params: [String : Any] = ["type": type]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.banner let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.banner
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return } guard let self = self else { return }
//1. json字符串 转 对象 //1. json字符串 转 对象
if json.code == 200 { if json.code == 200 {
...@@ -85,4 +86,52 @@ extension YHHomePageViewModel { ...@@ -85,4 +86,52 @@ extension YHHomePageViewModel {
callBackBlock(false,err) callBackBlock(false,err)
} }
} }
func getHomeClassify(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.classify
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = [YHHomeClassifyModel].deserialize(from: dic as? [Any]) else {
callBackBlock(false,nil)
return
}
self.classify = result as? [YHHomeClassifyModel]
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func getList(_ classifyID: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10,
"classify_id": classifyID]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
// guard let result = [YHHomeListModel].deserialize(from: dic as? [Any]) else {
// callBackBlock(false,nil)
// return
// }
// self.lists = result as? [YHHomeListModel]
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
} }
...@@ -12,6 +12,7 @@ import JXSegmentedView ...@@ -12,6 +12,7 @@ import JXSegmentedView
class YHServiceListViewController: YHBaseViewController { class YHServiceListViewController: YHBaseViewController {
private let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel() private let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel()
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var orderListView: YHOrderListView! var orderListView: YHOrderListView!
var normalView: YHServerNoOrderView! var normalView: YHServerNoOrderView!
...@@ -32,6 +33,27 @@ class YHServiceListViewController: YHBaseViewController { ...@@ -32,6 +33,27 @@ class YHServiceListViewController: YHBaseViewController {
extension YHServiceListViewController { extension YHServiceListViewController {
func loadData() { func loadData() {
homeViewModel.getHomeBanner(1){[weak self] success, error in
guard let self = self else { return }
self.normalView.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? []
}
homeViewModel.getHomeClassify{[weak self] success, error in
guard let self = self, let classify = self.homeViewModel.classify else { return }
for item in classify {
let model = item as YHHomeClassifyModel
if model.id == 1 {
self.normalView.sectionView.items = model.children
let classifyID = model.children.first?.id ?? 0
self.homeViewModel.getList(classifyID) {[weak self] success, error in
guard let self = self else { return }
}
}
}
}
if YHLoginManager.shared.isLogin() == false { if YHLoginManager.shared.isLogin() == false {
self.handleRightUI() self.handleRightUI()
return return
......
...@@ -12,7 +12,12 @@ import FSPagerView ...@@ -12,7 +12,12 @@ import FSPagerView
class YHServiceBannerView: UIView { class YHServiceBannerView: UIView {
// 位置、大小、图片、文本 // 位置、大小、图片、文本
fileprivate var dataArr: [YHBannerModel] = [YHBannerModel(),YHBannerModel(),YHBannerModel(),YHBannerModel(),YHBannerModel()] var dataArr: [YHBannerModel] = [] {
didSet {
self.pageControl.numberOfPages = self.dataArr.count
bannerView.reloadData()
}
}
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
...@@ -89,12 +94,9 @@ extension YHServiceBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -89,12 +94,9 @@ extension YHServiceBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
if let url = URL(string: model.img_url) { if let url = URL(string: model.img_url) {
cell.imageView?.kf.setImage(with: url) cell.imageView?.kf.setImage(with: url)
} }
cell.textLabel?.text = model.name cell.textLabel?.text = model.name
} }
cell.imageView?.contentMode = .scaleAspectFill cell.imageView?.contentMode = .scaleAspectFill
cell.backgroundColor = .contentBkgColor cell.backgroundColor = .contentBkgColor
cell.contentView.layer.shadowColor = UIColor.clear.cgColor cell.contentView.layer.shadowColor = UIColor.clear.cgColor
......
...@@ -10,7 +10,13 @@ import UIKit ...@@ -10,7 +10,13 @@ import UIKit
class YHServiceSectionView: UIView { class YHServiceSectionView: UIView {
var items: [String] = []
var items: [YHClassifyModel] = [] {
didSet {
self.myCollectView.reloadData()
}
}
var selectIndex = 0 var selectIndex = 0
lazy var myCollectView = { lazy var myCollectView = {
// 设置布局方向 // 设置布局方向
...@@ -32,19 +38,13 @@ class YHServiceSectionView: UIView { ...@@ -32,19 +38,13 @@ class YHServiceSectionView: UIView {
collectinoView.alwaysBounceVertical = true collectinoView.alwaysBounceVertical = true
return collectinoView return collectinoView
}() }()
var dataSource: YHScemeHeadModel? {
didSet {
updateAllViews()
}
}
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
backgroundColor = .white backgroundColor = .white
setUpView() setUpView()
self.items = ["优才","高才","留学","专才"] // self.items = ["优才","高才","留学","专才"]
self.myCollectView.reloadData() // self.myCollectView.reloadData()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
...@@ -62,10 +62,6 @@ class YHServiceSectionView: UIView { ...@@ -62,10 +62,6 @@ class YHServiceSectionView: UIView {
// } // }
} }
func updateAllViews() {
guard let model = dataSource else { return }
}
} }
extension YHServiceSectionView: UICollectionViewDelegate, UICollectionViewDataSource { extension YHServiceSectionView: UICollectionViewDelegate, UICollectionViewDataSource {
...@@ -89,6 +85,7 @@ extension YHServiceSectionView: UICollectionViewDelegate, UICollectionViewDataSo ...@@ -89,6 +85,7 @@ extension YHServiceSectionView: UICollectionViewDelegate, UICollectionViewDataSo
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
selectIndex = indexPath.row selectIndex = indexPath.row
collectionView.reloadData() collectionView.reloadData()
print("index is \(indexPath.row)") print("index is \(indexPath.row)")
} }
} }
...@@ -121,7 +118,7 @@ class YHServiceSectionCollectionViewCell: UICollectionViewCell { ...@@ -121,7 +118,7 @@ class YHServiceSectionCollectionViewCell: UICollectionViewCell {
descripeLable.textColor = UIColor(hex: 0x94a3bb) descripeLable.textColor = UIColor(hex: 0x94a3bb)
} }
var dataSource: String? { var dataSource: YHClassifyModel? {
didSet { didSet {
updataAllSubViews() updataAllSubViews()
} }
...@@ -159,6 +156,6 @@ class YHServiceSectionCollectionViewCell: UICollectionViewCell { ...@@ -159,6 +156,6 @@ class YHServiceSectionCollectionViewCell: UICollectionViewCell {
func updataAllSubViews() { func updataAllSubViews() {
guard let dataSource = dataSource else { return } guard let dataSource = dataSource else { return }
descripeLable.text = dataSource descripeLable.text = dataSource.name
} }
} }
...@@ -18,7 +18,10 @@ class YHAllApiName { ...@@ -18,7 +18,10 @@ class YHAllApiName {
static let consult = "infoflow/home/consult" static let consult = "infoflow/home/consult"
//获取首页展示的banner //获取首页展示的banner
static let banner = "infoflow/banner/list" static let banner = "infoflow/banner/list"
//获取栏目
static let classify = "infoflow/classify/list"
//获取资讯
static let article = "infoflow/article/list"
} }
//order 模块 //order 模块
......
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