Commit 364058fe authored by David黄金龙's avatar David黄金龙

Merge branch 'develop'

* develop: (179 commits)
  no message
  删除不使用的代码
  进度字体修改
  去除侧滑代码
  1、使用配置URL 2、修改版本号 0.2.10.5
  图片相应交互
  // 测评码UI更改
  // adhoc
  // add aps-environment
  // UI
  保存图片到相册
  解决复杂UI布局下 滑动返回失效问题
  // add tag 0.2.10-4
  // UI走查
  //  UI走查
  1、每页20请求数据 2、添加webView下方保存按钮的button
  //  关于我们
  去除banner空隙
  // push
  还原一处代码
  ...

# Conflicts:
#	galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyViewController.swift
parents 3168859a 7fcf0883
This diff is collapsed.
......@@ -35,21 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//4.本地用户信息加载
YHLoginManager.shared.loadLocalUserInfoData()
YHConfigManager.shared.loadConfigData()
// YHAnalytics.analyticsStart(launchOptions: launchOptions)
// var i = 0
// for family: String in UIFont.familyNames {
// print("\(i)---项目字体---\(family)")
// for names: String in UIFont.fontNames(forFamilyName: family) {
// print("== \(names)")
// }
// i += 1
// }
return true
}
......@@ -123,30 +109,10 @@ extension AppDelegate {
//1.设置主窗口
private func setupRootVC() {
let tabBarController = YHTabBarViewController()
let homeVC = YHHomePageViewController()
tabBarController.delegate = homeVC
let v0 = YHNavigationController(rootVC:homeVC)
let v1 = YHNavigationController(rootVC:YHServiceViewController())
let v2 = YHNavigationController(rootVC:YHMsgViewController())
let v3 = YHNavigationController(rootVC:YHMyViewController())
v0.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "首页", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
v1.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "服务中心", image: UIImage(named: "service"), selectedImage: UIImage(named: "service_1"))
v2.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "消息", image: UIImage(named: "msg"), selectedImage: UIImage(named: "msg_1"))
v3.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
tabBarController.viewControllers = [v0,v1,v2,v3]
tabBarController.tabBar.backgroundColor = .white
let nav = YHNavigationController(rootVC:YHStartPageViewController())
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = YHStartPageViewController()
window?.rootViewController = nav
window?.makeKeyAndVisible()
}
}
......
......@@ -24,15 +24,21 @@ extension AppDelegate: JPUSHRegisterDelegate {
// init Push
// notice: 2.1.5 版本的 SDK 新增的注册方法,改成可上报 IDFA,如果没有使用 IDFA 直接传 nil
//初始化极光推送服务,调用了本 API 后,开启 JPush 推送服务,将会开始收集上报 SDK 业务功能所必要的用户个人信息
// [JPUSHService setupWithOption:launchOptions appKey:appKey
// channel:channel
// apsForProduction:isProduction
// advertisingIdentifier:advertisingId];
// [JPUSHService setupWithOption:launchOptions appKey:appKey
// channel:channel
// apsForProduction:isProduction
// advertisingIdentifier:advertisingId];
#if DEBUG
let isProduction = false
#elseif TESTENV
let isProduction = true
#else
let isProduction = true
#endif
JPUSHService.setup(withOption:launchOptions,
appKey:"c6a9e10575b85ee90f3e8afe",
channel:"",
channel:"appStore",
apsForProduction: isProduction)
}
......@@ -41,47 +47,80 @@ extension AppDelegate: JPUSHRegisterDelegate {
let deviceTokenStr = deviceToken.map{String(format:"%02.2hhx", arguments: [$0]) }.joined()
print("deviceToken:\(deviceTokenStr)")
JPUSHService.registerDeviceToken(deviceToken)
YHLoginManager.shared.userModel?.deviceToken = deviceTokenStr
YHLoginManager.shared.deviceTokenModel.deviceToken = deviceTokenStr
#if DEBUG
// YHHUD.flash(message: deviceTokenStr)
#elseif TESTENV
// YHHUD.flash(message: deviceTokenStr)
#else
#endif
}
//获取token 失败
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { //可选
print("did Fail To Register For Remote Notifications With Error: \(error)")
#if DEBUG
YHHUD.flash(message: error.localizedDescription)
#elseif TESTENV
YHHUD.flash(message: error.localizedDescription)
#else
#endif
}
//点推送进来执行这个方法
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
JPUSHService.handleRemoteNotification(userInfo)
completionHandler(UIBackgroundFetchResult.newData)
JPUSHService.handleRemoteNotification(userInfo)
completionHandler(UIBackgroundFetchResult.newData)
// 转换到消息tab
YHLoginManager.shared.needJumpToMsgTabFlag = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
})
}
//后台进前台
func applicationDidEnterBackground(_ application: UIApplication) {
//销毁通知红点
UIApplication.shared.applicationIconBadgeNumber = 0
JPUSHService.setBadge(0)
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
func applicationWillEnterForeground(_ application: UIApplication) {
DispatchQueue.main.async {
// 请求消息页面通知权限通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didReqeustNotifyPermissionNotification, object: nil)
}
}
@available(iOS 10.0, *)
func jpushNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: ((Int) -> Void)) {
let userInfo = notification.request.content.userInfo
if notification.request.trigger is UNPushNotificationTrigger {
JPUSHService.handleRemoteNotification(userInfo)
}
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler(Int(UNNotificationPresentationOptions.alert.rawValue))
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler(Int(UNNotificationPresentationOptions.alert.rawValue))
// 显示通知时需要刷新消息列表和消息未读总数
DispatchQueue.main.async {
// 请求消息未读总数通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
// 请求消息列表通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgListNotification, object: nil)
}
}
@available(iOS 10.0, *)
func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) {
let userInfo = response.notification.request.content.userInfo
let userInfo = response.notification.request.content.userInfo
if response.notification.request.trigger is UNPushNotificationTrigger {
JPUSHService.handleRemoteNotification(userInfo)
}
// 系统要求执行这个方法
completionHandler()
// 转换到消息tab
YHLoginManager.shared.needJumpToMsgTabFlag = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
})
}
......
......@@ -28,8 +28,7 @@ class YHBaseViewController: UIViewController {
#if DEBUG
IQKeyboardManager.shared.enable = true
#endif
navigationController?.interactivePopGestureRecognizer?.delegate = self
}
override var prefersStatusBarHidden: Bool {
......@@ -45,4 +44,36 @@ class YHBaseViewController: UIViewController {
printLog(#function)
#endif
}
func popGestureClose() {
if let ges = self.navigationController?.interactivePopGestureRecognizer?.view?.gestureRecognizers {
for item in ges {
item.isEnabled = false
}
}
}
func popGestureOpen() {
if let ges = self.navigationController?.interactivePopGestureRecognizer?.view?.gestureRecognizers {
for item in ges {
item.isEnabled = false
}
}
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if children.count == 1 {
return false
}else{
return true
}
}
}
extension YHBaseViewController: UIGestureRecognizerDelegate {
// 这个方法是在手势将要激活前调用
// 返回YES允许右滑手势的激活,返回NO不允许右滑手势的激活
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
......@@ -10,6 +10,13 @@ import UIKit
class YHNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
guard let targets = interactivePopGestureRecognizer?.value(forKey: "_targets") as? [NSObject] else {return}
let targetObjc = targets[0]
let target = targetObjc.value(forKey: "target")
let action = Selector(("handleNavigationTransition:"))
let panges = UIPanGestureRecognizer(target: target, action: action)
view.addGestureRecognizer(panges)
}
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
......
......@@ -10,9 +10,28 @@ import UIKit
import ESTabBarController_swift
class YHTabBarViewController: ESTabBarController {
lazy var viewModel = {
let model = YHMsgViewModel()
return model
}()
override func viewDidLoad() {
super.viewDidLoad()
handleTabBarLine()
addObservers()
if YHLoginManager.shared.isLogin() {
getTotalUnreadMsgCount()
reportDeviceInfo()
}
}
func addObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(clearAllUnreadBadge), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
}
}
......@@ -24,6 +43,68 @@ extension YHTabBarViewController {
@objc func showTabBar() -> Void {
self.tabBar.isHidden = false
}
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
getTotalUnreadMsgCount()
}
@objc func logoutSuccess() {
printLog("登出成功")
}
@objc func clearAllUnreadBadge() {
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
msgListVC.tabBarItem.badgeValue = nil
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
}
// 请求未读消息总数
@objc func getTotalUnreadMsgCount() {
if !YHLoginManager.shared.isLogin() {
return
}
self.viewModel.requestTotalUnreadMsgCount {
[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
let count = self.viewModel.unreadTotalCount
var unreadText:String? = nil
if 0 < count && count <= 99 {
unreadText = String(count)
} else if count > 99 {
unreadText = "99+"
}
msgListVC.tabBarItem.badgeValue = unreadText
}
}
}
}
func reportDeviceInfo() {
if !YHLoginManager.shared.isLogin() {
return
}
JPUSHService.registrationIDCompletionHandler {
resCode, registrationID in
if let deviceId = registrationID, !deviceId.isEmpty {
printLog("deviceId:\(deviceId)")
YHLoginManager.shared.deviceTokenModel.registerId = deviceId
self.viewModel.requestReportDeviceInfo(deviceId: deviceId) {
success, error in
if let error = error, !error.errorMsg.isEmpty {
printLog("error:\(error.errorMsg)")
}
}
}
}
}
}
extension YHTabBarViewController {
......@@ -31,7 +112,7 @@ extension YHTabBarViewController {
//展示tabbar上的横线
func handleTabBarLine() -> Void {
let rect = CGRect.init(x:0,y:0,width:KScreenWidth,height:0.5)
let fillColor = UIColor(hex:0x222222,transparency: 0.2)!
let fillColor = UIColor(hex:0x121A26,transparency: 0.05)!
let img = UIImage.from(color: fillColor, rect: rect)
UIView.transition(with:self.tabBar, duration:0.5, options: .transitionCrossDissolve) {
......@@ -42,5 +123,4 @@ extension YHTabBarViewController {
} completion: { Bool in
}
}
}
......@@ -22,16 +22,65 @@ class YHConfigManager: NSObject {
super.init()
}
//测试环境-H5
static let baseH5UrlTest : String = "https://test-hkdiy-h5.galaxy-immi.com"
//正式环境-H5
static let baseH5UrlRelease : String = "https://hkdiy-h5.galaxy-immi.com"
//h5地址
var h5Url : String {
return reqVM.configModel?.article_h5_url ?? ""
var tH5url = reqVM.configModel?.article_h5_url ?? ""
if tH5url.isEmpty {
#if DEBUG
tH5url = YHConfigManager.baseH5UrlTest
#elseif TESTENV
tH5url = YHConfigManager.baseH5UrlTest
#else
tH5url = YHConfigManager.baseH5UrlRelease
#endif
}
if !loadNewDataFlag {
loadConfigData()
}
return tH5url + "/"
}
//测试环境-OSS
static let baseOSSUrlTest : String = "https://test-comserver.galaxy-immi.com"
//正式环境-OSS
static let baseOSSUrlRelease : String = "http://comserver.galaxy-immi.com"
//OSS
var ossUrl : String {
var tOssUrl = reqVM.configModel?.oss_server ?? ""
if tOssUrl.isEmpty {
#if DEBUG
tOssUrl = YHConfigManager.baseOSSUrlTest
#elseif TESTENV
tOssUrl = YHConfigManager.baseOSSUrlTest
#else
tOssUrl = YHConfigManager.baseOSSUrlRelease
#endif
}
if !loadNewDataFlag {
loadConfigData()
}
return tOssUrl + "/"
}
}
extension YHConfigManager {
func loadConfigData() {
reqVM.getHomeConfig { flag, error in
if flag {
self.loadNewDataFlag = true
DispatchQueue.global().async {
self.reqVM.getHomeConfig { flag, error in
DispatchQueue.main.async {
if flag {
self.loadNewDataFlag = true
}
}
}
}
}
......
......@@ -17,23 +17,9 @@ class YHFourKingViewController: YHBaseViewController {
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
self.tableFootView.items = dataSouce
}
}
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()
......@@ -53,18 +39,35 @@ extension YHFourKingViewController {
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 ?? []
if self.classId == 0 {
gk_navTitle = model.name
self.sectionView.items = model.children
if model.children.count == 1 {
self.updateAllView()
}
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 updateAllView() {
sectionView.snp.remakeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(0)
}
tableFootView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
}
}
func setupUI() {
gk_navBarAlpha = 1
......@@ -73,81 +76,46 @@ extension YHFourKingViewController {
let view = YHServiceSectionView()
view.block = {[weak self] model in
guard let self = self else { return }
self.tableFootView.myCollectView.es.resetNoMoreData()
self.tableFootView.myCollectView.setContentOffset(CGPoint.zero, animated: false)
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()
self.tableFootView.myCollectView.es.noticeNoMoreData()
}
}
}
return view
}()
view.addSubview(homeTableView)
homeTableView.tableFooterView = tableFootView
homeTableView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
view.addSubview(sectionView)
sectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(48)
}
homeTableView.delegate = self
homeTableView.dataSource = self
homeTableView.es.addInfiniteScrolling {[weak self] in
tableFootView = YHServiceTableFootView()
tableFootView.moreBlock = {[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()
}
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
CATransaction.setDisableActions(true)
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
CATransaction.commit()
self.tableFootView.myCollectView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.tableFootView.myCollectView.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) {
view.addSubview(tableFootView)
tableFootView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar + 48)
}
}
}
......@@ -8,6 +8,7 @@
import UIKit
import WebKit
import Photos
class YHHKEventViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
......@@ -23,6 +24,17 @@ class YHHKEventViewController: YHBaseViewController {
super.viewWillAppear(animated)
loadData()
}
lazy var bottomViewForSavePic: YHHomeWebViewBottomForSavePicView = {
let view = YHHomeWebViewBottomForSavePicView()
view.isHidden = true
return view
}()
private var picUrl : String = ""
}
extension YHHKEventViewController {
......@@ -53,6 +65,21 @@ extension YHHKEventViewController {
let request = NSURLRequest(url: url! as URL)
// 加载请求
self.webview.load(request as URLRequest)
let navHeight = self.navigationController?.navigationBar.frame.height
//获取状态栏高度
let statusHeight = k_Height_statusBar()
if model.tag.contains("日历") {
picUrl = urlString
bottomViewForSavePic.isHidden = false
// 创建wkwebview
webview.frame = CGRect(x: 0, y: statusHeight + navHeight! + 48, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight! - 48 - YHHomeWebViewBottomForSavePicView.viewH)
} else {
bottomViewForSavePic.isHidden = true
webview.frame = CGRect(x: 0, y: statusHeight + navHeight! + 48, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight! - 48)
}
}
return view
}()
......@@ -71,7 +98,55 @@ extension YHHKEventViewController {
// 创建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)
view.addSubview(webview)
view.addSubview(bottomViewForSavePic)
bottomViewForSavePic.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(YHHomeWebViewBottomForSavePicView.viewH)
}
bottomViewForSavePic.block = { tag in
self.saveImageToPhotoLib()
}
}
}
extension YHHKEventViewController {
func saveImageToPhotoLib() {
var urlString = self.picUrl
guard let url = URL(string: urlString) else {
YHHUD.flash(message: "参数错误,保存失败")
return
}
YHHUD.show(.progress(message: "处理中..."))
let task = URLSession.shared.dataTask(with: url) { data, response, error in
DispatchQueue.main.async {
YHHUD.hide()
guard let data = data, error == nil else { return YHHUD.flash(message: "保存成功") }
let image = UIImage(data: data)
if let image = image {
// 保存图片到图库
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAsset(from: image)
}, completionHandler: { success, error in
if success {
// 图片保存成功
DispatchQueue.main.async {
YHHUD.flash(message: "保存成功")
}
} else if let error = error {
// 保存失败
DispatchQueue.main.async {
YHHUD.flash(message: "保存失败")
}
print("保存图片出错: \(error.localizedDescription)")
}
})
}
}
}
task.resume()
}
}
......@@ -20,7 +20,7 @@ class YHHomePageViewController: YHBaseViewController {
// 设置布局方向
let flowLayout = YHHomeCollectionLayout()
flowLayout.minimumInteritemSpacing = 7.0
flowLayout.minimumColumnSpacing = 10.0
flowLayout.minimumColumnSpacing = 7.0
flowLayout.sectionInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
......@@ -55,9 +55,8 @@ class YHHomePageViewController: YHBaseViewController {
return view
}()
var tapTimestamp : CFAbsoluteTime = -10.0
var tapTimestamp : CFAbsoluteTime = -10.0
}
private extension YHHomePageViewController {
......@@ -67,44 +66,58 @@ private extension YHHomePageViewController {
}
func getData() {
homeHeaderView.homeBannerView.dataArr = [YHBannerModel.localDefaultItem()]
loadFirstData()
getHomeBannerData()
viewModel.getHomeBanner(0) {[weak self] success, error in
guard let self = self else { return }
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? []
}
func getHomeBannerData() {
DispatchQueue.global().async {
self.viewModel.getHomeBanner(0) {[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.async {
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? [YHBannerModel.localDefaultItem()]
}
}
}
}
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()
DispatchQueue.global().async {
self.viewModel.getHomeNewsList(firstPageFlag : false) {[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
CATransaction.setDisableActions(true)
self.homeCollectView.reloadData()
CATransaction.commit()
self.homeCollectView.es.stopLoadingMore()
if self.viewModel.hasMoreForHomeNews == false {
self.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()
DispatchQueue.global().async {
self.viewModel.getHomeNewsList(firstPageFlag : true) {[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.async {
self.homeCollectView.es.stopPullToRefresh()
if self.viewModel.hasMoreForHomeNews == false {
self.homeCollectView.es.noticeNoMoreData()
}
CATransaction.setDisableActions(true)
self.homeCollectView.reloadData()
CATransaction.commit()
}
}
self.homeCollectView.reloadData()
// DispatchQueue.main.asyncAfter(deadline: .now() + 3, execute:{
// printLog(YHHomeHeadView.viewH)
// printLog(self.homeCollectView.contentOffset)
// })
}
}
......@@ -112,7 +125,9 @@ private extension YHHomePageViewController {
gk_navigationBar.isHidden = true
view.backgroundColor = .white
// NotificationCenter.default.addObserver(self, selector: #selector(homepageRefresh), name:YhConstant.YhNotification.refreshHomePageNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
view.addSubview(searchView)
searchView.snp.makeConstraints { make in
......@@ -124,13 +139,14 @@ private extension YHHomePageViewController {
view.addSubview(homeCollectView)
homeCollectView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.left.right.equalToSuperview()
make.top.equalTo(searchView.snp.bottom).offset(6)
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
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)
homeCollectView.contentInset = UIEdgeInsets(top: YHHomeHeadView.viewH, left: 0, bottom: 0, right: 0)
let tmpHeadView = homeCollectView.es.addPullToRefresh {
self.loadFirstData()
......@@ -140,6 +156,8 @@ private extension YHHomePageViewController {
r.origin.y = r.origin.y - YHHomeHeadView.viewH
tmpHeadView.frame = r
homeCollectView.showsHorizontalScrollIndicator = false
homeCollectView.showsVerticalScrollIndicator = false
homeCollectView.es.addInfiniteScrolling {
self.loadMoreData()
}
......@@ -148,6 +166,15 @@ private extension YHHomePageViewController {
@objc func homepageRefresh() {
loadFirstData()
}
@objc func loginSuccess() {
getData()
}
@objc func logoutSuccess() {
getData()
}
}
extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDataSource {
......@@ -166,7 +193,7 @@ extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDa
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.url = YHBaseUrlManager.shared.curH5URL() + "articleDetail.html" + "?id=\(model.id)"
vc.id = model.id
vc.block = { item in
if let arr = self.viewModel.arrHomeNewsData {
......@@ -174,11 +201,10 @@ extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDa
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.homeCollectView.reloadItems(at: [IndexPath.SubSequence(item: index, section: 0)])
}
}
}
}
self.navigationController?.pushViewController(vc)
} else if model.type == 1 {
......@@ -203,11 +229,36 @@ extension YHHomePageViewController : UITabBarControllerDelegate {
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.homeCollectView.setContentOffset(CGPoint(x: 0, y: -YHHomeHeadView.viewH), animated: true)
}
self.tapTimestamp = timestamp
} else if tabBarController.selectedIndex == 2 {
// 点击消息tab 清空应用icon未读数
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
guard let index = tabBarController.viewControllers?.firstIndex(of: viewController) else {
return false
}
if index == 1 || index == 2 {
if YHLoginManager.shared.isLogin() {
return true
} else {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
vc.modalPresentationStyle = .custom
UIViewController.current?.navigationController?.present(vc, animated: true)
YHLoginManager.shared.loginSuccessActionBlock = {[weak self] in
guard self != nil else { return }
tabBarController.selectedIndex = index
YHLoginManager.shared.loginSuccessActionBlock = nil
}
return false
}
}
return true
}
}
......@@ -8,6 +8,7 @@
import UIKit
import WebKit
import Photos
class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
......@@ -23,9 +24,25 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
var bottomView: YHHomeWebBottomView!
var url = ""
var id: Int = 0
var vcTitle : String?
lazy var bottomViewForSavePic: YHHomeWebViewBottomForSavePicView = {
let view = YHHomeWebViewBottomForSavePicView()
view.isHidden = true
return view
}()
//有些界面需要保存图片的功能
var showSavePicBottomFlag : Bool = false
override func viewDidLoad() {
super.viewDidLoad()
gk_navBarAlpha = 1.0
gk_navLineHidden = false
gk_navTitle = vcTitle
view.backgroundColor = .white
viewModel = YHHomeWebViewModel()
//获取导航栏高度
let navHeight = self.navigationController?.navigationBar.frame.height
......@@ -67,7 +84,6 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已点赞")
self.getData()
} else {
operationFlag = false
......@@ -78,7 +94,6 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已取消点赞")
self.getData()
} else {
operationFlag = false
......@@ -100,7 +115,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已收藏")
YHHUD.flash(message: "已加入收藏")
self.getData()
} else {
operationFlag = false
......@@ -111,7 +126,6 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
guard let self = self else { return }
if success {
operationFlag = true
YHHUD.flash(message: "已取消收藏")
self.getData()
} else {
operationFlag = false
......@@ -126,7 +140,6 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
make.bottom.left.right.equalToSuperview()
make.height.equalTo(59 + k_Height_safeAreaInsetsBottom())
}
getData()
if id == 0 {
if self.url.contains("?id=") {
......@@ -134,6 +147,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
if list.count == 2 {
if let iddd = list[1].int {
id = iddd
getData()
return
}
}
......@@ -141,6 +155,24 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
bottomView.isHidden = true
webview.frame = CGRect(x: 0, y: statusHeight + navHeight!, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight!)
}
if showSavePicBottomFlag {
bottomViewForSavePic.isHidden = false
view.addSubview(bottomViewForSavePic)
bottomViewForSavePic.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview()
make.height.equalTo(YHHomeWebViewBottomForSavePicView.viewH)
}
bottomViewForSavePic.block = { tag in
self.saveImageToPhotoLib()
}
webview.frame = CGRect(x: 0, y: statusHeight + navHeight!, width: self.view.frame.width, height: self.view.frame.height - statusHeight - navHeight! - YHHomeWebViewBottomForSavePicView.viewH)
} else {
bottomViewForSavePic.isHidden = true
}
getData()
}
deinit {
......@@ -148,23 +180,31 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
}
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)
if id > 0 {
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
if operationFlag {
self.block?(model)
}
}
}
}
}
// MARK: - WKNavigationDelegate
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.navigationItem.title = webview.title
if vcTitle == nil {
gk_navTitle = webview.title
}
}
// MARK: - WKUIDelegate
......@@ -193,7 +233,7 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
webview.goBack()
}
}
@objc func toForward() {
if webview.canGoForward {
webview.goForward()
......@@ -201,12 +241,12 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
}
// MARK: - KVO
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "estimatedProgress" {
self.progBar.alpha = 1.0
progBar.setProgress(Float(webview.estimatedProgress), animated: true)
//进度条的值最大为1.0
//进度条的值最大为1.0
if(self.webview.estimatedProgress >= 1.0) {
UIView.animate(withDuration: 0.3, delay: 0.1, options: .curveEaseInOut, animations: { () -> Void in
self.progBar.alpha = 0.0
......@@ -220,4 +260,41 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
override class func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
}
func saveImageToPhotoLib() {
var urlString = self.url
guard let url = URL(string: urlString) else {
YHHUD.flash(message: "参数错误,保存失败")
return
}
YHHUD.show(.progress(message: "处理中..."))
let task = URLSession.shared.dataTask(with: url) { data, response, error in
DispatchQueue.main.async {
YHHUD.hide()
guard let data = data, error == nil else { return YHHUD.flash(message: "保存成功") }
let image = UIImage(data: data)
if let image = image {
// 保存图片到图库
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAsset(from: image)
}, completionHandler: { success, error in
if success {
// 图片保存成功
DispatchQueue.main.async {
YHHUD.flash(message: "保存成功")
}
} else if let error = error {
// 保存失败
DispatchQueue.main.async {
YHHUD.flash(message: "保存失败")
}
print("保存图片出错: \(error.localizedDescription)")
}
})
}
}
}
task.resume()
}
}
......@@ -7,11 +7,14 @@
//
import UIKit
import AVFoundation
import AVKit
class YHSearchInfomationVC: YHBaseViewController {
static let searchInfoHistoryKey = "searchInfoHistoryKey"
static let searchHistoryMaxCount = 10
var searchStr = ""
var items:[YHHomeListModel] = []
lazy var viewModel: YHHomePageViewModel = {
......@@ -19,6 +22,11 @@ class YHSearchInfomationVC: YHBaseViewController {
return viewModel
}()
lazy var homeViewModel: YHHomeWebViewModel = {
let viewModel = YHHomeWebViewModel()
return viewModel
}()
lazy var navBar:UIView = {
let bar = UIView()
let backBtn = UIButton()
......@@ -39,9 +47,16 @@ class YHSearchInfomationVC: YHBaseViewController {
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)
searchStr = self.searchBar.textField.text ?? ""
searchStr = searchStr.trimmingCharacters(in: .whitespaces)
if isEmptyString(searchStr) {
searchStr = "香港身份"
self.searchBar.textField.text = "香港身份"
}
searchText()
if searchStr.count > 0 {
self.saveSearchHistory(searchStr)
}
}
bar.textChange = {
......@@ -60,10 +75,7 @@ class YHSearchInfomationVC: YHBaseViewController {
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.contentInsetAdjustmentBehavior = .never
tableView.estimatedSectionHeaderHeight = 0.1
tableView.estimatedSectionFooterHeight = 20.0
tableView.showsVerticalScrollIndicator = false
......@@ -73,6 +85,12 @@ class YHSearchInfomationVC: YHBaseViewController {
tableView.backgroundColor = .white
tableView.backgroundView = emptyDataTipsView
tableView.register(YHSearchInfoCell.self, forCellReuseIdentifier: YHSearchInfoCell.cellReuseIdentifier)
tableView.es.addPullToRefresh {
self.loadFirstData()
}
tableView.es.addInfiniteScrolling {
self.loadMoreData()
}
return tableView
}()
......@@ -84,7 +102,8 @@ class YHSearchInfomationVC: YHBaseViewController {
guard let self = self else { return }
self.searchHistoryView.isHidden = true
self.searchBar.textField.text = text
searchText(text)
self.searchStr = text
searchText()
self.saveSearchHistory(text)
}
return view
......@@ -118,6 +137,11 @@ class YHSearchInfomationVC: YHBaseViewController {
return view
}()
lazy var playerViewController: AVPlayerViewController = {
let vc = AVPlayerViewController()
return vc
}()
override func viewDidLoad() {
super.viewDidLoad()
self.setupUI()
......@@ -159,12 +183,14 @@ class YHSearchInfomationVC: YHBaseViewController {
}
}
func searchText(_ text:String) {
func searchText() {
self.tableView.scrollToTop()
YHHUD.show(.progress(message: "搜索中..."))
self.viewModel.searchArticleList(text) {
viewModel.searchArticleList(self.searchStr, isFirstPage : true) {
[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)
......@@ -172,6 +198,67 @@ class YHSearchInfomationVC: YHBaseViewController {
emptyDataTipsView.isHidden = (items.count > 0)
searchHistoryView.isHidden = true
self.tableView.reloadData()
tableView.es.stopPullToRefresh()
// 只有一页的时候不展示没有更多数据了
if self.viewModel.totalCount < self.viewModel.searchPageSize { // 不足一页
tableView.footer?.isHidden = true
} else {
tableView.footer?.isHidden = false
if self.viewModel.hasMoreForHomeNews == false {
tableView.es.noticeNoMoreData()
}
}
}
}
func loadMoreData() {
viewModel.searchArticleList(self.searchStr, isFirstPage : false) {
[weak self] success, error in
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()
tableView.es.stopLoadingMore()
// 只有一页的时候不展示没有更多数据了
if self.viewModel.totalCount < self.viewModel.searchPageSize { // 不足一页
tableView.footer?.isHidden = true
} else {
tableView.footer?.isHidden = false
if self.viewModel.hasMoreForHomeNews == false {
tableView.es.noticeNoMoreData()
}
}
}
}
func loadFirstData() {
viewModel.searchArticleList(self.searchStr, isFirstPage : true) {
[weak self] success, error in
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()
tableView.es.stopPullToRefresh()
// 只有一页的时候不展示没有更多数据了
if self.viewModel.totalCount < self.viewModel.searchPageSize { // 不足一页
tableView.footer?.isHidden = true
} else {
tableView.footer?.isHidden = false
if self.viewModel.hasMoreForHomeNews == false {
tableView.es.noticeNoMoreData()
}
}
}
}
......@@ -187,10 +274,13 @@ class YHSearchInfomationVC: YHBaseViewController {
if isEmptyString(text) { return }
var arr = getSearchHistoryList()
// 去除两端的空格
let targetText = text.trimmingCharacters(in: .whitespaces)
// 查找历史记录中是否有相同记录
var targetIndex = -1
for (index, history) in arr.enumerated() {
if history == text {
if history == targetText {
targetIndex = index
break
}
......@@ -202,9 +292,9 @@ class YHSearchInfomationVC: YHBaseViewController {
// 将最近记录放在第一位
if arr.count < Self.searchHistoryMaxCount {
arr.insert(text, at: 0)
arr.insert(targetText, at: 0)
} else {
arr.insert(text, at: 0)
arr.insert(targetText, at: 0)
arr.removeLast()
}
UserDefaults.standard.set(arr, forKey: Self.searchInfoHistoryKey)
......@@ -233,7 +323,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section]
cell.updateModel(item)
cell.renderHighLightText(self.searchBar.textField.text ?? "")
cell.renderHighLightText(searchStr)
}
return cell
}
......@@ -246,9 +336,29 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.section && indexPath.section < items.count {
let model = items[indexPath.section]
if model.type == 1 { // 视频
if !model.media_url.isEmpty, let url = URL(string: model.media_url) {
let player = AVPlayer(url:url)
player.isMuted = true
playerViewController.player = player
self.present(self.playerViewController, animated: true) {
self.playerViewController.player!.play() // 开始播放视频
}
DispatchQueue.main.async {
self.homeViewModel.getWebDetail(model.id) { success, error in
}
}
}
return
}
// 非视频类型
let vc = YHHomeWebViewController()
vc.url = YHConfigManager.shared.h5Url + "?id=\(model.id)"
vc.url = YHBaseUrlManager.shared.curH5URL() + "articleDetail.html" + "?id=\(model.id)"
vc.id = model.id
print("URL: \(vc.url)")
self.navigationController?.pushViewController(vc)
}
}
......
......@@ -35,8 +35,13 @@ class YHStartPageViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initView()
self.startTimer()
}
lazy var agreeAlertView : YHAgreementAlertView = {
let view = YHAgreementAlertView()
view.isHidden = true
return view
}()
}
......@@ -70,13 +75,14 @@ private extension YHStartPageViewController {
}
func initView() {
gk_navigationBar.isHidden = true
imagV.image = UIImage(named: "start_page_bkg")
view.addSubview(imagV)
imagV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
view.addSubview(closeBtn)
closeBtn.layer.zPosition = 10
closeBtn.clipsToBounds = true
......@@ -88,6 +94,54 @@ private extension YHStartPageViewController {
make.height.equalTo(28)
}
closeBtn.addTarget(self, action: #selector(clickCancelBtn), for: .touchUpInside)
view.addSubview(agreeAlertView)
agreeAlertView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
if let key = UserDefaults.standard.value(forKey: "userAgreeProtocal") as? String,key.contains("true") {
startTimer()
} else {
agreeAlertView.isHidden = false
cancelTimer()
closeBtn.isHidden = true
agreeAlertView.agreeBlock = {
UserDefaults.standard.set("true", forKey: "userAgreeProtocal")
UserDefaults.standard.synchronize()
self.closeBtn.isHidden = false
self.startTimer()
}
agreeAlertView.cancelBlock = {
//点击了取消按钮
YHCommonAlertView.show("", "确认退出智汇银河App?", "退出", "继续使用") {
//退出
exit(0)
} callBack: {
//继续使用
self.view.addSubview(self.agreeAlertView)
self.agreeAlertView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
self.agreeAlertView.isHidden = false
self.cancelTimer()
self.closeBtn.isHidden = true
}
}
agreeAlertView.urlBlock = { [weak self] url in
guard let self = self else { return }
let vc = YHWebViewViewController()
vc.url = url
self.navigationController?.pushViewController(vc)
}
}
}
@objc func clickCancelBtn() {
......@@ -101,13 +155,13 @@ private extension YHStartPageViewController {
let homeVC = YHHomePageViewController()
tabBarController.delegate = homeVC
let v0 = YHNavigationController(rootVC:homeVC)
let v1 = YHNavigationController(rootVC:YHServiceViewController())
let v2 = YHNavigationController(rootVC:YHMsgViewController())
let v1 = YHNavigationController(rootVC:YHServiceCenterMainViewController())
let v2 = YHNavigationController(rootVC:YHMessageListVC())
let v3 = YHNavigationController(rootVC:YHMyViewController())
v0.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "首页", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
v1.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "服务中心", image: UIImage(named: "service"), selectedImage: UIImage(named: "service_1"))
v1.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "服务", image: UIImage(named: "service"), selectedImage: UIImage(named: "service_1"))
v2.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "消息", image: UIImage(named: "msg"), selectedImage: UIImage(named: "msg_1"))
......@@ -119,5 +173,11 @@ private extension YHStartPageViewController {
let window = UIApplication.shared.yhKeyWindow()
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()
if YHLoginManager.shared.needJumpToMsgTabFlag {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
})
}
}
}
......@@ -16,4 +16,16 @@ class YHBannerModel: YHBaseModel {
var create_at: String = ""
var skip_type: Int = 0
var id: Int = 0
//是否为本地
var isLocalItemFlag : Bool = false
//
static func localDefaultItem() -> YHBannerModel {
let model = YHBannerModel()
model.isLocalItemFlag = true
model.img_url = "home_banner_default_icon"
model.type = 0
return model
}
}
......@@ -71,6 +71,8 @@ class YHHomeListModel: YHBaseModel {
imageHeight = width * imageSize.height/imageSize.width
if imageHeight > 280 {
imageHeight = 280
} else if imageHeight < 140 {
imageHeight = 140
}
}
......
//
// YHAgreementAlertView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/16.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
class YHAgreementAlertView: UIView {
typealias UrlBlock = (_ url: String) -> ()
var urlBlock: UrlBlock?
typealias AgreeBlock = () -> ()
var agreeBlock: AgreeBlock?
var cancelBlock:AgreeBlock?
var centerView: UIView!
var titleLabel: UILabel!
var lineView: UIView!
var messageLabel: UILabel!
var agreeButton: UIButton!
var disAgressButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self
addGestureRecognizer(tap)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
addSubview(centerView)
centerView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.left.equalTo(38)
make.right.equalTo(-38)
}
titleLabel = {
let label = UILabel()
label.textAlignment = .center
label.textColor = UIColor.mainTextColor
label.font = UIFont.PFSC_M(ofSize: 17)
label.numberOfLines = 0
label.text = "欢迎使用智汇银河App"
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(22)
make.right.equalTo(-22)
make.top.equalTo(kMargin)
}
lineView = {
let line = UIView()
line.backgroundColor = UIColor(hex: 0xF0F0F0)
return line
}()
centerView.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.height.equalTo(1)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
}
messageLabel = {
let label = UILabel()
label.textAlignment = .center
label.textColor = UIColor.mainTextColor
label.font = UIFont.PFSC_R(ofSize: 16)
label.numberOfLines = 0
label.text = ""
return label
}()
centerView.addSubview(messageLabel)
messageLabel.snp.makeConstraints { make in
make.left.equalTo(21)
make.right.equalTo(-21)
make.top.equalTo(lineView.snp.bottom).offset(kMargin)
}
disAgressButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor(hex:0xffffff)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("取消", for: .normal)
button.setTitleColor( UIColor(hex:0x3c86f8), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.layer.borderWidth = 1
button.layer.borderColor = UIColor(hex: 0x3c86f8).cgColor
button.addTarget(self, action: #selector(disagree), for: .touchUpInside)
return button
}()
let itemW = (KScreenWidth - kMargin * 2 - 10 - 38 * 2) / 2.0
centerView.addSubview(disAgressButton)
disAgressButton.snp.makeConstraints { make in
make.top.equalTo(messageLabel.snp.bottom).offset(21)
make.left.equalTo(kMargin)
make.bottom.equalTo(-kMargin)
make.height.equalTo(45)
make.width.equalTo(itemW)
}
agreeButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor(hex:0x3c86f8)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("确认", for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.addTarget(self, action: #selector(agree), for: .touchUpInside)
return button
}()
centerView.addSubview(agreeButton)
agreeButton.snp.makeConstraints { make in
make.height.equalTo(disAgressButton.snp.height)
make.top.equalTo(disAgressButton.snp.top)
make.width.equalTo(itemW)
make.left.equalTo(disAgressButton.snp.right).offset(10)
}
let a: ASAttributedString = .init("感谢您信任并使用智汇银河App,我们将通过", .font(UIFont.PFSC_R(ofSize: 16)),.foreground(UIColor.mainTextColor))
let aa: ASAttributedString = .init("《智汇银河App隐私协议》", .font(UIFont.PFSC_M(ofSize: 16)),.foreground(UIColor.brandMainColor), .action {
if let block = self.urlBlock {
block("https://www.baidu.com")
}
})
let and: ASAttributedString = .init("和", .font(UIFont.PFSC_R(ofSize: 16)),.foreground(UIColor.mainTextColor))
let aab: ASAttributedString = .init("《智汇银河App用户条款》", .font(UIFont.PFSC_M(ofSize: 16)),.foreground(UIColor.brandMainColor), .action {
if let block = self.urlBlock {
block("https://www.baidu.com")
}
})
let aaa: ASAttributedString = .init("帮助您了解我们收集、使用、存储和共享个人信息的情况,特别是我们所采取的个人信息类型和用途的对应关系。此外,您还能了解到您所享受的相关权利以及实现途径。认真阅读之后,如您同意,请点击下方的按钮开始接受我们的服务。", .font(UIFont.PFSC_R(ofSize: 16)),.foreground(UIColor.mainTextColor))
messageLabel.attributed.text = a + aa + and + aab + aaa
}
@objc func agree() {
if let block = self.agreeBlock {
block()
}
dismiss()
}
@objc private func handleTap(_ sender: AnyObject?) {
print("处理点击手势")
dismiss()
}
@objc func disagree() {
if let block = self.cancelBlock {
block()
}
dismiss()
}
func dismiss() {
removeFromSuperview()
}
}
extension YHAgreementAlertView: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer:UIGestureRecognizer, shouldReceive touch:UITouch) -> Bool {
if touch.view == self {
return true
}
return false
}
}
......@@ -121,29 +121,14 @@ private extension YHHkLifeAndIdItemView {
@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)
}
}
}
}
let vc = YHServiceViewController()
vc.defaltIndex = 0
UIViewController.current?.navigationController?.pushViewController(vc)
} 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)
}
}
}
}
let vc = YHServiceViewController()
vc.defaltIndex = 1
UIViewController.current?.navigationController?.pushViewController(vc)
} else {
printLog("errorr:未处理")
}
......
......@@ -27,6 +27,7 @@ class YHHomeBannerCollectionViewCell: FSPagerViewCell {
let imagV : UIImageView = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.clipsToBounds = true
imagV.image = UIImage(named: "global_default_image")
return imagV
}()
......@@ -75,9 +76,22 @@ private extension YHHomeBannerCollectionViewCell {
func updateUI() {
guard let model = dataModel else { return }
if let url = URL(string: model.img_url) {
bannerImagV.kf.setImage(with: url)
if model.isLocalItemFlag {
bannerTitleLable.isHidden = true
effectV.isHidden = true
bannerImagV.image = UIImage(named: model.img_url)
} else {
bannerTitleLable.isHidden = false
effectV.isHidden = false
if let url = URL(string: model.img_url) {
bannerImagV.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
} else {
bannerImagV.image = UIImage(named: "global_default_image")
}
bannerTitleLable.text = model.name
}
bannerTitleLable.text = model.name
}
}
......@@ -32,7 +32,7 @@ class YHHomeBannerView: UIView {
let view = FSPagerView()
view.delegate = self
view.dataSource = self
view.automaticSlidingInterval = 4
view.automaticSlidingInterval = 3
view.register(YHHomeBannerCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
view.itemSize = CGSizeMake(YHHomeBannerView.viewH, YHHomeBannerView.viewH)//FSPagerView.automaticSize
return view
......@@ -106,6 +106,9 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
return
}
let model = dataArr[index]
if model.isLocalItemFlag {
return
}
if model.skip_url.isEmpty == false {
switch model.skip_type {
case 1: //跳转H5
......
......@@ -28,8 +28,9 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
}
lazy var titleImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_title_image"))
let imageV = UIImageView(image: UIImage(named: "home_banner_default_icon"))
imageV.contentMode = .scaleAspectFill
imageV.isUserInteractionEnabled = true
return imageV
}()
......@@ -40,7 +41,7 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
label.textColor = UIColor(hex: 0x121A26, alpha: 1.0)
label.font = UIFont.PFSC_R(ofSize: 14)
label.numberOfLines = 2
label.lineBreakMode = .byWordWrapping
label.lineBreakMode = .byTruncatingTail
return label
}()
......@@ -92,14 +93,20 @@ extension YHHomeCollectionViewCell {
@objc func clickPlayButton() {
guard let listModel = listModel else { return }
//"https://upload.cdn.galaxy-immi.com/sell/production/video/1638527500518.mp4"
if listModel.media_url.isEmpty == false,let url = URL(string: listModel.media_url) {
let player = AVPlayer(url:url)
player.isMuted = true
playerViewController.player = player
self.parentViewController?.present(playerViewController, animated: true) {
self.playerViewController.player!.play() // 开始播放视频
}
DispatchQueue.main.async {
self.viewModel.getWebDetail(listModel.id) { success, error in
}
}
}
}
......@@ -164,15 +171,17 @@ extension YHHomeCollectionViewCell {
make.height.equalTo(listModel.img_height_use)
}
if let url = URL(string: listModel.img_url) {
titleImageView.kf.setImage(with: url)
titleImageView.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
}
descripeLable.text = listModel.title.defaultStringIfEmpty(detaultValue: "***")
descripeLable.text = listModel.title.defaultStringIfEmpty(detaultValue: "银河世纪")
descripeLable.snp.removeConstraints()
descripeLable.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(10)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.bottom.equalTo(-36)
make.height.equalTo(listModel.textH)
// make.bottom.equalTo(-36)
}
numLable.text = listModel.like_count.string
heartImageViewBtn.isSelected = listModel.is_like
......@@ -198,7 +207,6 @@ extension YHHomeCollectionViewCell {
viewModel.getLike(listModel.id, 1) {[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "已点赞")
listModel.is_like = true
listModel.like_count = listModel.like_count + 1
updataSubViews()
......@@ -208,7 +216,6 @@ extension YHHomeCollectionViewCell {
viewModel.getLike(listModel.id, 0) {[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "已取消点赞")
listModel.is_like = false
listModel.like_count = listModel.like_count - 1
updataSubViews()
......
......@@ -36,7 +36,7 @@ private extension YHHomeSearchView {
let lable = UILabel()
lable.text = "大家正在搜香港身份"
lable.text = "香港身份"
lable.font = UIFont.PFSC_R(ofSize: 12)
lable.textColor = UIColor(hex: 0x94A3B8, alpha: 1.0)
addSubview(lable)
......
......@@ -50,13 +50,13 @@ class YHHomeWebBottomView: UIView {
likeButton = {
let button = YHHomeWebBottomButton()
button.setContent("home_web_like", "652")
button.setContent("home_web_like", "0")
button.addTarget(self, action: #selector(likeBtnClick), for: .touchUpInside)
return button
}()
addSubview(likeButton)
likeButton.snp.makeConstraints { make in
make.right.equalTo(-31)
make.right.equalTo(-79)
make.top.equalTo(10)
make.height.equalTo(39)
make.width.equalTo(24)
......@@ -64,13 +64,13 @@ class YHHomeWebBottomView: UIView {
starButton = {
let button = YHHomeWebBottomButton()
button.setContent("home_web_star", "34")
button.setContent("home_web_star", "0")
button.addTarget(self, action: #selector(starBtnClick), for: .touchUpInside)
return button
}()
addSubview(starButton)
starButton.snp.makeConstraints { make in
make.right.equalTo(-79)
make.right.equalTo(-31)
make.top.equalTo(10)
make.height.equalTo(39)
make.width.equalTo(24)
......@@ -78,6 +78,12 @@ class YHHomeWebBottomView: UIView {
}
@objc private func likeBtnClick() {
if YHLoginManager.shared.isLogin() == false {
if let block = likeBlock {
block(isLike)
}
return
}
isLike = !isLike
if let block = likeBlock {
block(isLike)
......@@ -85,6 +91,13 @@ class YHHomeWebBottomView: UIView {
}
@objc private func starBtnClick() {
if YHLoginManager.shared.isLogin() == false {
if let block = starBlock {
block(isStar)
}
return
}
isStar = !isStar
if let block = starBlock {
block(isStar)
......
//
// YHHomeWebViewBottomForSavePicView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/22.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeWebViewBottomForSavePicView: UIView {
static let viewH : CGFloat = 98.0
override init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: YHBasicInfoFillBottomView.viewH))
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
typealias Block = (Int) -> ()
var block: Block?
var saveButton: UIButton!
}
private extension YHHomeWebViewBottomForSavePicView {
func setupUI() {
backgroundColor = .white
saveButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.contentBkgColor
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("保存到相册", for: .normal)
button.setTitleColor(UIColor.brandMainColor, for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.layer.borderWidth = 0.5
button.layer.borderColor = UIColor.brandMainColor.cgColor
button.addTarget(self, action: #selector(save), for: .touchUpInside)
return button
}()
addSubview(saveButton)
saveButton.snp.makeConstraints { make in
make.left.equalTo(kMargin)
make.right.equalTo(-kMargin)
make.top.equalTo(12)
make.height.equalTo(44)
}
}
@objc func save() {
block?(0)
}
}
......@@ -37,7 +37,7 @@ class YHSearchInfoBar: UIView {
lazy var textField:UITextField = {
let textField = UITextField()
textField.backgroundColor = .clear
textField.attributedPlaceholder = NSAttributedString(string: "大家正在搜香港身份".local, attributes: [NSAttributedString.Key.foregroundColor : UIColor(hex: 0x94A3B8)])
textField.attributedPlaceholder = NSAttributedString(string: "香港身份".local, attributes: [NSAttributedString.Key.foregroundColor : UIColor(hex: 0x94A3B8)])
textField.font = UIFont.PFSC_M(ofSize: 12)
textField.tintColor = UIColor(hex: 0x3570DC)
textField.textColor = UIColor(hexString: "#121A26")
......
......@@ -18,7 +18,6 @@ class YHSearchInfoCell: UITableViewCell {
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
......@@ -40,7 +39,7 @@ class YHSearchInfoCell: UITableViewCell {
lazy var titleLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.font = .PFSC_R(ofSize: 15)
label.textAlignment = .left
label.textColor = UIColor(hex: 0x121A26)
label.numberOfLines = 2
......@@ -51,9 +50,8 @@ class YHSearchInfoCell: UITableViewCell {
self.model = model
titleLabel.text = model.title
videoPlayImgView.isHidden = (model.type != 1)
if let url = URL(string: model.img_url) {
headImgView.kf.setImage(with: url)
}
let url = URL(string: model.img_url)
headImgView.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
}
func setupUI() {
......@@ -108,7 +106,7 @@ class YHSearchInfoCell: UITableViewCell {
var occurrences: [Range<String.Index>] = []
var searchStartIndex = string.startIndex
while let range = string.range(of: searchString, options: [], range: searchStartIndex..<string.endIndex) {
while let range = string.range(of: searchString, options: [.caseInsensitive], range: searchStartIndex..<string.endIndex) {
occurrences.append(range)
searchStartIndex = range.upperBound
}
......
......@@ -81,8 +81,8 @@ class YHSearchInfoHistoryView: UIView {
func getwith(font: UIFont, height: CGFloat, string: String) -> CGSize {
let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height)
let dic = [NSAttributedString.Key.font: font] // swift 4.2
let strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return strSize
var strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(ceil(strSize.width), strSize.height)
}
}
......@@ -99,8 +99,8 @@ extension YHSearchInfoHistoryView: UICollectionViewDelegate, UICollectionViewDat
let size = self.getwith(font: UIFont.systemFont(ofSize: 12), height: 24, string: historyItems[indexPath.item])
var width = size.width + gap*2.0
if width > collectionView.width {
width = collectionView.width
if width > 226.0 {
width = 226.0
}
return CGSize(width: width, height: cellHeight)
}
......
//
// YHServiceOrderAlertView.swift
// galaxy
//
// Created by EDY on 2024/4/16.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
class YHServiceOrderAlertView: UIView {
var centerView: UIView!
var titleLabel: UILabel!
var closeButton: UIButton!
var lineView: UIView!
var knowButton: UIButton!
var measageLabel: UILabel!
var subMeasageLabel: UILabel!
static func show() {
let view = YHServiceOrderAlertView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
}
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self
addGestureRecognizer(tap)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius8
return view
}()
addSubview(centerView)
centerView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(401)
}
titleLabel = {
let label = UILabel()
label.text = "原因说明"
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = UIColor.mainTextColor
label.textAlignment = .center
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.height.equalTo(21)
make.right.equalTo(-21)
}
closeButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_close"), for: .normal)
button.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return button
}()
centerView.addSubview(closeButton)
closeButton.snp.makeConstraints { make in
make.right.equalTo(-21)
make.width.height.equalTo(24)
make.top.equalTo(16)
}
lineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.right.equalTo(-21)
make.left.equalTo(21)
make.top.equalTo(52)
make.height.equalTo(1)
}
knowButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("我知道了", for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.clipsToBounds = true
button.addTarget(self, action: #selector(goNext), for: .touchUpInside)
return button
}()
centerView.addSubview(knowButton)
knowButton.snp.makeConstraints { make in
make.right.equalTo(-16)
make.left.equalTo(16)
make.height.equalTo(48)
make.bottom.equalTo(-29)
}
measageLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor.mainTextColor
label.numberOfLines = 0
return label
}()
centerView.addSubview(measageLabel)
measageLabel.snp.makeConstraints { make in
make.right.equalTo(-21)
make.left.equalTo(21)
make.top.equalTo(73)
}
subMeasageLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor.mainTextColor
label.numberOfLines = 0
return label
}()
centerView.addSubview(subMeasageLabel)
subMeasageLabel.snp.makeConstraints { make in
make.right.equalTo(-21)
make.left.equalTo(21)
make.top.equalTo(157)
}
let a: ASAttributedString = .init("1.当前仅支持查看", .font(UIFont.PFSC_M(ofSize: 15)),.foreground(UIColor(hex: 0x121a26).withAlphaComponent(0.7)))
let aa: ASAttributedString = .init(NSAttributedString(string: "优才订单"), .font(UIFont.PFSC_M(ofSize: 15)),.foreground(UIColor.brandMainColor))
let aaa: ASAttributedString = .init(",如果是签约了其他高才、专扌、留学等订单,请与您的服务管家或销售顾问企微沟通联系哦", .font(UIFont.PFSC_M(ofSize: 15)),.foreground(UIColor(hex: 0x121a26).withAlphaComponent(0.7)))
let b: ASAttributedString = .init(NSAttributedString(string: "2.使用其他手机号签约合同/订单,请退出登录"), .font(UIFont.PFSC_M(ofSize: 15)),.foreground(UIColor(hex: 0x121a26).withAlphaComponent(0.7)))
let bb: ASAttributedString = .init("切换账号", .font(UIFont.PFSC_M(ofSize: 15)),.foreground(UIColor.brandMainColor))
let bbb: ASAttributedString = .init("查看", .font(UIFont.PFSC_M(ofSize: 15)),.foreground(UIColor(hex: 0x121a26).withAlphaComponent(0.7)))
measageLabel.attributed.text = a + aa + aaa
subMeasageLabel.attributed.text = b + bb + bbb
knowButton.backgroundColor = .brandMainColor
knowButton.addYinHeGradualLayer()
}
@objc private func handleTap(_ sender: AnyObject?) {
print("处理点击手势")
dismiss()
}
@objc func dismiss() {
removeFromSuperview()
}
@objc func goNext() {
dismiss()
}
}
extension YHServiceOrderAlertView: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer:UIGestureRecognizer, shouldReceive touch:UITouch) -> Bool {
if touch.view == self {
return true
}
return false
}
}
......@@ -17,9 +17,11 @@ class YHHomePageViewModel : YHBaseViewModel {
var hkList: [YHHKEventModel]?
//首页相关参数
private var curPageIndex : Int = 1
private var page_Size : Int = 6
private var totalCount : Int = 0
private var page_Size : Int = 20
var totalCount : Int = 0
var hasMoreForHomeNews : Bool = true
// 搜索
let searchPageSize: Int = 20
}
//接口
......@@ -47,12 +49,11 @@ extension YHHomePageViewModel {
/*
firstPageFlag true - 首页 false - 更多
*/
func getHomeNewsList(firstPageFlag : Bool,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = ["page": curPageIndex,
"page_size": page_Size]
if firstPageFlag {
params = ["page": curPageIndex,
params = ["page": 1,
"page_size": page_Size]
} else {
params = ["page": curPageIndex + 1,
......@@ -85,7 +86,7 @@ extension YHHomePageViewModel {
}
if let count = self.arrHomeNewsData?.count {
if count == self.totalCount {
if count >= self.totalCount {
self.hasMoreForHomeNews = false
} else {
self.hasMoreForHomeNews = true
......@@ -114,23 +115,41 @@ extension YHHomePageViewModel {
if json.code == 200 {
let dic = json.data
guard let result = [YHBannerModel].deserialize(from: dic as? [Any]) else {
let model = YHBannerModel.localDefaultItem()
self.banners?.removeAll()
self.banners = [model]
callBackBlock(false,nil)
return
}
var arrData = result as? [YHBannerModel]
if let arr = arrData,arr.count > 6 {
arrData = Array(arrData?[0...5] ?? [])
if let arr = arrData {
if arr.isEmpty {
let model = YHBannerModel.localDefaultItem()
arrData = [model]
} else if arr.count > 10 {
arrData = Array(arrData?[0...9] ?? [])
}
}
self.banners = arrData
callBackBlock(true, nil)
} else {
let model = YHBannerModel.localDefaultItem()
self.banners?.removeAll()
self.banners = [model]
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
let model = YHBannerModel.localDefaultItem()
self.banners?.removeAll()
self.banners = [model]
callBackBlock(false,err)
}
}
......@@ -159,18 +178,16 @@ extension YHHomePageViewModel {
func getList(_ firstPageFlag : Bool, _ classifyID: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = ["page": curPageIndex,
"page_size": page_Size,
"page_size": searchPageSize,
"classify_id[0]": classifyID]
if firstPageFlag {
curPageIndex = 1
params = ["page": curPageIndex,
"page_size": page_Size,
params = ["page": 1,
"page_size": searchPageSize,
"classify_id[0]": classifyID]
} else {
params = ["page": curPageIndex + 1,
"page_size": page_Size,
"page_size": searchPageSize,
"classify_id[0]": classifyID]
curPageIndex = curPageIndex + 1
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
......@@ -188,9 +205,11 @@ extension YHHomePageViewModel {
}
if firstPageFlag {
self.curPageIndex = 1
self.totalCount = result.total
self.arrHomeNewsData = result.data
} else {
self.curPageIndex = self.curPageIndex + 1
self.arrHomeNewsData?.append(contentsOf: result.data)
}
......@@ -237,34 +256,60 @@ extension YHHomePageViewModel {
}
// 搜索
func searchArticleList(_ title: String, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10,
"title": title]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHHomeListTotalModel.deserialize(from: dic as? Dictionary) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
for item in result.data {
item.calHeightParam()
}
func searchArticleList(_ title: String, isFirstPage:Bool, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = [:]
if isFirstPage {
params = ["page": 1,
"page_size": searchPageSize,
"title": title]
} else {
params = ["page": curPageIndex + 1,
"page_size": searchPageSize,
"title": title]
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHHomeListTotalModel.deserialize(from: dic as? Dictionary) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
for item in result.data {
item.calHeightParam()
}
if isFirstPage {
self.totalCount = result.total
self.arrHomeNewsData = result.data
callBackBlock(true, nil)
curPageIndex = 1
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
curPageIndex = curPageIndex + 1
self.arrHomeNewsData?.append(contentsOf: result.data)
}
} failBlock: { err in
callBackBlock(false,err)
if let count = self.arrHomeNewsData?.count {
if count == self.totalCount {
self.hasMoreForHomeNews = false
} else {
self.hasMoreForHomeNews = true
}
}
callBackBlock(true, nil)
} else {
self.arrHomeNewsData = []
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
self.arrHomeNewsData = []
callBackBlock(false,err)
}
}
}
......@@ -109,9 +109,11 @@ extension YHInformationPerfectListVC {
serviceCenterMainReqVM.submitSweetNotifyOp(params: params as [String : Any]) { success, error in
if success == true {
YHInformationFillTipsAlertView.hideCheckView()
} else {
YHHUD.flash(message: error?.errorMsg ?? "发生错误,请重试")
}
self.loadData()
}
}
......@@ -130,7 +132,7 @@ extension YHInformationPerfectListVC {
guard let orderId = orderId else { return}
self.serviceCenterMainReqVM.getPersonInfoFillStep(params: ["orderId":orderId]) { success, error in
if success == true {
if self.serviceCenterMainReqVM.myInfoFillStep > 6 {
self.hasSubmitFlag = true
} else {
......@@ -146,6 +148,12 @@ extension YHInformationPerfectListVC {
}
}
self.homeTableView.reloadData()
// if self.serviceCenterMainReqVM.informationFillStepModel?.sweet_notify_status == 0 {
// self.showTipsAlert()
// return
// }
}
}
......@@ -459,7 +467,7 @@ extension YHInformationPerfectListVC : UITableViewDelegate,UITableViewDataSource
let vc = YHOtherInfoFillViewController()
vc.orderId = orderId
navigationController?.pushViewController(vc)
}
}
else {
}
......
//
// YHOrderDetailViewController.swift
// galaxy
//
// Created by EDY on 2024/4/19.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHOrderDetailViewController: YHBaseViewController {
var centerView: UIView!
var titleLabel: UILabel!
var lineView: UIView!
var orderLabel: UILabel!
var orderNumLabel: UILabel!
var phoneLabel: UILabel!
var phoneNumLabel: UILabel!
var copyButton: UIButton!
var model: YHContactItemModel = YHContactItemModel()
override func viewDidLoad() {
super.viewDidLoad()
setView()
// Do any additional setup after loading the view.
}
func setView() {
gk_navTitle = "我的订单"
gk_navBackgroundColor = UIColor.white
gk_navBarAlpha = 1
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius8
view.masksToBounds = true
return view
}()
view.addSubview(centerView)
centerView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 16)
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(149)
}
titleLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = UIColor.mainTextColor
label.text = model.productName
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(18)
make.left.equalTo(16)
make.height.equalTo(24)
}
lineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.top.equalTo(54.5)
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(1)
}
orderLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor(hex: 0x121A26).withAlphaComponent(0.5)
label.text = "合同编号: "
return label
}()
centerView.addSubview(orderLabel)
orderLabel.snp.makeConstraints { make in
make.top.equalTo(72.5)
make.left.equalTo(16)
make.height.equalTo(20)
}
phoneLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor(hex: 0x121A26).withAlphaComponent(0.5)
label.text = "签约手机号:"
return label
}()
centerView.addSubview(phoneLabel)
phoneLabel.snp.makeConstraints { make in
make.top.equalTo(110.5)
make.left.equalTo(16)
make.height.equalTo(20)
}
orderNumLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor(hex: 0x121A26)
label.text = model.orderSn
label.textAlignment = .right
return label
}()
centerView.addSubview(orderNumLabel)
orderNumLabel.snp.makeConstraints { make in
make.top.equalTo(72.5)
make.right.equalTo(-58)
make.height.equalTo(20)
}
phoneNumLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor(hex: 0x121A26)
label.text = model.mobile
label.textAlignment = .right
return label
}()
centerView.addSubview(phoneNumLabel)
phoneNumLabel.snp.makeConstraints { make in
make.top.equalTo(110.5)
make.right.equalTo(-16)
make.height.equalTo(20)
}
copyButton = {
let button = UIButton(type: .custom)
button.setTitle("复制", for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 13)
button.setTitleColor(UIColor.brandMainColor, for: .normal)
button.addTarget(self, action: #selector(copyButtonClick), for: .touchUpInside)
return button
}()
centerView.addSubview(copyButton)
copyButton.snp.makeConstraints { make in
make.top.equalTo(72.5)
make.right.equalTo(-16)
make.height.equalTo(18)
make.width.equalTo(26)
}
let subLineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
centerView.addSubview(subLineView)
subLineView.snp.makeConstraints { make in
make.centerY.equalTo(copyButton.snp.centerY)
make.right.equalTo(-50)
make.width.equalTo(1)
make.height.equalTo(6)
}
}
@objc func copyButtonClick() {
let textToCopy = orderNumLabel.text
UIPasteboard.general.string = textToCopy
YHHUD.flash(message: "复制成功")
}
}
......@@ -15,9 +15,10 @@ class YHServerHKLifeViewController: YHBaseViewController {
var tableFootView: YHServiceTableFootView!
var sectionView: YHServiceSectionView!
var classId: Int = 0
var cell: YHServerHKLifeViewCell!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
cell.tableFootView.items = dataSouce
}
}
var homeTableView: UITableView = {
......@@ -31,6 +32,7 @@ class YHServerHKLifeViewController: YHBaseViewController {
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.bounces = false
tableView.register(YHServerHKLifeViewCell.self,forCellReuseIdentifier: YHServerHKLifeViewCell.cellReuseIdentifier)
return tableView
}()
......@@ -48,10 +50,11 @@ class YHServerHKLifeViewController: YHBaseViewController {
extension YHServerHKLifeViewController {
func loadData() {
self.tableHeadView.bannarView.dataArr = [YHBannerModel.localDefaultItem()]
homeViewModel.getHomeBanner(2){[weak self] success, error in
guard let self = self else { return }
self.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? []
self.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? [YHBannerModel.localDefaultItem()]
}
homeViewModel.getHomeClassify{[weak self] success, error in
......@@ -60,13 +63,15 @@ extension YHServerHKLifeViewController {
let model = item as YHHomeClassifyModel
if model.id == 2 {
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 ?? []
if self.homeViewModel.hasMoreForHomeNews == false {
self.homeTableView.es.noticeNoMoreData()
if self.classId == 0 {
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 ?? []
if self.homeViewModel.hasMoreForHomeNews == false {
self.homeTableView.es.noticeNoMoreData()
}
}
}
}
......@@ -77,11 +82,14 @@ extension YHServerHKLifeViewController {
func setupUI() {
gk_navBarAlpha = 0
gk_navigationBar.isHidden = true
view.backgroundColor = .white
sectionView = {
let view = YHServiceSectionView()
view.block = {[weak self] model in
guard let self = self else { return }
self.cell.tableFootView.myCollectView.es.resetNoMoreData()
self.cell.tableFootView.myCollectView.setContentOffset(CGPoint.zero, animated: false)
self.classId = model.id
self.homeViewModel.getList(true, model.id) {[weak self] success, error in
guard let self = self else { return }
......@@ -101,21 +109,10 @@ extension YHServerHKLifeViewController {
homeTableView.tableFooterView = tableFootView
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
make.bottom.equalToSuperview()
}
homeTableView.delegate = self
homeTableView.dataSource = self
homeTableView.es.addInfiniteScrolling {[weak self] in
guard let self = self else { return }
self.homeTableView.es.stopLoadingMore()
self.homeViewModel.getList(false, self.classId) {[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()
}
}
}
}
}
......@@ -131,6 +128,9 @@ extension YHServerHKLifeViewController : UITableViewDelegate,UITableViewDataSour
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if sectionView.items.count == 1 {
return 0
}
return 48
}
......@@ -148,15 +148,31 @@ extension YHServerHKLifeViewController : UITableViewDelegate,UITableViewDataSour
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return KScreenHeight
// return KScreenHeight - k_Height_NavigationtBarAndStatuBar - 48 - k_Height_safeAreaInsetsBottom() - 50
return self.view.frame.height - 48
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell0.tableFootView.items = dataSouce
cell0.tableFootView.myCollectView.es.removeRefreshFooter()
cell0.selectionStyle = .none
return cell0
cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell.moreBlock = {[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 }
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
CATransaction.setDisableActions(true)
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
CATransaction.commit()
self.cell.tableFootView.myCollectView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.cell.tableFootView.myCollectView.es.noticeNoMoreData()
}
})
}
}
cell.tableFootView.items = dataSouce
// cell.tableFootView.myCollectView.es.removeRefreshFooter()
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......@@ -171,6 +187,9 @@ extension YHServerHKLifeViewController: JXSegmentedListContainerViewListDelegate
}
class YHServerHKLifeViewCell: UITableViewCell {
typealias LoadBlock = () -> ()
var moreBlock: LoadBlock?
static let cellReuseIdentifier = "YHServerHKLifeViewCell"
var tableFootView: YHServiceTableFootView!
......@@ -210,8 +229,17 @@ extension YHServerHKLifeViewCell {
backgroundColor = .clear
contentView.backgroundColor = .clear
tableFootView = YHServiceTableFootView()
tableFootView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)
tableFootView.moreBlock = {[weak self] in
guard let self = self else { return }
if let block = self.moreBlock {
block()
}
}
// tableFootView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)
contentView.addSubview(tableFootView)
tableFootView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
}
}
......@@ -10,7 +10,7 @@ import UIKit
//服务中心
class YHServiceCenterSecondViewController: YHBaseViewController {
var orderId : Int?
var orderId : Int = 0
var mobile: String?
private let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel()
private var unfoldFlag : Bool = true //是否展开
......@@ -54,13 +54,11 @@ class YHServiceCenterSecondViewController: YHBaseViewController {
extension YHServiceCenterSecondViewController {
func loadData2() {
guard let orderId = orderId else { return}
self.serviceCenterMainReqVM.getPersonInfoFillStep(params: ["orderId":orderId]) { success, error in
}
}
func loadData() {
guard let orderId = orderId else { return}
self.serviceCenterMainReqVM.getContactStatus(params: ["orderId":orderId]) { success, error in
self.homeTableView.reloadData()
}
......@@ -198,12 +196,12 @@ extension YHServiceCenterSecondViewController : UITableViewDelegate,UITableViewD
navigationController?.pushViewController(vc)
} else if model.type == 4 {
let vc = YHMyDocumentsListViewController()
vc.orderId = orderId ?? 0
vc.orderId = orderId
vc.mobile = mobile ?? ""
navigationController?.pushViewController(vc)
} else if model.type == 5 {
let vc = YHMySignatureListViewController()
vc.orderId = orderId ?? 0
vc.orderId = orderId
navigationController?.pushViewController(vc)
} else if model.type == 6 {
let vc = YHMineSchemeViewController()
......
//
// YHServiceOrderListView.swift
// galaxy
//
// Created by EDY on 2024/4/16.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHServiceOrderListView: YHBaseViewController {
private let viewModel : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel()
typealias Block = (Int,Int) -> ()
var block: Block?
var orderID: Int = 0
var type: Int = 0
var mobile: String = ""
var homeTableView: UITableView!
private let noDataView : YHNoDataTipsView = {
let view = YHNoDataTipsView()
view.isHidden = true
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
loadData()
}
}
extension YHServiceOrderListView {
func loadData() {
if YHLoginManager.shared.isLogin() {
viewModel.getServiceCenterProgressList(orderID, type) {[weak self] success, error in
guard let self = self else { return }
if (self.homeTableView != nil) {
if self.viewModel.arrDataForSeviceCenterProgress.count == 0 {
self.homeTableView.isHidden = true
self.noDataView.isHidden = false
} else {
self.homeTableView.isHidden = false
self.noDataView.isHidden = true
self.homeTableView.reloadData()
}
}
if let block = self.block {
block(type, self.viewModel.arrDataForSeviceCenterProgress.count)
}
}
}
}
func setupUI() {
gk_navBarAlpha = 0
gk_navigationBar.isHidden = true
homeTableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.dataSource = self
tableView.delegate = self
tableView.register(cellWithClass: YHServiceOrderProgressTableViewCell.self)
return tableView
}()
view.addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.right.left.bottom.equalToSuperview()
}
view.addSubview(noDataView)
noDataView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(KScreenWidth)
make.height.equalTo(150)
}
}
}
extension YHServiceOrderListView : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return self.viewModel.arrDataForSeviceCenterProgress.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return kMargin
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: kMargin))
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 144
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServiceOrderProgressTableViewCell.self)
cell0.selectionStyle = .none
if indexPath.section < self.viewModel.arrDataForSeviceCenterProgress.count {
cell0.dataModel = self.viewModel.arrDataForSeviceCenterProgress[indexPath.section]
}
return cell0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let model = self.viewModel.arrDataForSeviceCenterProgress[indexPath.section]
if model.status == 1 {
return
} else {
//1 证件 2 信息完善 3 我的评分 4 我的方案 5 我的签字 6我的文书
if model.type == 1 {
let vc = YHMineCertificateEntryViewController()
vc.orderId = orderID
navigationController?.pushViewController(vc)
} else if model.type == 2 {
let vc = YHInformationPerfectListVC()
vc.orderId = orderID
navigationController?.pushViewController(vc)
} else if model.type == 3 {
let vc = YHScoreDetailViewController()
vc.orderId = orderID
// vc.model = serviceCenterMainReqVM.allInfoScoreModel
navigationController?.pushViewController(vc)
} else if model.type == 4 {
let vc = YHMineSchemeViewController()
navigationController?.pushViewController(vc)
} else if model.type == 5 {
let vc = YHMySignatureListViewController()
vc.orderId = orderID
navigationController?.pushViewController(vc)
} else if model.type == 6 {
let vc = YHMyDocumentsListViewController()
vc.orderId = orderID
vc.mobile = mobile
navigationController?.pushViewController(vc)
}
}
}
}
extension YHServiceOrderListView: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
......@@ -10,14 +10,8 @@ import UIKit
import JXSegmentedView
class YHServiceViewController: YHBaseViewController {
var canScroll : Bool = false {
didSet {
for vc in arrItemVCs {
}
}
}
var defaltIndex: Int = 0
let arrItemTitles = ["香港身份","香港生活"]
......@@ -40,12 +34,30 @@ class YHServiceViewController: YHBaseViewController {
return dataSource
}()
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
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self, type: .scrollView)
}()
@objc func didBackBtnClicked() {
self.navigationController?.popViewController(animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
gk_navBarAlpha = 0
......@@ -64,7 +76,6 @@ class YHServiceViewController: YHBaseViewController {
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
segmentedView.collectionView.backgroundColor = .white
view.addSubview(segmentedView)
......@@ -79,9 +90,19 @@ class YHServiceViewController: YHBaseViewController {
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = .blue
indicator.indicatorColor = UIColor(hex: 0x3570dc)
segmentedView.indicators = [indicator]
segmentedView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1)
view.addSubview(navBar)
navBar.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_statusBar())
make.height.equalTo(k_Height_NavContentBar)
make.width.equalTo(47)
}
segmentedView.defaultSelectedIndex = defaltIndex
}
override func viewWillAppear(_ animated: Bool) {
......@@ -105,26 +126,16 @@ class YHServiceViewController: YHBaseViewController {
listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop())
}
}
extension YHServiceViewController {
func jumpToItemIndex(itemIndex : Int) {
self.segmentedView.selectItemAt(index: itemIndex)
}
}
extension YHServiceViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
// NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewDidEndDragging"), object: nil)
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
}
/// 正在滚动中的回调
///
/// - Parameters:
/// - segmentedView: JXSegmentedView
/// - leftIndex: 正在滚动中,相对位置处于左边的index
/// - rightIndex: 正在滚动中,相对位置处于右边的index
/// - percent: 从左往右计算的百分比
func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
// NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewWillBeginDragging"), object: nil)
extension YHServiceViewController {
func jumpToItemIndex(itemIndex : Int) {
self.segmentedView.selectItemAt(index: itemIndex)
}
}
......
//
// YHServiceCenterProgressModel.swift
// galaxy
//
// Created by davidhuangA on 2024/4/16.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHServiceCenterProgressModel : YHBaseModel {
var name : String = ""
var percentage : Int = 0
var status : Int = 0 // 0未知 1待开始 2进行中 3 已完成
var num : Int = 0
var type : Int = 0 // 1 证件 2 信息完善 3 我的评分 4 我的方案 5 我的签字 6我的文书
}
......@@ -13,7 +13,7 @@ import UIKit
class YHMineCertificateEntryViewController: YHBaseViewController {
var orderId : Int?
var orderId : Int = 0
private let certificateReqVM : YHCertificateViewModel = YHCertificateViewModel()
lazy var navBar: YHCustomNavigationBar = {
......@@ -70,8 +70,8 @@ class YHMineCertificateEntryViewController: YHBaseViewController {
extension YHMineCertificateEntryViewController {
func loadData() {
if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") {
let param = ["order_id":orderID,"node":"1","state":"1"]
if orderId != 0 {
let param = ["order_id":orderId,"node":"1","state":"1"] as [String : Any]
certificateReqVM.getCertificateStatisticData(params: param) { success, error in
if success == true {
self.headerView.dataModel = self.certificateReqVM.certificateEntryModel
......@@ -81,8 +81,6 @@ extension YHMineCertificateEntryViewController {
self.homeTableView.reloadData()
}
} else {
printLog("error : orderID 为空")
}
}
......@@ -189,7 +187,7 @@ extension YHMineCertificateEntryViewController : UITableViewDelegate,UITableView
printLog("点击了 tableView Cell \(indexPath.section)")
guard let model = certificateReqVM.certificateEntryModel else { return }
let vc = YHCertificateListContainerVC()
vc.orderId = orderId
if indexPath.section < model.category_data.count {
......
......@@ -56,6 +56,7 @@ class YHCustomNavigationBar: UIView {
private lazy var rightButton: UIButton = {
let btn = UIButton()
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
btn.addTarget(self, action: #selector(didRightButtonClicked), for: .touchUpInside)
return btn
}()
......
......@@ -183,7 +183,7 @@ class YHSchemeTableViewCell: UITableViewCell {
if title.contains("资料清单") {
if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") {
let vc = YHMineCertificateEntryViewController()
vc.orderId = orderID as? Int
vc.orderId = orderID as? Int ?? 0
UIViewController.current?.navigationController?.pushViewController(vc)
} else {
YHHUD.flash(message: "订单号为空")
......
......@@ -218,9 +218,9 @@ extension YHScorePersonInfoCell {
self.requestVM.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard success != nil else { return }
self.headImagV.kf.setImage(with: URL(string: success))
self.headImagV.kf.setImage(with: URL(string: success), placeholder: UIImage(named: "global_default_image"))
}
}
}
}
......@@ -11,6 +11,7 @@ import UIKit
class YHCommonAlertView: UIView {
typealias AgreeBlock = () -> ()
var agreeBlock: AgreeBlock?
var cancelBlcok: AgreeBlock?
var centerView: UIView!
var titleLabel: UILabel!
var lineView: UIView!
......@@ -18,9 +19,10 @@ class YHCommonAlertView: UIView {
var agreeButton: UIButton!
var disAgressButton: UIButton!
static func show(_ title: String? = nil, _ message: String? = nil, _ leftButtonString: String? = nil, _ rightButtonString: String? = nil, callBack: @escaping (() -> Void)) {
static func show(_ title: String? = nil, _ message: String? = nil, _ leftButtonString: String? = nil, _ rightButtonString: String? = nil,cancelCallBack: (() -> Void)? = nil, callBack: @escaping (() -> Void)) {
let view = YHCommonAlertView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.agreeBlock = callBack
view.cancelBlcok = cancelCallBack
view.setContent(title, message, leftButtonString, rightButtonString)
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
......@@ -54,6 +56,10 @@ class YHCommonAlertView: UIView {
make.height.lessThanOrEqualTo(60)
make.top.equalTo(37)
}
lineView.isHidden = true
} else {
lineView.isHidden = false
}
}
......@@ -176,6 +182,9 @@ class YHCommonAlertView: UIView {
}
@objc func disagree() {
if let block = self.cancelBlcok {
block()
}
dismiss()
}
......
......@@ -112,14 +112,14 @@ class YHPreviewControllerHoldViewController: UIViewController {
super.viewWillAppear(animated)
//处于第一个item的时候,才允许屏幕边缘手势返回
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
// navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//离开页面的时候,需要恢复屏幕边缘手势,不能影响其他页面
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
// navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewDidLayoutSubviews() {
......
......@@ -75,7 +75,8 @@ class YHImageViewController: YHBaseViewController {
self.back()
}
}
self.resultView.kf.setImage(with: URL(string: success))
// self.resultView.kf.setImage(with: URL(string: success))
self.resultView.kf.setImage(with: URL(string: success), placeholder: UIImage(named: "global_default_image"))
}
}
}
//
// YHNoDataTipsView.swift
// galaxy
//
// Created by EDY on 2024/4/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHNoDataTipsView: UIView {
private lazy var iconImgV : UIImageView = {
let imagV = UIImageView()
imagV.image = UIImage(named: "list_no_data")
imagV.contentMode = .scaleAspectFill
return imagV
}()
lazy var tipsLab : UILabel = {
let lable = UILabel()
lable.textColor = UIColor.labelTextColor2
lable.font = UIFont.PFSC_R(ofSize: 14)
lable.textAlignment = .center
lable.text = "暂无"
return lable
}()
public override init(frame: CGRect) {
super.init(frame:frame)
initView()
}
private func initView() {
addSubview(iconImgV)
iconImgV.snp.makeConstraints { make in
make.top.equalToSuperview()
make.centerX.equalToSuperview()
make.height.equalTo(93)
make.width.equalTo(93)
}
addSubview(tipsLab)
tipsLab.snp.makeConstraints { make in
make.top.equalTo(iconImgV.snp.bottom).offset(12)
make.centerX.equalToSuperview()
make.left.right.equalToSuperview()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
//
// YHOrderListView.swift
// galaxy
//
// Created by EDY on 2024/4/9.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHOrderListView: UIView {
var dataSource: [YHContactItemModel] = [] {
didSet {
self.homeTableView.reloadData()
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.register(YHContractCell.self,forCellReuseIdentifier: YHContractCell.cellReuseIdentifier)
return tableView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupUI() {
addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
homeTableView.delegate = self
homeTableView.dataSource = self
}
}
extension YHOrderListView : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return self.dataSource.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return kMargin
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: kMargin))
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 81
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHContractCell.self)
cell0.selectionStyle = .none
if indexPath.section < self.dataSource.count {
cell0.dataModel = self.dataSource[indexPath.section]
}
return cell0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
printLog("点击了 tableView Cell \(indexPath.section)")
//获取订单号
let orderId = dataSource[indexPath.section].id
UserDefaults.standard.set(orderId, forKey: "orderIdForPreview")
UserDefaults.standard.synchronize()
let vc = YHServiceCenterSecondViewController()
vc.orderId = orderId
vc.mobile = dataSource[indexPath.section].mobile
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
//
// YHProgressView.swift
// galaxy
//
// Created by EDY on 2024/4/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHProgressView: UIView {
private let progressLayer = CAShapeLayer()
override init(frame: CGRect) {
super.init(frame: frame)
configure()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
configure()
}
func changeColor(_ color: UIColor) {
progressLayer.strokeColor = color.cgColor // 设置进度条颜色
}
private func configure() {
// 创建底部圆形路径
let center = CGPoint(x: bounds.midX, y: bounds.midY)
let lineWidth: CGFloat = 3 // 圆环路径宽度
let radius = (min(bounds.width, bounds.height) - lineWidth) / 2 // 圆的半径
let startAngle = -CGFloat.pi / 2 // 起始角度
let endAngle = 1.5 * CGFloat.pi // 终点角度
// 创建进度条圆形路径
let progressPath = UIBezierPath(arcCenter: center,
radius: radius,
startAngle: startAngle,
endAngle: endAngle,
clockwise: true)
// 配置进度条CAShapeLayer
progressLayer.path = progressPath.cgPath
progressLayer.strokeColor = UIColor(hex: 0x00BF60).cgColor // 进度条颜色
progressLayer.fillColor = UIColor.clear.cgColor
progressLayer.lineWidth = lineWidth // 进度条宽度
progressLayer.lineCap = .round
// 设置初始进度
progressLayer.strokeEnd = 0
layer.addSublayer(progressLayer)
}
func setProgress(_ progress: Float, animated: Bool) {
let animation = CABasicAnimation(keyPath: "strokeEnd")
animation.fromValue = progressLayer.strokeEnd
animation.toValue = progress
animation.duration = animated ? 1.0 : 0
progressLayer.strokeEnd = CGFloat(progress)
progressLayer.add(animation, forKey: "progressAnimation")
}
}
......@@ -37,7 +37,7 @@ class YHServiceBannerView: UIView {
view.automaticSlidingInterval = 3
view.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
view.itemSize = FSPagerView.automaticSize
view.interitemSpacing = 10
// view.interitemSpacing = 10
return view
}()
......@@ -118,12 +118,16 @@ extension YHServiceBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
let image = UIImage(named: "default_placeholder_image")?.bs_scaled(toWidth: UIDevice.kScreenW - 16*2, opaque: false)
cell.imageView?.image = image
if index < dataArr.count {
let model = dataArr[index]
if let url = URL(string: model.img_url) {
cell.imageView?.kf.setImage(with: url)
if model.id != 0 {
if let url = URL(string: model.img_url) {
// cell.imageView?.kf.setImage(with: url)
cell.imageView?.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
}
} else {
cell.imageView?.image = UIImage(named: model.img_url)
}
// cell.textLabel?.text = model.name
}
......@@ -143,6 +147,11 @@ extension YHServiceBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
return
}
let model = dataArr[index]
if model.isLocalItemFlag {
return
}
if model.skip_url.isEmpty == false {
switch model.skip_type {
case 1: //跳转H5
......
......@@ -43,10 +43,11 @@ class YHServiceSectionView: UIView {
collectinoView.register(YHServiceSectionCollectionViewCell.self, forCellWithReuseIdentifier:YHServiceSectionCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.showsVerticalScrollIndicator = false
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
collectinoView.bounces = false
collectinoView.showsHorizontalScrollIndicator = false
collectinoView.showsVerticalScrollIndicator = false
return collectinoView
}()
......@@ -121,7 +122,7 @@ class YHServiceSectionCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHServiceSectionCollectionViewCell"
func setSelectedStyle() {
contentView.backgroundColor = UIColor.brandMainColor
contentView.backgroundColor = UIColor(hex: 0x3570dc)
descripeLable.textColor = UIColor.white
}
......
......@@ -17,8 +17,10 @@ struct YHUserModel: SmartCodable {
var sex: Int?
var token: String?
}
struct YHDeviceTokenModel {
var deviceToken: String = ""
var pushUserId: String = ""
var registerId: String = ""
}
......
......@@ -12,10 +12,10 @@ import UIKit
extension UIColor {
//品牌主色
static let brandMainColor : UIColor = UIColor(hexString: "#2F7EF6")!
static let brandMainColor : UIColor = UIColor(hexString: "#3570DC")!
//品牌渐变色
static let arrBrandGradaterColors : [UIColor] = [UIColor(hexString: "#2274EE")!,UIColor(hexString: "#3A85FC")!]
static let arrBrandGradaterColors : [UIColor] = [UIColor(hexString: "#3570DC")!,UIColor(hexString: "#3A85FC")!]
//品牌主色 16
static let brandMainColor16 : UIColor = UIColor(hexString: "#2F7EF6",transparency: 0.16)!
......
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