Commit f9dcb1f0 authored by Steven杜宇's avatar Steven杜宇

Merge branch 'yinhe-live-1212' into develop

# Conflicts:
#	galaxy/galaxy.xcodeproj/project.pbxproj
parents ce4f767c 155ba004
......@@ -34,7 +34,7 @@ platform :ios do
main_fix = "main-fix"
#打包正使用的分支
myPack_branch = main_fix
myPack_branch = develop_branch
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,6 +10,40 @@ import UIKit
class YHAutoTextView: UITextView, UITextViewDelegate {
private var calculateHeight: CGFloat = 0.0
var isShowKeyboard: Bool = false {
didSet {
if !isShowKeyboard {
self.snp.updateConstraints { make in
make.top.equalTo(5)
make.height.equalTo(36)
make.bottom.equalTo(-5)
}
} else {
var realHeight = self.calculateHeight
if self.calculateHeight > maxHeight {
realHeight = maxHeight
self.snp.updateConstraints { make in
make.top.equalTo(11)
make.height.equalTo(realHeight)
make.bottom.equalTo(-11)
}
} else {
self.snp.updateConstraints { make in
make.top.equalTo(11-Self.verticalGap)
make.height.equalTo(realHeight)
make.bottom.equalTo(-(11-Self.verticalGap))
}
}
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
var textChange:((String)->())?
override open var text: String! {
......@@ -28,25 +62,27 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
}
}
let placeholderLabel: UILabel = {
lazy var placeholderLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = UIColor.init(hex: 0xB3C8E9)
label.font = UIFont.PFSC_R(ofSize: 14)
return label
}()
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
self.font = .PFSC_R(ofSize: 14)
delegate = self
isScrollEnabled = false // 禁止滚动
self.addSubview(placeholderLabel)
placeholderLabel.snp.makeConstraints { make in
make.center.equalToSuperview()
make.left.equalTo(5)
make.right.equalTo(-5)
}
}
required init?(coder: NSCoder) {
......@@ -72,17 +108,21 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
let size = sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))
var height = size.height
self.calculateHeight = height
isScrollEnabled = height > maxHeight
if height > maxHeight {
height = maxHeight
self.snp.updateConstraints { make in
make.top.equalTo(11)
make.height.equalTo(height)
make.bottom.equalTo(-11)
}
} else {
self.snp.updateConstraints { make in
make.top.equalTo(11-Self.verticalGap)
make.height.equalTo(height)
make.bottom.equalTo(-(11-Self.verticalGap))
}
}
......
//
// YHPageControl.swift
// galaxy
//
// Created by Dufet on 2024/12/13.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHPageControl: UIView {
// MARK: - Properties
private var dots: [UIView] = []
var dotSize: CGSize = CGSize(width: 40, height: 8) // 普通点的大小
var selectedDotSize: CGSize = CGSize(width: 60, height: 8) // 选中点的大小
var spacing: CGFloat = 8 // 点之间的间距
// 当前页码
var currentPage: Int = 0 {
didSet {
guard oldValue != currentPage else { return }
updateDots(animated: true)
}
}
// 总页数
var numberOfPages: Int = 0 {
didSet {
guard oldValue != numberOfPages else { return }
setupDots()
}
}
// 自定义颜色
var dotColor: UIColor = UIColor.lightGray {
didSet {
dots.forEach { $0.backgroundColor = dotColor }
dots[safe: currentPage]?.backgroundColor = selectedDotColor
}
}
var selectedDotColor: UIColor = UIColor.systemBlue {
didSet {
dots[safe: currentPage]?.backgroundColor = selectedDotColor
}
}
// MARK: - Initialization
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
// MARK: - Setup
private func setupView() {
backgroundColor = .clear
}
private func setupDots() {
// 移除现有的点
dots.forEach { $0.removeFromSuperview() }
dots.removeAll()
// 创建新的点
for _ in 0..<numberOfPages {
let dot = UIView()
dot.backgroundColor = dotColor
dot.layer.shadowOffset = .zero
addSubview(dot)
dots.append(dot)
}
// 更新布局
setNeedsLayout()
updateDots(animated: false)
}
// MARK: - Layout
override func layoutSubviews() {
super.layoutSubviews()
let totalWidth = CGFloat(numberOfPages - 1) * (dotSize.width + spacing) + selectedDotSize.width
var xOffset = (bounds.width - totalWidth) / 2
for (index, dot) in dots.enumerated() {
let isSelected = index == currentPage
let width = isSelected ? selectedDotSize.width : dotSize.width
dot.frame = CGRect(x: xOffset,
y: (bounds.height - dotSize.height) / 2,
width: width,
height: dotSize.height)
dot.layer.cornerRadius = self.dotSize.height / 2
dot.clipsToBounds = true
xOffset += width + spacing
}
}
// MARK: - Updates
private func updateDots(animated: Bool) {
guard !dots.isEmpty else { return }
let update = {
self.dots.enumerated().forEach { index, dot in
let isSelected = index == self.currentPage
dot.backgroundColor = isSelected ? self.selectedDotColor : self.dotColor
let width = isSelected ? self.selectedDotSize.width : self.dotSize.width
var frame = dot.frame
frame.size.width = width
dot.layer.cornerRadius = self.dotSize.height / 2
dot.clipsToBounds = true
dot.frame = frame
}
self.layoutSubviews()
}
if animated {
UIView.animate(withDuration: 0.3,
delay: 0,
usingSpringWithDamping: 0.7,
initialSpringVelocity: 0.5,
options: [.curveEaseInOut],
animations: update)
} else {
update()
}
}
}
// MARK: - Safe Array Access
private extension Array {
subscript(safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
......@@ -47,6 +47,7 @@ class YHAIMainChatViewController: YHBaseViewController {
lazy var bottomInputView: YHAITextInputView = {
let v = YHAITextInputView(frame: .zero)
v.backgroundColor = .clear
v.sendBlock = {
[weak self] text in
guard let self = self else { return }
......@@ -82,7 +83,7 @@ class YHAIMainChatViewController: YHBaseViewController {
tableView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.top.equalTo(0)
make.bottom.equalTo(-64-k_Height_safeAreaInsetsBottom())
make.bottom.equalTo(-66-k_Height_safeAreaInsetsBottom())
}
bottomInputView.snp.makeConstraints { make in
......@@ -261,19 +262,6 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
if msgType == .text {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
cell.message = msg
cell.messageClick = {
[weak self] text in
guard let self = self else { return }
self.bottomInputView.showKeyBoard(false)
if self.isNeedStopResonse() {
self.stopAutoResponse { success in
self.sendMessage(text)
}
} else {
self.sendMessage(text)
}
}
return cell
} else if msgType == .recommendText {
......@@ -379,17 +367,41 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
return height
}
if msgType == .recommendText { // 推荐文字消息
let label = UILabel()
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize:12)
label.numberOfLines = 0
label.text = message.body.contentText
let maxWidth = KScreenWidth-20*2-16*2 // 最大宽度限制
let size = label.sizeThatFits(CGSize(width: maxWidth, height: .greatestFiniteMagnitude))
var textHeight = ceil(size.height)
return textHeight+10.0*3.0
}
if msgType != .text {
return UITableView.automaticDimension
}
let text = message.body.contentText // 要显示的文本内容
let font = UIFont.PFSC_R(ofSize: 14) // 字体大小
let maxWidth = KScreenWidth-20*2-16*2 // 最大宽度限制
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
// 以下是文字消息计算高度
let label = UILabel()
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.numberOfLines = 0
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 4.0
let attributedText = NSAttributedString(
string: message.body.contentText,
attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.PFSC_R(ofSize:14)]
)
label.attributedText = attributedText
let maxWidth = message.isSelf ? KScreenWidth-58-20-16*2 : KScreenWidth-20*2-16*2 // 最大宽度限制
let size = label.sizeThatFits(CGSize(width: maxWidth, height: .greatestFiniteMagnitude))
var textHeight = ceil(size.height)
if textHeight < 20.0 {
textHeight = 20.0
......@@ -416,12 +428,12 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
return resultHeight
}
return UITableView.automaticDimension
return 0.0
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 16.0
return 40.0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
......
......@@ -81,12 +81,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
lazy var bannerView: YHAIChatBannerView = {
let view = YHAIChatBannerView(frame: CGRectMake(0, 0, KScreenWidth, 360))
view.bgImgV.image = getBannerBg()
view.titleLabel.text = getHeaderTitle()
view.descLabel.text = getHeaderDesc()
view.bannerArr = self.getBannerForRobotType(robotType)
view.messages = getFlowMessages()
let bgImgHeight = 242.0/335.0 * (KScreenWidth-40.0)
let height = 350.0-242.0+bgImgHeight
let view = YHAIChatBannerView(frame: CGRectMake(0, 0, KScreenWidth, height))
view.config = getBannerConfig()
view.selectFlowMsgBlock = {
[weak self] text in
guard let self = self else { return }
......@@ -145,12 +143,6 @@ class YHAIRobotChatViewController: YHBaseViewController {
self.tableView.tableHeaderView = nil
}
// cleanBtn.snp.makeConstraints { make in
// make.width.height.equalTo(24)
// make.top.equalTo(k_Height_statusBar()+k_Height_NavContentBar/2.0-12)
// make.right.equalToSuperview().offset(-20)
// }
bgImgView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
......@@ -321,64 +313,33 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
}
func getBannerBg() -> UIImage? {
if robotType == YHAIRobotType.education.rawValue {
return UIImage(named: "ai_chat_header_bg_1")
} else if robotType == YHAIRobotType.sale.rawValue {
return UIImage(named: "ai_chat_header_bg_0")
}
return UIImage(named: "ai_chat_header_bg_0")
}
func getFlowMessages() -> [String] {
func getBannerConfig() -> YHAIChatBannerViewConfig {
if robotType == YHAIRobotType.education.rawValue {
return ["香港教育有哪些优势?", "去香港读书有哪些条件?", "申请香港学校费用是多少?", "了解银河教育插班服务流程", "了解银河教育插班录取率"]
} else if robotType == YHAIRobotType.sale.rawValue {
return ["优才学历加分要求是什么?", "优才现在要怎么申请?", "墨尔本大学是优才合资格大学吗?", "推荐一些优才产品"]
}
return []
}
func getHeaderTitle() -> String {
if robotType == YHAIRobotType.education.rawValue {
return "Hello,我是香港教育宝"
} else if robotType == YHAIRobotType.sale.rawValue {
return "Hello,我是新港生活规划师"
}
return ""
}
func getHeaderDesc() -> String {
if robotType == YHAIRobotType.education.rawValue {
return "有香港教育的问题尽管问我"
} else if robotType == YHAIRobotType.sale.rawValue {
return "香港身份办理问题可以找我"
}
return ""
}
func getBannerForRobotType(_ robotType: String) -> [YHAIChatBannerItem] {
let config = YHAIChatBannerViewConfig()
if robotType == YHAIRobotType.sale.rawValue {
return [YHAIChatBannerItem(id: 0, title: "了解银河集团", desc: "香港身份生活一站式服务平台", msg: "银河集团,能够为我提供什么?"),
YHAIChatBannerItem(id: 1, title: "香港身份智能评估", desc: "20s快速评估,了解自身条件是否符合", msg: "开始身份办理评估"),
YHAIChatBannerItem(id: 2, title: "银河产品矩阵", desc: "香港身份、生活多样产品", msg: "介绍一下银河的产品"),]
}
if robotType == YHAIRobotType.education.rawValue {
return [YHAIChatBannerItem(id: 0, title: "幼中小学升学", desc: "去香港插班需要考核哪些"),
YHAIChatBannerItem(id: 1, title: "大学升学", desc: "DSE分数和Alevel的换算关系"),
YHAIChatBannerItem(id: 2, title: "银河教育服务", desc: "银河教育插班成功率如何?"),]
config.title = "Hello,我是新港生活规划师"
config.desc = "香港身份办理问题可以找我"
config.bgColor = .init(hex: 0xE6F4FF)
config.indicatorColor = .brandMainColor
config.bgImageName = "ai_chat_header_bg_0"
config.bannerItems = [YHAIChatBannerItem(id: 0, title: "了解银河集团", desc: "香港身份生活一站式服务平台", msg: "银河集团,能够为我提供什么?"),
YHAIChatBannerItem(id: 1, title: "香港身份智能评估", desc: "20s快速评估,了解自身条件是否符合", msg: "开始身份办理评估"),
YHAIChatBannerItem(id: 2, title: "银河产品矩阵", desc: "香港身份、生活多样产品", msg: "介绍一下银河的产品"),]
config.flowMessages = ["优才学历加分要求是什么?", "优才现在要怎么申请?", "墨尔本大学是优才合资格大学吗?", "推荐一些优才产品"]
} else if robotType == YHAIRobotType.education.rawValue {
config.title = "Hello,我是香港教育宝"
config.desc = "有香港教育的问题尽管问我"
config.bgColor = .init(hex: 0xDAF6FC)
config.indicatorColor = .init(hex: 0x00C77C)
config.bgImageName = "ai_chat_header_bg_1"
config.bannerItems = [YHAIChatBannerItem(id: 0, title: "幼中小学升学", desc: "去香港插班需要考核哪些"),
YHAIChatBannerItem(id: 1, title: "大学升学", desc: "DSE分数和Alevel的换算关系"),
YHAIChatBannerItem(id: 2, title: "银河教育服务", desc: "银河教育插班成功率如何?"),]
config.flowMessages = ["香港教育有哪些优势?", "去香港读书有哪些条件?", "申请香港学校费用是多少?", "了解银河教育插班服务流程", "了解银河教育插班录取率"]
}
return []
return config
}
func isNeedStopResonse() -> Bool {
......@@ -404,11 +365,6 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
if msgType == .text {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
cell.message = msg
cell.messageClick = {
[weak self] text in
guard let self = self else { return }
}
return cell
} else if msgType == .recommendText {
......@@ -513,17 +469,41 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return height
}
if msgType == .recommendText { // 推荐文字消息
let label = UILabel()
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize:12)
label.numberOfLines = 0
label.text = message.body.contentText
let maxWidth = KScreenWidth-20*2-16*2 // 最大宽度限制
let size = label.sizeThatFits(CGSize(width: maxWidth, height: .greatestFiniteMagnitude))
let textHeight = ceil(size.height)
return textHeight+10.0*3.0
}
if msgType != .text {
return UITableView.automaticDimension
}
let text = message.body.contentText // 要显示的文本内容
let font = UIFont.PFSC_R(ofSize: 14) // 字体大小
let maxWidth = KScreenWidth-20*2-16*2 // 最大宽度限制
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
// 以下是文字消息计算高度
let label = UILabel()
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.numberOfLines = 0
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 4.0
let attributedText = NSAttributedString(
string: message.body.contentText,
attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.PFSC_R(ofSize:14)]
)
label.attributedText = attributedText
let maxWidth = message.isSelf ? KScreenWidth-58-20-16*2 : KScreenWidth-20*2-16*2 // 最大宽度限制
let size = label.sizeThatFits(CGSize(width: maxWidth, height: .greatestFiniteMagnitude))
var textHeight = ceil(size.height)
if textHeight < 20.0 {
textHeight = 20.0
......@@ -550,7 +530,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return resultHeight
}
return UITableView.automaticDimension
return 0.0
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
......@@ -567,9 +547,8 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return 1.0
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 1.0
return 40.0
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
......
......@@ -33,48 +33,19 @@ class YHAIServiceListViewController: YHBaseViewController {
collectView.dataSource = self
collectView.register(YHAIProductCell.self, forCellWithReuseIdentifier: YHAIProductCell.cellReuseIdentifier)
collectView.register(YHAIGreetCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: YHAIGreetCollectionReusableView.reuseIdentifier)
collectView.register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "UICollectionReusableView")
collectView.contentInset = .zero
collectView.showsVerticalScrollIndicator = false
return collectView
}()
lazy var bottomInputView: UIView = {
let v = UIView()
let whiteView = UIView()
whiteView.backgroundColor = .white
whiteView.layer.cornerRadius = 12.0
v.addSubview(whiteView)
let label = UILabel()
label.font = .PFSC_R(ofSize: 14)
label.text = "有什么问题尽管问我"
label.textColor = .init(hex: 0xB3C8E9)
whiteView.addSubview(label)
let sendImgV = UIImageView(image: UIImage(named: "ai_chat_send_gray"))
whiteView.addSubview(sendImgV)
lazy var bottomInputView: YHAITextInputView = {
let v = YHAITextInputView(frame: .zero)
v.backgroundColor = .clear
v.disable = true
let btn = UIButton()
btn.addTarget(self, action: #selector(didInputButtonClicked), for: .touchUpInside)
whiteView.addSubview(btn)
whiteView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
label.snp.makeConstraints { make in
make.left.equalTo(16)
make.height.equalTo(20)
make.centerY.equalToSuperview()
}
sendImgV.snp.makeConstraints { make in
make.right.equalTo(-16)
make.width.height.equalTo(24)
make.centerY.equalToSuperview()
}
v.addSubview(btn)
btn.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
......@@ -101,14 +72,11 @@ class YHAIServiceListViewController: YHBaseViewController {
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalToSuperview()
make.bottom.equalTo(bottomInputView.snp.top).offset(-8)
}
bottomInputView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(46)
make.bottom.equalTo(-10-k_Height_safeAreaInsetsBottom())
make.top.equalTo(collectionView.snp.bottom).offset(8)
make.left.right.bottom.equalToSuperview()
}
}
}
......@@ -207,14 +175,21 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
headerView.updateGreetingText()
return headerView
}
let footerView: UICollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "UICollectionReusableView", for: indexPath)
return footerView
return UICollectionReusableView(frame: CGRectMake(0, 0, KScreenWidth, 42.0))
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection:Int) -> CGSize {
return CGSize(width: KScreenWidth, height: 177)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection:Int) -> CGSize {
return CGSize(width: KScreenWidth, height: 42.0)
}
}
extension YHAIServiceListViewController: JXSegmentedListContainerViewListDelegate {
......
......@@ -254,11 +254,13 @@ extension YHAITabViewController: JXSegmentedViewDelegate {
bgImgView.isHidden = false
headerImgView.isHidden = true
cleanBtn.isHidden = false
mainChatVC.bottomInputView.backgroundColor = mainChatVC.bottomInputView.bgColor
} else { // 港小宝
bgImgView.isHidden = true
headerImgView.isHidden = false
cleanBtn.isHidden = true
mainChatVC.bottomInputView.backgroundColor = .clear
}
}
}
......
......@@ -133,6 +133,8 @@ class YHAICardItemView: UIView {
@objc func didItemViewClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
YHAIJumpPageTool.jumpPageWithType(mode: cardModel.redirectMode, path: cardModel.redirectPath) {
dict in
self.evaluationResultCallback?(dict)
......
......@@ -21,14 +21,14 @@ class YHAIChatBannerItemCell: FSPagerViewCell {
static let cellReuseIdentifier = "YHAIChatBannerItemCell"
lazy var effectView:VisualEffectView = {
let visualEffectView = VisualEffectView()
visualEffectView.colorTint = UIColor(hex: 0xAFAFAF).withAlphaComponent(0.15)
visualEffectView.blurRadius = 16
visualEffectView.scale = 1
visualEffectView.isHidden = true
return visualEffectView
}()
// lazy var effectView:VisualEffectView = {
// let visualEffectView = VisualEffectView()
// visualEffectView.colorTint = UIColor(hex: 0xAFAFAF).withAlphaComponent(0.15)
// visualEffectView.blurRadius = 16
// visualEffectView.scale = 1
// visualEffectView.isHidden = true
// return visualEffectView
// }()
lazy var titleLabel: UILabel = {
let lable = UILabel()
......@@ -62,11 +62,11 @@ class YHAIChatBannerItemCell: FSPagerViewCell {
contentView.layer.shadowOpacity = 0
contentView.layer.shadowOffset = .zero
contentView.addSubview(effectView)
effectView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(95)
}
// contentView.addSubview(effectView)
// effectView.snp.makeConstraints { make in
// make.bottom.left.right.equalToSuperview()
// make.height.equalTo(95)
// }
contentView.addSubview(subtitleLabel)
subtitleLabel.snp.makeConstraints { make in
......
......@@ -8,6 +8,7 @@
import UIKit
import FSPagerView
//import JXPageControl
class YHAIChatBannerItem {
var id: Int = 0
......@@ -23,12 +24,35 @@ class YHAIChatBannerItem {
}
}
class YHAIChatBannerViewConfig {
var bgColor: UIColor = .init(hex: 0xE6F4FF)
var bgImageName: String = ""
var title: String = ""
var desc: String = ""
var indicatorColor: UIColor = .brandMainColor
var bannerItems:[YHAIChatBannerItem] = []
var flowMessages:[String] = []
}
class YHAIChatBannerView: UIView {
static let bannersHeight = 95.0
let cellHeight: CGFloat = 33.0 // 单元格的固定高度
var selectFlowMsgBlock:((String)->())?
var selectBannerItemBlock:((YHAIChatBannerItem)->())?
var config = YHAIChatBannerViewConfig() {
didSet {
titleLabel.text = config.title
descLabel.text = config.desc
bgCardView.backgroundColor = config.bgColor
bgImgV.image = UIImage(named: config.bgImageName)
indicatorView.selectedDotColor = config.indicatorColor
bannerArr = config.bannerItems
messages = config.flowMessages
}
}
var messages:[String] = [] {
didSet {
......@@ -62,14 +86,21 @@ class YHAIChatBannerView: UIView {
return imagV
}()
lazy var bgCardView: UIView = {
let v = UIView()
v.layer.cornerRadius = 12.0
v.clipsToBounds = true
return v
}()
var bannerArr: [YHAIChatBannerItem] = [] {
didSet {
// 设置为0是先停掉自动滑动定时器
bannerView.automaticSlidingInterval = 0
self.indicatorView.indicatorItems = self.bannerArr.count
self.indicatorView.numberOfPages = self.bannerArr.count
bannerView.reloadData()
// 指定指示器为第一个
self.indicatorView.curIndicatorIndex = 0
self.indicatorView.currentPage = 0
// 指定显示图片为第一个
bannerView.selectItem(at: 0, animated: false)
// 开启定时器开始滚动
......@@ -88,17 +119,20 @@ class YHAIChatBannerView: UIView {
view.automaticSlidingInterval = bannerSildingInterval
view.register(YHAIChatBannerItemCell.self, forCellWithReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier)
view.itemSize = CGSizeMake(KScreenWidth-40.0, YHAIChatBannerView.bannersHeight)//FSPagerView.automaticSize
view.layer.cornerRadius = 4.0
view.clipsToBounds = true
return view
}()
lazy var indicatorView : YHHomeBannerIndicatorView = {
let view = YHHomeBannerIndicatorView()
view.normalColor = .init(hex: 0xD5DAE1)
view.selectedColor = .brandMainColor
view.layer.cornerRadius = 1.0
return view
lazy var indicatorView: YHPageControl = {
let pageControl = YHPageControl(frame: .zero)
let dotHeight = 3.0
pageControl.spacing = 2.0
pageControl.dotSize = CGSizeMake(5, dotHeight)
pageControl.selectedDotSize = CGSizeMake(12, dotHeight)
pageControl.numberOfPages = 0
pageControl.currentPage = 0
pageControl.dotColor = .init(hex: 0xD5DAE1)
pageControl.selectedDotColor = .brandMainColor
return pageControl
}()
lazy var layout: YHAIChatCustomFlowLayout = {
......@@ -137,26 +171,33 @@ class YHAIChatBannerView: UIView {
func createUI() {
addSubview(shadowView)
addSubview(bgCardView)
addSubview(bgImgV)
bgImgV.addSubview(titleLabel)
bgImgV.addSubview(descLabel)
bgImgV.addSubview(bannerView)
bannerView.addSubview(indicatorView)
bgImgV.addSubview(indicatorView)
shadowView.snp.makeConstraints { make in
make.edges.equalTo(bgCardView)
}
let bgImgHeight = 242.0/335.0 * (KScreenWidth-40.0)
bgCardView.snp.makeConstraints { make in
make.left.right.bottom.equalTo(bgImgV)
make.top.equalTo(bgImgV.snp.top).offset(33)
make.top.equalTo(bgImgV).offset(33.0/242.0 * bgImgHeight)
}
bgImgV.snp.makeConstraints { make in
make.top.equalTo(0)
make.top.equalTo(10)
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(242)
make.height.equalTo(bgImgHeight)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(57)
make.top.equalTo(bgCardView).offset(24.0)
make.left.equalTo(20)
make.height.equalTo(20)
}
......@@ -171,12 +212,12 @@ class YHAIChatBannerView: UIView {
make.bottom.equalTo(bgImgV)
make.left.equalTo(0)
make.right.equalTo(0)
make.height.equalTo(YHAIChatBannerView.bannersHeight)
make.height.equalTo(YHAIChatBannerView.bannersHeight/242.0 * bgImgHeight)
}
indicatorView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(2)
make.height.equalTo(3)
make.bottom.equalTo(-16)
}
bannerView.reloadData()
......@@ -186,8 +227,7 @@ class YHAIChatBannerView: UIView {
make.left.equalTo(0)
make.right.equalTo(0)
make.height.equalTo(33.0*2+10.0 + 10.0*2.0)
make.top.equalTo(bannerView.snp.bottom).offset(6)
make.bottom.equalTo(-6)
make.top.equalTo(bgImgV.snp.bottom).offset(6)
}
}
......@@ -228,11 +268,11 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
}
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.indicatorView.curIndicatorIndex = targetIndex
self.indicatorView.currentPage = targetIndex
}
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.indicatorView.curIndicatorIndex = pagerView.currentIndex
self.indicatorView.currentPage = pagerView.currentIndex
}
}
......
......@@ -26,9 +26,10 @@ class YHAIChatInputShadowView: UIView {
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 12)
layer.shadowPath = shadowPath.cgPath
layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.12).cgColor
layer.shadowColor = UIColor(red: 0.35, green: 0.432, blue: 0.556, alpha: 0.12).cgColor
layer.shadowOpacity = 1
layer.shadowRadius = 6
layer.shadowRadius = 20
layer.shadowOffset = CGSize(width: 0, height: 0)
}
......
......@@ -25,7 +25,7 @@ class YHAIChatShadowView: UIView {
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 6)
// 设置阴影属性
layer.shadowPath = shadowPath.cgPath
layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.06).cgColor
layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.08).cgColor
layer.shadowOpacity = 1
layer.shadowRadius = 6.0
layer.shadowOffset = CGSize(width: 0, height: 4)
......
......@@ -8,6 +8,8 @@
import UIKit
import SDWebImage
import Photos
import PhotosUI
class YHAIPictureMessageCell: UITableViewCell {
......@@ -68,16 +70,6 @@ class YHAIPictureMessageCell: UITableViewCell {
ratio = img.size.width/img.size.height
}
imgH = imgW/ratio
// if imgH > 476 {
// imgH = 476
// imgW = imgH*ratio
//
// } else {
// imgW = 220
// imgH = imgW/ratio
// }
return CGSizeMake(imgW, imgH)
}
......@@ -86,10 +78,17 @@ class YHAIPictureMessageCell: UITableViewCell {
return v
}()
lazy var downloadBtn: UIButton = {
let btn = UIButton()
btn.setImage(UIImage(named: "ai_chat_img_download"), for: .normal)
btn.addTarget(self, action: #selector(didDownloadBtnClicked), for: .touchUpInside)
btn.layer.cornerRadius = 6.0
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
return btn
}()
lazy var whiteContentView: UIView = {
let v = UIView()
v.layer.cornerRadius = 12.0
v.clipsToBounds = true
let tap = UITapGestureRecognizer(target: self, action: #selector(didMessageClicked))
v.addGestureRecognizer(tap)
return v
......@@ -100,13 +99,6 @@ class YHAIPictureMessageCell: UITableViewCell {
return v
}()
lazy var rightAngleView: UIView = {
let v = UIView()
v.backgroundColor = .white
v.isHidden = true
return v
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
......@@ -116,15 +108,20 @@ class YHAIPictureMessageCell: UITableViewCell {
setupUI()
}
override func layoutSubviews() {
super.layoutSubviews()
roundCorners(keepTopLeft: true)
}
func setupUI() {
selectionStyle = .none
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(shadowView)
contentView.addSubview(rightAngleView)
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(imgView)
whiteContentView.addSubview(downloadBtn)
whiteContentView.snp.makeConstraints { make in
make.left.equalTo(20)
......@@ -138,19 +135,117 @@ class YHAIPictureMessageCell: UITableViewCell {
make.edges.equalToSuperview()
}
shadowView.snp.makeConstraints { make in
make.edges.equalTo(whiteContentView)
downloadBtn.snp.makeConstraints { make in
make.width.equalTo(26)
make.height.equalTo(26)
make.left.equalTo(16)
make.bottom.equalTo(-16)
}
rightAngleView.snp.makeConstraints { make in
make.top.left.equalTo(whiteContentView)
make.width.height.equalTo(15)
shadowView.snp.makeConstraints { make in
make.left.equalTo(whiteContentView).offset(-0)
make.right.equalTo(whiteContentView).offset(0)
make.top.equalTo(whiteContentView).offset(-0)
make.bottom.equalTo(whiteContentView).offset(0)
}
}
@objc func didMessageClicked() {
self.endEditing(true)
UIApplication.shared.yhKeyWindow()?.endEditing(true)
YHPictureReviewManager.shared.showNetWorkPicturs(curIndex: 0, arrPicturs: [imgInfo.imageUrl])
}
@objc func didDownloadBtnClicked() {
if imgInfo.imageType == YHAIImageType.url.rawValue {
// 尝试从缓存中获取图片
let cachedImage = SDImageCache.shared.imageFromCache(forKey: imgInfo.imageUrl)
downloadImage(cachedImage, urlString: imgInfo.imageDownloadUrl)
} else if imgInfo.imageType == YHAIImageType.local.rawValue {
let img = UIImage(named: imgInfo.localImageName)
downloadImage(img, urlString: imgInfo.imageDownloadUrl)
}
}
func downloadImage(_ img: UIImage?, urlString: String) {
if let img = img {
saveImage(img)
return
}
guard let url = URL(string: urlString) else {
YHHUD.flash(message: "保存失败")
return
}
let task = URLSession.shared.dataTask(with: url) {
[weak self] data, response, error in
DispatchQueue.main.async {
guard let self = self else { return }
guard let data = data else {
YHHUD.flash(message: "保存失败")
return
}
let image = UIImage(data: data)
if let image = image {
self.saveImage(image)
}
}
}
task.resume()
}
func saveImage(_ image: UIImage) {
// 确保应用有权访问相册
PHPhotoLibrary.requestAuthorization { status in
if status == .authorized {
// 保存图片到相册
DispatchQueue.main.async {
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
YHHUD.flash(message: "保存成功")
}
} else {
DispatchQueue.main.async {
YHHUD.flash(message: "保存失败,请检查系统权限")
}
}
}
}
func roundCorners(keepTopLeft: Bool) {
let path = UIBezierPath()
let radius: CGFloat = 6.0 // 圆角半径
// 设置路径
path.move(to: CGPoint(x: keepTopLeft ? 0 : radius, y: 0)) // 从左上角开始,视情况决定是否切圆角
// 左上角
if keepTopLeft {
path.addLine(to: CGPoint(x: 0, y: 0)) // 不切左上角
} else {
path.addArc(withCenter: CGPoint(x: radius, y: radius), radius: radius, startAngle: .pi, endAngle: .pi * 1.5, clockwise: true)
}
// 右上角
path.addLine(to: CGPoint(x: self.bounds.width, y: 0))
path.addArc(withCenter: CGPoint(x: self.bounds.width - radius, y: radius), radius: radius, startAngle: .pi * 1.5, endAngle: 0, clockwise: true)
// 右下角
path.addLine(to: CGPoint(x: self.bounds.width, y: self.bounds.height))
path.addArc(withCenter: CGPoint(x: self.bounds.width - radius, y: self.bounds.height - radius), radius: radius, startAngle: 0, endAngle: .pi / 2, clockwise: true)
// 左下角
path.addLine(to: CGPoint(x: 0, y: self.bounds.height))
path.addArc(withCenter: CGPoint(x: radius, y: self.bounds.height - radius), radius: radius, startAngle: .pi / 2, endAngle: .pi, clockwise: true)
path.close() // 关闭路径
// 创建 CAShapeLayer
let maskLayer = CAShapeLayer()
maskLayer.path = path.cgPath
self.whiteContentView.layer.mask = maskLayer // 设置 UIView 的 mask
}
}
......@@ -18,10 +18,12 @@ enum YHAITextInputStatus: Int {
class YHAITextInputView: UIView {
let bgColor = UIColor.init(hex: 0xF8FCFF)
var sendBlock: ((String)->())?
var stopSendBlock: (()->())?
var keyBoardChangeBlock: ((_ isShow: Bool)->())?
var disable: Bool = false
var status: YHAITextInputStatus = .enableSend {
didSet {
if status == .enableSend {
......@@ -91,6 +93,8 @@ class YHAITextInputView: UIView {
textView.text = ""
textView.isScrollEnabled = false
self.endEditing(true)
textLabel.isHidden = true
textView.isHidden = false
}
@objc func didStopSendBtnClicked() {
......@@ -101,10 +105,12 @@ class YHAITextInputView: UIView {
let v = YHAutoTextView()
v.backgroundColor = .clear
v.font = .PFSC_R(ofSize: 14)
v.textColor = .mainTextColor
v.placeHolder = "有什么问题尽管问我"
v.textChange = {
[weak self] text in
guard let self = self else { return }
self.textLabel.text = text
if status != .loading {
status = text.count > 0 ? .enableSend : .disableSend
}
......@@ -112,6 +118,22 @@ class YHAITextInputView: UIView {
return v
}()
lazy var textLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .mainTextColor
label.font = .PFSC_R(ofSize: 14)
label.isHidden = true
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(tapText))
label.addGestureRecognizer(tap)
return label
}()
@objc func tapText() {
textView.becomeFirstResponder()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
......@@ -145,13 +167,14 @@ class YHAITextInputView: UIView {
func createUI() {
self.backgroundColor = UIColor.init(hex: 0xF8FCFF)
self.backgroundColor = self.bgColor
self.addSubview(whiteView)
whiteView.addSubview(shadowView)
whiteView.addSubview(contentView)
contentView.addSubview(sendBtn)
contentView.addSubview(loadingImgView)
contentView.addSubview(textView)
contentView.addSubview(textLabel)
status = .disableSend
whiteView.snp.makeConstraints { make in
......@@ -181,23 +204,43 @@ class YHAITextInputView: UIView {
}
textView.snp.makeConstraints { make in
make.left.equalTo(5)
make.left.equalTo(16)
make.top.equalTo(11-YHAutoTextView.verticalGap)
make.height.equalTo(30)
make.bottom.equalTo(-(11-YHAutoTextView.verticalGap))
make.right.equalTo(sendBtn.snp.left).offset(-5)
}
textLabel.snp.makeConstraints { make in
make.center.equalToSuperview()
make.left.equalTo(textView).offset(5)
make.right.equalTo(textView).offset(-5)
}
addKeyBoardNotify()
}
@objc func handleKeyboardNotification(_ notification: Notification) {
if disable {
return
}
if notification.userInfo != nil {
guard let keyboardFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as AnyObject).cgRectValue else {return }
let isKeyboardShow = notification.name == UIResponder.keyboardWillShowNotification
let bottomMargin = (isKeyboardShow ? -keyboardFrame.height : 0)
if isKeyboardShow {
textLabel.isHidden = true
textView.isHidden = false
} else {
textLabel.isHidden = textView.text.isEmpty
textView.isHidden = !textView.text.isEmpty
}
textLabel.text = textView.text
textView.isShowKeyboard = isKeyboardShow
contentView.snp.updateConstraints { make in
make.bottom.equalTo(-10-(isKeyboardShow ? 0.0 : k_Height_safeAreaInsetsBottom()))
}
......
......@@ -18,17 +18,24 @@ class YHAITextMessageCell: UITableViewCell {
var message: YHAIChatMessage = YHAIChatMessage() {
didSet {
messageLabel.text = message.body.contentText
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 4.0
let textColor: UIColor = message.isSelf ? .white : .mainTextColor
let attributedText = NSAttributedString(
string: message.body.contentText,
attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.font: UIFont.PFSC_R(ofSize:14)]
)
messageLabel.attributedText = attributedText
rightAngleView.backgroundColor = message.isSelf ? .brandMainColor : .white
rightAngleView.isHidden = message.getType() != .text
if message.isSelf {
whiteContentView.backgroundColor = .brandMainColor
messageLabel.textColor = .white
whiteContentView.snp.remakeConstraints { make in
make.left.greaterThanOrEqualTo(20)
make.left.greaterThanOrEqualTo(58)
make.right.equalTo(-20)
make.top.equalTo(16)
make.bottom.equalTo(0)
......@@ -45,18 +52,10 @@ class YHAITextMessageCell: UITableViewCell {
} else {
messageLabel.text = message.body.contentText
whiteContentView.backgroundColor = .white
messageLabel.textColor = .mainTextColor
whiteContentView.snp.remakeConstraints { make in
make.left.equalTo(20)
if message.getType() == .recommendText {
make.right.lessThanOrEqualTo(-20)
} else {
make.right.equalTo(-20)
}
make.right.equalTo(-20)
make.top.equalTo(16)
make.bottom.equalTo(0)
}
......@@ -167,7 +166,7 @@ class YHAITextMessageCell: UITableViewCell {
make.height.equalTo(37)
make.width.equalTo(82)
}
copyBtn.iconInLeft(spacing: 0.0)
copyBtn.iconInLeft(spacing: 2.0)
return v
......@@ -261,9 +260,6 @@ class YHAITextMessageCell: UITableViewCell {
@objc func didMessageClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
if message.getType() == .recommendText {
let text = message.getText()
messageClick?(text)
}
messageClick?(self.message.body.contentText)
}
}
......@@ -194,6 +194,8 @@ class YHCardMessageCell: UITableViewCell {
@objc func didBottomButtonClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
var type = YHAIJumpType.common
if cardListModel.isEvaluation() {
type = YHAIJumpType.evaluation
......
......@@ -62,7 +62,7 @@ class YHProductItemView: UIView {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:14)
lable.font = UIFont.PFSC_M(ofSize:16)
return lable
}()
......@@ -91,6 +91,8 @@ class YHProductItemView: UIView {
}
@objc func didClickProductItem() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
if let configModel = YHConfigManager.shared.reqVM.configModel,configModel.is_integral_open {
YHAIJumpPageTool.jumpPageWithType(mode: productModel.redirectMode, path: productModel.redirectPath) {
dict in
......@@ -111,35 +113,35 @@ class YHProductItemView: UIView {
iconImgView.snp.makeConstraints { make in
make.width.height.equalTo(80)
make.left.equalTo(16)
make.left.equalTo(0)
make.top.equalTo(20)
make.bottom.equalTo(-20)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(iconImgView.snp.right).offset(12)
make.right.equalTo(-12)
make.right.equalTo(0)
make.top.equalTo(iconImgView)
make.height.equalTo(22)
}
tagContentView.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.right.equalTo(-12)
make.right.equalTo(0)
make.height.equalTo(16)
make.top.equalTo(titleLabel.snp.bottom).offset(4)
}
priceLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.right.equalTo(-12)
make.right.equalTo(0)
make.bottom.equalTo(iconImgView)
make.height.equalTo(20)
}
bottomLineView.snp.makeConstraints { make in
make.left.equalTo(iconImgView)
make.right.equalTo(-12)
make.right.equalTo(0)
make.height.equalTo(0.5)
make.bottom.equalTo(0)
}
......
......@@ -111,14 +111,12 @@ class YHProductListMessageCell: UITableViewCell {
@objc func didMoreButtonClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
if let configModel = YHConfigManager.shared.reqVM.configModel,configModel.is_integral_open {
YHAIJumpPageTool.jumpPageWithType(mode: listModel.redirectMode, path: listModel.redirectPath) {
dict in
}
}
}
required init?(coder: NSCoder) {
......
......@@ -85,24 +85,22 @@ class YHRecommendTextMessageCell: UITableViewCell {
whiteContentView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.lessThanOrEqualTo(-20)
make.top.equalTo(16)
make.top.equalTo(10)
make.bottom.equalTo(0)
}
messageLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(16)
make.bottom.equalTo(-16)
make.top.equalTo(10)
make.bottom.equalTo(-10)
}
}
@objc func didMessageClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
if message.getType() == .recommendText {
let text = message.getText()
messageClick?(text)
}
let text = message.getText()
messageClick?(text)
}
}
......@@ -8,14 +8,15 @@
import UIKit
import JXSegmentedView
import dsBridge
@preconcurrency import WebKit
//MARK: - 生命周期函数 及变量
class YHHomeHoldViewPageViewController: YHBaseViewController {
class YHHomeHoldViewPageViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
private var needShowManagerTipsView = false
private var didFirstLoadYhManager = false
var viewModel = YHHomePageViewModel()
var webview = DWKWebView()
var arrItemTitles: [String] = []
var arrItemVCs : [YHBaseViewController] = []
......@@ -69,6 +70,28 @@ class YHHomeHoldViewPageViewController: YHBaseViewController {
// getConfigData()
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
}
// MARK: - WKUIDelegate
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
// 实现非安全链接的跳转。如果目标主视图不为空,则允许导航
if !(navigationAction.targetFrame?.isMainFrame != nil) {
webview.load(navigationAction.request)
}
return nil
}
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
}
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
printLog("\(error.localizedDescription)")
}
func getConfigData() {
viewModel.getHomeInfo {[weak self] success, error in
guard let self = self else { return }
......@@ -445,9 +468,17 @@ extension YHHomeHoldViewPageViewController {
// }
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
webview = DWKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 0))
webview.navigationDelegate = self
let current = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/preload/preload"
if let url = URL(string: current) {
let request = URLRequest(url: url)
webview.load(request)
}
// 添加wkwebview
self.view.addSubview(webview)
}
// 跳转到资讯tab
@objc func didJumpToNewsTab() {
jumpToItemIndex(itemIndex: 3)
......
......@@ -338,7 +338,7 @@ class YHLookCollectionViewCell: UICollectionViewCell {
flagImageView = {
let view = LottieAnimationView(name: "live")
view.backgroundColor = UIColor.black
view.backgroundColor = UIColor.black.withAlphaComponent(0.6)
view.loopMode = .loop
return view
}()
......
//
// YHGCMineSchemeViewController.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCMineSchemeViewController: YHBaseViewController {
var tableView: UITableView!
var dataSource: [YHScemeItemModel]? = []
lazy var reqSchemeVM: YHMySchemeViewModel = {
let vm = YHMySchemeViewModel()
return vm
}()
lazy var headView: YHGCSchemeTableHeadView = {
let headView = YHGCSchemeTableHeadView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 422))
headView.update(type: .typeA, name: "--")
return headView
}()
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "我的方案"
gk_navTitleColor = .white
gk_navBarAlpha = 1
gk_navBackgroundImage = UIImage(named: "my_scheme_nav")
gk_backImage = UIImage(named: "nav_icon_back_white")
setView()
loadData()
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
extension YHGCMineSchemeViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataSource?.count ?? 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHSchemeTableViewCell.self)
cell.dataSource = dataSource?[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0 {
return 199
} else if indexPath.row == 1 {
return 251
} else if indexPath.row == 2 {
return 190
}
return 0
}
}
extension YHGCMineSchemeViewController {
func getData() {
let model1 = YHScemeItemModel(title: "行业定位", mainMessage: "根据您目前给来的材料,初步建议您申请的行业:--", lightMessage: "--", subMessage: "后续会根据您文书准备的补充情况来最终确定,如有修改会再告知您。")
let model2 = YHScemeItemModel(title: "资料清单", buttonTitle: "资料清单", mainMessage: "这是您的资料清单,请您前往查看。请您在1-2周内上传基础类证件哦,需要重新办理的可以晚些提供。需要注意的点如下:", lightMessage: "1-2周内", subMessage: "(1)港澳通如未办理,请尽快办理好反馈过来;\n(2)如为国内学校,需要尽快办理学位认证报告;\n(3)如为海外学校,需提供成绩单副本")
let model3 = YHScemeItemModel(title: "文书清单", buttonTitle: "文书写作", mainMessage: "这是您的文书清单,包括推荐信、赴港计划书,我写好后会发在微信里,与您一起沟通进行哈。3周-4周左右完成,需要咱们共同配合完成的噢", lightMessage: "3周-4周")
dataSource = [model1, model2, model3]
tableView.reloadData()
}
func updateDataSource() {
}
func setView() {
view.backgroundColor = .contentBkgColor
tableView = {
let tableView = UITableView(frame: .zero, style: .plain)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.tableFooterView = YHSchemeTableFooterView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 112))
tableView.tableHeaderView = headView
tableView.register(cellWithClass: YHSchemeTableViewCell.self)
tableView.bounces = false
return tableView
}()
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.bottom.equalToSuperview()
}
}
func loadData() {
if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") {
let param = ["order_id": orderID]
reqSchemeVM.getMySchemeData(params: param) { [weak self] success, error in
guard let self = self else {
return
}
if success == true {
guard let model = self.reqSchemeVM.schemeModel else { return }
let industry = model.industry.defaultStringIfEmpty()
let model1 = YHScemeItemModel(title: "行业定位", mainMessage: "根据您目前给来的材料,初步建议您申请的行业:" + industry, lightMessage: industry, subMessage: "后续会根据您文书准备的补充情况来最终确定,如有修改会再告知您。")
let model2 = YHScemeItemModel(title: "资料清单", buttonTitle: "资料清单", mainMessage: "这是您的资料清单,请您前往查看。请您在1-2周内上传基础类证件哦,需要重新办理的可以晚些提供。需要注意的点如下:", lightMessage: "1-2周内", subMessage: "(1)港澳通如未办理,请尽快办理好反馈过来;\n(2)如为国内学校,需要尽快办理学位认证报告;\n(3)如为海外学校,需提供成绩单副本")
let model3 = YHScemeItemModel(title: "文书清单", buttonTitle: "文书写作", mainMessage: "这是您的文书清单,包括推荐信、赴港计划书,我写好后会发在微信里,与您一起沟通进行哈。3周-4周左右完成,需要咱们共同配合完成的噢", lightMessage: "3周-4周")
self.dataSource = [model1, model2, model3]
self.tableView.reloadData()
let ageTxt = "年龄" + model.age_score.string + "分"
let eduTxtA = "学历" + model.education_score_a.string + "分,名校加分XX分"
let workExp = "工作经验加分" + model.work_experience_score.string + "分"
let famous_enterprise = "名企加分" + model.famous_enterprise.string + "分"
let talent_list = "人才清单加分" + model.talent_list.string + "分"
let language = "语言加分" + model.language_score.string + "分"
let family = "家庭背景加分" + model.background_score.string + "分"
let arrText: [String] = [ageTxt, eduTxtA, workExp, famous_enterprise, talent_list, language, family]
let arrH: [String] = [model.age_score.string, model.education_score_a.string, model.work_experience_score.string, model.famous_enterprise.string, model.talent_list.string, model.language_score.string, model.background_score.string]
self.headView.update(type: .typeA, name: model.username.defaultStringIfEmpty())
} else {
YHHUD.flash(message: error?.errorMsg ?? "请求出错")
}
}
} else {
printLog("error : orderID 为空")
}
}
}
//
// YHGCSchemeTableHeadView.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import AttributedString
import UIKit
class YHGCSchemeTableHeadView: UIView {
private lazy var centerImageView: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "gc_scheme_head_bg")
return view
}()
private lazy var centerView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var leftImageView: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "scheme_head_left")
return view
}()
private lazy var rightImageView: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "scheme_head_right")
return view
}()
private lazy var nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 24)
label.textColor = UIColor(hex: 0xFFFFFF)
label.textAlignment = .center
label.lineBreakMode = .byTruncatingMiddle
label.text = "尊敬的--"
return label
}()
private lazy var messageLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 14)
label.textColor = UIColor(hex: 0xFFFFFF)
label.textAlignment = .center
label.numberOfLines = 0
label.text = "您好,如电话沟通,这是我们为您定制的申请方案,方案详情如下:"
return label
}()
private lazy var logoImageView: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "scheme_head_logo")
return view
}()
private lazy var titleView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0xD48638)
return view
}()
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = UIColor.mainTextColor
label.text = "申请方案"
return label
}()
private lazy var subContainerView: YHBaseDynamicCornerRadiusView = {
let view = YHBaseDynamicCornerRadiusView(cornerRadius: 6, corner: .allCorners)
view.backgroundColor = UIColor(hex: 0xCF9764, alpha: 0.12)
return view
}()
private lazy var applicationTypeLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor.mainTextColor
label.text = "申请类型:"
return label
}()
private lazy var applicationTypeResultLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 24)
label.textColor = UIColor(hex: 0xD48638)
label.text = "--"
return label
}()
private lazy var dotView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hexString: "#F2DABF")
view.layer.cornerRadius = 1.0
view.clipsToBounds = true
return view
}()
private lazy var infoDetailLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor.mainTextColor
label.text = "--"
label.numberOfLines = 0
label.lineBreakMode = .byCharWrapping
return label
}()
private lazy var dashLineView: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "scheme_line_image")
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(hex: 0x070E33)
setUpView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func update(type: YHGCApplicationType, name: String) {
applicationTypeResultLabel.text = type.titleString
infoDetailLabel.attributed.text = type.attributedTips()
nameLabel.text = name
}
private func setUpView() {
addSubview(centerImageView)
addSubview(centerView)
addSubview(leftImageView)
addSubview(rightImageView)
addSubview(nameLabel)
addSubview(messageLabel)
addSubview(logoImageView)
addSubview(titleView)
addSubview(titleLabel)
addSubview(subContainerView)
subContainerView.addSubview(applicationTypeLabel)
subContainerView.addSubview(applicationTypeResultLabel)
addSubview(dotView)
addSubview(infoDetailLabel)
addSubview(dashLineView)
centerImageView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(416)
}
centerView.snp.makeConstraints { make in
make.left.equalTo(8)
make.right.equalTo(-8)
make.top.equalTo(416)
make.bottom.equalToSuperview()
}
leftImageView.snp.makeConstraints { make in
make.left.equalTo(35)
make.height.equalTo(80)
make.width.equalTo(65)
make.top.equalTo(27)
}
rightImageView.snp.makeConstraints { make in
make.right.equalTo(-35)
make.height.equalTo(80)
make.width.equalTo(65)
make.top.equalTo(27)
}
nameLabel.snp.makeConstraints { make in
make.right.equalTo(-75)
make.height.equalTo(33.5)
make.left.equalTo(75)
make.top.equalTo(26)
}
messageLabel.snp.makeConstraints { make in
make.right.equalTo(-75)
make.height.equalTo(43)
make.left.equalTo(75)
make.top.equalTo(65.5)
}
logoImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.height.equalTo(22)
make.width.equalTo(58.5)
make.top.equalTo(147)
}
titleView.snp.makeConstraints { make in
make.left.equalTo(28)
make.top.equalTo(238.5)
make.height.equalTo(16.5)
make.width.equalTo(3.5)
}
titleLabel.snp.makeConstraints { make in
make.centerY.equalTo(titleView.snp.centerY)
make.left.equalTo(titleView.snp.right).offset(4)
make.height.equalTo(24)
make.width.equalTo(150)
}
subContainerView.snp.makeConstraints { make in
make.left.equalTo(titleView.snp.left)
make.top.equalTo(titleLabel.snp.bottom).offset(18)
make.right.equalToSuperview().offset(-28)
make.height.equalTo(64)
}
applicationTypeLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.centerY.equalToSuperview()
}
applicationTypeResultLabel.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-16)
make.centerY.equalToSuperview()
make.left.greaterThanOrEqualTo(applicationTypeLabel.snp.right).offset(10)
}
infoDetailLabel.snp.makeConstraints { make in
make.left.equalTo(subContainerView.snp.left).offset(11)
make.top.equalTo(subContainerView.snp.bottom).offset(13)
make.right.lessThanOrEqualToSuperview().offset(-28)
}
dotView.snp.makeConstraints { make in
make.right.equalTo(infoDetailLabel.snp.left).offset(-4)
make.top.equalTo(infoDetailLabel.snp.top).offset(8)
make.width.height.equalTo(3)
}
dashLineView.snp.makeConstraints { make in
make.left.equalTo(subContainerView.snp.left)
make.right.equalTo(subContainerView.snp.right)
make.top.equalTo(infoDetailLabel.snp.bottom).offset(28)
make.height.equalTo(1)
}
}
}
private extension YHGCApplicationType {
func attributedTips() -> ASAttributedString {
switch self {
case .typeA:
let attr1: ASAttributedString = .init(string: "根据评估,您近12个月的税前收入超过", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
let attr2: ASAttributedString = .init(string: "250万港元", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor(hexString: "#D48638") ?? .brown))
let attr3: ASAttributedString = .init(string: ",符合", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
let attr4: ASAttributedString = .init(string: "高才A类", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor(hexString: "#D48638") ?? .brown))
let attr5: ASAttributedString = .init(string: "申请资格。", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
return attr1 + attr2 + attr3 + attr4 + attr5
case .typeB:
let attr1: ASAttributedString = .init(string: "根据评估,您已取得", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
let attr2: ASAttributedString = .init(string: "合资格高校学士学位", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor(hexString: "#D48638") ?? .brown))
let attr3: ASAttributedString = .init(string: ",符合", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
let attr4: ASAttributedString = .init(string: "高才B类", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor(hexString: "#D48638") ?? .brown))
let attr5: ASAttributedString = .init(string: "申请资格。", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
return attr1 + attr2 + attr3 + attr4 + attr5
case .typeC:
let attr1: ASAttributedString = .init(string: "根据评估,您已取得", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
let attr2: ASAttributedString = .init(string: "合资格高校学士学位", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor(hexString: "#D48638") ?? .brown))
let attr3: ASAttributedString = .init(string: ",符合", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
let attr4: ASAttributedString = .init(string: "高才C类", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor(hexString: "#D48638") ?? .brown))
let attr5: ASAttributedString = .init(string: "申请资格。", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor.mainTextColor))
return attr1 + attr2 + attr3 + attr4 + attr5
}
}
}
//
// YHGCApplicationTypeController.swift
// galaxy
//
// Created by alexzzw on 2024/11/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCApplicationTypeController: YHBaseViewController {
private lazy var datas: [[YHGCApplicationModel]] = {
let typeA = YHGCApplicationModel(type: .typeA, isSelected: false)
let typeB = YHGCApplicationModel(type: .typeB, isSelected: false)
let typeC = YHGCApplicationModel(type: .typeC, isSelected: false)
return [[typeA], [typeB], [typeC]]
}()
private lazy var headerView: UIView = {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 104))
let label = UILabel()
label.text = "您好,请选择申请类别"
label.textColor = .mainTextColor
label.font = .PFSC_M(ofSize: 21)
view.addSubview(label)
label.snp.makeConstraints { make in
make.top.equalToSuperview().offset(32)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-10)
}
return view
}()
private lazy var tableView: UITableView = {
let view = UITableView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight), style: .grouped)
view.estimatedSectionHeaderHeight = 0.01
view.estimatedSectionFooterHeight = 20
view.sectionHeaderHeight = 0.01
view.sectionFooterHeight = 20
view.contentInsetAdjustmentBehavior = .never
view.backgroundColor = .clear
view.separatorStyle = .none
view.rowHeight = UITableView.automaticDimension
view.estimatedRowHeight = 148.0
view.dataSource = self
view.delegate = self
view.showsVerticalScrollIndicator = false
view.register(YHGCApplicationTypeSelectCell.self, forCellReuseIdentifier: YHGCApplicationTypeSelectCell.cellReuseIdentifier)
return view
}()
private lazy var bgIcon: UIImageView = {
let view = UIImageView()
view.image = UIImage(named: "gc_application_type_bg")
return view
}()
private lazy var submitButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("提交", for: .normal)
button.setTitle("提交", for: .highlighted)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .highlighted)
button.addTarget(self, action: #selector(clickSubmitButton), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .brandMainColor
return button
}()
private lazy var bottomView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var viewModel = YHGCApplicationTypeViewModel()
private var didAppear: Bool = false
private let orderId: Int
init(orderId: Int) {
self.orderId = orderId
super.init(nibName: nil, bundle: nil)
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if !didAppear {
didAppear.toggle()
requestData(isNeedLoading: true)
} else {
requestData(isNeedLoading: false)
}
}
}
extension YHGCApplicationTypeController {
@objc private func clickSubmitButton() {
guard let model = datas.flatMap({ $0 }).first(where: { model in
model.isSelected == true
}) else {
YHHUD.flash(message: "请选择申请类别")
return
}
YHCommonAlertView.show("", "确定是否提交申请类别?提交后将不能修改", "取消", "确认", fullGuestureEnable: false) {
//
} callBack: { [weak self] in
guard let self = self else {
return
}
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.submitApplyType(orderId, model.type.rawValue) { [weak self] success, error in
guard let self = self else {
return
}
YHHUD.hide()
if success {
YHHUD.flash(message: "提交成功")
//self.requestData(isNeedLoading: false)
self.gotoResultPage(model)
} else {
var errorMsg = "提交失败"
if let error = error, error.errorMsg.count > 0 {
errorMsg = error.errorMsg
}
YHHUD.flash(message: errorMsg)
}
}
}
}
private func gotoResultPage(_ model: YHGCApplicationModel) {
if let navigationController = self.navigationController {
let ctl = YHGCApplicationTypeResultController(type: model.type)
var viewControllers = navigationController.viewControllers
viewControllers.removeLast()
viewControllers.append(ctl)
navigationController.setViewControllers(viewControllers, animated: true)
}
}
private func setupUI() {
gk_navTitle = "申请类别"
gk_navBarAlpha = 0
gk_navigationBar.backgroundColor = .clear
view.backgroundColor = UIColor.contentBkgColor
view.addSubview(bgIcon)
view.addSubview(tableView)
view.addSubview(bottomView)
bottomView.addSubview(submitButton)
let ratio = 318.0 / 375.0
bgIcon.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(bgIcon.snp.width).multipliedBy(ratio)
}
bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-66)
}
submitButton.snp.makeConstraints { make in
make.left.equalToSuperview().offset(kMargin)
make.right.equalToSuperview().offset(-kMargin)
make.top.equalToSuperview().offset(8)
make.height.equalTo(48)
}
tableView.snp.makeConstraints { make in
make.left.equalToSuperview()
make.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomView.snp.top)
}
tableView.tableHeaderView = headerView
}
private func requestData(isNeedLoading: Bool = false) {
if isNeedLoading {
YHHUD.show(.progress(message: "加载中..."))
}
viewModel.getApplyType(orderId: orderId) { [weak self] model, error in
guard let self = self else {
return
}
if isNeedLoading {
YHHUD.hide()
}
guard let model = model else {
printLog("YHGCApplicationTypeController: 请求失败")
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
}
return
}
self.datas.flatMap { $0 }.forEach {
if $0.type.rawValue == model.apply_type {
$0.isSelected = true
} else {
$0.isSelected = false
}
}
self.tableView.reloadData()
}
}
private func showPopVC(type: YHGCApplicationType) {
let vc = YHGCVisaProgramPopVC(type: type)
let pc = YHBottomPresentationController(presentedViewController: vc, presenting: self)
pc.customRadius = 8.0
vc.transitioningDelegate = pc
vc.sureButtonEvent = { [weak vc] in
vc?.dismiss(animated: true)
}
present(vc, animated: true, completion: nil)
}
}
extension YHGCApplicationTypeController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return datas.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard datas.count > section else {
return 0
}
return datas[section].count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard datas.count > indexPath.section else {
return UITableViewCell()
}
let sectionArr = datas[indexPath.section]
guard sectionArr.count > indexPath.row else {
return UITableViewCell()
}
let model = sectionArr[indexPath.row]
if let cell = tableView.dequeueReusableCell(withIdentifier: YHGCApplicationTypeSelectCell.cellReuseIdentifier) as? YHGCApplicationTypeSelectCell {
cell.setupCellInfo(type: model.type, isCurrentSelected: model.isSelected)
cell.actionBtnEvent = { [weak self] in
self?.showPopVC(type: model.type)
}
return cell
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 148.0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard datas.count > indexPath.section else {
return
}
let sectionArr = datas[indexPath.section]
guard sectionArr.count > indexPath.row else {
return
}
tableView.deselectRow(at: indexPath, animated: true)
let model = sectionArr[indexPath.row]
model.isSelected.toggle()
datas.flatMap { $0 }.forEach {
if $0.type != model.type, $0.isSelected {
$0.isSelected = false
}
}
tableView.reloadData()
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 0.01
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
return 20
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
return view
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView()
return view
}
}
//
// YHGCApplicationTypeResultController.swift
// galaxy
//
// Created by alexzzw on 2024/11/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCApplicationTypeResultController: YHBaseViewController {
private lazy var bgIcon: UIImageView = {
let view = UIImageView()
return view
}()
private lazy var backButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("返回", for: .normal)
button.setTitle("返回", for: .highlighted)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .highlighted)
button.addTarget(self, action: #selector(clickBackButton), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .brandMainColor
return button
}()
private lazy var headerLabel: UILabel = {
let label = UILabel()
label.textColor = .mainTextColor
label.font = .PFSC_M(ofSize: 21)
label.text = "您已选定高才申请类型"
return label
}()
private lazy var infoTitleLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_B(ofSize: 17)
label.textColor = .mainTextColor
return label
}()
private lazy var infoDetailLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hexString: "#6D788A")
label.font = .PFSC_R(ofSize: 13)
label.lineBreakMode = .byCharWrapping
label.numberOfLines = 3
return label
}()
private lazy var barView: UIView = {
let view = UIView()
return view
}()
private lazy var actionBtn: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("申请标准", for: .normal)
button.setTitleColor(.mainTextColor, for: .normal)
button.titleLabel?.font = .PFSC_R(ofSize: 14)
button.setImage(UIImage(named: "right_arrow_black_20"), for: .normal)
button.addTarget(self, action: #selector(actionBtnClicked), for: .touchUpInside)
return button
}()
private lazy var subContainerView: YHBaseDynamicCornerRadiusView = {
let view = YHBaseDynamicCornerRadiusView(cornerRadius: 6, corner: .allCorners)
view.backgroundColor = .white
return view
}()
private lazy var bottomView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
var backButtonEvent: (() -> Void)?
private let type: YHGCApplicationType
init(type: YHGCApplicationType) {
self.type = type
super.init(nibName: nil, bundle: nil)
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
}
extension YHGCApplicationTypeResultController {
@objc private func actionBtnClicked() {
showPopVC(type: type)
}
@objc private func clickBackButton() {
backButtonEvent?()
navigationController?.popViewController(animated: true)
}
private func setupUI() {
gk_navTitle = "申请类别"
gk_navBarAlpha = 0
gk_navigationBar.backgroundColor = .clear
view.backgroundColor = UIColor.contentBkgColor
view.addSubview(bgIcon)
view.addSubview(headerLabel)
view.addSubview(bottomView)
bottomView.addSubview(backButton)
view.addSubview(subContainerView)
subContainerView.addSubview(barView)
subContainerView.addSubview(infoTitleLabel)
subContainerView.addSubview(infoDetailLabel)
subContainerView.addSubview(actionBtn)
let ratio = 318.0 / 375.0
bgIcon.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(bgIcon.snp.width).multipliedBy(ratio)
}
headerLabel.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 42)
make.left.equalToSuperview().offset(20)
make.right.lessThanOrEqualToSuperview().offset(-20)
}
subContainerView.snp.makeConstraints { make in
make.top.equalTo(headerLabel.snp.bottom).offset(50)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(148)
}
barView.snp.makeConstraints { make in
make.left.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(3)
make.height.equalTo(108)
}
infoTitleLabel.snp.makeConstraints { make in
make.left.equalTo(barView.snp.right).offset(20)
make.top.equalTo(barView.snp.top)
make.right.lessThanOrEqualToSuperview().offset(-20)
}
infoDetailLabel.snp.makeConstraints { make in
make.left.equalTo(infoTitleLabel.snp.left)
make.top.equalTo(infoTitleLabel.snp.bottom).offset(8)
make.right.lessThanOrEqualToSuperview().offset(-20)
}
actionBtn.snp.makeConstraints { make in
make.left.equalTo(infoTitleLabel.snp.left)
make.top.greaterThanOrEqualTo(infoDetailLabel.snp.bottom).offset(0).priority(.high)
make.bottom.equalTo(barView.snp.bottom)
}
actionBtn.iconInRight(with: 0)
bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-66)
}
backButton.snp.makeConstraints { make in
make.left.equalToSuperview().offset(kMargin)
make.right.equalToSuperview().offset(-kMargin)
make.top.equalToSuperview().offset(8)
make.height.equalTo(48)
}
bgIcon.image = UIImage(named: type.bgIconTitle())
infoTitleLabel.text = type.titleString
infoDetailLabel.text = type.detailString
barView.backgroundColor = type.barColor()
}
private func showPopVC(type: YHGCApplicationType) {
let vc = YHGCVisaProgramPopVC(type: type)
let pc = YHBottomPresentationController(presentedViewController: vc, presenting: self)
pc.customRadius = 8.0
vc.transitioningDelegate = pc
vc.sureButtonEvent = { [weak vc] in
vc?.dismiss(animated: true)
}
present(vc, animated: true, completion: nil)
}
}
private extension YHGCApplicationType {
func bgIconTitle() -> String {
switch self {
case .typeA:
return "gc_application_type_bg_a"
case .typeB:
return "gc_application_type_bg_b"
case .typeC:
return "gc_application_type_bg_c"
}
}
func barColor() -> UIColor? {
switch self {
case .typeA:
return UIColor(hexString: "#EEDBBD")
case .typeB:
return UIColor(hexString: "#BFCDEF")
case .typeC:
return UIColor(hexString: "#BBE1F2")
}
}
}
//
// YHGCVisaProgramPopVC.swift
// galaxy
//
// Created by alexzzw on 2024/11/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
class YHGCVisaProgramPopVC: YHBaseViewController {
private lazy var topProgramIcon: UIImageView = {
let view = UIImageView()
return view
}()
private lazy var sureButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("我已知悉,确认", for: .normal)
button.setTitle("我已知悉,确认", for: .highlighted)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .highlighted)
button.addTarget(self, action: #selector(clickSureButton), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .brandMainColor
return button
}()
private lazy var infoDetailLabel: UILabel = {
let label = UILabel()
label.textColor = .mainTextColor
label.font = .PFSC_R(ofSize: 14)
label.lineBreakMode = .byCharWrapping
label.numberOfLines = 0
return label
}()
private lazy var subContainerView: YHBaseDynamicCornerRadiusView = {
let view = YHBaseDynamicCornerRadiusView(cornerRadius: 6, corner: .allCorners)
view.backgroundColor = .contentBkgColor
return view
}()
private lazy var infoMarkLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hexString: "#6D788A")
label.font = .PFSC_R(ofSize: 14)
label.lineBreakMode = .byCharWrapping
label.numberOfLines = 0
return label
}()
var sureButtonEvent: (() -> Void)?
private let type: YHGCApplicationType
init(type: YHGCApplicationType) {
self.type = type
super.init(nibName: nil, bundle: nil)
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
}
extension YHGCVisaProgramPopVC {
@objc private func clickSureButton() {
sureButtonEvent?()
}
private func setupUI() {
gk_navBarAlpha = 0
gk_navigationBar.isHidden = true
view.backgroundColor = UIColor.white
view.addSubview(topProgramIcon)
view.addSubview(sureButton)
view.addSubview(infoDetailLabel)
view.addSubview(subContainerView)
subContainerView.addSubview(infoMarkLabel)
let ratio = 143.0 / 375.0
topProgramIcon.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(topProgramIcon.snp.width).multipliedBy(ratio)
}
let widthRatio = KScreenWidth / 375.0
infoDetailLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(124.0 * widthRatio)
make.left.equalToSuperview().offset(20 * widthRatio)
make.right.equalToSuperview().offset(-20 * widthRatio)
}
subContainerView.snp.makeConstraints { make in
make.top.equalTo(infoDetailLabel.snp.bottom).offset(20.0 * widthRatio)
make.left.equalToSuperview().offset(20 * widthRatio)
make.right.equalToSuperview().offset(-20 * widthRatio)
}
infoMarkLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16.0 * widthRatio)
make.left.equalToSuperview().offset(16 * widthRatio)
make.right.equalToSuperview().offset(-16 * widthRatio)
make.bottom.equalToSuperview().offset(-16.0 * widthRatio)
}
sureButton.snp.makeConstraints { make in
make.top.greaterThanOrEqualTo(subContainerView.snp.bottom).offset(10)
make.left.equalToSuperview().offset(kMargin * widthRatio)
make.right.equalToSuperview().offset(-kMargin * widthRatio)
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-10 * widthRatio)
make.height.equalTo(48)
}
topProgramIcon.image = UIImage(named: type.programIconTitle())
infoDetailLabel.text = type.detailText()
infoMarkLabel.attributed.text = type.attributedTips()
preferredContentSize = CGSize(width: KScreenWidth, height: 452 * widthRatio)
}
}
private extension YHGCApplicationType {
func programIconTitle() -> String {
switch self {
case .typeA:
return "gc_visa_program_a"
case .typeB:
return "gc_visa_program_b"
case .typeC:
return "gc_visa_program_c"
}
}
func detailText() -> String {
switch self {
case .typeA:
return "在紧接申请前一年,全年收入达港币250万元或以上(或等值外币) 的人士"
case .typeB:
return "4个指定榜单中的世界百强大学的学士学位毕业生(以入境处内置榜单为准),且过去5年累积有不低于3年的工作经验"
case .typeC:
return "过去5年在4个指定榜单中的世界百强大学取得学士学位(以入境处内置榜单为准),但累积工作经验不足3年"
}
}
func attributedTips() -> ASAttributedString {
switch self {
case .typeA:
let attr1: ASAttributedString = .init(string: "注:必须是", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor(hexString: "#6D788A") ?? UIColor.gray))
let attr2: ASAttributedString = .init(string: "课税收入", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor.brandMainColor))
let attr3: ASAttributedString = .init(string: ",享受税收优惠、免税的收入,不计算在内", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor(hexString: "#6D788A") ?? UIColor.gray))
return attr1 + attr2 + attr3
case .typeB:
let attr1: ASAttributedString = .init(string: "注:必须是", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor(hexString: "#6D788A") ?? UIColor.gray))
let attr2: ASAttributedString = .init(string: "紧接申请", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor.brandMainColor))
let attr3: ASAttributedString = .init(string: "的前五年,累积工作经验不低于三年", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor(hexString: "#6D788A") ?? UIColor.gray))
return attr1 + attr2 + attr3
case .typeC:
let attr1: ASAttributedString = .init(string: "注:", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor(hexString: "#6D788A") ?? UIColor.gray))
let attr2: ASAttributedString = .init(string: "不适用于", .font(UIFont.PFSC_B(ofSize: 14)), .foreground(UIColor.brandMainColor))
let attr3: ASAttributedString = .init(string: "在港修读全日制经本地评审课程而获得学士学位的非本地生", .font(UIFont.PFSC_R(ofSize: 14)), .foreground(UIColor(hexString: "#6D788A") ?? UIColor.gray))
return attr1 + attr2 + attr3
}
}
}
//
// YHGCApplicationModel.swift
// galaxy
//
// Created by alexzzw on 2024/11/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
class YHGCApplicationModel {
var type: YHGCApplicationType = .typeA
var isSelected: Bool = false
init(type: YHGCApplicationType, isSelected: Bool) {
self.type = type
self.isSelected = isSelected
}
}
//
// YHGCApplicationType.swift
// galaxy
//
// Created by alexzzw on 2024/11/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
enum YHGCApplicationType: Int {
case typeA = 1
case typeB = 2
case typeC = 3
var titleString: String {
switch self {
case .typeA:
return "高才A类申请"
case .typeB:
return "高才B类申请"
case .typeC:
return "高才C类申请"
}
}
var detailString: String {
switch self {
case .typeA:
return "近一年度纳税收入250万港元及以上人士"
case .typeB:
return "百强大学毕业,且近5年累积工作经验时长不低于3年人士"
case .typeC:
return "百强大学毕业不足5年,且工作经验时长不足3年人士"
}
}
}
//
// YHGCApplicationTypeResponseModel.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHGCApplicationTypeResponseModel: SmartCodable {
var apply_type: Int = -1
required init() {
}
}
//
// YHGCApplicationTypeSelectCell.swift
// galaxy
//
// Created by alexzzw on 2024/11/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCApplicationTypeSelectCell: UITableViewCell {
static let cellReuseIdentifier = "YHGCApplicationTypeSelectCell"
private let selectedBorderColor: UIColor = .brandMainColor
var actionBtnEvent: (() -> Void)?
var isCurrentSelected: Bool = false {
didSet {
guard isCurrentSelected != oldValue else {
return
}
selectIconView.image = isCurrentSelected ? UIImage(named: "gc_application_type_selected"): UIImage(named: "gc_application_type_unselected")
subContainerView.lineWidth = isCurrentSelected ? 1 : nil
subContainerView.lineColor = isCurrentSelected ? selectedBorderColor.cgColor : nil
}
}
private lazy var subContainerView: YHBaseCornerRadiusBorderView = {
let view = YHBaseCornerRadiusBorderView(cornerRadius: 6, corner: .allCorners, lineWidth: nil, lineColor: nil)
view.backgroundColor = .white
return view
}()
private lazy var infoTitleLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_B(ofSize: 17)
label.textColor = .mainTextColor
return label
}()
private lazy var infoDetailLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hexString: "#6D788A")
label.font = .PFSC_R(ofSize: 13)
label.lineBreakMode = .byCharWrapping
label.numberOfLines = 3
return label
}()
private lazy var iconView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private lazy var selectIconView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "gc_application_type_unselected")
return imageView
}()
private lazy var actionBtn: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("申请标准", for: .normal)
button.setTitleColor(.mainTextColor, for: .normal)
button.titleLabel?.font = .PFSC_R(ofSize: 14)
button.setImage(UIImage(named: "right_arrow_black_20"), for: .normal)
button.addTarget(self, action: #selector(actionBtnClicked), for: .touchUpInside)
return button
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(type: YHGCApplicationType, isCurrentSelected: Bool) {
infoTitleLabel.text = type.titleString
infoDetailLabel.text = type.detailString
iconView.image = UIImage(named: type.iconString())
self.isCurrentSelected = isCurrentSelected
}
}
extension YHGCApplicationTypeSelectCell {
@objc private func actionBtnClicked() {
actionBtnEvent?()
}
private func setupUI() {
selectionStyle = .none
backgroundColor = .clear
contentView.addSubview(subContainerView)
subContainerView.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
}
subContainerView.addSubview(iconView)
subContainerView.addSubview(infoTitleLabel)
subContainerView.addSubview(selectIconView)
subContainerView.addSubview(infoDetailLabel)
subContainerView.addSubview(actionBtn)
iconView.setContentCompressionResistancePriority(.required, for: .horizontal)
infoTitleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
selectIconView.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
infoDetailLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
actionBtn.setContentCompressionResistancePriority(.required, for: .vertical)
infoDetailLabel.setContentCompressionResistancePriority(.defaultLow, for: .vertical)
iconView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.left.equalToSuperview().offset(20)
make.width.equalTo(88)
make.height.equalTo(108).priority(.high)
make.bottom.lessThanOrEqualToSuperview().offset(-20)
}
infoTitleLabel.snp.makeConstraints { make in
make.left.equalTo(iconView.snp.right).offset(20)
make.top.equalTo(iconView.snp.top)
}
selectIconView.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-20)
make.top.equalTo(iconView.snp.top)
make.left.greaterThanOrEqualTo(infoTitleLabel.snp.right).offset(20)
}
infoDetailLabel.snp.makeConstraints { make in
make.left.equalTo(infoTitleLabel.snp.left)
make.top.equalTo(infoTitleLabel.snp.bottom).offset(8)
make.right.lessThanOrEqualToSuperview().offset(-20)
}
actionBtn.snp.makeConstraints { make in
make.left.equalTo(infoTitleLabel.snp.left)
make.top.greaterThanOrEqualTo(infoDetailLabel.snp.bottom).offset(0).priority(.high)
make.bottom.equalTo(iconView.snp.bottom)
}
actionBtn.iconInRight(with: 0)
}
}
private extension YHGCApplicationType {
func iconString() -> String {
switch self {
case .typeA:
return "gc_application_type_a"
case .typeB:
return "gc_application_type_b"
case .typeC:
return "gc_application_type_c"
}
}
}
//
// YHGCApplicationTypeViewModel.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCApplicationTypeViewModel: YHBaseViewModel {
func getApplyType(orderId: Int, callback: @escaping (_ model: YHGCApplicationTypeResponseModel?, _ error: YHErrorModel?) -> ()) {
let params = ["order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.GCApplyType.getApplyType
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { json, code in
//1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let resultModel = YHGCApplicationTypeResponseModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callback(nil, err)
return
}
callback(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(nil, err)
}
} failBlock: { err in
callback(nil, err)
}
}
func submitApplyType(_ orderId: Int, _ applyType: Int, callBackBlock: @escaping (_ success: Bool, _ error:YHErrorModel?) -> () ) {
let params: [String : Any] = ["order_id": orderId, "apply_type": applyType]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.GCApplyType.submitApplyType
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { json, code in
//1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
callBackBlock(true, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(false, err)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
//
// YHGCBasicInfoFillViewController.swift
// galaxy
//
// Created by alexzzw on 2024/11/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCBasicInfoFillViewController: YHBaseViewController {
var orderId: Int?
private let basicInfoVM: YHBasicInfoFillViewModel = YHBasicInfoFillViewModel()
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.register(YHBasicInfoFillCell.self, forCellReuseIdentifier: YHBasicInfoFillCell.cellReuseIdentifier)
return tableView
}()
override func viewDidLoad() {
super.viewDidLoad()
// 1.0
initView()
// 2.0
loadData()
}
}
// MARK: - private methods
extension YHGCBasicInfoFillViewController {
private func initView() {
gk_backStyle = .black
gk_navTitle = "基本资料信息填写"
gk_navBackgroundColor = .white
gk_navBarAlpha = 1
let bottomView = YHBasicInfoFillBottomView()
view.addSubview(bottomView)
bottomView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(YHBasicInfoFillBottomView.viewH)
}
bottomView.block = { tag in
if tag == 0 {
// 点击了保存按钮
printLog("点击了保存按钮")
self.saveData()
} else {
// 点击了提交按钮
printLog("点击了提交按钮")
self.submitData()
}
}
homeTableView.delegate = self
homeTableView.dataSource = self
view.addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomView.snp.top)
make.left.equalTo(kMargin)
make.right.equalTo(-kMargin)
}
}
private func loadData() {
guard let orderId = orderId else { return }
let param = ["order_id": orderId]
basicInfoVM.getBasicInfo(params: param) { success, error in
if success == true {
self.homeTableView.reloadData()
} else {
YHHUD.flash(message: error?.errorMsg ?? "发生错误,请重试")
self.navigationController?.popViewController(animated: true)
}
self.homeTableView.reloadData()
}
}
private func saveData() {
// 保存
submitAndSaveDataOp(isSaveFlag: true)
}
private func submitData() {
// 提交
// 1.校验
if dataIsOK() == true {
// 提交数据
submitAndSaveDataOp(isSaveFlag: false)
} else {
homeTableView.reloadData()
YHHUD.flash(message: "您还有信息未填写")
}
}
// 检查数据是否合法
private func dataIsOK() -> Bool {
var returnValue: Bool = true
let arr = basicInfoVM.arrBasicInfoSessionDataForEdit
for item in arr {
for (_, item0) in item.arrQuestionItem.enumerated() {
if (item0.answer == "Y" && item0.info.count < 1) || item0.answer == "" {
item0.needCheckFlag = true
returnValue = returnValue && false
}
}
}
return returnValue
}
private func submitAndSaveDataOp(isSaveFlag: Bool) {
// 保存
let arr = basicInfoVM.arrBasicInfoSessionDataForEdit
var param: [String: Any] = ["order_id": orderId as Any, "save_type": isSaveFlag ? "save" : "submit"]
for item in arr {
if item.sessionTitle == "主申请人" {
var applicant: [String: Any] = [:]
for (index0, item0) in item.arrQuestionItem.enumerated() {
if index0 == 0 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "has_conviction")
} else if index0 == 1 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "has_departure")
} else if index0 == 2 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "has_deny")
} else if index0 == 3 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "has_breaking_law")
} else if index0 == 4 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "has_other_id")
} else {
printLog("其他数据没有处理")
}
}
applicant.updateValue(basicInfoVM.dataModelForBasicInfo?.applicant?.id ?? 0, forKey: "id")
param.updateValue(applicant, forKey: "applicant")
} else if item.sessionTitle == "配偶" {
var applicant: [String: Any] = [:]
for (index0, item0) in item.arrQuestionItem.enumerated() {
if index0 == 0 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "child_departure")
} else if index0 == 1 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "child_deny")
} else {
printLog("其他数据没有处理")
}
}
applicant.updateValue(basicInfoVM.dataModelForBasicInfo?.spouse?.id ?? 0, forKey: "id")
applicant.updateValue(basicInfoVM.dataModelForBasicInfo?.spouse?.subset_name ?? 0, forKey: "subset_name")
param.updateValue(applicant, forKey: "spouse")
} else if item.sessionTitle.hasPrefix("子女") {
var arr: [[String: Any]] = []
if let tArr = param["child"] as? [[String: Any]] {
arr = tArr
}
var applicant: [String: Any] = [:]
for (index0, item0) in item.arrQuestionItem.enumerated() {
if index0 == 0 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "child_departure")
} else if index0 == 1 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "child_deny")
} else {
printLog("其他数据没有处理")
}
}
applicant.updateValue(item.model?.id ?? 0, forKey: "id")
applicant.updateValue(item.model?.subset_name ?? "", forKey: "subset_name")
arr.append(applicant)
param.updateValue(arr, forKey: "child")
} else if item.sessionTitle == "家庭背景" {
var applicant: [String: Any] = [:]
for (index0, item0) in item.arrQuestionItem.enumerated() {
if index0 == 0 {
let value = ["has": item0.answer, "info": item0.answer == "Y" ? item0.info : ""]
applicant.updateValue(value, forKey: "background_member")
} else {
printLog("其他数据没有处理")
}
}
param.updateValue(applicant, forKey: "background")
} else {
}
}
printLog(param)
basicInfoVM.saveBasicInfo(params: param) { [weak self] success, error in
if success == true {
let title = isSaveFlag ? "保存成功" : "提交成功"
YHHUD.flash(message: title)
if isSaveFlag == false {
self?.navigationController?.popViewController(animated: true)
}
} else {
let title = isSaveFlag ? "保存失败" : "提交失败"
let msg = error?.errorMsg ?? title
YHHUD.flash(message: msg)
}
}
}
}
// MARK: - delegates
// MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHGCBasicInfoFillViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return basicInfoVM.arrBasicInfoSessionDataForEdit.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 15
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 15))
view.backgroundColor = .clear
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, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHBasicInfoFillCell.self)
cell.dataModel = basicInfoVM.arrBasicInfoSessionDataForEdit[indexPath.section]
cell.indexPath = indexPath
cell.block = { indexPath in
if let indexPath = indexPath {
tableView.reloadRows(at: [indexPath], with: .none)
}
}
return cell
}
}
......@@ -18,6 +18,32 @@ class YHJsApi: NSObject {
}
extension YHJsApi {
// 返回tab服务页
@objc func goAppTab(_ tag : Any) {
DispatchQueue.main.async {
if let tag = tag as? String {
UIViewController.current?.navigationController?.popToRootViewController(animated: false)
if tag == "home" {
goTabBarBy(tabType: .home)
} else if tag == "server" {
goTabBarBy(tabType: .service)
} else if tag == "ai" {
goTabBarBy(tabType: .AI)
} else if tag == "friend" {
goTabBarBy(tabType: .community)
} else if tag == "mine" {
goTabBarBy(tabType: .mine)
}
}
}
}
//禁用全局手势返回
@objc func disableFullScreenGestureSyn(_ tag : Any) {
DispatchQueue.main.async {
......@@ -35,6 +61,7 @@ extension YHJsApi {
}
}
// 关闭优才测评
@objc func closeEvaluationGetResult(_ dicData: String) {
DispatchQueue.main.async {
if let data = dicData.data(using: .utf8) {
......
......@@ -37,16 +37,10 @@ class YHBasePlayerViewController: YHBaseViewController {
return view
}()
// 控制状态
private var isControlsVisible = true
private var controlsAutoHideTimer: Timer?
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
//setupGestures()
//setupNotifications()
}
override func viewWillAppear(_ animated: Bool) {
......@@ -62,8 +56,6 @@ class YHBasePlayerViewController: YHBaseViewController {
gk_navBarAlpha = 1
gk_navigationBar.isHidden = false
view.backgroundColor = .black
// controlsAutoHideTimer?.invalidate()
// controlsAutoHideTimer = nil
UIApplication.shared.isIdleTimerDisabled = false
}
......@@ -96,111 +88,6 @@ class YHBasePlayerViewController: YHBaseViewController {
make.height.equalTo(k_Height_NavigationtBarAndStatuBar)
}
}
// private func setupGestures() {
// let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
// containerView.addGestureRecognizer(tap)
// }
//
// // MARK: - Controls Visibility
// @objc private func handleTap() {
// toggleControls()
// }
//
// private func toggleControls() {
// isControlsVisible.toggle()
// //controlView.showControls(isControlsVisible)
// resetControlsAutoHideTimer()
// }
//
// private func resetControlsAutoHideTimer() {
// controlsAutoHideTimer?.invalidate()
// if isControlsVisible {
// controlsAutoHideTimer = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false) { [weak self] _ in
// self?.hideControls()
// }
// }
// }
//
// private func hideControls() {
// isControlsVisible = false
// //controlView.showControls(false)
// }
}
// MARK: - Notifications
extension YHBasePlayerViewController {
private func setupNotifications() {
NotificationCenter.default.addObserver(
self,
selector: #selector(handleAppDidEnterBackground),
name: UIApplication.didEnterBackgroundNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(handleAppWillEnterForeground),
name: UIApplication.willEnterForegroundNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(handleAudioSessionInterruption),
name: AVAudioSession.interruptionNotification,
object: nil
)
}
@objc private func handleAppDidEnterBackground() {
YHPlayerManager.shared.pause()
}
@objc private func handleAppWillEnterForeground() {
YHPlayerManager.shared.resume()
}
@objc private func handleAudioSessionInterruption(_ notification: Notification) {
guard let userInfo = notification.userInfo,
let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt,
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else {
return
}
switch type {
case .began:
YHPlayerManager.shared.pause()
case .ended:
if let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt {
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue)
if options.contains(.shouldResume) {
YHPlayerManager.shared.resume()
}
}
@unknown default:
break
}
}
}
// MARK: - Helper Methods
extension YHBasePlayerViewController {
func formatTime(_ timeInMilliseconds: Int) -> String {
let totalSeconds = timeInMilliseconds / 1000
let minutes = totalSeconds / 60
let seconds = totalSeconds % 60
return String(format: "%02d:%02d", minutes, seconds)
}
func showAlert(message: String) {
let alert = UIAlertController(title: "提示",
message: message,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "确定", style: .default))
present(alert, animated: true)
}
}
// MARK: - Orientation Support
......
......@@ -8,6 +8,7 @@
import AgoraRtcKit
import HyphenateChat
//import AVKit
import UIKit
class YHLivePlayerViewController: YHBasePlayerViewController {
......@@ -59,7 +60,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
}
vc.closeEvent = { [weak self] in
self?.leaveLiveRoom()
//self?.leaveLiveRoom()
self?.closeLive()
}
......@@ -86,12 +87,6 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
let imageView = UIImageView(image: UIImage(named: "live_player_bg"))
return imageView
}()
// private lazy var blurredView: YHBlurredAvatarView = {
// let view = YHBlurredAvatarView()
// view.isHidden = true
// return view
// }()
// MARK: - Initialization
......@@ -123,6 +118,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
joinLiveRoom(id: liveId, callback: { _, _ in })
}
setupTimer()
setupLifeCycleNotifications()
}
override func viewWillAppear(_ animated: Bool) {
......@@ -275,9 +271,14 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
playbackInfo?.title = liveDetail.live_title
playbackInfo?.uid = UInt(liveDetail.user_id)
messageListView.anchorName = liveDetail.hxNickname
let isOnLive = liveDetail.getLiveState() == .onLive || liveDetail.getLiveState() == .stop
if needJoinLiveChannel {
if !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player, !player.isJoined {
if !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player, isOnLive {
YHPlayerManager.shared.joinChannel(for: player, token: liveDetail.token, channelId: liveDetail.rtmp_channel, uid: uid, view: playerView, defaultMuted: false)
} else if !isOnLive {
if let player = player {
YHPlayerManager.shared.leaveChannel(for: player)
}
}
}
// 如果没有预设roomId,使用接口返回的roomId
......@@ -601,21 +602,20 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
case .liveStart:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .liveEnd:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .livePause:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
case .liveResume:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .liveGoodsRefresh:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.goodsListView?.dataSource = liveDetail.goods
}
} else {
printLog("YHLivePlayerViewController: 请求失败")
if let errorMsg = error?.errorMsg, !errorMsg.isEmpty {
YHHUD.flash(message: errorMsg)
}
return
// if let errorMsg = error?.errorMsg, !errorMsg.isEmpty {
// YHHUD.flash(message: errorMsg)
// }
}
}
}
......@@ -691,7 +691,8 @@ extension YHLivePlayerViewController: YHPlayerDelegate {
// 直播开始时的特殊处理
break
case .failed:
self.showAlert(message: "播放失败,错误原因:\(reason.rawValue)")
break
//self.showAlert(message: "播放失败,错误原因:\(reason.rawValue)")
default:
break
}
......@@ -713,3 +714,67 @@ extension YHLivePlayerViewController: YHPlayerDelegate {
#endif
}
}
// MARK: - Notifications
extension YHLivePlayerViewController {
private func setupLifeCycleNotifications() {
NotificationCenter.default.addObserver(
self,
selector: #selector(handleAppDidEnterBackground),
name: UIApplication.didEnterBackgroundNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(handleAppWillEnterForeground),
name: UIApplication.willEnterForegroundNotification,
object: nil
)
/*
NotificationCenter.default.addObserver(
self,
selector: #selector(handleAudioSessionInterruption),
name: AVAudioSession.interruptionNotification,
object: nil
)
*/
}
@objc private func handleAppDidEnterBackground() {
leaveLiveRoom()
}
@objc private func handleAppWillEnterForeground() {
if YHLoginManager.shared.isLogin() {
joinLiveRoom(id: liveId, callback: { _, _ in })
}
}
/*
@objc private func handleAudioSessionInterruption(_ notification: Notification) {
guard let userInfo = notification.userInfo,
let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt,
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else {
return
}
switch type {
case .began:
if let player = player {
YHPlayerManager.shared.leaveChannel(for: player)
}
case .ended:
if let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt {
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue)
if options.contains(.shouldResume) {
if let liveDetail = viewModel.liveDetailModel, !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player {
YHPlayerManager.shared.joinChannel(for: player, token: liveDetail.token, channelId: liveDetail.rtmp_channel, uid: uid, view: playerView, defaultMuted: false)
}
}
}
@unknown default:
break
}
}
*/
}
......@@ -9,6 +9,7 @@
import UIKit
enum YHLiveState: Int {
case unknown = -1
case start = 0
case stop = 1
case end = 2
......@@ -122,7 +123,7 @@ class YHLiveStateViewController: YHBaseViewController {
view.addSubview(logImageView)
logImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(196)
make.top.equalTo(240)
make.width.height.equalTo(78)
}
......@@ -229,7 +230,7 @@ class YHLiveStateViewController: YHBaseViewController {
loginSubTitleLabel.text = "直播已结束"
messageLabel.text = "直播已结束,去首页逛逛吧~"
getCodeButton.isHidden = false
case .onLive:
case .onLive, .unknown:
break
}
}
......
......@@ -48,7 +48,7 @@ class YHLiveDetailModel: SmartCodable {
func getLiveState() -> YHLiveState {
switch status {
case 0:
return .onLive
return .unknown
case 1:
if stream_status == 3 {
return .stop
......@@ -59,7 +59,7 @@ class YHLiveDetailModel: SmartCodable {
case 3:
return .end
default:
return .onLive
return .unknown
}
}
......
//
// YHFadeView.swift
// galaxy
//
// Created by alexzzw on 2024/11/26.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFadeView: UIView {
private let maskLayer = CAGradientLayer()
override init(frame: CGRect) {
super.init(frame: frame)
setupMask()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupMask()
}
private func setupMask() {
// 使用黑色渐变作为mask
maskLayer.colors = [
UIColor.black.cgColor,
UIColor.clear.cgColor,
]
maskLayer.startPoint = CGPoint(x: 0, y: 0)
maskLayer.endPoint = CGPoint(x: 0, y: 1)
// 重要:将渐变层设置为mask
layer.mask = maskLayer
}
override func layoutSubviews() {
super.layoutSubviews()
// 确保mask大小与视图相同
maskLayer.frame = bounds
}
}
......@@ -15,13 +15,6 @@ class YHLiveMessageListView: UIView {
// MARK: - UI Components
private lazy var topFadeView: YHFadeView = {
let view = YHFadeView()
view.isHidden = true
view.backgroundColor = .clear.withAlphaComponent(0.1)
return view
}()
private lazy var tableView: UITableView = {
let view = UITableView()
view.backgroundColor = .clear
......@@ -49,12 +42,6 @@ class YHLiveMessageListView: UIView {
private func setupUI() {
backgroundColor = .clear
addSubview(tableView)
addSubview(topFadeView)
bringSubviewToFront(topFadeView)
topFadeView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(26)
}
tableView.snp.makeConstraints { make in
make.top.equalToSuperview()
......@@ -81,6 +68,27 @@ class YHLiveMessageListView: UIView {
// MARK: - UITableViewDelegate & UITableViewDataSource
extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let fadeRange: CGFloat = 50
tableView.visibleCells.forEach { cell in
guard let indexPath = tableView.indexPath(for: cell) else { return }
let cellRect = tableView.rectForRow(at: indexPath)
// 因为视图是倒置的,所以我们需要用 tableView 的高度来计算正确的位置
let cellPositionFromBottom = tableView.bounds.height - (cellRect.origin.y - scrollView.contentOffset.y) - cellRect.height
if cellPositionFromBottom >= 0 && cellPositionFromBottom <= fadeRange {
let progress = cellPositionFromBottom / fadeRange
cell.alpha = progress
} else if cellPositionFromBottom > fadeRange {
cell.alpha = 1.0
} else {
cell.alpha = 0.0
}
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
......
......@@ -39,7 +39,6 @@ class YHLiveShopView: UIView {
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)
......@@ -51,7 +50,6 @@ class YHLiveShopView: UIView {
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
......@@ -61,7 +59,6 @@ class YHLiveShopView: UIView {
centerView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(295)
make.left.right.bottom.equalToSuperview()
// make.height.equalTo(518)
}
let headImageView = {
......@@ -150,16 +147,29 @@ class YHLiveShopView: UIView {
}
static func show(callBack: @escaping ((Int) -> Void)) -> YHLiveShopView {
let view = YHLiveShopView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
let view = YHLiveShopView(frame: CGRect(x: 0, y: KScreenWidth, width: KScreenWidth, height: KScreenHeight))
view.backData = callBack
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut) {
view.frame.origin.y = 0
} completion: { _ in }
return view
}
@objc func dismiss() {
removeFromSuperview()
closeEvent?()
// 禁用交互防止动画过程中的重复点击
isUserInteractionEnabled = false
centerView.isUserInteractionEnabled = false
UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn) {
self.frame.origin.y = KScreenHeight
self.centerView.alpha = 0
} completion: { _ in
self.centerView.removeFromSuperview()
self.removeFromSuperview()
self.closeEvent?()
}
}
}
......@@ -283,7 +293,7 @@ class YHLiveShopViewCell: UITableViewCell {
}
func setupUI() {
//self.backgroundColor = .white
self.backgroundColor = .clear
lineView = {
let view = UIView()
......
......@@ -218,7 +218,7 @@ class YHShareAlertView: UIView {
let label = UILabel()
label.numberOfLines = 0
let a: ASAttributedString = .init("银河", .font(UIFont.PFSC_B(ofSize: 13)),.foreground(UIColor.mainTextColor))
let b: ASAttributedString = .init("港生活\n", .font(UIFont.PFSC_B(ofSize: 14)),.foreground(UIColor.brandMainColor))
let b: ASAttributedString = .init("港生活\n", .font(UIFont.PFSC_B(ofSize: 13)),.foreground(UIColor.brandMainColor))
let c: ASAttributedString = .init("美好新生活从这里开始", .font(UIFont.PFSC_R(ofSize: 10)),.foreground(UIColor(hex: 0x8993a2)))
label.attributed.text = a + b + c
return label
......
......@@ -137,6 +137,7 @@ enum tabBarPageType : Int {
// case message //消息
case mine //我的
case community //社区
case AI // 港小宝
}
func goTabBarBy(tabType : tabBarPageType) {
......@@ -147,14 +148,22 @@ func goTabBarBy(tabType : tabBarPageType) {
tabIndex = 0
case .service:
tabIndex = 1
case .AI:
tabIndex = 2
case .community:
tabIndex = 3
case .mine:
tabIndex = 4
}
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = tabIndex
if tabType == .AI {
let vc = YHAITabViewController()
UIViewController.current?.navigationController?.pushViewController(vc)
} else {
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = tabIndex
}
}
}
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 2033196882@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033196882@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment