Commit 0a0de105 authored by David黄金龙's avatar David黄金龙

Merge branch '630-dev' into youhua-dev

* 630-dev: (199 commits)
  修改版本号
  首页 数据展示
  删除 不必要的刷新
  修改 文案
  图片展示图片优化
  一处 bug修改
  处理 一处刷新
  //  头像
  //  添加好友失败信息
  头像存储
  // 我的好友显示
  // 用户头像
  avif 图片逻辑提交
  // 兴趣爱好显示异常处理
  //  报名结果bug修复
  //  活动bug修复
  授权成功之后主动匹配
  出现一键登录之后的跳转问题
  //  一键登录
  //  添加点击事件
  ...
parents 33fdd2c0 8928169f
......@@ -166,7 +166,7 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-pgyer (0.2.8)
fastlane-plugin-pgyer (0.2.9)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
......
......@@ -87,6 +87,8 @@ target 'galaxy' do
pod 'lottie-ios', '4.4.0'
#GIF图播放
pod 'YYImage', '1.0.4'
#滑动卡片
pod 'DragCardContainer', '1.2.0'
end
......
This diff is collapsed.
......@@ -163,14 +163,14 @@ extension AppDelegate {
tabBarController.delegate = homeVC
let v0 = YHNavigationController(rootVC:homeVC)
let v1 = YHNavigationController(rootVC:YHServiceCenterMainViewController())
let v2 = YHNavigationController(rootVC:YHMessageListVC())
let v2 = YHNavigationController(rootVC:YHCommunityViewController())
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"))
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"))
......@@ -183,7 +183,7 @@ extension AppDelegate {
if YHLoginManager.shared.needJumpToMsgTabFlag {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
goToMessagePage()
})
}
}
......
......@@ -79,7 +79,7 @@ extension AppDelegate: JPUSHRegisterDelegate {
// 转换到消息tab
YHLoginManager.shared.needJumpToMsgTabFlag = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
goToMessagePage()
})
}
......@@ -121,7 +121,7 @@ extension AppDelegate: JPUSHRegisterDelegate {
// 转换到消息tab
YHLoginManager.shared.needJumpToMsgTabFlag = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
goToMessagePage()
})
}
......
......@@ -22,7 +22,7 @@ class YHBaseViewController: UIViewController {
gk_navLineHidden = true
gk_navBarAlpha = 0
gk_backImage = UIImage(named: "nav_back_icon")
gk_backImage = UIImage(named: "back_icon")
#if DEBUG
......
......@@ -12,7 +12,7 @@ import Alamofire
class YHBaseViewModel {
// 上传方法
func uploadImage(_ image: UIImage, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
func uploadImage(_ image: UIImage, _ isPublic: Bool = false, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
#if DEBUG
let size = image.imageSize()
YHHUD.flash(message: "\(Float(size/1024/1024))M")
......@@ -44,7 +44,7 @@ class YHBaseViewModel {
return
}
YHOSSManager.share.updateToken {
YHOSSManager.share.putObject(image: image) {[weak self] success, error in
YHOSSManager.share.putObject(image: image, isPublic) {[weak self] success, error in
guard let _ = self else { return }
DispatchQueue.main.async {
// 在这里执行需要在主线程上完成的任务
......@@ -54,8 +54,7 @@ class YHBaseViewModel {
}
}
//换取一张
func getPublicImageUrl(_ url: String, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
func getPublicImageUrl(_ url: String, _ isPublic: Bool = false, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
// let strUrl = YHBaseUrlManager.shared.curOssURL() + YHAllApiName.OSS.getPublicApi
// let param: [String: Any] = ["fileUrl": url]
// let _ = YHNetRequest.getRequest(url: strUrl, params: param) { [weak self] json, code in
......@@ -80,7 +79,7 @@ class YHBaseViewModel {
return
}
YHOSSManager.share.updateToken {
YHOSSManager.share.getPublic(url: url, callBackBlock: { [weak self] success, error in
YHOSSManager.share.getPublic(url: url, isPublic, callBackBlock: { [weak self] success, error in
guard let _ = self else { return }
DispatchQueue.main.async {
// 在这里执行需要在主线程上完成的任务
......@@ -109,7 +108,7 @@ class YHBaseViewModel {
}
// 上传方法
func uploadFile(_ url: String, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
func uploadFile(_ url: String, _ isPublic: Bool = false, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
// let strUrl = YHBaseUrlManager.shared.curOssURL() + YHAllApiName.OSS.uploadApi
// printLog("\(url)")
// let boundary = UUID().uuidString
......@@ -138,7 +137,7 @@ class YHBaseViewModel {
return
}
YHOSSManager.share.updateToken {
YHOSSManager.share.putFile(file: url, callBackBlock: {[weak self] success, error in
YHOSSManager.share.putFile(file: url, isPublic, callBackBlock: {[weak self] success, error in
guard let _ = self else { return }
DispatchQueue.main.async {
// 在这里执行需要在主线程上完成的任务
......
......@@ -21,7 +21,6 @@ class YHTabBarViewController: ESTabBarController {
handleTabBarLine()
addObservers()
if YHLoginManager.shared.isLogin() {
getTotalUnreadMsgCount()
reportDeviceInfo()
}
}
......@@ -30,7 +29,6 @@ class YHTabBarViewController: ESTabBarController {
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)
}
}
......@@ -46,7 +44,6 @@ extension YHTabBarViewController {
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
getTotalUnreadMsgCount()
}
@objc func logoutSuccess() {
......@@ -56,37 +53,10 @@ extension YHTabBarViewController {
@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
}
}
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
func reportDeviceInfo() {
if !YHLoginManager.shared.isLogin() {
return
......
......@@ -18,7 +18,8 @@ let kEmptyMessageBgName = "no_data_bg_msg"
let kEmptyOrderBgName = "no_data_bg_order"
// 无网络空视图
let kNotNetWorkBgName = "no_network_bg"
// 人脉无好友空视图
let kNoFriendsBgName = "people_no_friend_bg"
class YHEmptyDataView: UIView {
......
......@@ -107,8 +107,13 @@ extension YHOneKeyLoginManager {
YHHUD.hide()
if success {
YHLoginManager.shared.loginSuccessActionBlock?()
YHHUD.flash(message: "登录成功")
TXCommonHandler.sharedInstance().cancelLoginVC(animated: true)
if YHLoginManager.shared.userModel?.is_first_login == 1 {
let vc = YHUserInfoSettingViewController()
vc.modalPresentationStyle = .fullScreen
UIViewController.current?.navigationController?.pushViewController(vc)
} else {
TXCommonHandler.sharedInstance().cancelLoginVC(animated: true)
}
return
}
if let err = error {
......@@ -264,7 +269,7 @@ extension YHOneKeyLoginManager {
}
// 登录按钮自定义UI
model.loginBtnText = NSAttributedString(string: "本机号码一键登录", attributes: [NSAttributedString.Key.foregroundColor : UIColor.init(hex: 0x121A26), NSAttributedString.Key.font: UIFont.PFSC_M(ofSize: 16)])
model.loginBtnText = NSAttributedString(string: "本机号码一键登录", attributes: [NSAttributedString.Key.foregroundColor : UIColor.mainTextColor, NSAttributedString.Key.font: UIFont.PFSC_M(ofSize: 16)])
let enableLoginBgImg = TXCommonUtils.image(with: .white, size: CGSize(width: KScreenWidth-20*2, height: 48), isRoundedCorner: true, radius: kCornerRadius3)!
let disableLoginBgImg = TXCommonUtils.image(with: .white, size: CGSize(width: KScreenWidth-20*2, height: 48), isRoundedCorner: true, radius: kCornerRadius3)!
......
//
// YHActivityDetailViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityDetailViewController: YHBaseViewController {
var activityId : String = ""
var activityName: String = ""
lazy var viewModel: YHActivityViewModel = {
let vm = YHActivityViewModel()
return vm
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.plain)
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor.white
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHActivityDetailCell.self, forCellReuseIdentifier: YHActivityDetailCell.cellReuseIdentifier)
tableView.tableHeaderView = nil
tableView.tableFooterView = nil
tableView.estimatedSectionHeaderHeight = 0
tableView.estimatedSectionFooterHeight = 0
return tableView
}()
lazy var topView : UIImageView = {
let view = UIImageView()
view.contentMode = .scaleAspectFill
view.image = UIImage(named: "activity_detail_top_bkg")
return view
}()
lazy var bottomView : YHActivityDetailBottomView = {
let view = YHActivityDetailBottomView()
return view
}()
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
}
}
extension YHActivityDetailViewController {
func gotoTheRightVcForStatus() {
guard let model = self.viewModel.activityDetailModel else {
return
}
if let status = YHActivityStatus(rawValue: model.status.int ?? 0) {
switch status {
case .notApply:
// printLog("立即报名")
showApplyUI()
case .applied:
printLog("已报名")
let vc = YHActivityTravelViewController()
vc.travelId = viewModel.activityDetailModel?.checkId ?? ""
navigationController?.pushViewController(vc)
case .canceled:
// printLog("已取消报名")
showApplyUI()
case .end:
printLog("活动已结束")
// YHHUD.flash(message: "活动已结束")
default:
printLog("")
}
}
}
func showApplyUI() {
YHApplyActivityAlert.showApplyActivityAlertView(name: self.viewModel.activityDetailModel?.businessCardName ?? "") { (tag,name,number,phone) in
if tag {
printLog(tag)
printLog(name)
printLog(number)
printLog(phone)
if tag {
let param = ["id" : self.activityId,
"name":name,
"mobile":phone,
"number":number]
self.applyActivity(param: param)
}
}
}
}
func setupUI() {
gk_navigationBar.isHidden = false
gk_navigationBar.backgroundColor = .clear
//1.
view.addSubview(tableView)
view.addSubview(bottomView)
view.addSubview(topView)
//2.
tableView.contentInsetAdjustmentBehavior = .never
tableView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.bottom.equalTo(bottomView.snp.top)
}
//3.
bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(YHActivityDetailBottomView.viewH)
}
bottomView.block = { [weak self] tag in
//判断是否登录成功
if YHLoginManager.shared.isLogin() {
self?.gotoTheRightVcForStatus()
} else {
YHOneKeyLoginManager.shared.oneKeyLogin()
YHLoginManager.shared.loginSuccessActionBlock = {[weak self] in
guard self != nil else { return }
self?.loadData()
YHLoginManager.shared.loginSuccessActionBlock = nil
}
}
}
//4.
topView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(114)
}
}
func loadData() {
if !activityId.isEmpty {
viewModel.getActivityDetailData(activityID: activityId) { success, error in
if success {
//bottomView
self.bottomView.dataModel = self.viewModel.activityDetailModel
} else {
let msg = error?.errorMsg ?? "获取数据出错"
YHHUD.flash(message: msg)
self.navigationController?.popViewController()
}
//tableView
self.tableView.reloadData()
}
} else {
YHHUD.flash(message: "参数错误")
navigationController?.popViewController()
}
}
func applyActivity(param : [String : Any]) {
viewModel.applyActivity(param: param) { success, error in
if success {
YHHUD.flash(message: "报名成功")
self.loadData()
DispatchQueue.main.async {
let vc = YHApplyActivityResultViewController()
vc.isSuccessFlag = true
vc.activityTravelId = self.viewModel.travelModel?.id ?? ""
vc.activityName = self.viewModel.activityDetailModel?.name ?? self.activityName
self.navigationController?.pushViewController(vc)
}
} else {
if error?.errorCode == 10001 {
let vc = YHApplyActivityResultViewController()
vc.isSuccessFlag = false
vc.activityTravelId = self.viewModel.travelModel?.id ?? ""
vc.activityName = self.viewModel.activityDetailModel?.name ?? self.activityName
self.navigationController?.pushViewController(vc)
} else {
let msg = error?.errorMsg ?? "报名失败,请重试"
YHHUD.flash(message: msg)
}
}
}
}
}
extension YHActivityDetailViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell.cellReuseIdentifier, for: indexPath) as! YHActivityDetailCell
cell.dataModel = viewModel.activityDetailModel
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
}
//
// YHActivityListViewController.swift
// galaxy
//
// Created by EDY on 2024/6/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
enum YHActivityStatus: Int {
//活动的状态 1:立即报名 2:已报名 3:活动结束 4:已取消报名
case unknow = 0 // 未知
case notApply = 1 // 立即报名
case applied = 2 // 已报名
case end = 3 // 活动结束
case canceled = 4 // 已取消报名
var titleForList : String {
switch self {
case .notApply:
return "立即报名"
case .applied:
return "已报名"
case .end:
return "活动结束"
case .canceled:
return "立即报名"
default:
return ""
}
}
var titleForMyApplyList : String {
switch self {
case .notApply:
return "立即报名"
case .applied:
return "已报名"
case .end:
return "活动结束"
case .canceled:
return "已取消"
default:
return ""
}
}
var titleForDetail : String {
switch self {
case .notApply:
return "立即报名"
case .applied:
return "查看行程单"
case .end:
return "活动结束"
case .canceled:
return "立即报名"
default:
return ""
}
}
var activityColor : UIColor {
switch self {
case .notApply:
return UIColor.brandMainColor
case .applied:
return UIColor.successColor
case .end:
return UIColor.mainTextColor30
case .canceled:
return UIColor.brandMainColor
default:
return UIColor.clear
}
}
var activityColorForMyApplyList : UIColor {
switch self {
case .notApply:
return UIColor.brandMainColor
case .applied:
return UIColor.successColor
case .end:
return UIColor.mainTextColor30
case .canceled:
return UIColor.mainTextColor30
default:
return UIColor.clear
}
}
}
/*
活动列表 或 我的报名活动
*/
class YHActivityListViewController: YHBaseViewController {
var type : Int = 0 //0-活动列表 1-我的报名活动
lazy var viewModel: YHActivityViewModel = {
let vm = YHActivityViewModel()
return vm
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor.white
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHActivityListCell.self, forCellReuseIdentifier: YHActivityListCell.cellReuseIdentifier)
tableView.backgroundView = self.emptyDataTipsView
return tableView
}()
lazy var emptyDataTipsView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无活动", kEmptyCommonBgName)
view.topMargin = 222
view.isHidden = true
return view
}()
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
gk_navigationBar.isHidden = true
gk_navigationBar.backgroundColor = .white
view.addSubview(tableView)
if type == 1 {
gk_navTitle = "我的活动"
gk_navigationBar.isHidden = false
gk_navigationBar.backgroundColor = .clear
tableView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.bottom.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
}
} else {
tableView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.bottom.equalToSuperview()
make.top.equalToSuperview()
}
}
tableView.es.addYHPullToRefresh {
self.loadFirstData()
}
tableView.es.addInfiniteScrolling {
self.loadMoreData()
}
emptyDataTipsView.isHidden = viewModel.arrActivityListData.count > 0 ? true : false
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadFirstData()
}
}
extension YHActivityListViewController {
func loadMoreData() {
self.viewModel.getActivityList(firstFlag : false,type : type) {[weak self] success, error in
guard let self = self else { return }
self.tableView.reloadData()
self.emptyDataTipsView.isHidden = self.viewModel.arrActivityListData.count > 0 ? true : false
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
self.tableView.es.stopLoadingMore()
if self.viewModel.hasMoreForActivityList == false {
self.tableView.es.noticeNoMoreData()
self.tableView.footer?.alpha = 1
}
})
}
}
func loadFirstData() {
self.viewModel.getActivityList(firstFlag : true,type: type) {[weak self] success, error in
guard let self = self else { return }
self.tableView.reloadData()
self.emptyDataTipsView.isHidden = self.viewModel.arrActivityListData.count > 0 ? true : false
DispatchQueue.main.asyncAfter(deadline: .now()+0.5, execute: {
self.tableView.es.stopPullToRefresh()
self.emptyDataTipsView.isHidden = self.viewModel.arrActivityListData.count > 0 ? true : false
if self.viewModel.hasMoreForActivityList == false {
self.tableView.es.noticeNoMoreData()
if self.viewModel.arrActivityListData.count > 0 {
self.tableView.footer?.alpha = 1
} else {
self.tableView.footer?.alpha = 0
}
}
})
}
}
}
extension YHActivityListViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
if viewModel.arrActivityListData.count > 0 {
return viewModel.arrActivityListData.count
}
return 0
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityListCell.cellReuseIdentifier, for: indexPath) as! YHActivityListCell
cell.sessionIndex = indexPath.section
cell.type = type
if indexPath.section < viewModel.arrActivityListData.count {
cell.dataModel = viewModel.arrActivityListData[indexPath.section]
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 185.0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section < viewModel.arrActivityListData.count {
let model = viewModel.arrActivityListData[indexPath.section]
if type == 1 && model.status.int == 2 {
let vc = YHActivityTravelViewController()
vc.travelId = model.checkId
navigationController?.pushViewController(vc)
return
}
let vc = YHActivityDetailViewController()
vc.activityId = String(model.id)
vc.activityName = model.name
navigationController?.pushViewController(vc)
}
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
var height : CGFloat = 16.0
if section != 0 {
height = 20.0
}
return height
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
var height : CGFloat = 16.0
if section != 0 {
height = 20.0
}
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth-16.0*2, height: height))
view.backgroundColor = .clear
return view
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth-16.0*2, height: 0.001))
view.backgroundColor = .clear
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.001
}
}
extension YHActivityListViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
//
// YHActivityTravelViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityTravelViewController: YHBaseViewController {
//vm对象
lazy var viewModel: YHActivityViewModel = {
let vm = YHActivityViewModel()
return vm
}()
//活动行程单Id
var travelId : String = ""
//tableView
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.plain)
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor.clear
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHActivityTravelCell.self, forCellReuseIdentifier: YHActivityTravelCell.cellReuseIdentifier)
tableView.tableHeaderView = nil
tableView.tableFooterView = nil
tableView.estimatedSectionHeaderHeight = 0
tableView.estimatedSectionFooterHeight = 0
return tableView
}()
lazy var topBkgImageV : UIImageView = {
let view = UIImageView()
view.contentMode = .scaleAspectFill
view.image = UIImage(named: "activity_travel_bkg")
return view
}()
lazy var topView : UIView = {
let view = UIView()
return view
}()
lazy var bottomView : YHActivityDetailBottomView = {
let view = YHActivityDetailBottomView()
return view
}()
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
}
}
extension YHActivityTravelViewController {
func setupUI() {
gk_navigationBar.isHidden = false
gk_navigationBar.backgroundColor = .clear
gk_navBarAlpha = 0
view.backgroundColor = UIColor.pageBkgColor
//1.
view.addSubview(topBkgImageV)
view.addSubview(tableView)
topBkgImageV.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(332)
}
tableView.contentInsetAdjustmentBehavior = .never
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.equalTo(20)
make.right.equalTo(-20)
make.bottom.equalToSuperview()
}
}
func loadData() {
if !travelId.isEmpty {
viewModel.getActivityTravelDetail(travelId: travelId) { success, error in
if success {
self.tableView.reloadData()
} else {
let msg = error?.errorMsg ?? "获取数据出错"
YHHUD.flash(message: msg)
self.navigationController?.popViewController()
}
}
} else {
YHHUD.flash(message: "参数错误")
navigationController?.popViewController()
}
}
func cancelActivityApply() {
viewModel.cancelActivityTravel(travelId:travelId) { [weak self] (success, error) in
if success {
YHHUD.flash(message: "已取消报名")
self?.loadData()
} else {
let msg = error?.errorMsg ?? "取消失败"
YHHUD.flash(message: msg)
}
}
}
func clickBottomButton() {
if self.viewModel.activityTravelModel?.status.int == 2 {
//取消
YHCommonAlertView.show("", "是否取消报名?", "是", "否",fullGuestureEnable: false) {
self.cancelActivityApply()
} callBack: {
}
} else if self.viewModel.activityTravelModel?.status.int == 4 {
if let nav = self.navigationController {
let rrr = nav.viewControllers.contains { $0.isKind(of: YHActivityDetailViewController.self) }
if rrr {
var targetVc : UIViewController?
for(_,value) in nav.viewControllers.enumerated() {
if value.isKind(of: YHActivityDetailViewController.self) {
targetVc = value
break
}
}
if let vc = targetVc {
navigationController?.popToViewController(vc, animated: true)
}
return
}
}
let vc = YHActivityDetailViewController()
vc.activityId = String(self.viewModel.activityTravelModel?.id ?? 0)
vc.activityName = self.viewModel.activityDetailModel?.name ?? ""
navigationController?.pushViewController(vc)
}
}
// func showApplyUI() {
// YHApplyActivityAlert.showApplyActivityAlertView { (tag,name,number,phone) in
// if tag {
// printLog(tag)
// printLog(name)
// printLog(number)
// printLog(phone)
// if tag {
// if let model = self.viewModel.activityTravelModel,model.id > 0 {
// let param = ["id" : model.id,
// "name":name,
// "mobile":phone,
// "number":number]
// self.applyActivity(param: param)
// }
// }
// }
// }
// }
// func applyActivity(param : [String : Any]) {
//
// viewModel.applyActivity(param: param) { success, error in
// if success {
// YHHUD.flash(message: "报名成功")
// self.loadData()
// DispatchQueue.main.async {
// let vc = YHApplyActivityResultViewController()
// vc.activityTravelId = String(self.viewModel.activityTravelModel?.id ?? 0)
//
// self.navigationController?.pushViewController(vc)
// }
// } else {
// let msg = error?.errorMsg ?? "报名失败,请重试"
// YHHUD.flash(message: msg)
// }
// }
// }
}
extension YHActivityTravelViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityTravelCell.cellReuseIdentifier, for: indexPath) as! YHActivityTravelCell
cell.dataModel = viewModel.activityTravelModel
cell.block = {[weak self] in
self?.clickBottomButton()
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
}
//
// YHApplyActivityResultViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
/*
报名结果页
*/
class YHApplyActivityResultViewController: YHBaseViewController {
var isSuccessFlag : Bool = false
var messageTips : String = ""
var activityTravelId : String = ""
var activityName : String = ""
lazy var statusImageV:UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "activity_apply_result_success")
view.contentMode = .scaleAspectFill
return view
}()
lazy var titleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .center
lable.font = UIFont.PFSC_M(ofSize:18)
lable.text = "报名成功"
lable.numberOfLines = 0
return lable
}()
lazy var nameLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor30
lable.textAlignment = .center
lable.font = UIFont.PFSC_R(ofSize:14)
lable.text = "已报名成功活动【哈佛爸爸线下教育沙龙】,记得准时参加哦"
lable.numberOfLines = 0
return lable
}()
lazy var submitButton:UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_R(ofSize: 16)
button.contentHorizontalAlignment = .center
button.setTitle("查看行程单", for: .normal)
button.setTitle("查看行程单", for: .highlighted)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .highlighted)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(clickSubmitBtn), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .brandMainColor
return button
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
}
extension YHApplyActivityResultViewController {
func setupUI() {
gk_navigationBar.isHidden = false
gk_navigationBar.backgroundColor = .clear
gk_navTitle = "报名结果"
// view.backgroundColor = UIColor.pageBkgColor
view.backgroundColor = UIColor.white
view.addSubview(statusImageV)
statusImageV.snp.makeConstraints { make in
make.top.equalTo(180)
make.centerX.equalToSuperview()
make.height.width.equalTo(128)
}
view.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(statusImageV.snp.bottom)
make.centerX.equalToSuperview()
make.height.equalTo(25)
}
view.addSubview(nameLabel)
nameLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.centerX.equalToSuperview()
make.left.equalTo(46)
make.right.equalTo(-46)
}
view.addSubview(submitButton)
submitButton.snp.makeConstraints { make in
make.top.equalTo(nameLabel.snp.bottom).offset(42)
make.centerX.equalToSuperview()
make.width.equalTo(142)
make.height.equalTo(42)
}
if isSuccessFlag {
titleLabel.text = "报名成功"
statusImageV.image = UIImage(named: "activity_apply_result_success")
nameLabel.text = "已报名成功活动【" + activityName + "】,记得准时参加哦"
submitButton.setTitle("查看行程单", for: .normal)
} else {
titleLabel.text = "报名失败"
statusImageV.image = UIImage(named: "activity_apply_result_fail")
nameLabel.text = "活动【" + activityName + "】,活动时间已结束,请您看看其他活动~"
submitButton.setTitle("返回活动列表", for: .normal)
}
}
@objc func clickSubmitBtn() {
if isSuccessFlag {
//行程单详情
let vc = YHActivityTravelViewController()
vc.travelId = activityTravelId
self.navigationController?.pushViewController(vc)
} else {
//返回活动列表
navigationController?.popToRootViewController(animated: true)
}
}
}
//
// YHActivityDetailModel.swift
// galaxy
//
// Created by davidhuangA on 2024/6/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityDetailModel: YHActivityModel {
// var cover : String = "" //活动封面
// var name : String = "" //活动标题
// var tag : Int = 0 //活动标签枚举 1:V专享
// var beginTime : String = "" //开始时间戳
// var endTime : String = "" //结束时间戳
// var place : String = "" //活动地点
// var id : Int = 0 //活动ID
// var status : String = "" //活动的状态 1:立即报名 2:已报名 3:活动结束 4:已取消报名
var tips : String = "" //温馨提示
var guidance : String = "" //交通引导
var introduce : String = "" //活动介绍
var posters : [String] = [] //活动海报
var businessCardName : String = "" //报名人姓名
}
//
// YHActivityListModel.swift
// galaxy
//
// Created by davidhuangA on 2024/6/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityListModel : YHBaseModel {
var total : String = ""
var data : [YHActivityModel] = []
required init() {
}
}
//
// YHActivityModel.swift
// galaxy
//
// Created by davidhuangA on 2024/6/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityModel: YHBaseModel {
var id : Int = 0 //活动ID
var tag : Int = 0 //活动标签枚举 1:V专享
var name : String = "" //活动标题
var cover : String = "" //活动封面
var beginTime : String = "" //开始时间戳
var endTime : String = "" //结束时间戳
var place : String = "" //活动地点
var status : String = "" //活动的状态 1:立即报名 2:已报名 3:活动结束 4:已取消报名
var checkId : String = "" //活动行程ID 仅当活动状态为2(已报名)时才大于0
private var beginTimeForUI : String = ""
func getDateString() -> String {
if beginTimeForUI.isEmpty {
if let tttt = beginTime.double() {
//1.
// 将时间戳转换为Date对象
let date = Date(timeIntervalSince1970: TimeInterval(tttt))
// 创建一个DateFormatter实例
let dateFormatter = DateFormatter()
// 设置日期格式,这里设置为"年-月-日 时:分:秒"
dateFormatter.dateFormat = "yyyy-MM-dd" // HH:mm:ss
// 使用DateFormatter将Date对象转换为字符串
let dateString = dateFormatter.string(from: date)
dateFormatter.dateFormat = "HH:mm"
let titmeString = dateFormatter.string(from: date)
// 获取Calendar的当前实例
let calendar = Calendar.current
// 使用Calendar来获取星期几
let weekday = calendar.component(.weekday, from: date)
// 星期几的名称,根据weekday的值,1到7分别代表周一到周日
if weekday > 0 && weekday < 8 {
let weekdayName = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][weekday - 1]
if let tttt = endTime.double() {
// 将时间戳转换为Date对象
let date2 = Date(timeIntervalSince1970: TimeInterval(tttt))
let titmeString2 = dateFormatter.string(from: date2)
beginTimeForUI = dateString + " " + weekdayName + " " + titmeString + "-" + titmeString2
}
}
}
}
return beginTimeForUI
}
}
//
// YHActivityTravelModel.swift
// galaxy
//
// Created by davidhuangA on 2024/6/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityApplyInfoModel : YHBaseModel {
var name : String = "" //用户姓名
var mobile : String = "" //手机号码
var number : Int32 = 0 //报名人数
}
class YHActivityTravelModel: YHActivityModel {
var statusCn : String = "" //行程状态
var user : YHActivityApplyInfoModel?
var tips : String = "" //温馨提示
var guidance : String = "" //交通引导
}
//
// YHTravelModel.swift
// galaxy
//
// Created by davidhuangA on 2024/6/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHTravelModel : YHBaseModel {
var id : String = ""
}
//
// YHActivityApplyInfoView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityApplyInfoItemView: UIView {
var dataModel : YHActivityApplyInfoModel? {
didSet {
updateUI()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
lazy var titleLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize:17)
label.text = "报名信息"
return label
}()
lazy var nameItem:YHActivityTwoItemView = {
let view = YHActivityTwoItemView()
return view
}()
lazy var numberItem:YHActivityTwoItemView = {
let view = YHActivityTwoItemView()
return view
}()
lazy var phoneItem:YHActivityTwoItemView = {
let view = YHActivityTwoItemView()
return view
}()
}
extension YHActivityApplyInfoItemView {
func updateUI() {
guard let model = dataModel else {
return
}
nameItem.updateItem(title: "您的姓名", value: model.name)
numberItem.updateItem(title: "报名人数", value: "\(model.number)人")
phoneItem.updateItem(title: "手机号码", value: model.mobile)
}
func setupUI() {
addSubview(titleLable)
addSubview(nameItem)
addSubview(numberItem)
addSubview(phoneItem)
titleLable.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(24)
}
nameItem.snp.makeConstraints { make in
make.top.equalTo(titleLable.snp.bottom).offset(16)
make.left.right.equalToSuperview()
}
numberItem.snp.makeConstraints { make in
make.top.equalTo(nameItem.snp.bottom).offset(16)
make.left.right.equalToSuperview()
}
phoneItem.snp.makeConstraints { make in
make.top.equalTo(numberItem.snp.bottom).offset(16)
make.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
}
}
//
// YHActivityDetailBottomView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityDetailBottomView: UIView {
static let viewH : CGFloat = 98.0
var dataModel : YHActivityDetailModel? {
didSet {
updateUI()
}
}
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 lazy var bottomLine : UIView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
}
private extension YHActivityDetailBottomView {
func updateUI() {
guard let model = dataModel else {
return
}
if let status = Int(model.status) {
isHidden = false
saveButton.setTitle(YHActivityStatus.init(rawValue: status)?.titleForDetail, for: .normal)
saveButton.backgroundColor = YHActivityStatus.init(rawValue: status)?.activityColor
} else {
isHidden = true
}
}
func setupUI() {
backgroundColor = .white
addSubview(bottomLine)
bottomLine.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(1)
}
saveButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandMainColor
button.titleLabel?.font = UIFont.PFSC_R(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("立即报名", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(save), for: .touchUpInside)
return button
}()
addSubview(saveButton)
saveButton.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(bottomLine.snp.bottom).offset(8)
make.height.equalTo(48)
}
}
@objc func save() {
block?(0)
}
}
//
// YHActivityDetailCell.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityDetailCell: UITableViewCell {
static let cellReuseIdentifier = "YHActivityDetailCell"
var dataModel : YHActivityDetailModel? {
didSet {
updateUI()
}
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
lazy var topImgV:UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "global_default_image")
view.contentMode = .scaleAspectFill
view.clipsToBounds = true
return view
}()
//活动名称地址
lazy var acitivityTitle:YHActivityTitleItemView = {
let view = YHActivityTitleItemView()
return view
}()
//活动详情
lazy var acitivityDetail:YHActivityDetailItemView = {
let view = YHActivityDetailItemView()
return view
}()
//活动温馨提示
lazy var acitivityTips:YHActivityTipsItemView = {
let view = YHActivityTipsItemView()
return view
}()
//活动温馨提示
lazy var fakeView:UIView = {
let view = UIView()
view.backgroundColor = .clear
return view
}()
}
extension YHActivityDetailCell {
func updateUI() {
guard let model = dataModel else {
return
}
contentView.removeSubviews()
contentView.addSubview(topImgV)
contentView.addSubview(acitivityTitle)
contentView.addSubview(acitivityDetail)
contentView.addSubview(acitivityTips)
contentView.addSubview(fakeView)
topImgV.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(KScreenWidth)
}
if let url = URL(string: model.cover) {
topImgV.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
} else {
topImgV.image = UIImage(named: "global_default_image")
}
acitivityTitle.dataModel = model
acitivityTitle.snp.makeConstraints { make in
make.top.equalTo(topImgV.snp.bottom).offset(24)
make.left.equalTo(20)
make.right.equalTo(-20)
}
var lastView : UIView = acitivityTitle
//acitivityDetail
if model.introduce.isEmpty && model.posters.count < 1 {
//隐藏
acitivityDetail.isHidden = true
} else {
//展示
acitivityDetail.isHidden = false
acitivityDetail.dataModel = model
acitivityDetail.snp.makeConstraints { make in
make.top.equalTo(lastView.snp.bottom).offset(24)
make.left.equalTo(20)
make.right.equalTo(-20)
}
lastView = acitivityDetail
}
//acitivityTips
if model.tips.isEmpty {
acitivityTips.isHidden = true
} else {
acitivityTips.isHidden = false
acitivityTips.dataModel = model
acitivityTips.snp.makeConstraints { make in
make.top.equalTo(lastView.snp.bottom).offset(24)
make.left.equalTo(20)
make.right.equalTo(-20)
}
lastView = acitivityTips
}
fakeView.snp.makeConstraints { make in
make.top.equalTo(lastView.snp.bottom).offset(24)
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(1)
make.bottom.equalToSuperview().offset(-42)
}
}
func setupUI() {
backgroundColor = .clear
contentView.backgroundColor = .pageBkgColor
selectionStyle = .none
}
}
//
// YHActivityDetailItemView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityDetailItemView: UIView {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
var dataModel : YHActivityDetailModel? {
didSet {
updateUI()
}
}
private lazy var bottomLine : UIView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
lazy var nameLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_M(ofSize:17)
lable.text = "活动详情"
lable.numberOfLines = 0
return lable
}()
lazy var describeLable:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor70
lable.textAlignment = .left
lable.lineBreakMode = .byCharWrapping
lable.font = UIFont.PFSC_R(ofSize:14)
lable.text = " "
lable.numberOfLines = 0
lable.isHidden = true
return lable
}()
}
extension YHActivityDetailItemView {
func updateUI() {
guard let model = dataModel else {
return
}
describeLable.text = model.introduce
nameLabel.snp.remakeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(bottomLine.snp.bottom).offset(24)
}
var lastView : UIView = nameLabel
if model.introduce.isEmpty {
} else {
describeLable.isHidden = false
if model.posters.count > 0 {
describeLable.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(nameLabel.snp.bottom).offset(24)
}
} else {
describeLable.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(nameLabel.snp.bottom).offset(24)
make.bottom.equalToSuperview()
}
}
lastView = describeLable
}
if model.posters.count > 0 {
for (index, value) in model.posters.enumerated() {
print("Index: \(index), Value: \(value)")
let imageV : UIImageView = UIImageView()
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
if let url = URL(string: value) {
imageV.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
}
addSubview(imageV)
if model.posters.count - 1 == index {
if index == 0 {
imageV.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(lastView.snp.bottom).offset(24)
make.height.equalTo(376)
make.bottom.equalToSuperview()
}
} else {
imageV.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(lastView.snp.bottom).offset(20)
make.height.equalTo(376)
make.bottom.equalToSuperview()
}
}
} else {
imageV.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(lastView.snp.bottom).offset(20)
make.height.equalTo(376)
}
}
lastView = imageV
}
}
}
func setupUI() {
addSubview(bottomLine)
addSubview(nameLabel)
addSubview(describeLable)
bottomLine.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(1)
}
nameLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(bottomLine.snp.bottom).offset(24)
make.bottom.equalToSuperview()
}
}
}
//
// YHActivityListCell.swift
// galaxy
//
// Created by davidhuangA on 2024/6/19.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityListCell: UITableViewCell {
static let cellReuseIdentifier = "YHActivityListCell"
var dataModel : YHActivityModel? {
didSet {
updateUI()
}
}
var type : Int = 0
var sessionIndex : Int = 0 {
didSet {
let tmp = sessionIndex % 3
let name = "activity_cell_bkg_" + String(tmp)
bkgImgV.image = UIImage(named: name)
}
}
lazy var bkgImgV:UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "activity_cell_bkg_0")
view.contentMode = .scaleAspectFill
view.clipsToBounds = true
return view
}()
lazy var vipImgV:UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "activity_vip_icon")
view.contentMode = .scaleAspectFill
view.isHidden = true
return view
}()
lazy var nameLabel:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_M(ofSize:18)
nameLabel.text = "银河APP发布会"
nameLabel.numberOfLines = 2
return nameLabel
}()
lazy var activityImgV:UIImageView = {
let view = UIImageView()
view.contentMode = .scaleAspectFill
view.image = UIImage(named: "global_default_image")
return view
}()
lazy var lineView:UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var dateLabel:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor70
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:12)
label.text = "08/08 周五 18:00-20:00"
return label
}()
lazy var detailLabel:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor70
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:12)
label.text = "深圳深南大道本元大厦26A银河体验中心"
return label
}()
lazy var statusLabel:UILabel = {
let label = UILabel()
label.textColor = UIColor.brandMainColor
label.textAlignment = .right
label.font = UIFont.PFSC_R(ofSize:12)
label.text = "立即报名"
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
}
extension YHActivityListCell {
func updateUI() {
guard let model = dataModel else {
return
}
if model.tag == 1 {
vipImgV.isHidden = false
} else {
vipImgV.isHidden = true
}
nameLabel.text = model.name
if let url = URL(string: model.cover) {
activityImgV.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
} else {
activityImgV.image = UIImage(named: "global_default_image")
}
//
dateLabel.text = model.getDateString()//String(model.beginTime)
//
detailLabel.text = model.place
if let status = Int(model.status) {
if type == 0 {
statusLabel.text = YHActivityStatus.init(rawValue: status)?.titleForList
statusLabel.textColor = YHActivityStatus.init(rawValue: status)?.activityColor
} else {
statusLabel.text = YHActivityStatus.init(rawValue: status)?.titleForMyApplyList
statusLabel.textColor = YHActivityStatus.init(rawValue: status)?.activityColorForMyApplyList
}
} else {
statusLabel.text = ""
}
}
func setupUI() {
backgroundColor = .clear
selectionStyle = .none
contentView.addSubview(bkgImgV)
contentView.addSubview(vipImgV)
contentView.addSubview(nameLabel)
contentView.addSubview(activityImgV)
contentView.addSubview(lineView)
contentView.addSubview(dateLabel)
contentView.addSubview(detailLabel)
contentView.addSubview(statusLabel)
bkgImgV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
vipImgV.snp.makeConstraints { make in
make.top.left.equalToSuperview()
make.width.equalTo(44)
make.height.equalTo(18)
}
activityImgV.snp.makeConstraints { make in
make.right.equalTo(-20)
make.top.equalTo(20)
make.width.height.equalTo(72)
}
nameLabel.snp.makeConstraints { make in
make.top.equalTo(28)
make.left.equalTo(18)
make.right.equalTo(activityImgV.snp.left).offset(-20)
}
lineView.snp.makeConstraints { make in
make.top.equalTo(activityImgV.snp.bottom).offset(20)
make.left.equalTo(nameLabel.snp.left)
make.right.equalTo(activityImgV.snp.right)
make.height.equalTo(1)
}
dateLabel.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom).offset(14)
make.left.equalTo(lineView.snp.left)
make.right.equalTo(lineView.snp.right)
make.height.equalTo(17)
}
statusLabel.snp.makeConstraints { make in
make.top.equalTo(dateLabel.snp.bottom).offset(8)
make.right.equalTo(dateLabel.snp.right)
make.height.equalTo(17)
make.width.equalTo(48)
}
detailLabel.snp.makeConstraints { make in
make.top.equalTo(statusLabel.snp.top)
make.left.equalTo(dateLabel.snp.left)
make.height.equalTo(17)
make.right.equalTo(statusLabel.snp.left).offset(16)
}
}
}
//
// YHActivityTipsItemView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityTipsItemView: UIView {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
var tipsText : String? {
didSet {
updateUI2()
}
}
var showLineFlag : Bool = true
var dataModel : YHActivityDetailModel? {
didSet {
updateUI()
}
}
private lazy var bottomLine : UIView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
return view
}()
lazy var nameLabel:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_M(ofSize:17)
nameLabel.text = "温馨提示"
nameLabel.numberOfLines = 0
return nameLabel
}()
lazy var describeLable:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor70
nameLabel.textAlignment = .left
nameLabel.lineBreakMode = .byCharWrapping
nameLabel.font = UIFont.PFSC_R(ofSize:14)
nameLabel.text = ""
nameLabel.numberOfLines = 0
return nameLabel
}()
override func layoutSubviews() {
super.layoutSubviews()
bottomLine.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(1)
}
if showLineFlag {
bottomLine.isHidden = false
nameLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(bottomLine.snp.bottom).offset(24)
}
} else {
bottomLine.isHidden = true
nameLabel.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
}
}
describeLable.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(nameLabel.snp.bottom).offset(24)
make.bottom.equalToSuperview()
}
}
}
extension YHActivityTipsItemView {
func updateUI2() {
guard let txt = tipsText else {
return
}
describeLable.text = txt
layoutIfNeeded()
}
func updateUI() {
guard let model = dataModel else {
return
}
describeLable.text = model.tips
layoutIfNeeded()
}
func setupUI() {
addSubview(bottomLine)
addSubview(nameLabel)
addSubview(describeLable)
layoutIfNeeded()
}
}
//
// YHActivityTitleItemView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityTitleItemView: UIView {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
var dataModel : YHActivityDetailModel? {
didSet {
updateUI()
}
}
private lazy var nameTextView : UITextView = {
let lable0 = UITextView()
lable0.textColor = UIColor.mainTextColor
lable0.textAlignment = .left
lable0.font = UIFont.PFSC_B(ofSize:24)
lable0.isScrollEnabled = false
lable0.isEditable = false
lable0.isSelectable = false
lable0.backgroundColor = .clear
return lable0
}()
lazy var timeStaticLable:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor50
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_R(ofSize:14)
nameLabel.text = "时间"
return nameLabel
}()
lazy var timeLable:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_R(ofSize:14)
nameLabel.text = "2024-08-06 周五 09:30"
return nameLabel
}()
lazy var addressStaticLable:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor50
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_R(ofSize:14)
nameLabel.text = "地址"
return nameLabel
}()
lazy var addressLable:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_R(ofSize:14)
nameLabel.text = "深圳市本元大厦26A银河集团体验中心"
return nameLabel
}()
lazy var navAddressLable:UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor.mainTextColor50
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_R(ofSize:14)
nameLabel.text = "距地铁10号线亮马站D口步行62"
nameLabel.numberOfLines = 0
return nameLabel
}()
}
extension YHActivityTitleItemView {
func updateUI() {
guard let model = dataModel else {
return
}
nameTextView.text = model.name
if model.tag == 1 {
nameTextView.attributed.text = """
\(model.name + " ", .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:24)))\(.image(UIImage(named: "activity_vip_icon2")!,.custom(.offset(CGPoint(x: 0, y: -7)), size: .init(width: 44, height: 34))))
"""
} else {
nameTextView.attributed.text = """
\(model.name, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:24)))
"""
}
timeLable.text = model.getDateString()//String(model.beginTime)
addressLable.text = model.place
navAddressLable.text = model.guidance
}
func setupUI() {
addSubview(nameTextView)
addSubview(timeStaticLable)
addSubview(timeLable)
addSubview(addressStaticLable)
addSubview(addressLable)
addSubview(navAddressLable)
nameTextView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
}
timeStaticLable.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalTo(nameTextView.snp.bottom).offset(24)
make.height.equalTo(20)
make.width.equalTo(28)
}
timeLable.snp.makeConstraints { make in
make.left.equalTo(timeStaticLable.snp.right).offset(16)
make.top.equalTo(timeStaticLable.snp.top)
make.right.equalToSuperview()
}
addressStaticLable.snp.makeConstraints { make in
make.left.equalTo(timeStaticLable.snp.left)
make.top.equalTo(timeLable.snp.bottom).offset(13)
make.height.equalTo(timeStaticLable.snp.height)
make.width.equalTo(timeStaticLable.snp.width)
}
addressLable.snp.makeConstraints { make in
make.left.equalTo(timeLable.snp.left)
make.top.equalTo(addressStaticLable.snp.top)
make.right.equalToSuperview()
}
navAddressLable.snp.makeConstraints { make in
make.left.equalTo(addressLable.snp.left)
make.top.equalTo(addressLable.snp.bottom).offset(8)
make.right.equalToSuperview()
make.bottom.equalToSuperview()
}
// nameTextView.attributed.text = """
// \("", .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:24)))\(.image(UIImage(named: "activity_vip_icon2")!,.custom(.offset(CGPoint(x: 0, y: -7)), size: .init(width: 44, height: 34))))
// """
}
}
//
// YHActivityTravelCell.swift
// galaxy
//
// Created by davidhuangA on 2024/6/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityTravelCell: UITableViewCell {
static let cellReuseIdentifier = "YHActivityTravelCell"
private var isApplyFlag : Bool = true
var dataModel : YHActivityTravelModel? {
didSet {
updateUI()
}
}
typealias Block = () -> ()
var block: Block?
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
lazy var statusLable:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_M(ofSize:28)
lable.text = "已报名"
return lable
}()
//活动名称地址
lazy var acitivityTitle:YHActivityTravelitemView = {
let view = YHActivityTravelitemView()
return view
}()
//报名人数
lazy var acitivityApplyInfo:YHActivityApplyInfoItemView = {
let view = YHActivityApplyInfoItemView()
return view
}()
//活动温馨提示
lazy var acitivityTips:YHActivityTipsItemView = {
let view = YHActivityTipsItemView()
view.showLineFlag = false
return view
}()
//取消活动
lazy var cancelButton:UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandMainColor
button.titleLabel?.font = UIFont.PFSC_R(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("取消报名", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(clickCancelBtn), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
return button
}()
}
extension YHActivityTravelCell {
func updateUI() {
guard let model = dataModel else {
return
}
if model.status.int == 2 {
cancelButton.isHidden = false
cancelButton.setTitle("取消报名", for: .normal)
cancelButton.setTitle("取消报名", for: .highlighted)
cancelButton.setTitleColor(UIColor.mainTextColor, for: .normal)
cancelButton.setTitleColor(UIColor.mainTextColor, for: .highlighted)
cancelButton.backgroundColor = .white
cancelButton.layer.borderWidth = 1
cancelButton.layer.borderColor = UIColor.mainTextColor50.cgColor
statusLable.text = "已报名"
} else if model.status.int == 4 || model.status.int == 1 {
cancelButton.isHidden = false
cancelButton.setTitle("重新报名", for: .normal)
cancelButton.setTitle("重新报名", for: .highlighted)
cancelButton.setTitleColor(UIColor.white, for: .normal)
cancelButton.setTitleColor(UIColor.white, for: .highlighted)
cancelButton.backgroundColor = .brandMainColor
cancelButton.layer.borderWidth = 0
cancelButton.layer.borderColor = UIColor.clear.cgColor
statusLable.text = "已取消"
} else if model.status.int == 3 {
cancelButton.isHidden = true
statusLable.text = "活动结束"
}
else {
cancelButton.isHidden = true
}
acitivityTitle.dataModel = model
acitivityTitle.snp.remakeConstraints { make in
make.top.equalTo(statusLable.snp.bottom).offset(20)
make.left.right.equalToSuperview()
}
acitivityApplyInfo.dataModel = model.user
acitivityApplyInfo.snp.remakeConstraints { make in
make.top.equalTo(acitivityTitle.snp.bottom).offset(32)
make.left.right.equalToSuperview()
}
var lastView : UIView = acitivityApplyInfo
if !model.tips.isEmpty {
acitivityTips.isHidden = false
acitivityTips.tipsText = model.tips
acitivityTips.snp.remakeConstraints { make in
make.top.equalTo(acitivityApplyInfo.snp.bottom).offset(32)
make.left.right.equalToSuperview()
}
acitivityTips.layoutIfNeeded()
lastView = acitivityTips
} else {
acitivityTips.isHidden = true
}
cancelButton.snp.remakeConstraints { make in
make.top.equalTo(lastView.snp.bottom).offset(32)
make.width.equalTo(178)
make.height.equalTo(42)
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-46)
}
}
@objc func clickCancelBtn() {
self.block?()
}
func setupUI() {
backgroundColor = .clear
contentView.backgroundColor = .clear
selectionStyle = .none
contentView.addSubview(statusLable)
contentView.addSubview(acitivityTitle)
contentView.addSubview(acitivityApplyInfo)
contentView.addSubview(acitivityTips)
contentView.addSubview(cancelButton)
statusLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.left.right.equalToSuperview()
make.height.equalTo(40)
}
acitivityTitle.snp.makeConstraints { make in
make.top.equalTo(statusLable.snp.bottom).offset(20)
make.left.right.equalToSuperview()
}
acitivityApplyInfo.snp.makeConstraints { make in
make.top.equalTo(acitivityTitle.snp.bottom).offset(32)
make.left.right.equalToSuperview()
}
acitivityTips.snp.makeConstraints { make in
make.top.equalTo(acitivityApplyInfo.snp.bottom).offset(32)
make.left.right.equalToSuperview()
}
acitivityTips.layoutIfNeeded()
cancelButton.snp.makeConstraints { make in
make.top.equalTo(acitivityTips.snp.bottom).offset(32)
make.width.equalTo(178)
make.height.equalTo(42)
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-46)
}
}
}
//
// YHActivityTravelitemView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityTravelitemView: UIView {
var dataModel : YHActivityTravelModel? {
didSet {
updateUI()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
lazy var activityImgV:UIImageView = {
let view = UIImageView()
view.contentMode = .scaleAspectFill
view.image = UIImage(named: "global_default_image")
return view
}()
lazy var nameLabel:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize:18)
label.text = ""
label.numberOfLines = 0
label.lineBreakMode = .byCharWrapping
return label
}()
lazy var timeStaticLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor50
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.text = "时间"
return label
}()
lazy var timeLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.text = "2024-08-06 周五 09:30"
label.numberOfLines = 0
return label
}()
lazy var addressStaticLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor50
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.text = "地址"
return label
}()
lazy var addressLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.text = ""
label.numberOfLines = 0
return label
}()
lazy var navAddressLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor50
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.text = ""
label.numberOfLines = 0
return label
}()
}
extension YHActivityTravelitemView {
func updateUI() {
guard let model = dataModel else {
return
}
nameLabel.text = model.name
if let url = URL(string: model.cover) {
activityImgV.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
} else {
activityImgV.image = UIImage(named: "global_default_image")
}
timeLable.text = model.getDateString()//String(model.beginTime)
addressLable.text = model.place
navAddressLable.text = model.guidance
}
func setupUI() {
backgroundColor = .white
layer.cornerRadius = kCornerRadius6
clipsToBounds = true
addSubview(activityImgV)
addSubview(nameLabel)
addSubview(timeStaticLable)
addSubview(timeLable)
addSubview(addressStaticLable)
addSubview(addressLable)
addSubview(navAddressLable)
activityImgV.snp.makeConstraints { make in
make.top.equalTo(20)
make.right.equalTo(-20)
make.height.width.equalTo(72)
}
nameLabel.snp.makeConstraints { make in
make.top.equalTo(24)
make.left.equalTo(20)
make.right.equalTo(activityImgV.snp.left).offset(-42)
}
timeStaticLable.snp.makeConstraints { make in
make.left.equalTo(nameLabel.snp.left)
make.top.equalTo(activityImgV.snp.bottom).offset(24)
make.height.equalTo(20)
make.width.equalTo(28)
}
timeLable.snp.makeConstraints { make in
make.left.equalTo(timeStaticLable.snp.right).offset(16)
make.top.equalTo(timeStaticLable.snp.top)
make.right.equalToSuperview().offset(-20)
}
addressStaticLable.snp.makeConstraints { make in
make.left.equalTo(timeStaticLable.snp.left)
make.top.equalTo(timeLable.snp.bottom).offset(13)
make.height.equalTo(timeStaticLable.snp.height)
make.width.equalTo(timeStaticLable.snp.width)
}
addressLable.snp.makeConstraints { make in
make.left.equalTo(timeLable.snp.left)
make.top.equalTo(addressStaticLable.snp.top)
make.right.equalToSuperview().offset(-20)
}
navAddressLable.snp.makeConstraints { make in
make.left.equalTo(addressLable.snp.left)
make.top.equalTo(addressLable.snp.bottom).offset(8)
make.right.equalToSuperview().offset(-20)
make.bottom.equalToSuperview().offset(-20)
}
}
}
//
// YHActivityTwoItemView.swift
// galaxy
//
// Created by davidhuangA on 2024/6/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityTwoItemView: UIView {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
lazy var titleLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor50
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.text = "您的姓名"
// label.numberOfLines = 0
return label
}()
lazy var detailLable:UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .right
label.font = UIFont.PFSC_R(ofSize:14)
label.text = "侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊侯林俊"
label.numberOfLines = 0
return label
}()
func updateItem(title : String, value : String) {
titleLable.text = title
detailLable.text = value
}
}
extension YHActivityTwoItemView {
func setupUI() {
addSubview(titleLable)
addSubview(detailLable)
titleLable.snp.makeConstraints { make in
make.top.left.equalToSuperview()
make.width.equalTo(56)
}
detailLable.snp.makeConstraints { make in
make.top.equalTo(titleLable.snp.top)
make.left.equalTo(titleLable.snp.right).offset(20)
make.right.equalToSuperview()
make.bottom.equalToSuperview()
}
}
}
//
// YHActivityViewModel.swift
// galaxy
//
// Created by davidhuangA on 2024/6/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivityViewModel: YHBaseViewModel {
//1、活动列表 、 我的报名活动列表
var hasMoreForActivityList : Bool = true
var isRequestActivityListDataFlag : Bool = false
private var curPageIndex : Int = 1
private var page_Size : Int = 20
private var totalCount : Int = 0
var arrActivityListData : [YHActivityModel] = []
//2.活动详情
var activityDetailModel : YHActivityDetailModel?
//3.活动报名
var travelModel : YHTravelModel?
//4.活动行程单
var activityTravelModel : YHActivityTravelModel?
}
extension YHActivityViewModel {
/*
*取消活动报名
*/
func cancelActivityTravel(travelId : String ,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Activity.cancelApi
let param = ["id":travelId]
let _ = YHNetRequest.putRequest(url: strUrl,params: param) { [weak self] json, code in
guard self != nil else { return }
//1. json字符串 转 对象
if json.code == 200 {
// let dic = json.data
// guard let result = YHActivityTravelModel.deserialize(from: dic as? Dictionary) else {
// self.activityTravelModel = nil
// callBackBlock(false,nil)
// return
// }
// self.activityTravelModel = result
callBackBlock(true, nil)
} else {
// self.activityTravelModel = nil
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
// self.activityTravelModel = nil
callBackBlock(false,err)
}
}
/*
*活动行程单
*/
func getActivityTravelDetail(travelId : String ,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Activity.travelApi + "/" + travelId
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHActivityTravelModel.deserialize(from: dic as? Dictionary) else {
self.activityTravelModel = nil
callBackBlock(false,nil)
return
}
self.activityTravelModel = result
callBackBlock(true, nil)
} else {
self.activityTravelModel = nil
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
self.activityTravelModel = nil
callBackBlock(false,err)
}
}
/*
*活动报名
*/
func applyActivity(param : [String : Any] ,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Activity.applyApi
let _ = YHNetRequest.postRequest(url: strUrl,params: param) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHTravelModel.deserialize(from: dic as? Dictionary) else {
self.travelModel = nil
callBackBlock(false,nil)
return
}
self.travelModel = result
callBackBlock(true, nil)
} else {
self.activityDetailModel = nil
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
self.activityDetailModel = nil
callBackBlock(false,err)
}
}
/*
*活动详情
*/
func getActivityDetailData(activityID : String ,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Activity.detailApi + "/" + activityID
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHActivityDetailModel.deserialize(from: dic as? Dictionary) else {
self.activityDetailModel = nil
callBackBlock(false,nil)
return
}
self.activityDetailModel = result
callBackBlock(true, nil)
} else {
self.activityDetailModel = nil
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
self.activityDetailModel = nil
callBackBlock(false,err)
}
}
/*
*活动列表
firstFlag true - 首次 false - 更多
type 0-活动列表 1-我的报名活动列表
*/
func getActivityList(firstFlag : Bool,type : Int = 0,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
if firstFlag == false {
guard hasMoreForActivityList == true else {
printLog("无更多数据可请求")
return
}
}
guard isRequestActivityListDataFlag == false else {
printLog("正在进行请求")
return
}
isRequestActivityListDataFlag = true
var params: [String : Any] = ["page": curPageIndex,
"page_size": page_Size]
if firstFlag {
params = ["page": 1,
"page_size": page_Size]
} else {
params = ["page": curPageIndex + 1,
"page_size": page_Size]
}
var strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Activity.listApi
if type == 1 {
strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Activity.myListApi
} else if type == 0 {
}
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in
guard let self = self else { return }
self.isRequestActivityListDataFlag = false
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHActivityListModel.deserialize(from: dic as? Dictionary) else {
self.arrActivityListData = []
callBackBlock(false,nil)
return
}
if firstFlag {
self.totalCount = Int(result.total) ?? 0
self.arrActivityListData = result.data
curPageIndex = 1
} else {
curPageIndex = curPageIndex + 1
self.arrActivityListData.append(contentsOf: result.data)
}
if result.data.count >= page_Size {
if self.arrActivityListData.count >= self.totalCount {
self.hasMoreForActivityList = false
} else {
self.hasMoreForActivityList = true
}
} else {
self.hasMoreForActivityList = false
}
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
self.isRequestActivityListDataFlag = false
callBackBlock(false,err)
}
}
}
//
// YHCommunityViewController.swift
// galaxy
//
// Created by EDY on 2024/6/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHCommunityViewController: YHBaseViewController {
var defaltIndex: Int = 0
let friendViewModel = YHMatchUserViewModel()
let arrItemTitles = ["人脉","活动"]
var arrItemVCs : [YHBaseViewController] = []
lazy var segmentedView : JXSegmentedView = {
let view = JXSegmentedView(frame: CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: KScreenWidth, height: 48))
view.backgroundColor = .clear
return view
}()
lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.isTitleColorGradientEnabled = true
dataSource.titles = arrItemTitles
dataSource.titleNormalFont = UIFont.PFSC_M(ofSize: 15)
dataSource.titleNormalColor = UIColor(hex: 0xFFFFFF, alpha: 0.6)
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 18)
dataSource.titleSelectedColor = .white
dataSource.isItemSpacingAverageEnabled = false
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 30
return dataSource
}()
lazy var bgImgV:UIImageView = {
let bg = UIImageView(image: UIImage(named: "people_match_bg"))
return bg
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
let view = JXSegmentedListContainerView(dataSource: self, type: .scrollView)
view.backgroundColor = .clear
return view
}()
lazy var friendsBtn:UIButton = {
let btn = UIButton()
btn.setImage(UIImage(named: "people_friends_btn"), for: .normal)
btn.setTitle("好友", for: .normal)
btn.setTitleColor(UIColor.white, for: .normal)
btn.iconInLeft(spacing: 4.0)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize:15)
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
btn.addTarget(self, action: #selector(didFriendsBtnClicked), for: .touchUpInside)
return btn
}()
let unreadHeight = 16.0
lazy var unreadLabel:UILabel = {
let label = UILabel()
label.textColor = .white
label.textAlignment = .center
label.backgroundColor = .failColor
label.font = .PFSC_M(ofSize: 10)
label.layer.cornerRadius = unreadHeight/2.0
label.clipsToBounds = true
label.isHidden = true
return label
}()
var unreadCount:Int = 0 {
didSet {
self.updateUnreadCount(self.unreadCount)
}
}
func updateUnreadCount(_ count : Int) {
self.unreadLabel.isHidden = (count <= 0)
if 0 < count && count < 100 {
self.unreadLabel.text = "\(count)"
} else if count >= 100 {
self.unreadLabel.text = "99+"
}
var width = unreadHeight
var leftMargin = -8
if 10 <= count && count < 100 {
width = 22.0
} else if count >= 100 {
width = 30.0
leftMargin = -14
}
self.unreadLabel.snp.updateConstraints { make in
make.width.equalTo(width)
make.left.equalTo(self.friendsBtn.snp.right).offset(leftMargin)
}
}
@objc func didBackBtnClicked() {
self.navigationController?.popViewController(animated: true)
}
@objc func didFriendsBtnClicked() {
if !YHLoginManager.shared.isLogin() {
YHOneKeyLoginManager.shared.oneKeyLogin()
return
}
let vc = YHMyGoodFriendsVC()
self.navigationController?.pushViewController(vc)
}
override func viewDidLoad() {
super.viewDidLoad()
gk_navBarAlpha = 0
gk_navigationBar.isHidden = true
self.view.backgroundColor = .white
self.view.addSubview(bgImgV)
self.bgImgV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
NotificationCenter.default.addObserver(self, selector: #selector(goActivityVC), name: YhConstant.YhNotification.goActivityVCNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(goConnectionVC), name: YhConstant.YhNotification.goConnectionVCNotifiction, object: nil)
for i in 0..<arrItemTitles.count {
if i != 0 {
let vc = YHActivityListViewController()
arrItemVCs.append(vc)
} else {
let vc = YHMatchUserViewController()
arrItemVCs.append(vc)
}
}
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
view.addSubview(segmentedView)
segmentedView.listContainer = listContainerView
view.addSubview(listContainerView)
//分类Title
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = UIColor.white
segmentedView.indicators = [indicator]
segmentedView.defaultSelectedIndex = defaltIndex
self.view.addSubview(friendsBtn)
friendsBtn.snp.makeConstraints { make in
make.width.equalTo(54.0)
make.height.equalTo(21)
make.right.equalTo(-20)
make.top.equalTo(12+k_Height_safeAreaInsetsTop())
}
self.friendsBtn.addSubview(self.unreadLabel)
self.unreadLabel.snp.makeConstraints { make in
make.width.height.equalTo(unreadHeight)
make.left.equalTo(self.friendsBtn.snp.right).offset(-8)
make.top.equalTo(self.friendsBtn.snp.top).offset(-8)
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
requestFriendRequest()
//处于第一个item的时候,才允许屏幕边缘手势返回
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//离开页面的时候,需要恢复屏幕边缘手势,不能影响其他页面
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
segmentedView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: view.bounds.size.width, height: 48)
listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop())
}
func requestFriendRequest() {
if YHLoginManager.shared.isLogin() {
self.friendViewModel.getMyFriendList { success, error in
let unreadCount = self.friendViewModel.friendListModel.applyFriends.count
self.unreadCount = unreadCount
self.friendsBtn.isHidden = self.segmentedView.selectedIndex != 0
}
} else {
self.unreadCount = 0
}
}
@objc func goActivityVC() {
segmentedView.selectItemAt(index: 1)
}
@objc func goConnectionVC() {
segmentedView.selectItemAt(index: 0)
}
}
extension YHCommunityViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
if segmentedView.selectedIndex == 0 {
bgImgV.isHidden = false
friendsBtn.isHidden = false
segmentedDataSource.titleNormalColor = UIColor(hex: 0xFFFFFF, alpha: 0.6)
segmentedDataSource.titleSelectedColor = .white
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = UIColor.white
segmentedView.indicators = [indicator]
} else {
bgImgV.isHidden = true
friendsBtn.isHidden = true
segmentedDataSource.titleNormalColor = UIColor(hex: 0x94a3b8)
segmentedDataSource.titleSelectedColor = UIColor.mainTextColor
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = UIColor.brandMainColor
segmentedView.indicators = [indicator]
}
segmentedView.dataSource = segmentedDataSource
segmentedView.reloadData()
}
}
extension YHCommunityViewController {
func jumpToItemIndex(itemIndex : Int) {
self.segmentedView.selectItemAt(index: itemIndex)
}
}
extension YHCommunityViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
return titleDataSource.dataSource.count
}
return 0
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
}
}
......@@ -16,7 +16,7 @@ class YHBannerModel: YHBaseModel {
var create_at: String = ""
var skip_type: Int = 0
var id: Int = 0
var img_url_compress: String = ""
//是否为本地
var isLocalItemFlag : Bool = false
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment