Commit 433d3320 authored by David黄金龙's avatar David黄金龙

Merge branch 'develop'

* develop: (106 commits)
  修改版本号
  首页 置顶
  1、处理 首页的数据刷新 2、处理 数据一致性
  // tag:0.2.9.
  多页每次请求  6 控制 banner 不超过6
  修改 版本号 0.2.3
  跳转逻辑
  //  我的
  处理一处 视频播放的问题
  //  点赞收藏最近浏览
  加载更多
  首页刷新逻辑
  // 消息
  处理第一张选择
  首页 指示器
  // 权限设置
  // 搜索
  加载更多
  // 搜索
  // 搜索
  ...
parents a240dcc1 1edd0e45
...@@ -17,8 +17,8 @@ target 'galaxy' do ...@@ -17,8 +17,8 @@ target 'galaxy' do
# pod 'RxSwift','6.6.0' # pod 'RxSwift','6.6.0'
# pod 'RxCocoa','6.6.0' # pod 'RxCocoa','6.6.0'
# pod 'RxAlamofire','6.1.1' # pod 'RxAlamofire','6.1.1'
#数据存储 # #数据存储
pod 'SwiftyUserDefaults','5.3.0' # pod 'SwiftyUserDefaults','5.3.0'
#数据加、解密 #数据加、解密
pod 'CryptoSwift','1.8.0' pod 'CryptoSwift','1.8.0'
#手动布局 #手动布局
...@@ -31,21 +31,21 @@ target 'galaxy' do ...@@ -31,21 +31,21 @@ target 'galaxy' do
pod 'ESPullToRefresh',"2.9.3" pod 'ESPullToRefresh',"2.9.3"
# #Toast # #Toast
# pod 'Toast-Swift', '5.0.1' # pod 'Toast-Swift', '5.0.1'
#富文本 UILabel # #富文本 UILabel
pod 'Nantes','0.1.2' # pod 'Nantes','0.1.2'
#提示框 #提示框
pod 'PKHUD','5.3.0' pod 'PKHUD','5.3.0'
#日志 调试 #日志 调试
# pod 'CocoaDebug', '1.7.7' # pod 'CocoaDebug', '1.7.7'
#date分类 # #date分类
pod 'SwiftDate','7.0.0' # pod 'SwiftDate','7.0.0'
#定时器 # #定时器
pod 'SwiftyTimer','2.1.0' # pod 'SwiftyTimer','2.1.0'
#UIColor 的扩展 #UIColor 的扩展
# pod 'Hue','5.0.0' # pod 'Hue','5.0.0'
# #内存泄漏 # #内存泄漏
# pod 'LifetimeTracker','1.8.1' # pod 'LifetimeTracker','1.8.1'
#控制台转换成中文 # #控制台转换成中文
pod 'ByebyeUnicode','1.1.0' pod 'ByebyeUnicode','1.1.0'
#轮播图 #轮播图
pod 'FSPagerView','0.8.3' pod 'FSPagerView','0.8.3'
...@@ -65,8 +65,8 @@ target 'galaxy' do ...@@ -65,8 +65,8 @@ target 'galaxy' do
pod 'JXSegmentedView','1.3.0' pod 'JXSegmentedView','1.3.0'
#UI调试组件 #UI调试组件
pod 'LookinServer','1.2.6',:subspecs => ['Swift'], :configurations => ['Debug'] pod 'LookinServer','1.2.6',:subspecs => ['Swift'], :configurations => ['Debug']
#阿里云OOS # #阿里云OOS
pod 'AliyunOSSiOS','2.10.18' # pod 'AliyunOSSiOS','2.10.18'
#极光推送 #极光推送
pod 'JPush', '5.2.0' pod 'JPush', '5.2.0'
pod 'JCore', '4.6.0-noidfa' pod 'JCore', '4.6.0-noidfa'
......
This diff is collapsed.
...@@ -15,7 +15,6 @@ import DeviceKit ...@@ -15,7 +15,6 @@ import DeviceKit
@main @main
class AppDelegate: UIResponder, UIApplicationDelegate { class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// JPush服务注册 // JPush服务注册
...@@ -37,6 +36,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -37,6 +36,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//4.本地用户信息加载 //4.本地用户信息加载
YHLoginManager.shared.loadLocalUserInfoData() YHLoginManager.shared.loadLocalUserInfoData()
YHConfigManager.shared.loadConfigData()
// YHAnalytics.analyticsStart(launchOptions: launchOptions) // YHAnalytics.analyticsStart(launchOptions: launchOptions)
...@@ -123,8 +124,11 @@ extension AppDelegate { ...@@ -123,8 +124,11 @@ extension AppDelegate {
//1.设置主窗口 //1.设置主窗口
private func setupRootVC() { private func setupRootVC() {
let tabBarController = YHTabBarViewController() let tabBarController = YHTabBarViewController()
let v0 = YHNavigationController(rootVC:YHHomeViewController())
let v1 = YHNavigationController(rootVC:YHServiceCenterMainViewController()) let homeVC = YHHomePageViewController()
tabBarController.delegate = homeVC
let v0 = YHNavigationController(rootVC:homeVC)
let v1 = YHNavigationController(rootVC:YHServiceViewController())
let v2 = YHNavigationController(rootVC:YHMsgViewController()) let v2 = YHNavigationController(rootVC:YHMsgViewController())
let v3 = YHNavigationController(rootVC:YHMyViewController()) let v3 = YHNavigationController(rootVC:YHMyViewController())
...@@ -137,15 +141,9 @@ extension AppDelegate { ...@@ -137,15 +141,9 @@ extension AppDelegate {
v3.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1")) v3.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
tabBarController.viewControllers = [v0,v1,v2,v3] tabBarController.viewControllers = [v0,v1,v2,v3]
// tabBarController.viewControllers = [v1,v2] //for test hjl 配合测试同学做自动化测试 Moon 2023.03.12
tabBarController.tabBar.backgroundColor = .white tabBarController.tabBar.backgroundColor = .white
window = UIWindow(frame: UIScreen.main.bounds) window = UIWindow(frame: UIScreen.main.bounds)
// window?.rootViewController = tabBarController
window?.rootViewController = YHStartPageViewController() window?.rootViewController = YHStartPageViewController()
window?.makeKeyAndVisible() window?.makeKeyAndVisible()
......
...@@ -41,6 +41,7 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -41,6 +41,7 @@ extension AppDelegate: JPUSHRegisterDelegate {
let deviceTokenStr = deviceToken.map{String(format:"%02.2hhx", arguments: [$0]) }.joined() let deviceTokenStr = deviceToken.map{String(format:"%02.2hhx", arguments: [$0]) }.joined()
print("deviceToken:\(deviceTokenStr)") print("deviceToken:\(deviceTokenStr)")
JPUSHService.registerDeviceToken(deviceToken) JPUSHService.registerDeviceToken(deviceToken)
YHLoginManager.shared.userModel?.deviceToken = deviceTokenStr
} }
//获取token 失败 //获取token 失败
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { //可选 func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { //可选
......
//
// YHMessageSessionCell.swift
// galaxy
//
// Created by edy on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMessageSessionCell: UITableViewCell {
static let cellReuseIdentifier = "YHMessageSessionCell"
let badgeHeight = 16.0
var iconContentView: UIView!
var iconImgView: UIImageView!
var badgeLabel: UILabel!
var nameLabel: UILabel!
var detailLabel: UILabel!
var timeLabel: UILabel!
var bottomLineView: UIView!
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
self.selectionStyle = .none
contentView.backgroundColor = .white
iconContentView = UIView()
iconContentView.backgroundColor = UIColor(hex: 0xF4F6FA)
iconContentView.layer.cornerRadius = 22.0
contentView.addSubview(iconContentView)
iconImgView = UIImageView()
iconImgView.backgroundColor = .red
iconContentView.addSubview(iconImgView)
badgeLabel = UILabel()
badgeLabel.backgroundColor = UIColor(hex:0xF81D22)
badgeLabel.textColor = .white
badgeLabel.textAlignment = .center
badgeLabel.font = UIFont.PFSC_M(ofSize:10)
badgeLabel.layer.cornerRadius = badgeHeight/2.0
badgeLabel.clipsToBounds = true
iconContentView.addSubview(badgeLabel)
nameLabel = UILabel()
nameLabel.textColor = UIColor(hex:0x121A26)
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_M(ofSize:15)
contentView.addSubview(nameLabel)
detailLabel = UILabel()
detailLabel.textColor = UIColor(hex:0x121A26, alpha: 0.5)
detailLabel.textAlignment = .left
detailLabel.font = UIFont.PFSC_R(ofSize:12)
contentView.addSubview(detailLabel)
timeLabel = UILabel()
timeLabel.textColor = UIColor(hex:0x121A26, alpha: 0.3)
timeLabel.textAlignment = .right
timeLabel.font = UIFont.PFSC_R(ofSize:11)
timeLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
timeLabel.setContentHuggingPriority(.required, for: .horizontal)
contentView.addSubview(timeLabel)
bottomLineView = UIView()
bottomLineView.backgroundColor = UIColor(hex: 0xF0F3F7)
contentView.addSubview(bottomLineView)
badgeLabel.text = "5"
nameLabel.text = "资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写"
detailLabel.text = "尊敬的用户,您好~很高兴通知您进行资料填写列尊敬的用户,您好~很高兴通知您进行资料填写列尊敬的用户,您好~很高兴通知您进行资料填写列"
timeLabel.text = "2024-01-01"
iconContentView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.size.equalTo(CGSize(width: 44, height: 44))
make.centerY.equalToSuperview()
}
iconImgView.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 21, height: 21))
make.center.equalToSuperview()
}
badgeLabel.snp.makeConstraints { make in
make.width.equalTo(badgeHeight)
make.height.equalTo(badgeHeight)
make.top.equalToSuperview().offset(-4)
make.left.equalTo(iconContentView.snp.right).offset(-12)
}
nameLabel.snp.makeConstraints { make in
make.left.equalTo(iconContentView.snp.right).offset(16)
make.right.equalTo(timeLabel.snp.left).offset(-20)
make.top.equalTo(iconContentView)
make.height.equalTo(21)
}
detailLabel.snp.makeConstraints { make in
make.left.equalTo(nameLabel)
make.right.equalTo(timeLabel)
make.top.equalTo(nameLabel.snp.bottom).offset(2)
make.height.equalTo(17)
}
timeLabel.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-20)
make.top.equalTo(nameLabel)
make.height.equalTo(15)
}
bottomLineView.snp.makeConstraints { make in
make.left.right.equalTo(detailLabel)
make.height.equalTo(1)
make.bottom.equalToSuperview()
}
}
}
...@@ -13,13 +13,6 @@ class YHTabBarViewController: ESTabBarController { ...@@ -13,13 +13,6 @@ class YHTabBarViewController: ESTabBarController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
handleTabBarLine() handleTabBarLine()
// self.tabBar.shadowImage = UIImage()
// self.tabBar.backgroundImage = UIImage()
// NotificationCenter.default.addObserver(self, selector: #selector(hideTabBar), name: BsConstant.BsNotification.tabBarHideNotification, object: nil)
//
// NotificationCenter.default.addObserver(self, selector: #selector(showTabBar), name: BsConstant.BsNotification.tabBarShowNotification, object: nil)
} }
} }
...@@ -38,20 +31,14 @@ extension YHTabBarViewController { ...@@ -38,20 +31,14 @@ extension YHTabBarViewController {
//展示tabbar上的横线 //展示tabbar上的横线
func handleTabBarLine() -> Void { func handleTabBarLine() -> Void {
let rect = CGRect.init(x:0,y:0,width:KScreenWidth,height:0.5) let rect = CGRect.init(x:0,y:0,width:KScreenWidth,height:0.5)
let fillColor = UIColor(hex:0x888888) let fillColor = UIColor(hex:0x222222,transparency: 0.2)!
let img = UIImage.from(color: fillColor, rect: rect) let img = UIImage.from(color: fillColor, rect: rect)
UIView.transition(with:self.tabBar, duration:0.5, options: .transitionCrossDissolve) { UIView.transition(with:self.tabBar, duration:0.5, options: .transitionCrossDissolve) {
if #available(iOS 13.0, *) { let appearance = self.tabBar.standardAppearance.copy()
let appearance = self.tabBar.standardAppearance.copy() appearance.backgroundImage = UIImage()
appearance.backgroundImage = UIImage() appearance.shadowImage = img
appearance.shadowImage = img self.tabBar.standardAppearance = appearance
self.tabBar.standardAppearance = appearance
}
else{
self.tabBar.backgroundImage = UIImage()
self.tabBar.shadowImage = img
}
} completion: { Bool in } completion: { Bool in
} }
} }
......
//
// YHTestViewController.swift
// galaxy
//
// Created by edy on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHTestViewController: YHBaseViewController {
lazy var nameLabel: UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor(hex:0x121A26)
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_M(ofSize:15)
nameLabel.numberOfLines = 0
return nameLabel
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(nameLabel)
nameLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview()
}
YHHUD.show(.progress(message: "加载中..."))
JPUSHService.registrationIDCompletionHandler {
resCode, registrationID in
YHHUD.hide()
YHLoginManager.shared.userModel?.registerId = registrationID ?? ""
var info = "deviceToken: \n" + (YHLoginManager.shared.userModel?.deviceToken ?? "")
info += "\nregisterId: \n" + (YHLoginManager.shared.userModel?.registerId ?? "")
DispatchQueue.main.async {
self.nameLabel.text = info
}
}
}
}
...@@ -13,12 +13,12 @@ class YHBasicContentView: ESTabBarItemContentView { ...@@ -13,12 +13,12 @@ class YHBasicContentView: ESTabBarItemContentView {
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
textColor = UIColor.init(white: 175.0 / 255.0, alpha: 1.0)
highlightTextColor = .brandMainColor
iconColor = UIColor.init(white: 175.0 / 255.0, alpha: 1.0)
highlightIconColor = .brandMainColor
// 此渲染模式会影响图片颜色哦
renderingMode = .alwaysOriginal
textColor = UIColor(hex: 0x121A26)
highlightTextColor = UIColor(hex: 0x121A26)
titleLabel.font = UIFont.PFSC_R(ofSize: 14) titleLabel.font = UIFont.PFSC_R(ofSize: 14)
} }
......
//
// 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()
}
var h5Url : String {
return reqVM.configModel?.article_h5_url ?? ""
}
}
extension YHConfigManager {
func loadConfigData() {
reqVM.getHomeConfig { flag, error in
if flag {
self.loadNewDataFlag = true
}
}
}
}
//
// YHDavidTestViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
import ESPullToRefresh
import JXSegmentedView
import GKNavigationBarSwift
class YHDavidTestViewController: YHBaseViewController {
var vcCanScroll : Bool = true
lazy var descripeLable:UILabel = {
let label = UILabel()
label.text = "赴港攻略,当日往返无忧,这个季节风景..赴港攻略,当日往返无忧,这个季节风景"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
label.numberOfLines = 2
label.lineBreakMode = .byTruncatingTail
return label
}()
lazy var headImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_person_icon"))
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"))
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)
return label
}()
lazy var items = {
return [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
}()
private lazy var bannerView: YHHomeBannerView = {
let view = YHHomeBannerView()
return view
}()
lazy var myCollectView = {
// 设置布局方向
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 = YHGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.contentInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
collectinoView.backgroundColor = .white
collectinoView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectinoView.register(YHDavidTestCollectionViewCell.self, forCellWithReuseIdentifier:YHDavidTestCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
return collectinoView
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
view.backgroundColor = .white
gk_navigationBar.isHidden = true
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
self.myCollectView.reloadData()
}
}
extension YHDavidTestViewController {
private func loadFirstItem() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
self.myCollectView.es.stopPullToRefresh(ignoreDate: true,ignoreFooter: false)
self.myCollectView.reloadData()
}
}
private func loadFakeData() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.myCollectView.es.stopLoadingMore()
self.myCollectView.reloadData()
}
}
func setupUI() {
gk_navTitle = "David的测试UI"
view.backgroundColor = .white
view.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalToSuperview().offset(10)
}
self.myCollectView.es.addInfiniteScrolling {
self.loadFakeData()
}
}
}
extension YHDavidTestViewController: UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHDavidTestCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHDavidTestCollectionViewCell
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
}
// MARK: - JXSegmentedListContainerViewListDelegate
extension YHDavidTestViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
// MARK: - 滑动使用
extension YHDavidTestViewController: UIScrollViewDelegate {
//控制滑动交互
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let scrollViewSet: CGFloat = scrollView.contentOffset.y
if vcCanScroll == false {//不能滚动时
scrollView.contentOffset = CGPoint(x: -20, y: 0)
} else {
if (scrollViewSet <= 0) {
scrollView.contentOffset = CGPoint(x: -20, y: 0)
vcCanScroll = false
NotificationCenter.default.post(name: Notification.Name(rawValue: "leaveTop"), object: nil)
} else {
scrollView.contentOffset = CGPoint(x: -20, y: scrollViewSet)
}
}
}
}
//
// YHFourKingViewController.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFourKingViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var tableFootView: YHServiceTableFootView!
var sectionView: YHServiceSectionView!
var id = 3
var classId: Int = 0
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.register(YHServerHKLifeViewCell.self,forCellReuseIdentifier: YHServerHKLifeViewCell.cellReuseIdentifier)
return tableView
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
}
}
extension YHFourKingViewController {
func loadData() {
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 == self.id {
gk_navTitle = model.name
self.sectionView.items = model.children
let classifyID = model.children.first?.id ?? 0
self.classId = classifyID
self.homeViewModel.getList(true, classifyID) {[weak self] success, error in
guard let self = self else { return }
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
}
}
}
}
}
func setupUI() {
gk_navBarAlpha = 1
sectionView = {
let view = YHServiceSectionView()
view.block = {[weak self] model in
guard let self = self else { return }
self.classId = model.id
self.homeViewModel.getList(true, model.id) {[weak self] success, error in
guard let self = self else { return }
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
if self.homeViewModel.hasMoreForHomeNews == false {
self.homeTableView.es.noticeNoMoreData()
}
}
}
return view
}()
view.addSubview(homeTableView)
homeTableView.tableFooterView = tableFootView
homeTableView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
}
homeTableView.delegate = self
homeTableView.dataSource = self
homeTableView.es.addInfiniteScrolling {[weak self] in
guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return }
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
self.homeTableView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.homeTableView.es.noticeNoMoreData()
}
}
}
}
}
// MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHFourKingViewController : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 48
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return sectionView
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return KScreenHeight
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell0.tableFootView.items = dataSouce
cell0.selectionStyle = .none
return cell0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
//
// YHHKEventViewController.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import WebKit
class YHHKEventViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var sectionView: YHServiceSectionView!
var webview = WKWebView()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
}
}
extension YHHKEventViewController {
func loadData() {
homeViewModel.getHKEvent {[weak self] success, error in
guard let self = self else { return }
self.sectionView.type = 1
self.sectionView.dataSource = self.homeViewModel.hkList ?? []
guard let model = self.homeViewModel.hkList?.first, let urlString = model.list.first else { return }
let url = NSURL(string: urlString)
// 创建请求
let request = NSURLRequest(url: url! as URL)
// 加载请求
self.webview.load(request as URLRequest)
}
}
func setupUI() {
gk_navBarAlpha = 1
sectionView = {
let view = YHServiceSectionView()
view.hkBlock = {[weak self] model in
guard let self = self else { return }
guard let urlString = model.list.first else { return }
let url = NSURL(string: urlString)
// 创建请求
let request = NSURLRequest(url: url! as URL)
// 加载请求
self.webview.load(request as URLRequest)
}
return view
}()
view.addSubview(sectionView)
sectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(48)
}
let navHeight = self.navigationController?.navigationBar.frame.height
//获取状态栏高度
let statusHeight = k_Height_statusBar()
// 创建wkwebview
webview = WKWebView(frame: CGRect(x: 0, y: statusHeight + navHeight! + 48, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight! - 48))
// 添加wkwebview
self.view.addSubview(webview)
}
}
//
// YHHomePageViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import ESPullToRefresh
import GKNavigationBarSwift
class YHHomePageViewController: YHBaseViewController {
lazy var viewModel : YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
return viewModel
}()
lazy var homeCollectView = {
// 设置布局方向
let flowLayout = YHHomeCollectionLayout()
flowLayout.minimumInteritemSpacing = 7.0
flowLayout.minimumColumnSpacing = 10.0
flowLayout.sectionInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
return collectinoView
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
getData()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
lazy var searchView: YHHomeSearchView = {
let view = YHHomeSearchView()
let tap = UITapGestureRecognizer(target: self, action: #selector(didSearchBarClicked))
view.addGestureRecognizer(tap)
return view
}()
lazy var homeHeaderView: YHHomeHeadView = {
let view = YHHomeHeadView()
return view
}()
var tapTimestamp : CFAbsoluteTime = -10.0
}
private extension YHHomePageViewController {
@objc func didSearchBarClicked() {
let vc = YHSearchInfomationVC()
self.navigationController?.pushViewController(vc)
}
func getData() {
loadFirstData()
viewModel.getHomeBanner(0) {[weak self] success, error in
guard let self = self else { return }
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? []
}
}
func loadMoreData() {
viewModel.getHomeNewsList(firstPageFlag : false) {[weak self] success, error in
guard let self = self else { return }
homeCollectView.es.stopLoadingMore()
if self.viewModel.hasMoreForHomeNews == false {
homeCollectView.es.noticeNoMoreData()
}
self.homeCollectView.reloadData()
}
}
func loadFirstData() {
viewModel.getHomeNewsList(firstPageFlag : true) {[weak self] success, error in
guard let self = self else { return }
homeCollectView.es.stopPullToRefresh()
if self.viewModel.hasMoreForHomeNews == false {
homeCollectView.es.noticeNoMoreData()
}
self.homeCollectView.reloadData()
// DispatchQueue.main.asyncAfter(deadline: .now() + 3, execute:{
// printLog(YHHomeHeadView.viewH)
// printLog(self.homeCollectView.contentOffset)
// })
}
}
func setupUI() {
gk_navigationBar.isHidden = true
view.backgroundColor = .white
// NotificationCenter.default.addObserver(self, selector: #selector(homepageRefresh), name:YhConstant.YhNotification.refreshHomePageNotifiction, object: nil)
view.addSubview(searchView)
searchView.snp.makeConstraints { make in
make.top.equalTo(k_Height_safeAreaInsetsTop() + 6)
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(YHHomeSearchView.viewH)
}
view.addSubview(homeCollectView)
homeCollectView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(searchView.snp.bottom).offset(6)
}
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: 20, right: 0)
let tmpHeadView = homeCollectView.es.addPullToRefresh {
self.loadFirstData()
}
var r = tmpHeadView.frame
r.origin.y = r.origin.y - YHHomeHeadView.viewH
tmpHeadView.frame = r
homeCollectView.es.addInfiniteScrolling {
self.loadMoreData()
}
}
@objc func homepageRefresh() {
loadFirstData()
}
}
extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.viewModel.arrHomeNewsData?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHHomeCollectionViewCell
cell.listModel = self.viewModel.arrHomeNewsData?[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let model = self.viewModel.arrHomeNewsData?[indexPath.row] else { return }
if model.type == 2 {
let vc = YHHomeWebViewController()
vc.url = YHConfigManager.shared.h5Url + "?id=\(model.id)"
vc.id = model.id
vc.block = { item in
if let arr = self.viewModel.arrHomeNewsData {
for (index,targetItem) in arr.enumerated() {
if targetItem.id == item.id {
targetItem.is_like = item.is_like
targetItem.like_count = item.like_count
self.homeCollectView.reloadItems(at: [IndexPath(index: index)])
}
}
}
}
self.navigationController?.pushViewController(vc)
} else if model.type == 1 {
printLog("直接播放视频")
}
}
}
extension YHHomePageViewController : CollectionViewWaterfallLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
guard let model = self.viewModel.arrHomeNewsData?[indexPath.row] else { return CGSize.zero }
return CGSize(width: model.img_width_cell, height: model.img_height_cell)
}
}
extension YHHomePageViewController : UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let doubleTapInterval : CGFloat = 0.3
if tabBarController.selectedIndex == 0 {
let timestamp = CFAbsoluteTimeGetCurrent()
printLog(timestamp - self.tapTimestamp)
if timestamp - self.tapTimestamp < doubleTapInterval {
UIView.animate(withDuration: 0.25) {
self.homeCollectView.contentOffset = CGPoint(x: 0, y: -YHHomeHeadView.viewH)//置顶功能
}
}
self.tapTimestamp = timestamp
}
}
}
...@@ -10,22 +10,30 @@ import UIKit ...@@ -10,22 +10,30 @@ import UIKit
import WebKit import WebKit
class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate { class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
var operationFlag:Bool = false
typealias Block = (YHWebModel) -> ()
var block: Block?
var viewModel: YHHomeWebViewModel!
var webview = WKWebView() var webview = WKWebView()
var progBar = UIProgressView() var progBar = UIProgressView()
var bottomView: YHHomeWebBottomView! var bottomView: YHHomeWebBottomView!
var url = "https://upload-cdn.galaxy-immi.com/crm/production/1620271613711.pdf" var url = ""
var id: Int = 0
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
viewModel = YHHomeWebViewModel()
//获取导航栏高度 //获取导航栏高度
let navHeight = self.navigationController?.navigationBar.frame.height let navHeight = self.navigationController?.navigationBar.frame.height
//获取状态栏高度 //获取状态栏高度
let statusHeight = k_Height_statusBar() let statusHeight = k_Height_statusBar()
// 创建wkwebview // 创建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 webview.navigationDelegate = self
// 创建网址 // 创建网址
let url = NSURL(string: url) let url = NSURL(string: url)
...@@ -48,19 +56,67 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD ...@@ -48,19 +56,67 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
let view = YHHomeWebBottomView() let view = YHHomeWebBottomView()
view.likeBlock = { [weak self] flag in view.likeBlock = { [weak self] flag in
guard let self = self else { return } 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 { if flag {
YHHUD.flash(message: "已点赞") self.viewModel.getLike(self.id, 1) {[weak self] success, error in
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已点赞")
self.getData()
} else {
operationFlag = false
}
}
} else { } else {
YHHUD.flash(message: "已取消点赞") self.viewModel.getLike(self.id, 0) {[weak self] success, error in
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已取消点赞")
self.getData()
} else {
operationFlag = false
}
}
} }
} }
view.starBlock = { [weak self] flag in view.starBlock = { [weak self] flag in
guard let self = self else { return } 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 { if flag {
YHHUD.flash(message: "已收藏") self.viewModel.getStar(self.id, 1) {[weak self] success, error in
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已收藏")
self.getData()
} else {
operationFlag = false
}
}
} else { } else {
YHHUD.flash(message: "已取消收藏") self.viewModel.getStar(self.id, 0) {[weak self] success, error in
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已取消收藏")
self.getData()
} else {
operationFlag = false
}
}
} }
} }
return view return view
...@@ -70,13 +126,41 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD ...@@ -70,13 +126,41 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
make.bottom.left.right.equalToSuperview() make.bottom.left.right.equalToSuperview()
make.height.equalTo(59 + k_Height_safeAreaInsetsBottom()) make.height.equalTo(59 + k_Height_safeAreaInsetsBottom())
} }
getData()
if id == 0 {
if self.url.contains("?id=") {
let list = self.url.components(separatedBy: "?id=")
if list.count == 2 {
if let iddd = list[1].int {
id = iddd
return
}
}
}
bottomView.isHidden = true
webview.frame = CGRect(x: 0, y: statusHeight + navHeight!, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight!)
}
} }
deinit { deinit {
webview.removeObserver(self, forKeyPath: "estimatedProgress") webview.removeObserver(self, forKeyPath: "estimatedProgress")
} }
func getData() {
viewModel.getWebDetail(self.id) {[weak self] success, error in
guard let self = self else { return }
if success {
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
self.block?(model)
}
}
}
// MARK: - WKNavigationDelegate // MARK: - WKNavigationDelegate
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
......
//
// YHSearchInfomationVC.swift
// galaxy
//
// Created by edy on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHSearchInfomationVC: YHBaseViewController {
static let searchInfoHistoryKey = "searchInfoHistoryKey"
static let searchHistoryMaxCount = 10
var items:[YHHomeListModel] = []
lazy var viewModel: YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
return viewModel
}()
lazy var navBar:UIView = {
let bar = UIView()
let backBtn = UIButton()
backBtn.setImage(UIImage(named: "back_icon"), for: .normal)
backBtn.addTarget(self, action: #selector(didBackBtnClicked), for: .touchUpInside)
backBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
bar.addSubview(backBtn)
backBtn.snp.makeConstraints { make in
make.width.height.equalTo(21)
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(16)
}
return bar
}()
lazy var searchBar: YHSearchInfoBar = {
let bar = YHSearchInfoBar(frame: CGRect(x: 20, y: k_Height_NavigationtBarAndStatuBar+8.0, width: KScreenWidth-40, height: 36.0))
bar.searchBlock = {
[weak self] text in
guard let self = self else { return }
searchText(self.searchBar.textField.text ?? "")
if let searchText = self.searchBar.textField.text, searchText.count > 0 {
self.saveSearchHistory(searchText)
}
}
bar.textChange = {
[weak self] text in
guard let self = self else { return }
if isEmptyString(text) {
searchHistoryView.isHidden = false
searchHistoryView.updateDataSource(self.getSearchHistoryList())
items.removeAll()
self.tableView.reloadData()
}
}
return bar
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.estimatedSectionHeaderHeight = 0.1
tableView.estimatedSectionFooterHeight = 20.0
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = .white
tableView.backgroundView = emptyDataTipsView
tableView.register(YHSearchInfoCell.self, forCellReuseIdentifier: YHSearchInfoCell.cellReuseIdentifier)
return tableView
}()
lazy var searchHistoryView: YHSearchInfoHistoryView = {
let view = YHSearchInfoHistoryView(frame: CGRect(x: 0, y: searchBar.frame.maxY+8, width: KScreenWidth, height: KScreenHeight-searchBar.frame.maxY-8))
view.updateDataSource(self.getSearchHistoryList())
view.selectBlock = {
[weak self] text in
guard let self = self else { return }
self.searchHistoryView.isHidden = true
self.searchBar.textField.text = text
searchText(text)
self.saveSearchHistory(text)
}
return view
}()
lazy var emptyDataTipsView:UIView = {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 124))
view.isHidden = true
let imgView = UIImageView(image: UIImage(named: "service_center_no_data"))
imgView.contentMode = .scaleAspectFill
view.addSubview(imgView)
let label = UILabel()
label.textColor = UIColor.labelTextColor2
label.font = UIFont.PFSC_R(ofSize: 14)
label.textAlignment = .center
label.text = "无搜索结果".local
view.addSubview(label)
imgView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(204)
make.width.height.equalTo(92)
make.centerX.equalTo(view)
}
label.snp.makeConstraints { make in
make.top.equalTo(imgView.snp.bottom).offset(12)
make.centerX.equalTo(view)
}
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.setupUI()
}
func setupUI() {
gk_navigationBar.isHidden = true
view.backgroundColor = .white
view.addSubview(navBar)
view.addSubview(searchBar)
view.addSubview(tableView)
view.addSubview(searchHistoryView)
searchBar.textField.becomeFirstResponder()
navBar.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_statusBar())
make.height.equalTo(k_Height_NavContentBar)
}
searchBar.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar+8.0)
make.height.equalTo(36.0)
}
searchHistoryView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(searchBar.snp.bottom).offset(20)
make.bottom.equalToSuperview()
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(searchBar.snp.bottom).offset(8+20)
make.bottom.equalToSuperview()
}
}
func searchText(_ text:String) {
YHHUD.show(.progress(message: "搜索中..."))
self.viewModel.searchArticleList(text) {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
items.removeAll()
if let arr = self.viewModel.arrHomeNewsData {
items.append(contentsOf: arr)
}
emptyDataTipsView.isHidden = (items.count > 0)
searchHistoryView.isHidden = true
self.tableView.reloadData()
}
}
func getSearchHistoryList() -> [String] {
if let arr = UserDefaults.standard.array(forKey: Self.searchInfoHistoryKey) as? [String] {
return arr
}
return []
}
func saveSearchHistory(_ text: String) {
if isEmptyString(text) { return }
var arr = getSearchHistoryList()
// 查找历史记录中是否有相同记录
var targetIndex = -1
for (index, history) in arr.enumerated() {
if history == text {
targetIndex = index
break
}
}
// 去除相同记录
if 0 <= targetIndex && targetIndex < arr.count {
arr.remove(at: targetIndex)
}
// 将最近记录放在第一位
if arr.count < Self.searchHistoryMaxCount {
arr.insert(text, at: 0)
} else {
arr.insert(text, at: 0)
arr.removeLast()
}
UserDefaults.standard.set(arr, forKey: Self.searchInfoHistoryKey)
UserDefaults.standard.synchronize()
}
@objc func didBackBtnClicked() {
self.navigationController?.popViewController(animated: true)
}
}
extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHSearchInfoCell.cellReuseIdentifier, for: indexPath) as! YHSearchInfoCell
if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section]
cell.updateModel(item)
cell.renderHighLightText(self.searchBar.textField.text ?? "")
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 70.0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.section && indexPath.section < items.count {
let model = items[indexPath.section]
let vc = YHHomeWebViewController()
vc.url = YHConfigManager.shared.h5Url + "?id=\(model.id)"
vc.id = model.id
self.navigationController?.pushViewController(vc)
}
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 0.1
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
return 20.0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
}
...@@ -14,7 +14,7 @@ import ESTabBarController_swift ...@@ -14,7 +14,7 @@ import ESTabBarController_swift
class YHStartPageViewController: UIViewController { class YHStartPageViewController: UIViewController {
private var MaxTime : Int = 10 //for test hjl private var MaxTime : Int = 3
private var timer : Timer? private var timer : Timer?
lazy var imagV: UIImageView = { lazy var imagV: UIImageView = {
...@@ -82,8 +82,8 @@ private extension YHStartPageViewController { ...@@ -82,8 +82,8 @@ private extension YHStartPageViewController {
closeBtn.clipsToBounds = true closeBtn.clipsToBounds = true
closeBtn.layer.cornerRadius = 14 closeBtn.layer.cornerRadius = 14
closeBtn.snp.makeConstraints { make in closeBtn.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) make.top.equalTo(k_Height_safeAreaInsetsTop() + 15)
make.right.equalTo(-10) make.right.equalTo(-20)
make.width.equalTo(56) make.width.equalTo(56)
make.height.equalTo(28) make.height.equalTo(28)
} }
...@@ -98,8 +98,10 @@ private extension YHStartPageViewController { ...@@ -98,8 +98,10 @@ private extension YHStartPageViewController {
//1.设置主窗口 //1.设置主窗口
func setupRootVC() { func setupRootVC() {
let tabBarController = YHTabBarViewController() let tabBarController = YHTabBarViewController()
let v0 = YHNavigationController(rootVC:YHHomeViewController()) let homeVC = YHHomePageViewController()
let v1 = YHNavigationController(rootVC:YHServiceCenterMainViewController()) tabBarController.delegate = homeVC
let v0 = YHNavigationController(rootVC:homeVC)
let v1 = YHNavigationController(rootVC:YHServiceViewController())
let v2 = YHNavigationController(rootVC:YHMsgViewController()) let v2 = YHNavigationController(rootVC:YHMsgViewController())
let v3 = YHNavigationController(rootVC:YHMyViewController()) let v3 = YHNavigationController(rootVC:YHMyViewController())
...@@ -112,10 +114,8 @@ private extension YHStartPageViewController { ...@@ -112,10 +114,8 @@ private extension YHStartPageViewController {
v3.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1")) v3.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
tabBarController.viewControllers = [v0,v1,v2,v3] tabBarController.viewControllers = [v0,v1,v2,v3]
// tabBarController.viewControllers = [v1,v2] //for test hjl 配合测试同学做自动化测试 Moon 2023.03.12
tabBarController.tabBar.backgroundColor = .white tabBarController.tabBar.backgroundColor = .white
let window = UIApplication.shared.yhKeyWindow() let window = UIApplication.shared.yhKeyWindow()
window?.rootViewController = tabBarController window?.rootViewController = tabBarController
window?.makeKeyAndVisible() window?.makeKeyAndVisible()
......
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
import Foundation import Foundation
class YHBannerModel { class YHBannerModel: YHBaseModel {
var title: String = "我是Title" //banner标题 var name: String = ""
var img_url: String = "https://upload-cdn.galaxy-immi.com/sell/test/1668772072522.jpg" //banner图片链接 var skip_url: String = ""
var link_type: Int = 0 //跳转类型 0:不跳转 10 :跳转H5 20:跳转原生页面 var img_url: String = ""
var link_url: String = "" //跳转地址 var type: Int = 0//banner 跳转类型:0-不跳转,1-跳转H5,2-跳转APP内Tab,3-跳转资讯页
var create_at: String = ""
required init() {} var skip_type: Int = 0
var id: Int = 0
} }
//
// 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 oss_server : String = ""
var start_up_url : String = ""
var article_h5_url : String = ""
var min_version_num : Int = 0
var countdown : Int = 0
required init() {
}
}
//
// YHDavidModel0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHDavidModel0: SmartCodable {
var imageUrl : String = ""
var titleDes : String = ""
var uImageUrl : String = ""
var uName : String = ""
var date : String = "12-11"
var heartNum : Int32 = 0
required init() {
}
}
//
// YHHKEventModel.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHKEventModel: YHBaseModel {
var tag: String = ""
var list: [String] = []
}
//
// 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
}
//
// YHHomeKingKongBlockModel.swift
// galaxy
//
// Created by davidhuangA on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeKingKongBlockModel {
var type : String
var iconName : String
var title : String
init(type: String, iconName: String, title: String) {
self.type = type
self.iconName = iconName
self.title = title
}
}
//
// YHHomeListModel.swift
// galaxy
//
// Created by EDY on 2024/4/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeListTotalModel: YHBaseModel {
var data: [YHHomeListModel] = []
var total: Int = 0
}
class YHHomeListModel: YHBaseModel {
var collect_count: Int = 0
var id: Int = 0
var title: String = ""
var content: String = ""
var view_count: Int = 0 //浏览数量
var img_url: String = ""
var type: Int = 0 //文章类型 '文章类型 1视频 2图文 3图片',
var is_like : Bool = false
var media_url : String = ""
var like_count : Int = 0 //点赞梳理
//网络返回的图片宽高
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 = 16.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
}
//
// YHBbxCollectionViewCell.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHBbxCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHBbxCollectionViewCell"
static let bbxCellHeight = 64
static let bbxCellWidth = 80
lazy var titleImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_bbx_icon"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var descripeLable:UILabel = {
let label = UILabel()
label.textColor = UIColor(red: 0.315, green: 0.315, blue: 0.315, alpha: 1)
label.font = UIFont.PFSC_R(ofSize: 12)
label.textAlignment = .center
label.text = "证件办理"
// label.backgroundColor = .blue
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
contentView.addSubview(titleImageView)
titleImageView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.height.width.equalTo(44)
make.centerX.equalToSuperview()
}
contentView.addSubview(descripeLable)
descripeLable.snp.makeConstraints { make in
make.top.equalTo(titleImageView.snp.bottom).offset(4)
make.centerX.equalToSuperview()
make.height.equalTo(16)
make.left.right.equalToSuperview()
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell0: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell0"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var headImage: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.image = UIImage(named: "home_cell0_head_icon")
return imagV
}()
lazy var contentImage: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.image = UIImage(named: "home_cell0_content_icon")
return imagV
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(headImage)
contentView.addSubview(contentImage)
contentImage.snp.makeConstraints { make in
make.top.equalToSuperview().offset(12)
make.right.equalToSuperview().offset(-16)
make.width.equalTo(242)
make.height.equalTo(97)
}
headImage.snp.makeConstraints { make in
make.right.equalTo(contentImage.snp.left)
make.width.equalTo(88)
make.height.equalTo(122)
make.bottom.equalToSuperview()
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell1: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell1"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var bigImageView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleToFill
imagV.image = UIImage(named: "home_cell1_bkg")
return imagV
}()
lazy var subContentView : UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x999999, alpha: 1.0)
view.layer.cornerRadius = kCornerRadius6
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(182)
}
subContentView.addSubview(bigImageView)
bigImageView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(182)
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell2: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell2"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var bigImageView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleToFill
imagV.image = UIImage(named: "home_cell1_bkg")
return imagV
}()
lazy var subContentView : UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x999999, alpha: 1.0)
view.layer.cornerRadius = kCornerRadius6
view.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
view.layer.cornerRadius = 10
view.layer.borderWidth = 0.5
view.layer.borderColor = UIColor(red: 0.862, green: 0.862, blue: 0.862, alpha: 1).cgColor
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(99)
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell3: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell3"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var bigImageView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleToFill
imagV.image = UIImage(named: "home_cell1_bkg")
return imagV
}()
lazy var subContentView : UIView = {
let view = UIView()
view.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(138)
}
let bbxLable = UILabel()
bbxLable.text = "银河推荐官"
bbxLable.textColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
bbxLable.font = UIFont.PFSC_R(ofSize: 18)
subContentView.addSubview(bbxLable)
bbxLable.snp.makeConstraints { make in
make.top.equalTo(13)
make.left.equalTo(25)
}
let desLable = UILabel()
desLable.text = "邀请拉新,合作共赢"
desLable.frame = CGRect(x: 0, y: 0, width: 141.5, height: 11.5)
desLable.textColor = UIColor(red: 0.592, green: 0.592, blue: 0.592, alpha: 1)
desLable.font = UIFont.PFSC_R(ofSize: 10)
subContentView.addSubview(desLable)
desLable.snp.makeConstraints { make in
make.left.equalTo(bbxLable.snp.right).offset(11)
make.centerY.equalTo(bbxLable)
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell5: UITableViewCell {
static let cellHeight : CGFloat = 219
static let cellReuseIdentifier = "YHDavidCell5"
let items : [Int32] = [1,2,3,4,5,6,7,8]
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var subContentView : UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
var myCollectView : UICollectionView!
// lazy var myCollectView = {
// // 设置布局方向
//
//
//
// return collectinoView
// }()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let bbxLable = UILabel()
bbxLable.text = "百宝箱"
bbxLable.textColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
bbxLable.font = UIFont.PFSC_R(ofSize: 18)
subContentView.addSubview(bbxLable)
bbxLable.snp.makeConstraints { make in
make.top.equalTo(13)
make.left.equalTo(25)
}
let desLable = UILabel()
desLable.text = "香港本地宝,智慧小助手"
desLable.frame = CGRect(x: 0, y: 0, width: 141.5, height: 11.5)
desLable.textColor = UIColor(red: 0.592, green: 0.592, blue: 0.592, alpha: 1)
desLable.font = UIFont.PFSC_R(ofSize: 10)
subContentView.addSubview(desLable)
desLable.snp.makeConstraints { make in
make.left.equalTo(bbxLable.snp.right).offset(11)
make.centerY.equalTo(bbxLable)
}
// subContentView.backgroundColor = UIColor(hex: 0x999999)
let flowLayout = UICollectionViewFlowLayout()
let margin = 16.0
let gap = 20.0
let itemWidth = 80.0
flowLayout.itemSize = CGSize(width: itemWidth, height: 64)
flowLayout.minimumInteritemSpacing = (KScreenWidth - 2 * 16 - 2*16 - 4 * itemWidth)/4
flowLayout.minimumLineSpacing = 15.0
flowLayout.scrollDirection = .vertical
let collectinoView = YHGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.contentInset = UIEdgeInsets(top: 0, left: margin, bottom: 20, right: margin)
collectinoView.backgroundColor = .white
collectinoView.register(YHBbxCollectionViewCell.self, forCellWithReuseIdentifier:YHBbxCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
myCollectView = collectinoView
myCollectView.isScrollEnabled = false
subContentView.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.top.equalTo(bbxLable.snp.bottom).offset(15)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.bottom.equalToSuperview().offset(-20)
}
}
}
extension YHDavidCell5: UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHBbxCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHBbxCollectionViewCell
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
}
//
// YHDavidTestCollectionViewCell.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
class YHDavidTestCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHDavidTestCollectionViewCell"
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
}()
lazy var descripeLable:UILabel = {
let label = UILabel()
label.text = "赴港攻略,当日往返无忧,这个季节风景..赴港攻略,当日往返无忧,这个季节风景"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
label.numberOfLines = 2
label.lineBreakMode = .byTruncatingTail
return label
}()
lazy var headImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_person_icon"))
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"))
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)
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
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
contentView.addSubview(subHoldView)
subHoldView.snp.makeConstraints { make in
make.top.equalTo(titleImageView.snp.bottom).offset(4)
make.left.right.equalToSuperview()
make.height.equalTo(87)
}
subHoldView.addSubview(descripeLable)
descripeLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.height.equalTo(30)
}
subHoldView.addSubview(headImageView)
headImageView.snp.makeConstraints { make in
make.top.equalTo(descripeLable.snp.bottom).offset(10)
make.left.equalTo(descripeLable.snp.left)
make.height.width.equalTo(25)
}
subHoldView.addSubview(nameLable)
nameLable.snp.makeConstraints { make in
make.top.equalTo(headImageView.snp.top)
make.left.equalTo(headImageView.snp.right).offset(5)
make.height.equalTo(12)
make.width.equalTo(50)
}
subHoldView.addSubview(dateLable)
dateLable.snp.makeConstraints { make in
make.top.equalTo(nameLable.snp.bottom).offset(2)
make.left.equalTo(nameLable.snp.left)
make.height.equalTo(12)
make.right.equalTo(nameLable.snp.right)
}
subHoldView.addSubview(numLable)
numLable.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8)
make.height.equalTo(12)
make.centerY.equalTo(headImageView.snp.centerY)
}
subHoldView.addSubview(heartImageView)
heartImageView.snp.makeConstraints { make in
make.right.equalTo(numLable.snp.left).offset(-6)
make.height.width.equalTo(12)
make.centerY.equalTo(headImageView.snp.centerY)
}
}
}
...@@ -18,11 +18,6 @@ extension YHGestureTableView: UIGestureRecognizerDelegate { ...@@ -18,11 +18,6 @@ extension YHGestureTableView: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true return true
} }
// open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// return true
// }
} }
...@@ -38,11 +33,6 @@ extension YHGestureScrollView: UIGestureRecognizerDelegate { ...@@ -38,11 +33,6 @@ extension YHGestureScrollView: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true return true
} }
// open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// return true
// }
} }
...@@ -57,9 +47,4 @@ extension YHGestureCollectionView: UIGestureRecognizerDelegate { ...@@ -57,9 +47,4 @@ extension YHGestureCollectionView: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true return true
} }
// open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// return true
// }
} }
//
// YHHkLifeAndIdItemView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
enum HkLifeItemType : Int {
case unknow = -1 //未知
case hkID = 0 //香港身份
case hklife = 1 //香港生活
}
class YHHkLifeAndIdItemView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var bkgImagV: UIImageView = {
let imageV = UIImageView()
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var iconV: UIImageView = {
let imageV = UIImageView()
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var titleLable : UILabel = {
let label = UILabel()
label.text = "香港身份"
label.textColor = UIColor.mainTextColor
label.font = UIFont.PFSC_M(ofSize: 17)
label.lineBreakMode = .byTruncatingMiddle
return label
}()
lazy var subtitleLable:UILabel = {
let label = UILabel()
label.text = "去香港"
label.textColor = UIColor(hex: 0x94A3B8, alpha: 1.0)
label.font = UIFont.PFSC_R(ofSize: 11)
label.lineBreakMode = .byTruncatingMiddle
return label
}()
var itemType : HkLifeItemType = .unknow {
didSet {
updateUI()
}
}
}
private extension YHHkLifeAndIdItemView {
func initView() {
addSubview(bkgImagV)
bkgImagV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
addSubview(iconV)
iconV.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(kMargin)
make.width.height.equalTo(34)
}
addSubview(titleLable)
titleLable.snp.makeConstraints { make in
make.top.equalTo(iconV.snp.top).offset(-3)
make.left.equalTo(iconV.snp.right).offset(kMargin)
make.height.equalTo(24)
make.right.equalTo(-10)
}
addSubview(subtitleLable)
subtitleLable.snp.makeConstraints { make in
make.top.equalTo(titleLable.snp.bottom).offset(2)
make.left.equalTo(titleLable.snp.left)
make.height.equalTo(16)
make.right.equalTo(titleLable.snp.right)
}
let tap = UITapGestureRecognizer(target: self, action: #selector(tapView(gestureRecognizer:)))
addGestureRecognizer(tap)
}
func updateUI() {
if itemType == .hkID {
bkgImagV.image = UIImage(named: "hklife_bkg_0")
iconV.image = UIImage(named: "hklife_icon_0")
titleLable.text = "香港身份"
subtitleLable.text = "去香港"
} else if itemType == .hklife {
bkgImagV.image = UIImage(named: "hklife_bkg_1")
iconV.image = UIImage(named: "hklife_icon_1")
titleLable.text = "香港生活"
subtitleLable.text = "在香港"
} else {
printLog("errorr:未处理")
}
}
@objc func tapView(gestureRecognizer:UITapGestureRecognizer) {
if itemType == .hkID {
//香港身份
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = 1
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
if let vcs = vc.viewControllers,vcs.count > 1 {
if let nvc = vcs[1] as? YHNavigationController,let vvc = nvc.topViewController as? YHServiceViewController {
vvc.jumpToItemIndex(itemIndex: 0)
}
}
}
}
} else if itemType == .hklife {
//香港生活
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = 1
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
if let vcs = vc.viewControllers,vcs.count > 1 {
if let nvc = vcs[1] as? YHNavigationController,let vvc = nvc.topViewController as? YHServiceViewController {
vvc.jumpToItemIndex(itemIndex: 1)
}
}
}
}
} else {
printLog("errorr:未处理")
}
}
}
//
// YHHkLifeAndIdView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
/*
香港身份 香港生活
*/
class YHHkLifeAndIdView: UIView {
static let viewH : CGFloat = 74.0
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
private extension YHHkLifeAndIdView {
func initView() {
let itemW : CGFloat = (KScreenWidth - 20 * 2 - 12) / 2.0
let item0 = YHHkLifeAndIdItemView()
item0.itemType = .hkID
addSubview(item0)
item0.snp.makeConstraints { make in
make.top.left.equalToSuperview()
make.height.equalTo(YHHkLifeAndIdView.viewH)
make.width.equalTo(itemW)
}
let item1 = YHHkLifeAndIdItemView()
item1.itemType = .hklife
addSubview(item1)
item1.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(item0.snp.right).offset(12)
make.height.equalTo(YHHkLifeAndIdView.viewH)
make.width.equalTo(itemW)
}
}
}
//
// YHHomeBannerCollectionViewCell.swift
// galaxy
//
// Created by davidhuangA on 2024/4/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
class YHHomeBannerCollectionViewCell: FSPagerViewCell {
override init(frame: CGRect) {
super.init(frame: frame)
textLabel?.text = ""
textLabel?.isHidden = true
imageView?.isHidden = true
initView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var bannerImagV: UIImageView = {
let imagV : UIImageView = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.clipsToBounds = true
return imagV
}()
lazy var bannerTitleLable: UILabel = {
let lable = UILabel()
lable.font = UIFont.PFSC_R(ofSize: 16)
lable.textColor = UIColor.white
return lable
}()
lazy var effectV : UIVisualEffectView = {
let effect = UIBlurEffect(style: .light)
let effectV = UIVisualEffectView.init(effect: effect)
return effectV
}()
var dataModel : YHBannerModel? {
didSet {
updateUI()
}
}
}
private extension YHHomeBannerCollectionViewCell {
func initView() {
contentView.addSubview(bannerImagV)
bannerImagV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
contentView.addSubview(effectV)
effectV.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(77)
}
contentView.addSubview(bannerTitleLable)
bannerTitleLable.snp.makeConstraints { make in
make.right.equalTo(-20)
make.bottom.equalTo(-35)
make.left.equalTo(20)
make.height.equalTo(22)
}
}
func updateUI() {
guard let model = dataModel else { return }
if let url = URL(string: model.img_url) {
bannerImagV.kf.setImage(with: url)
}
bannerTitleLable.text = model.name
}
}
//
// YHHomeBannerIndicatorView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeBannerIndicatorView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var indicatorItems : Int = 0 {
didSet {
createUI()
}
}
var curIndicatorIndex : Int = 0 {
didSet {
updateUI()
}
}
private var arrViews : [UIView] = []
private var normalColor : UIColor = UIColor(hex: 0xffffff, alpha: 0.3)
private var selectedColor : UIColor = UIColor(hex: 0xffffff)
lazy var subHoldView: UIView = {
let view = UIView()
return view
}()
}
extension YHHomeBannerIndicatorView {
func initView() {
addSubview(subHoldView)
subHoldView.snp.makeConstraints { make in
make.centerX.centerY.equalToSuperview()
make.top.bottom.equalToSuperview()
}
}
func createUI() {
arrViews.removeAll()
subHoldView.removeSubviews()
if indicatorItems == 1 {
let view = UIView()
view.backgroundColor = normalColor
subHoldView.addSubview(view)
view.snp.makeConstraints { make in
make.left.equalToSuperview()
make.right.equalToSuperview()
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
} else {
var tagView : UIView?
for i in 0..<indicatorItems {
let view = UIView()
view.backgroundColor = normalColor
subHoldView.addSubview(view)
if i == 0 {
view.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
view.backgroundColor = selectedColor
} else if i == indicatorItems - 1 {
view.snp.makeConstraints { make in
make.left.equalTo(tagView!.snp.right).offset(3)
make.right.equalToSuperview()
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
} else {
view.snp.makeConstraints { make in
make.left.equalTo(tagView!.snp.right).offset(3)
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
}
tagView = view
arrViews.append(view)
}
}
}
func updateUI() {
if curIndicatorIndex < indicatorItems {
for (index,item) in arrViews.enumerated() {
if index == curIndicatorIndex {
item.backgroundColor = selectedColor
} else {
item.backgroundColor = normalColor
}
}
}
}
}
...@@ -9,18 +9,15 @@ ...@@ -9,18 +9,15 @@
import Foundation import Foundation
import FSPagerView import FSPagerView
import Kingfisher import Kingfisher
//import SwifterSwift
class YHHomeBannerView: UIView { class YHHomeBannerView: UIView {
static let viewH : CGFloat = KScreenWidth - 20.0 * 2
// MARK: - constant 常量 var dataArr: [YHBannerModel] = [] {
// 位置、大小、图片、文本 didSet {
self.indicatorView.indicatorItems = self.dataArr.count
fileprivate var dataArr: [YHBannerModel] = [YHBannerModel(),YHBannerModel(),YHBannerModel(),YHBannerModel(),YHBannerModel()] bannerView.reloadData()
}
}
// MARK: - life cycle 生命周期
//工程的viewDidLoad、viewWillAppear、init、didReceiveMemoryWarning等方法都放在这里
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
...@@ -31,82 +28,62 @@ class YHHomeBannerView: UIView { ...@@ -31,82 +28,62 @@ class YHHomeBannerView: UIView {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
private lazy var bannerView: FSPagerView = {
let view = FSPagerView()
view.delegate = self
view.dataSource = self
view.automaticSlidingInterval = 4
view.register(YHHomeBannerCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
view.itemSize = CGSizeMake(YHHomeBannerView.viewH, YHHomeBannerView.viewH)//FSPagerView.automaticSize
return view
}()
// MARK: - view layout 子视图的布局 lazy var indicatorView : YHHomeBannerIndicatorView = {
//界面布局 let view = YHHomeBannerIndicatorView()
return view
}()
}
private extension YHHomeBannerView {
func initView() { func initView() {
addSubview(bannerView) addSubview(bannerView)
bannerView.snp.makeConstraints { make in bannerView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(10) make.top.equalToSuperview()
make.bottom.equalToSuperview() make.left.equalToSuperview()
make.left.equalToSuperview().offset(16) make.right.equalToSuperview()
make.right.equalToSuperview().offset(-16) make.height.equalTo(YHHomeBannerView.viewH)
} }
bannerView.addSubview(pageControl) bannerView.addSubview(indicatorView)
pageControl.snp.makeConstraints { make in indicatorView.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview() make.left.right.equalToSuperview()
make.height.equalTo(25) make.height.equalTo(2)
make.bottom.equalTo(-14)
} }
setupPageControl()
bannerView.reloadData() bannerView.reloadData()
} }
func setupPageControl() { func goAppTab(tabBarName : String) {
self.pageControl.numberOfPages = self.dataArr.count if !tabBarName.isEmpty {
self.pageControl.contentHorizontalAlignment = .center if tabBarName.contains("tabBarHome",caseSensitive: false) {
self.pageControl.contentInsets = UIEdgeInsets(top: 0, left: 12, bottom: 10, right: 12) //首页
goTabBarBy(tabType: .home)
} else if tabBarName.contains("tabBarService",caseSensitive: false) {
let normalImage = UIImage(color: UIColor(hex: 0xff0000, alpha: 1.0), size: CGSize(width: 5, height: 5))//UIImage(color: UIColor(white: 1, alpha: 0.5), size: CGSize(width: 5, height: 5)) //服务中心
let selectImage = UIImage(color: .white, size: CGSize(width: 8, height: 5)) goTabBarBy(tabType: .service)
self.pageControl.setImage(normalImage, for: .normal) } else if tabBarName.contains("tabBarMsg",caseSensitive: false) {
self.pageControl.setImage(selectImage, for: .selected) //消息
goTabBarBy(tabType: .message)
self.pageControl.interitemSpacing = 3 } else if tabBarName.contains("tabBarMine",caseSensitive: false) {
//我的
goTabBarBy(tabType: .mine)
} else {
}
}
} }
// public func refreshUI(_ arr: [YHBannerModel]) {
//
// let model : YHBannerModel = YHBannerModel()
// model.img_url = "https://upload-cdn.galaxy-immi.com/sell/test/1668772072522.jpg"
//
// model.link_type = 0
// model.title = "我是测试数据"
//
// let arr = [model,model,model,model,model]
//
// self.dataArr = arr
// setupPageControl()
// bannerView.reloadData()
// }
private lazy var bannerView: FSPagerView = {
let view = FSPagerView()
view.delegate = self
view.dataSource = self
view.automaticSlidingInterval = 3
view.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
view.itemSize = FSPagerView.automaticSize
view.interitemSpacing = 10
return view
}()
lazy var pageControl: FSPageControl = {
let view = FSPageControl()
return view
}()
} }
// MARK: - delegate 具体到某个delegate,比如UITableViewDelegate
//代理或者数据源
// MARK: - FSPagerViewDelegate
extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate { extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
public func numberOfItems(in pagerView: FSPagerView) -> Int { public func numberOfItems(in pagerView: FSPagerView) -> Int {
...@@ -114,28 +91,14 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -114,28 +91,14 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
} }
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell { public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index) let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index) as! YHHomeBannerCollectionViewCell
let image = UIImage(named: "default_placeholder_image")?.bs_scaled(toWidth: UIDevice.kScreenW - 16*2, opaque: false)
cell.imageView?.image = image
if index < dataArr.count { if index < dataArr.count {
let model = dataArr[index] cell.dataModel = dataArr[index]
if let url = URL(string: model.img_url) {
cell.imageView?.kf.setImage(with: url)
}
cell.textLabel?.text = model.title
} }
cell.imageView?.contentMode = .scaleAspectFill
cell.backgroundColor = .contentBkgColor
cell.contentView.layer.shadowColor = UIColor.clear.cgColor
return cell return cell
} }
// MARK: - FSPagerView Delegate // MARK: - FSPagerView Delegate
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) { func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true) pagerView.deselectItem(at: index, animated: true)
pagerView.scrollToItem(at: index, animated: true) pagerView.scrollToItem(at: index, animated: true)
...@@ -143,27 +106,34 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -143,27 +106,34 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
return return
} }
let model = dataArr[index] let model = dataArr[index]
switch model.link_type { if model.skip_url.isEmpty == false {
case 10: //跳转H5 switch model.skip_type {
// let vc = BsWebViewController() case 1: //跳转H5
// vc.urlString = model.link_url let vc = YHHomeWebViewController()
// UIViewController.navTopViewController?.navigationController?.pushViewController(vc, animated: true) vc.url = model.skip_url
break self.parentViewController?.navigationController?.pushViewController(vc)
case 20: //跳转原生页面 case 2: //跳转APP内Tab
if let vc = UIViewController.classFromString(model.link_url) { goAppTab(tabBarName:model.skip_url)
UIViewController.navTopViewController?.navigationController?.pushViewController(vc, animated: true) case 3://3-跳转资讯页
let vc = YHHomeWebViewController()
vc.url = model.skip_url
self.parentViewController?.navigationController?.pushViewController(vc)
case 0://0 不需要跳转
printLog("0 不需要跳转")
default:
YHHUD.flash(message: "不需要处理的类型")
break
} }
break } else {
default: YHHUD.flash(message: "error:skip_url不能为空")
break
} }
} }
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) { func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.pageControl.currentPage = targetIndex self.indicatorView.curIndicatorIndex = targetIndex
} }
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) { func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.pageControl.currentPage = pagerView.currentIndex self.indicatorView.curIndicatorIndex = pagerView.currentIndex
} }
} }
//
// YHHomeCustomCell.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
class YHHomeCustomCell: UITableViewCell {
static let cellReuseIdentifier = "YHHomeCustomCell"
lazy var items = {
return [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_response", title: "快速响应", detail: "身份规划师一对一专业服务,第一时间响应您的需求"),
AboutAdvantageItem(iconName: "about_service", title: "专业服务", detail: "5年经验+英语专8级文案导师团队倾力支持"),
AboutAdvantageItem(iconName: "about_service2", title: "精准匹配", detail: "香港专才、香港留学获批常年保持90%以上")]
}()
var dataArray: [String] = [] // 假定我们的数据结构就是一个String数组
var collectionView: UICollectionView!
var collectionContainer: UIView!
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// 设置布局方向
let flowLayout = UICollectionViewFlowLayout()
let margin = 18.0
let gap = 12.0
let itemWidth = floor((KScreenWidth-2*margin-gap)/2.0)
flowLayout.itemSize = CGSize(width: itemWidth, height: itemWidth)
flowLayout.minimumInteritemSpacing = 12.0
flowLayout.minimumLineSpacing = 12.0
flowLayout.scrollDirection = .vertical
collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectionView.contentInset = UIEdgeInsets(top: 0, left: margin, bottom: 0, right: margin)
collectionView.backgroundColor = UIColor.white
collectionView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectionView.delegate = self
collectionContainer = UIView(frame: .zero)
contentView.addSubview(collectionContainer)
collectionContainer.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(0)
}
collectionContainer.addSubview(collectionView)
collectionView.snp.makeConstraints({ make in
make.edges.equalToSuperview()
})
// collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "test")
// collectionView.delegate = self // 这里根据具体业务写吧,demo中我就把代理直接设置成cell了..
// collectionView.dataSource = self // 根据业务,demo直接先cell持有数据来控制collectionView的显示了..
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// 外部调用,用来设置collectionView的数据源
func setData(_ data: [String]) {
self.dataArray = data
collectionView.reloadData()
// 这里需要 layoutIfNeeded 一下,否则我们不能同步拿到contentSize
// 注意,如果上面collectionContainer的布局没有指明宽度,这个时候cell的宽度是estimate状态,所以下面就算layout也拿不到正确的contentSize
collectionView.layoutIfNeeded()
let height = collectionView.contentSize.height
printLog(height)
collectionContainer.snp.updateConstraints { make in
make.height.equalTo(height)
}
}
}
extension YHHomeCustomCell: UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAboutUsAdvantageCell.cellReuseIdentifier, for: indexPath) as! YHAboutUsAdvantageCell
cell.advantateItem = items[indexPath.row]
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
}
//
// YHHomeHeadView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeHeadView: UIView {
static let viewH : CGFloat = (20 + YHHomeBannerView.viewH) + (20 + YHHkLifeAndIdView.viewH) + (20 + YHHomeKingKongBlockView.viewH) + 31 + 31
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
//1.bannner
lazy var homeBannerView : YHHomeBannerView = {
let view = YHHomeBannerView()
return view
}()
//2.香港身份 香港生活
lazy var homeHkLife : YHHkLifeAndIdView = {
let view = YHHkLifeAndIdView()
return view
}()
//3. 四大金刚区
lazy var homeKingKongBlock : YHHomeKingKongBlockView = {
let view = YHHomeKingKongBlockView()
return view
}()
}
private extension YHHomeHeadView {
func initView() {
backgroundColor = .clear
addSubview(homeBannerView)
homeBannerView.snp.makeConstraints { make in
make.top.equalTo(20)
make.left.right.equalToSuperview()
make.height.equalTo(YHHomeBannerView.viewH)
}
addSubview(homeHkLife)
homeHkLife.snp.makeConstraints { make in
make.top.equalTo(homeBannerView.snp.bottom).offset(20)
make.left.right.equalToSuperview()
make.height.equalTo(YHHkLifeAndIdView.viewH)
}
addSubview(homeKingKongBlock)
homeKingKongBlock.snp.makeConstraints { make in
make.top.equalTo(homeHkLife.snp.bottom).offset(20)
make.left.right.equalToSuperview()
make.height.equalTo(YHHomeKingKongBlockView.viewH)
}
let line = UIView()
line.backgroundColor = UIColor(hex: 0xF0F3F7, alpha: 1.0)
addSubview(line)
line.snp.makeConstraints { make in
make.top.equalTo(homeKingKongBlock.snp.bottom).offset(31)
make.left.right.equalToSuperview()
make.height.equalTo(1)
}
}
}
//
// YHHomeKingKongBlockItem.swift
// galaxy
//
// Created by davidhuangA on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeKingKongBlockItem: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var iconV: UIImageView = {
let imageV = UIImageView()
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var subtitleLable:UILabel = {
let label = UILabel()
label.text = "去香港"
label.textColor = UIColor(hex: 0x94A3B8, alpha: 1.0)
label.font = UIFont.PFSC_M(ofSize: 12)
label.lineBreakMode = .byTruncatingMiddle
label.textAlignment = .center
return label
}()
var dataModel : YHHomeKingKongBlockModel? {
didSet {
updateUI()
}
}
}
private extension YHHomeKingKongBlockItem {
func initView() {
backgroundColor = UIColor(hex: 0xF8FAFB, alpha: 1.0)
addSubview(iconV)
iconV.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.width.height.equalTo(31)
make.top.equalTo(10)
}
addSubview(subtitleLable)
subtitleLable.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.left.equalTo(4)
make.right.equalTo(-4)
make.height.equalTo(18)
make.bottom.equalTo(-8)
}
}
func updateUI() {
guard let dataModel = dataModel else { return }
iconV.image = UIImage(named: dataModel.iconName)
subtitleLable.text = dataModel.title
}
}
//
// YHHomeKingKongBlockView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeKingKongBlockView: UIView {
static let viewH : CGFloat = (KScreenWidth - 20 * 2 - 16 * 3) / 4.0
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var arrData : [YHHomeKingKongBlockModel] = [
YHHomeKingKongBlockModel(type: "3", iconName: "kingkong_sffl", title: "身份福利"),
YHHomeKingKongBlockModel(type: "4", iconName: "kingkong_blgl", title: "办理攻略"),
YHHomeKingKongBlockModel(type: "5", iconName: "kingkong_khxs", title: "客户心声"),
YHHomeKingKongBlockModel(type: "6", iconName: "kingkong_xgbs", title: "香港办事"),
]
}
private extension YHHomeKingKongBlockView {
func initView() {
let gap : CGFloat = 16.0
var offsetX : CGFloat = 0.0
for (index,item) in arrData.enumerated() {
let view = YHHomeKingKongBlockItem()
view.dataModel = item
addSubview(view)
view.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(offsetX)
make.width.height.equalTo(YHHomeKingKongBlockView.viewH)
}
offsetX = offsetX + YHHomeKingKongBlockView.viewH + gap
view.tag = index
let tap = UITapGestureRecognizer(target: self, action: #selector(tapView(gestureRecognizer:)))
view.addGestureRecognizer(tap)
}
}
@objc func tapView(gestureRecognizer:UITapGestureRecognizer) {
if let tag = gestureRecognizer.view?.tag {
switch tag {
case 0:
let vc = YHFourKingViewController()
vc.id = 3
UIViewController.current?.navigationController?.pushViewController(vc)
printLog("跳转 身份福利")
case 1:
let vc = YHFourKingViewController()
vc.id = 4
UIViewController.current?.navigationController?.pushViewController(vc)
printLog("跳转 办理攻略")
case 2:
let vc = YHFourKingViewController()
vc.id = 5
UIViewController.current?.navigationController?.pushViewController(vc)
printLog("跳转 客户心声")
case 3:
let vc = YHHKEventViewController()
UIViewController.current?.navigationController?.pushViewController(vc)
printLog("跳转 香港办事")
default:
break
}
}
}
}
//
// YHHomeSearchView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeSearchView: UIView {
static let viewH : CGFloat = 36.0
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
private extension YHHomeSearchView {
func initView() {
backgroundColor = UIColor(hex: 0xF4F6FA, alpha: 1.0)
let imageV : UIImageView = UIImageView()
imageV.contentMode = .scaleAspectFill
imageV.image = UIImage(named: "home_search_icon")
addSubview(imageV)
imageV.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(12)
make.width.height.equalTo(16)
}
let lable = UILabel()
lable.text = "大家正在搜香港身份"
lable.font = UIFont.PFSC_R(ofSize: 12)
lable.textColor = UIColor(hex: 0x94A3B8, alpha: 1.0)
addSubview(lable)
lable.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(imageV.snp.right).offset(8)
make.height.equalTo(18)
make.right.equalToSuperview().offset(-12)
}
}
}
...@@ -12,23 +12,26 @@ class YHHomeWebBottomView: UIView { ...@@ -12,23 +12,26 @@ class YHHomeWebBottomView: UIView {
typealias Block = (Bool) -> () typealias Block = (Bool) -> ()
var likeBlock: Block? var likeBlock: Block?
var starBlock: Block? var starBlock: Block?
private var likeButton: YHHomeWebBottomButton! var likeButton: YHHomeWebBottomButton!
private var starButton: YHHomeWebBottomButton! var starButton: YHHomeWebBottomButton!
var likeCount: Int = 0
var starCount: Int = 0
var isStar: Bool = false { var isStar: Bool = false {
didSet { didSet {
if isStar { if isStar {
starButton.setContent("home_web_stared", "34") starButton.setContent("home_web_stared", "\(starCount)")
} else { } else {
starButton.setContent("home_web_star", "34") starButton.setContent("home_web_star", "\(starCount)")
} }
} }
}//是否收藏 }//是否收藏
var isLike: Bool = false { var isLike: Bool = false {
didSet { didSet {
if isLike { if isLike {
likeButton.setContent("home_web_liked", "34") likeButton.setContent("home_web_liked", "\(likeCount)")
} else { } else {
likeButton.setContent("home_web_like", "34") likeButton.setContent("home_web_like", "\(likeCount)")
} }
} }
}//是否点赞 }//是否点赞
......
//
// BsPageContentView.swift
// GDKit
//
// Created by GDKit on 01/11/2022.
// Copyright (c) 2022 GDKit. All rights reserved.
//
import UIKit
@objc public protocol YHPageContentViewDelegate : AnyObject {
func pageContentView(_ contentView : YHPageContentView, progress : CGFloat, sourceIndex : Int, targetIndex : Int)
}
private let ContentCellID = "BsContentCellID"
open class YHPageContentView: UIView {
// MARK: - 定义属性
fileprivate var childVcs : [UIViewController]
fileprivate weak var parentVC : UIViewController?
fileprivate var startOffsetX : CGFloat = 0
fileprivate var isForbidScrollDelegate : Bool = false
@objc public weak var delegate : YHPageContentViewDelegate?
public var isScrollEnabled: Bool? {
didSet {
if let isScrollEnabled = isScrollEnabled {
collectionView.isScrollEnabled = isScrollEnabled
}
}
}
@objc public func banScrollEnabled() {
// collectionView.isScrollEnabled = false
collectionView.isScrollEnabled = true
}
fileprivate func getLayout() -> UICollectionViewFlowLayout {
let layout = UICollectionViewFlowLayout()
layout.itemSize = self.bounds.size
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.scrollDirection = .horizontal
return layout
}
// MARK: - 懒加载属性
fileprivate lazy var collectionView : UICollectionView = {[weak self] in
// 1.创建layout
let layout = self?.getLayout() ?? UICollectionViewFlowLayout()
// 2.创建UICollectionView
let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
collectionView.backgroundColor = .clear//groupTableViewBackground
collectionView.showsHorizontalScrollIndicator = false
collectionView.isPagingEnabled = true
collectionView.bounces = false
collectionView.dataSource = self
collectionView.delegate = self
collectionView.scrollsToTop = false
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: ContentCellID)
return collectionView
}()
// MARK: - 自定义构造函数
@objc public init(frame: CGRect, childVcs : [UIViewController], parentViewController : UIViewController?) {
self.childVcs = childVcs
self.parentVC = parentViewController
super.init(frame: frame)
// 设置UI
setupUI()
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
// MARK: - 设置UI界面
extension YHPageContentView {
fileprivate func setupUI() {
// 1.将所有的子控制器添加父控制器中
// for childVc in childVcs {
// parentVC?.addChild(childVc)
// }
// 2.添加UICollectionView,用于在Cell中存放控制器的View
addSubview(collectionView)
collectionView.frame = bounds
}
public func refreshRect() {
collectionView.frame = bounds
collectionView.collectionViewLayout = self.getLayout()
}
}
// MARK: - 遵守UICollectionViewDataSource
extension YHPageContentView : UICollectionViewDataSource {
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return childVcs.count
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// 1.创建Cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ContentCellID, for: indexPath)
// 2.给Cell设置内容
for view in cell.contentView.subviews {
view.removeFromSuperview()
}
let childVc = childVcs[(indexPath as NSIndexPath).item]
childVc.view.frame = cell.contentView.bounds
cell.contentView.addSubview(childVc.view)
return cell
}
}
// MARK: - 遵守UICollectionViewDelegate
extension YHPageContentView : UICollectionViewDelegate {
public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
isForbidScrollDelegate = false
startOffsetX = scrollView.contentOffset.x
}
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
// 0.判断是否是点击事件
if isForbidScrollDelegate { return }
// 1.定义获取需要的数据
var progress : CGFloat = 0
var sourceIndex : Int = 0
var targetIndex : Int = 0
// 2.判断是左滑还是右滑
let currentOffsetX = scrollView.contentOffset.x
let scrollViewW = scrollView.bounds.width
if currentOffsetX > startOffsetX { // 左滑
// 1.计算progress
progress = currentOffsetX / scrollViewW - floor(currentOffsetX / scrollViewW)
// 2.计算sourceIndex
sourceIndex = Int(currentOffsetX / scrollViewW)
// 3.计算targetIndex
targetIndex = sourceIndex + 1
if targetIndex >= childVcs.count {
targetIndex = childVcs.count - 1
}
// 4.如果完全划过去
if currentOffsetX - startOffsetX == scrollViewW {
progress = 1
targetIndex = sourceIndex
}
} else { // 右滑
// 1.计算progress
progress = 1 - (currentOffsetX / scrollViewW - floor(currentOffsetX / scrollViewW))
// 2.计算targetIndex
targetIndex = Int(currentOffsetX / scrollViewW)
// 3.计算sourceIndex
sourceIndex = targetIndex + 1
if sourceIndex >= childVcs.count {
sourceIndex = childVcs.count - 1
}
}
// 3.将progress/sourceIndex/targetIndex传递给titleView
delegate?.pageContentView(self, progress: progress, sourceIndex: sourceIndex, targetIndex: targetIndex)
}
}
// MARK: - 对外暴露的方法
extension YHPageContentView {
@objc public func setCurrentIndex(_ currentIndex : Int) {
// 1.记录需要进制执行代理方法
isForbidScrollDelegate = true
// 2.滚动正确的位置
let offsetX = CGFloat(currentIndex) * collectionView.frame.width
collectionView.setContentOffset(CGPoint(x: offsetX, y: 0), animated: false)
}
}
//
// YHSearchInfoHistoryCell.swift
// galaxy
//
// Created by edy on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHSearchInfoHistoryCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHSearchInfoHistoryCell"
lazy var titleLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textAlignment = .left
label.textColor = UIColor(hex: 0x121A26)
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
contentView.backgroundColor = UIColor(hexString: "#F4F6FA")
contentView.clipsToBounds = true
contentView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalToSuperview().offset(12.0)
make.right.equalToSuperview().offset(-12.0)
}
}
}
// //
// YHHomeViewController.swift // YHServiceCenterMainViewController.swift
// galaxy // galaxy
// //
// Created by EDY on 2023/12/20. // Created by EDY on 2023/12/20.
// //
import UIKit import UIKit
import JXSegmentedView
//服务中心 //服务中心
class YHServiceCenterMainViewController: YHBaseViewController { class YHServiceCenterMainViewController: YHBaseViewController {
...@@ -222,3 +223,9 @@ extension YHServiceCenterMainViewController { ...@@ -222,3 +223,9 @@ extension YHServiceCenterMainViewController {
homeTableView.reloadData() homeTableView.reloadData()
} }
} }
extension YHServiceCenterMainViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
...@@ -63,7 +63,7 @@ class YHFileListViewController: YHBaseViewController { ...@@ -63,7 +63,7 @@ class YHFileListViewController: YHBaseViewController {
private lazy var footLable : UILabel = { private lazy var footLable : UILabel = {
let footLable = UILabel() let footLable = UILabel()
footLable.text = "*感谢您对银河移民的信赖,以上信息均用于香港优才签证申银河移民承诺对您所提供的信息将绝对保密" footLable.text = "*感谢您对银河移民的信赖,以上信息均用于香港优才签证申请,银河移民承诺对您所提供的信息将绝对保密"
footLable.textColor = .white footLable.textColor = .white
footLable.textAlignment = .center footLable.textAlignment = .center
footLable.font = UIFont.PFSC_R(ofSize: 12) footLable.font = UIFont.PFSC_R(ofSize: 12)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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