Commit 57c77d97 authored by Steven杜宇's avatar Steven杜宇

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

parents 51f3e487 b0c61a3c
......@@ -233,6 +233,8 @@
0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */; };
0480976D2BA158A1000B9DCA /* YHCertificateListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */; };
048097712BA18D66000B9DCA /* YHCertificateSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */; };
048B2A442BC7901900A93BF0 /* YHHomeWebViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A432BC7901900A93BF0 /* YHHomeWebViewModel.swift */; };
048B2A462BC7912400A93BF0 /* YHWebModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A452BC7912400A93BF0 /* YHWebModel.swift */; };
0493B3DC2BA7EFE600AF9393 /* YHCertificateSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0493B3DB2BA7EFE600AF9393 /* YHCertificateSearchViewController.swift */; };
0493B3DE2BA80C2300AF9393 /* YHCertificateFilterButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0493B3DD2BA80C2300AF9393 /* YHCertificateFilterButton.swift */; };
049537852BA9B28500AF7E59 /* YHCertificateTemplateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049537842BA9B28500AF7E59 /* YHCertificateTemplateCell.swift */; };
......@@ -322,6 +324,8 @@
A592FE932BA6CFFC0062FACA /* YHCertificateEntryBottomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A592FE922BA6CFFC0062FACA /* YHCertificateEntryBottomView.swift */; };
A592FE952BA6D23C0062FACA /* YHCertificateEntryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A592FE942BA6D23C0062FACA /* YHCertificateEntryCell.swift */; };
A592FE972BA6DB340062FACA /* YHCertificateViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A592FE962BA6DB340062FACA /* YHCertificateViewModel.swift */; };
A5A4FD632BC79901001EF9F7 /* YHConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FD622BC79901001EF9F7 /* YHConfigManager.swift */; };
A5A4FD652BC799A9001EF9F7 /* YHConfigModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FD642BC799A9001EF9F7 /* YHConfigModel.swift */; };
A5ACE9272B4564F7002C94D2 /* YHLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5ACE8DB2B4564F7002C94D2 /* YHLoginViewController.swift */; };
A5ACE9282B4564F7002C94D2 /* YHSmsCodeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5ACE8DE2B4564F7002C94D2 /* YHSmsCodeView.swift */; };
A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5ACE8E02B4564F7002C94D2 /* YHSmsCodeInputView.swift */; };
......@@ -670,6 +674,8 @@
0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateInfoCell.swift; sourceTree = "<group>"; };
0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateListVC.swift; sourceTree = "<group>"; };
048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchBar.swift; sourceTree = "<group>"; };
048B2A432BC7901900A93BF0 /* YHHomeWebViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeWebViewModel.swift; sourceTree = "<group>"; };
048B2A452BC7912400A93BF0 /* YHWebModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHWebModel.swift; sourceTree = "<group>"; };
0493B3DB2BA7EFE600AF9393 /* YHCertificateSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchViewController.swift; sourceTree = "<group>"; };
0493B3DD2BA80C2300AF9393 /* YHCertificateFilterButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateFilterButton.swift; sourceTree = "<group>"; };
049537842BA9B28500AF7E59 /* YHCertificateTemplateCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateTemplateCell.swift; sourceTree = "<group>"; };
......@@ -765,6 +771,8 @@
A592FE922BA6CFFC0062FACA /* YHCertificateEntryBottomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateEntryBottomView.swift; sourceTree = "<group>"; };
A592FE942BA6D23C0062FACA /* YHCertificateEntryCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateEntryCell.swift; sourceTree = "<group>"; };
A592FE962BA6DB340062FACA /* YHCertificateViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCertificateViewModel.swift; sourceTree = "<group>"; };
A5A4FD622BC79901001EF9F7 /* YHConfigManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHConfigManager.swift; sourceTree = "<group>"; };
A5A4FD642BC799A9001EF9F7 /* YHConfigModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHConfigModel.swift; sourceTree = "<group>"; };
A5ACE8DB2B4564F7002C94D2 /* YHLoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHLoginViewController.swift; sourceTree = "<group>"; };
A5ACE8DE2B4564F7002C94D2 /* YHSmsCodeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHSmsCodeView.swift; sourceTree = "<group>"; };
A5ACE8E02B4564F7002C94D2 /* YHSmsCodeInputView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHSmsCodeInputView.swift; sourceTree = "<group>"; };
......@@ -2154,6 +2162,8 @@
A53F42B82BC3DCA9009CAC70 /* YHHomeKingKongBlockModel.swift */,
049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */,
049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */,
A5A4FD642BC799A9001EF9F7 /* YHConfigModel.swift */,
048B2A452BC7912400A93BF0 /* YHWebModel.swift */,
);
path = M;
sourceTree = "<group>";
......@@ -2199,6 +2209,7 @@
A53D381F2BC243F1006AE6F7 /* YHStartPageViewController.swift */,
A5173D672BC399B9007D4E74 /* YHHomePageViewController.swift */,
044E1E802BC3BBC200A3B4AF /* YHSearchInfomationVC.swift */,
A5A4FD622BC79901001EF9F7 /* YHConfigManager.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2228,6 +2239,7 @@
isa = PBXGroup;
children = (
A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */,
048B2A432BC7901900A93BF0 /* YHHomeWebViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
......@@ -2459,6 +2471,7 @@
045EEF112B9F171A0022A143 /* YHMainInformationModel.swift in Sources */,
A58AC09D2BABD59600A30FA9 /* YHFileListModel.swift in Sources */,
045EEEFF2B9F171A0022A143 /* YHSaveAndSubmitView.swift in Sources */,
A5A4FD632BC79901001EF9F7 /* YHConfigManager.swift in Sources */,
A5173D682BC399B9007D4E74 /* YHHomePageViewController.swift in Sources */,
045EEF0E2B9F171A0022A143 /* YHBasicInfoFillView.swift in Sources */,
045EEEA12B9F171A0022A143 /* YHWorkExperienceDetailModel.swift in Sources */,
......@@ -2496,6 +2509,7 @@
A5ACE93A2B4564F7002C94D2 /* NSAttributedString+Extension.swift in Sources */,
A53F42BB2BC3DE6F009CAC70 /* YHHomeKingKongBlockItem.swift in Sources */,
04E86E662B86EB6F00A35F4B /* YHLoginManager.swift in Sources */,
048B2A442BC7901900A93BF0 /* YHHomeWebViewModel.swift in Sources */,
04A7BD112BA4218B00BD35A2 /* YHMyDocumentsListViewModel.swift in Sources */,
A5EF21352BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift in Sources */,
A5EF213B2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift in Sources */,
......@@ -2624,6 +2638,7 @@
045EEE942B9F171A0022A143 /* YHPreviewInfoQuestionAndAnswerItemView.swift in Sources */,
045EEED32B9F171A0022A143 /* YHScoreItemCell.swift in Sources */,
045EEEEE2B9F171A0022A143 /* YHCertificateUploadVC.swift in Sources */,
A5A4FD652BC799A9001EF9F7 /* YHConfigModel.swift in Sources */,
A510441A2B495DD0006B60BB /* UIView+Extension.swift in Sources */,
A5ACE93E2B4564F7002C94D2 /* UIImage+Extension.swift in Sources */,
A587F7C02BBADBE1002D9781 /* YHHKPlanItemView.swift in Sources */,
......@@ -2659,6 +2674,7 @@
045EEED12B9F171A0022A143 /* YHScorePersonInfoCell.swift in Sources */,
044CF8D42BB6BCF700008CE8 /* YHSignatureUploadTableViewCell.swift in Sources */,
045EEF0D2B9F171A0022A143 /* YHBasicInfoFillCell.swift in Sources */,
048B2A462BC7912400A93BF0 /* YHWebModel.swift in Sources */,
045EEEEC2B9F171A0022A143 /* YHBrotherInfoVC.swift in Sources */,
0477E17A2BA41C7E00436346 /* YHCertificateModel.swift in Sources */,
045EEF242B9F171A0022A143 /* YHStepView.swift in Sources */,
......@@ -2912,7 +2928,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......@@ -3113,7 +3129,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......@@ -3155,7 +3171,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......
......@@ -15,7 +15,6 @@ import DeviceKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// JPush服务注册
......@@ -37,6 +36,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//4.本地用户信息加载
YHLoginManager.shared.loadLocalUserInfoData()
YHConfigManager.shared.loadConfigData()
// YHAnalytics.analyticsStart(launchOptions: launchOptions)
......@@ -150,6 +151,22 @@ extension AppDelegate {
window?.makeKeyAndVisible()
}
// private func requestData() {
// self.homeReqVM.getHomeConfig { flag, error in
// if flag == true {
// //1. 调用model 刷新界面
// YHHUD.flash(message: "数据已更新")
// } else {
// //2. 给出 错误提示
// if let error = error {
// YHHUD.flash(message: error.errorMsg)
// }
// }
// }
// }
}
//
// YHConfigManager.swift
// galaxy
//
// Created by davidhuangA on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHConfigManager: NSObject {
static let shared = YHConfigManager()
lazy var reqVM: YHHomePageViewModel = {
let vm = YHHomePageViewModel()
return vm
}()
private var loadNewDataFlag : Bool = false
private override init() {
super.init()
// loadConfigData()
}
var h5Url : String {
return reqVM.configModel?.h5_url ?? ""
}
}
extension YHConfigManager {
func loadConfigData() {
reqVM.getHomeConfig { flag, error in
if flag {
self.loadNewDataFlag = true
}
}
}
}
......@@ -18,35 +18,13 @@ class YHHomePageViewController: YHBaseViewController {
}()
lazy var homeCollectView = {
// // 设置布局方向
// let flowLayout = UICollectionViewFlowLayout()
// let margin = 20.0
// let gap = 20.0
// let itemWidth = ceil((KScreenWidth - 2*margin - gap)/2.0)
// flowLayout.itemSize = CGSize(width: itemWidth, height: 210 + 87 + 4)
// flowLayout.minimumInteritemSpacing = 10.0
// flowLayout.minimumLineSpacing = 10.0
// flowLayout.scrollDirection = .vertical
//
// let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
// collectinoView.backgroundColor = .white
// collectinoView.register(YHDavidTestCollectionViewCell.self, forCellWithReuseIdentifier:YHDavidTestCollectionViewCell.cellReuseIdentifier)
// collectinoView.delegate = self
// collectinoView.dataSource = self
// collectinoView.showsVerticalScrollIndicator = false
//
// collectinoView.translatesAutoresizingMaskIntoConstraints = false
// collectinoView.alwaysBounceVertical = true
//
// 设置布局方向
let flowLayout = YHHomeCollectionLayout()
flowLayout.minimumInteritemSpacing = 7.0
flowLayout.minimumColumnSpacing = 10.0
flowLayout.sectionInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
let collectinoView = YHGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
// collectinoView.contentInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
......@@ -82,7 +60,7 @@ class YHHomePageViewController: YHBaseViewController {
}
func getData() {
viewModel.getHomeList {[weak self] success, error in
viewModel.getHomeNewsList {[weak self] success, error in
guard let self = self else { return }
self.homeCollectView.reloadData()
}
......@@ -91,10 +69,6 @@ class YHHomePageViewController: YHBaseViewController {
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? []
}
viewModel.getHomeClassify {[weak self] success, error in
guard let self = self else { return }
}
}
}
......@@ -119,114 +93,43 @@ private extension YHHomePageViewController {
homeHeaderView.frame = CGRect(x: 20, y: -YHHomeHeadView.viewH, width: KScreenWidth - 40, height: YHHomeHeadView.viewH)
homeCollectView.addSubview(homeHeaderView)
homeCollectView.contentInset = UIEdgeInsets(top: YHHomeHeadView.viewH, left: 0, bottom: 0, right: 0)
homeCollectView.contentInset = UIEdgeInsets(top: YHHomeHeadView.viewH, left: 0, bottom: 20, right: 0)
homeCollectView.es.addInfiniteScrolling {
self.loadFakeData()
}
loadFirstItem()
homeCollectView.reloadData()
}
func loadFirstItem() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "")]
self.homeCollectView.es.stopPullToRefresh(ignoreDate: true,ignoreFooter: false)
self.homeCollectView.reloadData()
}
}
func loadFakeData() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.homeCollectView.es.stopLoadingMore()
self.homeCollectView.reloadData()
}
}
func getImageSize(_ url: String?) -> CGSize {
guard let urlStr = url, urlStr.count != 0 else {
return CGSize.zero
}
let tempUrl = URL(string: urlStr)
let imageSourceRef = CGImageSourceCreateWithURL(tempUrl! as CFURL, nil)
var width: CGFloat = 0
var height: CGFloat = 0
if let imageSRef = imageSourceRef {
let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSRef, 0, nil)
if let imageP = imageProperties {
let imageDict = imageP as Dictionary
width = imageDict[kCGImagePropertyPixelWidth] as! CGFloat
height = imageDict[kCGImagePropertyPixelHeight] as! CGFloat
}
}
return CGSize(width: width, height: height)
}
}
extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.viewModel.lists?.count ?? 0
return self.viewModel.arrHomeNewsData.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHHomeCollectionViewCell
cell.listModel = self.viewModel.lists?[indexPath.row]
cell.listModel = self.viewModel.arrHomeNewsData[indexPath.row]
return cell
}
// func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
// print("index is \(indexPath.row)")
// }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let model = self.viewModel.arrHomeNewsData[indexPath.row]
let vc = YHHomeWebViewController()
vc.url = "https://test-hkdiy-h5.galaxy-immi.com/articleDetail.html?id=\(model?.id ?? 0)"
vc.id = model?.id ?? 0
self.navigationController?.pushViewController(vc)
}
}
extension YHHomePageViewController : CollectionViewWaterfallLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
guard let model = self.viewModel.lists?[indexPath.row] else { return CGSize(width: 0, height: 0) }
let text = model.title
let width = (KScreenWidth - 47) / 2
let font = UIFont.PFSC_R(ofSize: 14) // 字体大小
let maxWidth = width - 16 // 最大宽度限制
// 创建NSAttributedString对象并设置属性
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
_ = NSMutableAttributedString(string: text, attributes: attributes)
// 根据指定的最大宽度和字体大小计算文本的高度
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
var textHeight = size.height
if textHeight > 40 {
textHeight = 40
}
let imageSize = getImageSize(model.img_url)
var imageHeight = 0.0
if imageSize.width == 0 {
imageHeight = width
} else {
imageHeight = width * imageSize.height/imageSize.width
if imageHeight > 280 {
imageHeight = 280
}
}
let totalHeight = imageHeight + textHeight + 46
return CGSize(width: width, height: totalHeight)
// let margin = 20.0
// let gap = 7.0
// let itemWidth = ceil((KScreenWidth - 2*margin - gap)/2.0)
// let arrItemH : [CGFloat] = [100,150,200,250,300,350,400]
//
// let HHH = arrItemH[Int.random(in: 0...6)]
// return CGSize(width: itemWidth, height: HHH)
guard let model = self.viewModel.arrHomeNewsData[indexPath.row] else { return CGSize.zero }
return CGSize(width: model.img_width_cell, height: model.img_height_cell)
}
}
......@@ -223,17 +223,7 @@ extension YHHomeViewController {
}
private func requestData() {
self.homeReqVM.getHomeConfig { flag, error in
if flag == true {
//1. 调用model 刷新界面
YHHUD.flash(message: "数据已更新")
} else {
//2. 给出 错误提示
if let error = error {
YHHUD.flash(message: error.errorMsg)
}
}
}
}
private func initView()->Void {
......
......@@ -10,22 +10,24 @@ import UIKit
import WebKit
class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
var viewModel: YHHomeWebViewModel!
var webview = WKWebView()
var progBar = UIProgressView()
var bottomView: YHHomeWebBottomView!
var url = "https://upload-cdn.galaxy-immi.com/crm/production/1620271613711.pdf"
var url = ""
var id: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
viewModel = YHHomeWebViewModel()
//获取导航栏高度
let navHeight = self.navigationController?.navigationBar.frame.height
//获取状态栏高度
let statusHeight = k_Height_statusBar()
// 创建wkwebview
webview = WKWebView(frame: CGRect(x: 0, y: statusHeight + navHeight!, width: self.view.frame.width, height: self.view.frame.height))
webview = WKWebView(frame: CGRect(x: 0, y: statusHeight + navHeight!, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight! - 59 - k_Height_safeAreaInsetsBottom()))
webview.navigationDelegate = self
// 创建网址
let url = NSURL(string: url)
......@@ -48,19 +50,55 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
let view = YHHomeWebBottomView()
view.likeBlock = { [weak self] flag in
guard let self = self else { return }
if YHLoginManager.shared.isLogin() == false {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
}
if flag {
YHHUD.flash(message: "已点赞")
self.viewModel.getLike(self.id, 1) {[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "已点赞")
self.getData()
}
}
} else {
YHHUD.flash(message: "已取消点赞")
self.viewModel.getLike(self.id, 0) {[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "已取消点赞")
self.getData()
}
}
}
}
view.starBlock = { [weak self] flag in
guard let self = self else { return }
if YHLoginManager.shared.isLogin() == false {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
vc.modalPresentationStyle = .custom
self.navigationController?.present(vc, animated: true)
return
}
if flag {
YHHUD.flash(message: "已收藏")
self.viewModel.getStar(self.id, 1) {[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "已收藏")
self.getData()
}
}
} else {
YHHUD.flash(message: "已取消收藏")
self.viewModel.getStar(self.id, 0) {[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "已取消收藏")
self.getData()
}
}
}
}
return view
......@@ -70,13 +108,24 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
make.bottom.left.right.equalToSuperview()
make.height.equalTo(59 + k_Height_safeAreaInsetsBottom())
}
getData()
}
deinit {
webview.removeObserver(self, forKeyPath: "estimatedProgress")
}
func getData() {
viewModel.getWebDetail(self.id) {[weak self] success, error in
guard let self = self else { return }
guard let model = self.viewModel.mainModel else { return }
bottomView.likeCount = model.like_count
bottomView.starCount = model.collect_count
bottomView.isStar = model.is_collect
bottomView.isLike = model.is_like
}
}
// MARK: - WKNavigationDelegate
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
......
//
// YHConfigModel.swift
// galaxy
//
// Created by davidhuangA on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHConfigModel : SmartCodable {
var min_version_num : Int = 0
var oss_server : Int = 0
var countdown : Int = 0
var h5_url : String = ""
required init() {
}
}
......@@ -15,7 +15,63 @@ class YHHomeListModel: YHBaseModel {
var content: String = ""
var view_count: Int = 0
var img_url: String = ""
var type: Int = 0
var img_width: Int = 0
var img_height: Int = 0
var type: Int = 0 //文章类型 '文章类型 1视频 2图文 3图片',
var is_like : Bool = false
//网络返回的图片宽高
var img_width: CGFloat = 0
var img_height: CGFloat = 0
//实际使用的图片宽高
var img_width_use : CGFloat = 0
var img_height_use : CGFloat = 0
//cell的宽高
var img_width_cell : CGFloat = 0
var img_height_cell : CGFloat = 0
//描述的高度
var textH : CGFloat = 20.0
func calHeightParam() {
let text = self.title
let width = (KScreenWidth - 47) / 2
let font = UIFont.PFSC_R(ofSize: 14) // 字体大小
let maxWidth = width - 16 // 最大宽度限制
// 创建NSAttributedString对象并设置属性
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
_ = NSMutableAttributedString(string: text, attributes: attributes)
// 根据指定的最大宽度和字体大小计算文本的高度
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
var textHeight : CGFloat = size.height
if textHeight > 40.0 {
textHeight = 40.0
} else if textHeight < 16 {
textHeight = 16
}
self.textH = textHeight
let imageSize = CGSizeMake(CGFloat(self.img_width), CGFloat(self.img_height))
var imageHeight = 0.0
if imageSize.width == 0 {
imageHeight = width
} else {
imageHeight = width * imageSize.height/imageSize.width
if imageHeight > 280 {
imageHeight = 280
}
}
let totalHeight = imageHeight + textHeight + 30 + 16
self.img_width_use = width
self.img_height_use = imageHeight
self.img_width_cell = width
self.img_height_cell = totalHeight
}
}
//
// YHWebModel.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHWebModel: YHBaseModel {
var like_count: Int = 0
var id: Int = 0
var is_like: Bool = false
var view_count: Int = 0
var is_collect: Bool = false
var collect_count: Int = 0
}
......@@ -12,23 +12,26 @@ class YHHomeWebBottomView: UIView {
typealias Block = (Bool) -> ()
var likeBlock: Block?
var starBlock: Block?
private var likeButton: YHHomeWebBottomButton!
private var starButton: YHHomeWebBottomButton!
var likeButton: YHHomeWebBottomButton!
var starButton: YHHomeWebBottomButton!
var likeCount: Int = 0
var starCount: Int = 0
var isStar: Bool = false {
didSet {
if isStar {
starButton.setContent("home_web_stared", "34")
starButton.setContent("home_web_stared", "\(starCount)")
} else {
starButton.setContent("home_web_star", "34")
starButton.setContent("home_web_star", "\(starCount)")
}
}
}//是否收藏
var isLike: Bool = false {
didSet {
if isLike {
likeButton.setContent("home_web_liked", "34")
likeButton.setContent("home_web_liked", "\(likeCount)")
} else {
likeButton.setContent("home_web_like", "34")
likeButton.setContent("home_web_like", "\(likeCount)")
}
}
}//是否点赞
......
......@@ -10,22 +10,23 @@ import UIKit
class YHHomePageViewModel : YHBaseViewModel {
//数据源
var configModel:YHHomeCofigMode?
var lists: [YHHomeListModel]?
var configModel:YHConfigModel?
var arrHomeNewsData: [YHHomeListModel?] = []
var banners: [YHBannerModel]?
var classify: [YHHomeClassifyModel]?
}
//接口
extension YHHomePageViewModel {
//请求首页的配置
//请求配置
func getHomeConfig(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.homeConfigApi
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
let dic = json.data
guard let resultModel = YHHomeCofigMode.deserialize(dict: dic as? [AnyHashable : Any]) else {
guard let resultModel = YHConfigModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
callBackBlock(false,nil)
return
}
......@@ -38,7 +39,7 @@ extension YHHomePageViewModel {
}
}
func getHomeList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
func getHomeNewsList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.consult
......@@ -48,12 +49,18 @@ extension YHHomePageViewModel {
if json.code == 200 {
let dic = json.data
guard let result = [YHHomeListModel].deserialize(from: dic as? [Any]) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
self.lists = result as? [YHHomeListModel]
for item in result {
item?.calHeightParam()
}
self.arrHomeNewsData = result
callBackBlock(true, nil)
} else {
self.arrHomeNewsData = []
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
......@@ -119,11 +126,14 @@ extension YHHomePageViewModel {
//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]
guard let result = [YHHomeListModel].deserialize(from: dic as? [Any]) else {
callBackBlock(false,nil)
return
}
for item in result {
item?.calHeightParam()
}
self.arrHomeNewsData = result
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
......
//
// YHHomeWebViewModel.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeWebViewModel : YHBaseViewModel {
//数据源
var mainModel :YHWebModel?
}
extension YHHomeWebViewModel {
//请求web详情
func getWebDetail(_ id: Int, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let params: [String : Any] = ["id": id]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.webInfo
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
let dic = json.data
guard let resultModel = YHWebModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(false,nil)
return
}
self.mainModel = resultModel
callBackBlock(true,nil)
} failBlock: { err in
callBackBlock(false,err)
}
}
// type:0取消 1收藏
func getStar(_ id: Int, _ type: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["operate_type": type,
"article_id": id]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.star
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
// type:0取消 1收藏
func getLike(_ id: Int, _ type: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["operate_type": type,
"article_id": id]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.like
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -10,12 +10,16 @@ import UIKit
import JXSegmentedView
class YHServerHKLifeViewController: YHBaseViewController {
private let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel()
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var tableHeadView: YHServerTableHeadView!
var tableFootView: YHServiceTableFootView!
var sectionView: YHServiceSectionView!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
if #available(iOS 15.0, *) {
......@@ -44,15 +48,24 @@ class YHServerHKLifeViewController: YHBaseViewController {
extension YHServerHKLifeViewController {
func loadData() {
if YHLoginManager.shared.isLogin() == false {
return
homeViewModel.getHomeBanner(2){[weak self] success, error in
guard let self = self else { return }
self.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? []
}
serviceCenterMainReqVM.getContactList { success, error in
if success == true {
} else {
YHHUD.flash(message: error?.errorMsg ?? "请求出错")
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 == 2 {
self.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 }
self.dataSouce = self.homeViewModel.arrHomeNewsData
}
}
}
}
}
......@@ -63,6 +76,13 @@ extension YHServerHKLifeViewController {
sectionView = {
let view = YHServiceSectionView()
view.block = {[weak self] model in
guard let self = self else { return }
self.homeViewModel.getList(model.id) {[weak self] success, error in
guard let self = self else { return }
self.dataSouce = self.homeViewModel.arrHomeNewsData
}
}
return view
}()
......@@ -116,6 +136,7 @@ extension YHServerHKLifeViewController : UITableViewDelegate,UITableViewDataSour
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell0.tableFootView.items = dataSouce
cell0.selectionStyle = .none
return cell0
}
......@@ -134,12 +155,6 @@ extension YHServerHKLifeViewController: JXSegmentedListContainerViewListDelegate
class YHServerHKLifeViewCell: UITableViewCell {
static let cellReuseIdentifier = "YHServerHKLifeViewCell"
var tableFootView: YHServiceTableFootView!
var dataModel : YHContactItemModel? {
didSet {
updateUI()
}
}
override func awakeFromNib() {
super.awakeFromNib()
......
......@@ -47,7 +47,7 @@ extension YHServiceListViewController {
let classifyID = model.children.first?.id ?? 0
self.homeViewModel.getList(classifyID) {[weak self] success, error in
guard let self = self else { return }
self.normalView.dataSouce = self.homeViewModel.arrHomeNewsData
}
}
}
......@@ -85,6 +85,13 @@ extension YHServiceListViewController {
normalView = {
let view = YHServerNoOrderView()
view.sectionBlock = {[weak self] model in
guard let self = self else { return }
self.homeViewModel.getList(model.id) {[weak self] success, error in
guard let self = self else { return }
self.normalView.dataSouce = self.homeViewModel.arrHomeNewsData
}
}
return view
}()
view.addSubview(normalView)
......
......@@ -56,6 +56,10 @@ class YHMyDocumentsDetailViewController: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
viewModel.requestSignBack("\(self.viewModel.mainModel?.writing_document.doc_sign.id ?? 0)") {[weak self] success, error in
guard let self = self else { return }
self.getData()
}
getData()
}
......@@ -71,7 +75,7 @@ class YHMyDocumentsDetailViewController: YHBaseViewController {
}
self.bottomView.isHidden = true
}
if self.viewModel.mainModel?.writing_document.doc_sign.supplement_id == 0 {
if self.viewModel.mainModel?.writing_document.status ?? 0 < 6 {
//没有doc_sign
self.stepView.currentIndex = 0
self.bottomView.isHidden = true
......@@ -143,7 +147,7 @@ class YHMyDocumentsDetailViewController: YHBaseViewController {
}
func getPromptHeight(_ value: String) -> CGFloat {
let text = value // 要显示的文本内容
let text = "驳回原因:" + value // 要显示的文本内容
let font = UIFont.PFSC_R(ofSize: 12) // 字体大小
let maxWidth = KScreenWidth - 74 // 最大宽度限制
......@@ -212,6 +216,7 @@ class YHMyDocumentsDetailViewController: YHBaseViewController {
bottomView = {
let bottom = UIView()
bottom.backgroundColor = .white
bottom.isHidden = true
return bottom
}()
view.addSubview(bottomView)
......@@ -308,7 +313,8 @@ class YHMyDocumentsDetailViewController: YHBaseViewController {
guard let self = self else { return }
if success {
YHHUD.flash(message: "提交成功")
self.navigationController?.popViewController()
self.getData()
// self.navigationController?.popViewController()
}
}
}
......@@ -749,6 +755,10 @@ extension YHMyDocumentsDetailViewController: SFSafariViewControllerDelegate {
// MARK: 点击左上角的完成
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
controller.navigationController?.popViewController()
viewModel.requestSignBack("\(self.viewModel.mainModel?.writing_document.doc_sign.id ?? 0)") {[weak self] success, error in
guard let self = self else { return }
self.getData()
}
}
// MARK: 加载完成
......
......@@ -346,24 +346,17 @@ extension YHMyDocumentsListViewController: UITableViewDelegate, UITableViewDataS
tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
updateBottomViewNumbers()
} else {
if model.document.status == 6 && model.sign_doc.id > 0 && model.sign_doc.status > 2 {
//签字状态
let vc = YHMySignatureDetailViewController()
vc.id = model.sign_doc.id
//文书状态
if model.template_id == 195 {
//跳转赴港计划书
let vc = YHHKPlanDoctumentVC()
vc.supplement_id = model.id
vc.status = model.status
self.navigationController?.pushViewController(vc)
} else {
//文书状态
if model.template_id == 195 {
//跳转赴港计划书
let vc = YHHKPlanDoctumentVC()
vc.supplement_id = model.id
vc.status = model.status
self.navigationController?.pushViewController(vc)
} else {
let vc = YHMyDocumentsDetailViewController()
vc.id = model.id
self.navigationController?.pushViewController(vc)
}
let vc = YHMyDocumentsDetailViewController()
vc.id = model.id
self.navigationController?.pushViewController(vc)
}
}
}
......
......@@ -106,33 +106,7 @@ class YHDocumentToActionTableViewCell: UITableViewCell {
bottomView.snp.makeConstraints { make in
make.right.left.equalToSuperview()
make.height.equalTo(1)
make.top.equalTo(123)
}
bottomLeftLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomLeftLineView)
bottomLeftLineView.snp.makeConstraints { make in
make.left.equalTo(width)
make.width.equalTo(1)
make.bottom.equalTo(-17.5)
make.height.equalTo(16)
}
bottomRightLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomRightLineView)
bottomRightLineView.snp.makeConstraints { make in
make.left.equalTo(width * 2)
make.width.equalTo(1)
make.bottom.equalTo(-17.5)
make.height.equalTo(16)
make.top.equalTo(115)
}
editButton = {
......@@ -208,6 +182,32 @@ class YHDocumentToActionTableViewCell: UITableViewCell {
make.height.equalTo(40)
make.centerY.equalToSuperview()
}
bottomLeftLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomLeftLineView)
bottomLeftLineView.snp.makeConstraints { make in
make.left.equalTo(width)
make.width.equalTo(1)
make.centerY.equalTo(editButton.snp.centerY)
make.height.equalTo(16)
}
bottomRightLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomRightLineView)
bottomRightLineView.snp.makeConstraints { make in
make.left.equalTo(width * 2)
make.width.equalTo(1)
make.centerY.equalTo(editButton.snp.centerY)
make.height.equalTo(16)
}
}
func updateAllViews() {
......
......@@ -129,6 +129,16 @@ class YHDocumentUploadTableViewCell: UITableViewCell {
make.bottom.equalTo(-153)
make.top.equalTo(52)
}
let line = UIView()
line.backgroundColor = UIColor.separatorColor
centerView.addSubview(line)
line.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(52)
make.height.equalTo(1)
make.right.equalTo(-18)
}
}
func updateAllViews() {
......
......@@ -297,6 +297,25 @@ class YHMyDocumentsDetailViewModel: YHBaseViewModel {
callBackBlock(false, err)
}
}
func requestSignBack(_ id: String, callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
// let params: [String : Any] = ["order_id": orderId]
let params: [String : Any] = ["id": id]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Signature.signCallBack
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
private extension YHMyDocumentsDetailViewModel {
......
......@@ -53,6 +53,10 @@ class YHMySignatureDetailViewController: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
viewModel.requestSignBack("\(id)") {[weak self] success, error in
guard let self = self else { return }
self.getData()
}
getData()
}
......@@ -116,7 +120,7 @@ class YHMySignatureDetailViewController: YHBaseViewController {
}
func getPromptHeight(_ value: String) -> CGFloat {
let text = value // 要显示的文本内容
let text = "驳回原因:" + value // 要显示的文本内容
let font = UIFont.PFSC_R(ofSize: 12) // 字体大小
let maxWidth = KScreenWidth - 74 // 最大宽度限制
......@@ -173,6 +177,7 @@ class YHMySignatureDetailViewController: YHBaseViewController {
bottomView = {
let bottom = UIView()
bottom.backgroundColor = .white
bottom.isHidden = true
return bottom
}()
view.addSubview(bottomView)
......@@ -643,6 +648,10 @@ extension YHMySignatureDetailViewController: SFSafariViewControllerDelegate {
// MARK: 点击左上角的完成
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
controller.navigationController?.popViewController()
viewModel.requestSignBack("\(id)") {[weak self] success, error in
guard let self = self else { return }
self.getData()
}
}
// MARK: 加载完成
......
......@@ -118,33 +118,7 @@ class YHSignatureToActionTableViewCell: UITableViewCell {
bottomView.snp.makeConstraints { make in
make.right.left.equalToSuperview()
make.height.equalTo(1)
make.top.equalTo(123)
}
bottomLeftLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomLeftLineView)
bottomLeftLineView.snp.makeConstraints { make in
make.left.equalTo(width)
make.width.equalTo(1)
make.bottom.equalTo(-17.5)
make.height.equalTo(16)
}
bottomRightLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomRightLineView)
bottomRightLineView.snp.makeConstraints { make in
make.left.equalTo(width * 2)
make.width.equalTo(1)
make.bottom.equalTo(-17.5)
make.height.equalTo(16)
make.top.equalTo(115)
}
editButton = {
......@@ -220,6 +194,32 @@ class YHSignatureToActionTableViewCell: UITableViewCell {
make.height.equalTo(40)
make.centerY.equalToSuperview()
}
bottomLeftLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomLeftLineView)
bottomLeftLineView.snp.makeConstraints { make in
make.left.equalTo(width)
make.width.equalTo(1)
make.centerY.equalTo(editButton.snp.centerY)
make.height.equalTo(16)
}
bottomRightLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(bottomRightLineView)
bottomRightLineView.snp.makeConstraints { make in
make.left.equalTo(width * 2)
make.width.equalTo(1)
make.centerY.equalTo(editButton.snp.centerY)
make.height.equalTo(16)
}
}
func updateAllViews() {
......
......@@ -129,6 +129,16 @@ class YHSignatureUploadTableViewCell: UITableViewCell {
make.bottom.equalTo(-153)
make.top.equalTo(52)
}
let line = UIView()
line.backgroundColor = UIColor.separatorColor
centerView.addSubview(line)
line.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(52)
make.height.equalTo(1)
make.right.equalTo(-18)
}
}
func updateAllViews() {
......
......@@ -210,4 +210,23 @@ class YHMySignatureDetailViewModel: YHBaseViewModel {
callBackBlock(false, err)
}
}
func requestSignBack(_ id: String, callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
// let params: [String : Any] = ["order_id": orderId]
let params: [String : Any] = ["id": id]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Signature.signCallBack
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
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,12 +12,6 @@ import Kingfisher
class YHHomeCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHHomeCollectionViewCell"
var dataSource: AboutAdvantageItem? {
didSet {
updataAllSubViews()
}
}
var listModel: YHHomeListModel? {
didSet {
updataSubViews()
......@@ -27,8 +21,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
lazy var titleImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_title_image"))
imageV.contentMode = .scaleAspectFill
imageV.roundCorners(UIRectCorner.topLeft, radius: 8)
imageV.roundCorners(UIRectCorner.topRight, radius: 8)
return imageV
}()
......@@ -37,49 +29,30 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
let label = UILabel()
label.text = "赴港攻略,当日往返无忧,这个季节风景..赴港攻略,当日往返无忧,这个季节风景"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
label.font = UIFont.PFSC_R(ofSize: 14)
label.numberOfLines = 2
label.lineBreakMode = .byTruncatingTail
label.lineBreakMode = .byWordWrapping
return label
}()
lazy var headImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_person_icon"))
let imageV = UIImageView(image: UIImage(named: ""))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var nameLable:UILabel = {
let label = UILabel()
label.text = "Fiona"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
return label
}()
lazy var dateLable:UILabel = {
let label = UILabel()
label.text = "12-12"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
return label
}()
lazy var heartImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_red_heart"))
let imageV = UIImageView(image: UIImage(named: "home_grey_heart"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var numLable:UILabel = {
let label = UILabel()
label.text = "2000"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 14)
label.text = ""
label.textColor = UIColor(hex: 0x121A264D, alpha: 0.3)
label.font = UIFont.PFSC_R(ofSize: 12)
return label
}()
......@@ -93,21 +66,18 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
}
private func setupUI() {
contentView.backgroundColor = UIColor(hexString: "#F8F9FB")
contentView.roundCorners([.topLeft,.topRight], radius: 4)
contentView.clipsToBounds = true
contentView.addSubview(titleImageView)
titleImageView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(210)
}
let subHoldView = UIView()
subHoldView.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
subHoldView.layer.borderWidth = 0.5
subHoldView.layer.borderColor = UIColor(red: 0.798, green: 0.798, blue: 0.798, alpha: 1).cgColor
subHoldView.layer.backgroundColor = UIColor.white.cgColor
subHoldView.layer.borderWidth = 0.6
subHoldView.layer.borderColor = UIColor(red: 0.943, green: 0.952, blue: 0.969, alpha: 1).cgColor
contentView.addSubview(subHoldView)
subHoldView.snp.makeConstraints { make in
make.top.equalTo(titleImageView.snp.bottom)
......@@ -119,87 +89,47 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
make.top.equalToSuperview().offset(10)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.bottom.equalTo(-36)
}
subHoldView.addSubview(numLable)
numLable.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8)
make.height.equalTo(12)
make.bottom.equalTo(-10)
make.top.equalTo(descripeLable.snp.bottom).offset(10)
make.height.equalTo(16)
}
subHoldView.addSubview(heartImageView)
heartImageView.snp.makeConstraints { make in
make.right.equalTo(numLable.snp.left).offset(-6)
make.height.width.equalTo(12)
make.bottom.equalTo(-10)
make.right.equalTo(numLable.snp.left).offset(-2)
make.height.width.equalTo(16)
make.centerY.equalTo(numLable)
}
}
func updataAllSubViews() {
guard let dataSource = dataSource else { return }
let imageSize = getImageSize(dataSource.url)
var imageHeight = 0.0
if imageSize.width == 0 {
imageHeight = width
} else {
imageHeight = width * imageSize.height/imageSize.width
if imageHeight > 280 {
imageHeight = 280
}
}
titleImageView.snp.remakeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(imageHeight)
}
if let url = URL(string: dataSource.url) {
titleImageView.kf.setImage(with: url)
}
descripeLable.text = dataSource.title
}
func updataSubViews() {
guard let listModel = listModel else { return }
let imageSize = getImageSize(listModel.img_url)
var imageHeight = 0.0
if imageSize.width == 0 {
imageHeight = width
} else {
imageHeight = width * imageSize.height/imageSize.width
if imageHeight > 280 {
imageHeight = 280
}
}
titleImageView.snp.remakeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(imageHeight)
make.height.equalTo(listModel.img_height_use)
}
if let url = URL(string: listModel.img_url) {
titleImageView.kf.setImage(with: url)
}
descripeLable.text = listModel.title
}
func getImageSize(_ url: String?) -> CGSize {
// guard let urlStr = url, urlStr.count != 0 else {
// return CGSize.zero
// }
// let tempUrl = URL(string: urlStr)
// let imageSourceRef = CGImageSourceCreateWithURL(tempUrl! as CFURL, nil)
// var width: CGFloat = 0
// var height: CGFloat = 0
// if let imageSRef = imageSourceRef {
// let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSRef, 0, nil)
// if let imageP = imageProperties {
// let imageDict = imageP as Dictionary
// width = imageDict[kCGImagePropertyPixelWidth] as! CGFloat
// height = imageDict[kCGImagePropertyPixelHeight] as! CGFloat
// }
// }
descripeLable.text = listModel.title.defaultStringIfEmpty(detaultValue: "***")
descripeLable.snp.removeConstraints()
descripeLable.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(10)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.height.equalTo(listModel.textH)
make.bottom.equalTo(-36)
}
numLable.text = listModel.collect_count.string
return CGSize(width: 200, height: 250)
if listModel.is_like {
headImageView.image = UIImage(named: "home_red_heart")
} else {
headImageView.image = UIImage(named: "home_grey_heart")
}
}
}
......@@ -9,10 +9,16 @@
import UIKit
class YHServerNoOrderView: UIView {
typealias SectionBlock = (YHClassifyModel) -> ()
var sectionBlock: SectionBlock?
var tableHeadView: YHServerTableHeadView!
var tableFootView: YHServiceTableFootView!
var sectionView: YHServiceSectionView!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
if #available(iOS 15.0, *) {
......@@ -41,16 +47,19 @@ class YHServerNoOrderView: UIView {
sectionView = {
let view = YHServiceSectionView()
view.block = {[weak self] model in
guard let self = self else { return }
if let block = sectionBlock {
block(model)
}
}
return view
}()
tableHeadView = YHServerTableHeadView()
tableHeadView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 365)
// tableFootView = YHServiceTableFootView()
// tableFootView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)
addSubview(homeTableView)
homeTableView.tableHeaderView = tableHeadView
homeTableView.tableFooterView = tableFootView
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview()
......@@ -94,6 +103,7 @@ extension YHServerNoOrderView : UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell0.tableFootView.items = dataSouce
cell0.selectionStyle = .none
return cell0
}
......
......@@ -10,7 +10,8 @@ import UIKit
class YHServiceSectionView: UIView {
typealias Block = (YHClassifyModel) -> ()
var block: Block?
var items: [YHClassifyModel] = [] {
didSet {
......@@ -43,8 +44,6 @@ class YHServiceSectionView: UIView {
super.init(frame: frame)
backgroundColor = .white
setUpView()
// self.items = ["优才","高才","留学","专才"]
// self.myCollectView.reloadData()
}
required init?(coder: NSCoder) {
......@@ -74,46 +73,34 @@ extension YHServiceSectionView: UICollectionViewDelegate, UICollectionViewDataSo
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHServiceSectionCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHServiceSectionCollectionViewCell
cell.dataSource = items[indexPath.row]
if indexPath.row == selectIndex {
cell.isSelected = true
cell.setSelectedStyle()
} else {
cell.isSelected = false
cell.setDeSelectedStyle()
}
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
selectIndex = indexPath.row
collectionView.reloadData()
let model = items[indexPath.row]
if let block = block {
block(model)
}
print("index is \(indexPath.row)")
}
}
class YHServiceSectionCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHServiceSectionCollectionViewCell"
private var isSelect: Bool = false
override var isSelected: Bool {
set {
self.isSelect = newValue
if newValue {
self.setSelectedStyle()
} else {
self.setDeSelectedStyle()
}
}
get {
return self.isSelect
}
}
private func setSelectedStyle() {
func setSelectedStyle() {
contentView.backgroundColor = UIColor.brandMainColor
descripeLable.textColor = UIColor.white
}
private func setDeSelectedStyle() {
func setDeSelectedStyle() {
contentView.backgroundColor = UIColor(hex: 0xf4f6fa)
descripeLable.textColor = UIColor(hex: 0x94a3bb)
}
......
......@@ -10,14 +10,11 @@ import UIKit
class YHServiceTableFootView: UIView {
lazy var items = {
return [
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "")
]
}()
var items:[YHHomeListModel?] = [] {
didSet {
self.myCollectView.reloadData()
}
}
lazy var myCollectView = {
// 设置布局方向
......@@ -36,24 +33,10 @@ class YHServiceTableFootView: UIView {
return collectinoView
}()
var dataSource: YHScemeHeadModel? {
didSet {
updateAllViews()
}
}
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
setUpView()
self.items = [
AboutAdvantageItem(iconName: "about_match", title: "精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "https://copyright.bdstatic.com/vcg/creative/cc9c744cf9f7c864889c563cbdeddce6.jpg@h_1280"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配精准匹配精准匹配精准匹配精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配精准匹配精准匹配精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "https://img.pconline.com.cn/images/upload/upc/tx/itbbs/2101/25/c1/251135935_1611532823091_mthumb.jpg"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "https://photo.16pic.com/00/47/86/16pic_4786353_b.jpg"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "https://inews.gtimg.com/om_bt/OMvPDmiuH_X5Vq1YLNgbFEzD2h_-2dCfWQ7xZFcKFSEsAAA/641")
]
self.myCollectView.reloadData()
}
required init?(coder: NSCoder) {
......@@ -70,29 +53,6 @@ class YHServiceTableFootView: UIView {
// self.loadFakeData()
// }
}
func updateAllViews() {
guard let model = dataSource else { return }
}
func getImageSize(_ url: String?) -> CGSize {
// guard let urlStr = url, urlStr.count != 0 else {
// return CGSize.zero
// }
// let tempUrl = URL(string: urlStr)
// let imageSourceRef = CGImageSourceCreateWithURL(tempUrl! as CFURL, nil)
// var width: CGFloat = 0
// var height: CGFloat = 0
// if let imageSRef = imageSourceRef {
// let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSRef, 0, nil)
// if let imageP = imageProperties {
// let imageDict = imageP as Dictionary
// width = imageDict[kCGImagePropertyPixelWidth] as! CGFloat
// height = imageDict[kCGImagePropertyPixelHeight] as! CGFloat
// }
// }
return CGSize(width: 150, height: 250)
}
}
extension YHServiceTableFootView: UICollectionViewDelegate, UICollectionViewDataSource {
......@@ -103,7 +63,7 @@ extension YHServiceTableFootView: UICollectionViewDelegate, UICollectionViewData
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHHomeCollectionViewCell
cell.dataSource = items[indexPath.row]
cell.listModel = items[indexPath.row]
return cell
}
......@@ -112,38 +72,18 @@ extension YHServiceTableFootView: UICollectionViewDelegate, UICollectionViewData
print("index is \(indexPath.row)")
}
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
//
// }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let model = items[indexPath.row]
let vc = YHHomeWebViewController()
vc.url = "https://test-hkdiy-h5.galaxy-immi.com/articleDetail.html?id=\(model?.id ?? 0)"
vc.id = model?.id ?? 0
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
extension YHServiceTableFootView: CollectionViewWaterfallLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let model = items[indexPath.row]
let text = model.title
let width = (KScreenWidth - 47) / 2
let font = UIFont.PFSC_R(ofSize: 14) // 字体大小
let maxWidth = width - 16 // 最大宽度限制
// 创建NSAttributedString对象并设置属性
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
_ = NSMutableAttributedString(string: text, attributes: attributes)
// 根据指定的最大宽度和字体大小计算文本的高度
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
var textHeight = size.height
if textHeight > 40 {
textHeight = 40
}
let imageSize = getImageSize(model.url)
var imageHeight = 0.0
if imageSize.width == 0 {
imageHeight = width
} else {
imageHeight = width * imageSize.height/imageSize.width
if imageHeight > 280 {
imageHeight = 280
}
}
let totalHeight = imageHeight + textHeight + 46
return CGSize(width: width, height: totalHeight)
guard let model = items[indexPath.row] else { return CGSize.zero }
return CGSize(width: model.img_width_cell, height: model.img_height_cell)
}
}
......@@ -10,10 +10,8 @@
class YHAllApiName {
//接口 模块名 Common
struct Common {
//具体的业务接口
//首页配置接口
static let homeConfigApi = "common/homepage-config/index"
static let homeConfigApi = "infoflow/app/config"
//获取首页展示的资讯
static let consult = "infoflow/home/consult"
//获取首页展示的banner
......@@ -22,6 +20,12 @@ class YHAllApiName {
static let classify = "infoflow/classify/list"
//获取资讯
static let article = "infoflow/article/list"
//资讯详情
static let webInfo = "infoflow/article/info"
//资讯收藏
static let star = "infoflow/article/collect"
//资讯点赞
static let like = "infoflow/article/like"
}
//order 模块
......@@ -199,7 +203,8 @@ class YHAllApiName {
static let confirm = "infoflow/my-sign/confirm"
// 查看合同
static let look = "infoflow/sign/view-detail"
// 查看签署状态
static let signCallBack = "infoflow/sign/sign-callback"
}
//我的文书
......
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "Vector@2x.png",
"filename" : "编组-8@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Vector@3x.png",
"filename" : "编组-8@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "编组-8@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "编组-8@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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