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 ...@@ -34,7 +34,7 @@ platform :ios do
main_fix = "main-fix" main_fix = "main-fix"
#打包正使用的分支 #打包正使用的分支
myPack_branch = main_fix myPack_branch = develop_branch
......
This diff is collapsed.
...@@ -10,6 +10,40 @@ import UIKit ...@@ -10,6 +10,40 @@ import UIKit
class YHAutoTextView: UITextView, UITextViewDelegate { 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)->())? var textChange:((String)->())?
override open var text: String! { override open var text: String! {
...@@ -28,25 +62,27 @@ class YHAutoTextView: UITextView, UITextViewDelegate { ...@@ -28,25 +62,27 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
} }
} }
let placeholderLabel: UILabel = { lazy var placeholderLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = UIColor.init(hex: 0xB3C8E9) label.textColor = UIColor.init(hex: 0xB3C8E9)
label.font = UIFont.PFSC_R(ofSize: 14) label.font = UIFont.PFSC_R(ofSize: 14)
return label return label
}() }()
override init(frame: CGRect, textContainer: NSTextContainer?) { override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer) super.init(frame: frame, textContainer: textContainer)
self.font = .PFSC_R(ofSize: 14) self.font = .PFSC_R(ofSize: 14)
delegate = self delegate = self
isScrollEnabled = false // 禁止滚动 isScrollEnabled = false // 禁止滚动
self.addSubview(placeholderLabel) self.addSubview(placeholderLabel)
placeholderLabel.snp.makeConstraints { make in placeholderLabel.snp.makeConstraints { make in
make.center.equalToSuperview() make.center.equalToSuperview()
make.left.equalTo(5) make.left.equalTo(5)
make.right.equalTo(-5) make.right.equalTo(-5)
} }
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
...@@ -72,17 +108,21 @@ class YHAutoTextView: UITextView, UITextViewDelegate { ...@@ -72,17 +108,21 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
let size = sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude)) let size = sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))
var height = size.height var height = size.height
self.calculateHeight = height
isScrollEnabled = height > maxHeight isScrollEnabled = height > maxHeight
if height > maxHeight { if height > maxHeight {
height = maxHeight height = maxHeight
self.snp.updateConstraints { make in self.snp.updateConstraints { make in
make.top.equalTo(11) make.top.equalTo(11)
make.height.equalTo(height)
make.bottom.equalTo(-11) make.bottom.equalTo(-11)
} }
} else { } else {
self.snp.updateConstraints { make in self.snp.updateConstraints { make in
make.top.equalTo(11-Self.verticalGap) make.top.equalTo(11-Self.verticalGap)
make.height.equalTo(height)
make.bottom.equalTo(-(11-Self.verticalGap)) 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 { ...@@ -47,6 +47,7 @@ class YHAIMainChatViewController: YHBaseViewController {
lazy var bottomInputView: YHAITextInputView = { lazy var bottomInputView: YHAITextInputView = {
let v = YHAITextInputView(frame: .zero) let v = YHAITextInputView(frame: .zero)
v.backgroundColor = .clear
v.sendBlock = { v.sendBlock = {
[weak self] text in [weak self] text in
guard let self = self else { return } guard let self = self else { return }
...@@ -82,7 +83,7 @@ class YHAIMainChatViewController: YHBaseViewController { ...@@ -82,7 +83,7 @@ class YHAIMainChatViewController: YHBaseViewController {
tableView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.right.equalTo(0) make.left.right.equalTo(0)
make.top.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 bottomInputView.snp.makeConstraints { make in
...@@ -261,19 +262,6 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource ...@@ -261,19 +262,6 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
if msgType == .text { if msgType == .text {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
cell.message = msg 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 return cell
} else if msgType == .recommendText { } else if msgType == .recommendText {
...@@ -379,17 +367,41 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource ...@@ -379,17 +367,41 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
return height 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 { if msgType != .text {
return UITableView.automaticDimension 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) var textHeight = ceil(size.height)
if textHeight < 20.0 { if textHeight < 20.0 {
textHeight = 20.0 textHeight = 20.0
...@@ -416,12 +428,12 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource ...@@ -416,12 +428,12 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
return resultHeight return resultHeight
} }
return UITableView.automaticDimension return 0.0
} }
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 16.0 return 40.0
} }
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
......
...@@ -81,12 +81,10 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -81,12 +81,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
lazy var bannerView: YHAIChatBannerView = { lazy var bannerView: YHAIChatBannerView = {
let view = YHAIChatBannerView(frame: CGRectMake(0, 0, KScreenWidth, 360)) let bgImgHeight = 242.0/335.0 * (KScreenWidth-40.0)
view.bgImgV.image = getBannerBg() let height = 350.0-242.0+bgImgHeight
view.titleLabel.text = getHeaderTitle() let view = YHAIChatBannerView(frame: CGRectMake(0, 0, KScreenWidth, height))
view.descLabel.text = getHeaderDesc() view.config = getBannerConfig()
view.bannerArr = self.getBannerForRobotType(robotType)
view.messages = getFlowMessages()
view.selectFlowMsgBlock = { view.selectFlowMsgBlock = {
[weak self] text in [weak self] text in
guard let self = self else { return } guard let self = self else { return }
...@@ -145,12 +143,6 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -145,12 +143,6 @@ class YHAIRobotChatViewController: YHBaseViewController {
self.tableView.tableHeaderView = nil 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 bgImgView.snp.makeConstraints { make in
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
...@@ -321,64 +313,33 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -321,64 +313,33 @@ class YHAIRobotChatViewController: YHBaseViewController {
} }
} }
func getBannerBg() -> UIImage? { func getBannerConfig() -> YHAIChatBannerViewConfig {
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] {
if robotType == YHAIRobotType.education.rawValue { let config = YHAIChatBannerViewConfig()
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] {
if robotType == YHAIRobotType.sale.rawValue { if robotType == YHAIRobotType.sale.rawValue {
return [YHAIChatBannerItem(id: 0, title: "了解银河集团", desc: "香港身份生活一站式服务平台", msg: "银河集团,能够为我提供什么?"), config.title = "Hello,我是新港生活规划师"
YHAIChatBannerItem(id: 1, title: "香港身份智能评估", desc: "20s快速评估,了解自身条件是否符合", msg: "开始身份办理评估"), config.desc = "香港身份办理问题可以找我"
YHAIChatBannerItem(id: 2, title: "银河产品矩阵", desc: "香港身份、生活多样产品", msg: "介绍一下银河的产品"),] config.bgColor = .init(hex: 0xE6F4FF)
config.indicatorColor = .brandMainColor
} config.bgImageName = "ai_chat_header_bg_0"
if robotType == YHAIRobotType.education.rawValue { config.bannerItems = [YHAIChatBannerItem(id: 0, title: "了解银河集团", desc: "香港身份生活一站式服务平台", msg: "银河集团,能够为我提供什么?"),
return [YHAIChatBannerItem(id: 0, title: "幼中小学升学", desc: "去香港插班需要考核哪些"), YHAIChatBannerItem(id: 1, title: "香港身份智能评估", desc: "20s快速评估,了解自身条件是否符合", msg: "开始身份办理评估"),
YHAIChatBannerItem(id: 1, title: "大学升学", desc: "DSE分数和Alevel的换算关系"), YHAIChatBannerItem(id: 2, title: "银河产品矩阵", desc: "香港身份、生活多样产品", msg: "介绍一下银河的产品"),]
YHAIChatBannerItem(id: 2, title: "银河教育服务", desc: "银河教育插班成功率如何?"),] 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 { func isNeedStopResonse() -> Bool {
...@@ -404,11 +365,6 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -404,11 +365,6 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
if msgType == .text { if msgType == .text {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
cell.message = msg cell.message = msg
cell.messageClick = {
[weak self] text in
guard let self = self else { return }
}
return cell return cell
} else if msgType == .recommendText { } else if msgType == .recommendText {
...@@ -513,17 +469,41 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -513,17 +469,41 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return height 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 { if msgType != .text {
return UITableView.automaticDimension 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) var textHeight = ceil(size.height)
if textHeight < 20.0 { if textHeight < 20.0 {
textHeight = 20.0 textHeight = 20.0
...@@ -550,7 +530,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -550,7 +530,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return resultHeight return resultHeight
} }
return UITableView.automaticDimension return 0.0
} }
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
...@@ -567,9 +547,8 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -567,9 +547,8 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return 1.0 return 1.0
} }
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 1.0 return 40.0
} }
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
......
...@@ -33,48 +33,19 @@ class YHAIServiceListViewController: YHBaseViewController { ...@@ -33,48 +33,19 @@ class YHAIServiceListViewController: YHBaseViewController {
collectView.dataSource = self collectView.dataSource = self
collectView.register(YHAIProductCell.self, forCellWithReuseIdentifier: YHAIProductCell.cellReuseIdentifier) collectView.register(YHAIProductCell.self, forCellWithReuseIdentifier: YHAIProductCell.cellReuseIdentifier)
collectView.register(YHAIGreetCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: YHAIGreetCollectionReusableView.reuseIdentifier) collectView.register(YHAIGreetCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: YHAIGreetCollectionReusableView.reuseIdentifier)
collectView.register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "UICollectionReusableView")
collectView.contentInset = .zero collectView.contentInset = .zero
collectView.showsVerticalScrollIndicator = false collectView.showsVerticalScrollIndicator = false
return collectView return collectView
}() }()
lazy var bottomInputView: UIView = { lazy var bottomInputView: YHAITextInputView = {
let v = UIView() let v = YHAITextInputView(frame: .zero)
v.backgroundColor = .clear
let whiteView = UIView() v.disable = true
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)
let btn = UIButton() let btn = UIButton()
btn.addTarget(self, action: #selector(didInputButtonClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(didInputButtonClicked), for: .touchUpInside)
whiteView.addSubview(btn) v.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()
}
btn.snp.makeConstraints { make in btn.snp.makeConstraints { make in
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
...@@ -101,14 +72,11 @@ class YHAIServiceListViewController: YHBaseViewController { ...@@ -101,14 +72,11 @@ class YHAIServiceListViewController: YHBaseViewController {
make.left.equalTo(16) make.left.equalTo(16)
make.right.equalTo(-16) make.right.equalTo(-16)
make.top.equalToSuperview() make.top.equalToSuperview()
make.bottom.equalTo(bottomInputView.snp.top).offset(-8)
} }
bottomInputView.snp.makeConstraints { make in bottomInputView.snp.makeConstraints { make in
make.left.equalTo(20) make.top.equalTo(collectionView.snp.bottom).offset(8)
make.right.equalTo(-20) make.left.right.bottom.equalToSuperview()
make.height.equalTo(46)
make.bottom.equalTo(-10-k_Height_safeAreaInsetsBottom())
} }
} }
} }
...@@ -207,14 +175,21 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV ...@@ -207,14 +175,21 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
headerView.updateGreetingText() headerView.updateGreetingText()
return headerView 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 { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection:Int) -> CGSize {
return CGSize(width: KScreenWidth, height: 177) 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 { extension YHAIServiceListViewController: JXSegmentedListContainerViewListDelegate {
......
...@@ -254,11 +254,13 @@ extension YHAITabViewController: JXSegmentedViewDelegate { ...@@ -254,11 +254,13 @@ extension YHAITabViewController: JXSegmentedViewDelegate {
bgImgView.isHidden = false bgImgView.isHidden = false
headerImgView.isHidden = true headerImgView.isHidden = true
cleanBtn.isHidden = false cleanBtn.isHidden = false
mainChatVC.bottomInputView.backgroundColor = mainChatVC.bottomInputView.bgColor
} else { // 港小宝 } else { // 港小宝
bgImgView.isHidden = true bgImgView.isHidden = true
headerImgView.isHidden = false headerImgView.isHidden = false
cleanBtn.isHidden = true cleanBtn.isHidden = true
mainChatVC.bottomInputView.backgroundColor = .clear
} }
} }
} }
......
...@@ -133,6 +133,8 @@ class YHAICardItemView: UIView { ...@@ -133,6 +133,8 @@ class YHAICardItemView: UIView {
@objc func didItemViewClicked() { @objc func didItemViewClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
YHAIJumpPageTool.jumpPageWithType(mode: cardModel.redirectMode, path: cardModel.redirectPath) { YHAIJumpPageTool.jumpPageWithType(mode: cardModel.redirectMode, path: cardModel.redirectPath) {
dict in dict in
self.evaluationResultCallback?(dict) self.evaluationResultCallback?(dict)
......
...@@ -21,14 +21,14 @@ class YHAIChatBannerItemCell: FSPagerViewCell { ...@@ -21,14 +21,14 @@ class YHAIChatBannerItemCell: FSPagerViewCell {
static let cellReuseIdentifier = "YHAIChatBannerItemCell" static let cellReuseIdentifier = "YHAIChatBannerItemCell"
lazy var effectView:VisualEffectView = { // lazy var effectView:VisualEffectView = {
let visualEffectView = VisualEffectView() // let visualEffectView = VisualEffectView()
visualEffectView.colorTint = UIColor(hex: 0xAFAFAF).withAlphaComponent(0.15) // visualEffectView.colorTint = UIColor(hex: 0xAFAFAF).withAlphaComponent(0.15)
visualEffectView.blurRadius = 16 // visualEffectView.blurRadius = 16
visualEffectView.scale = 1 // visualEffectView.scale = 1
visualEffectView.isHidden = true // visualEffectView.isHidden = true
return visualEffectView // return visualEffectView
}() // }()
lazy var titleLabel: UILabel = { lazy var titleLabel: UILabel = {
let lable = UILabel() let lable = UILabel()
...@@ -62,11 +62,11 @@ class YHAIChatBannerItemCell: FSPagerViewCell { ...@@ -62,11 +62,11 @@ class YHAIChatBannerItemCell: FSPagerViewCell {
contentView.layer.shadowOpacity = 0 contentView.layer.shadowOpacity = 0
contentView.layer.shadowOffset = .zero contentView.layer.shadowOffset = .zero
contentView.addSubview(effectView) // contentView.addSubview(effectView)
effectView.snp.makeConstraints { make in // effectView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview() // make.bottom.left.right.equalToSuperview()
make.height.equalTo(95) // make.height.equalTo(95)
} // }
contentView.addSubview(subtitleLabel) contentView.addSubview(subtitleLabel)
subtitleLabel.snp.makeConstraints { make in subtitleLabel.snp.makeConstraints { make in
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import FSPagerView import FSPagerView
//import JXPageControl
class YHAIChatBannerItem { class YHAIChatBannerItem {
var id: Int = 0 var id: Int = 0
...@@ -23,12 +24,35 @@ class YHAIChatBannerItem { ...@@ -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 { class YHAIChatBannerView: UIView {
static let bannersHeight = 95.0 static let bannersHeight = 95.0
let cellHeight: CGFloat = 33.0 // 单元格的固定高度 let cellHeight: CGFloat = 33.0 // 单元格的固定高度
var selectFlowMsgBlock:((String)->())? var selectFlowMsgBlock:((String)->())?
var selectBannerItemBlock:((YHAIChatBannerItem)->())? 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] = [] { var messages:[String] = [] {
didSet { didSet {
...@@ -62,14 +86,21 @@ class YHAIChatBannerView: UIView { ...@@ -62,14 +86,21 @@ class YHAIChatBannerView: UIView {
return imagV return imagV
}() }()
lazy var bgCardView: UIView = {
let v = UIView()
v.layer.cornerRadius = 12.0
v.clipsToBounds = true
return v
}()
var bannerArr: [YHAIChatBannerItem] = [] { var bannerArr: [YHAIChatBannerItem] = [] {
didSet { didSet {
// 设置为0是先停掉自动滑动定时器 // 设置为0是先停掉自动滑动定时器
bannerView.automaticSlidingInterval = 0 bannerView.automaticSlidingInterval = 0
self.indicatorView.indicatorItems = self.bannerArr.count self.indicatorView.numberOfPages = self.bannerArr.count
bannerView.reloadData() bannerView.reloadData()
// 指定指示器为第一个 // 指定指示器为第一个
self.indicatorView.curIndicatorIndex = 0 self.indicatorView.currentPage = 0
// 指定显示图片为第一个 // 指定显示图片为第一个
bannerView.selectItem(at: 0, animated: false) bannerView.selectItem(at: 0, animated: false)
// 开启定时器开始滚动 // 开启定时器开始滚动
...@@ -88,17 +119,20 @@ class YHAIChatBannerView: UIView { ...@@ -88,17 +119,20 @@ class YHAIChatBannerView: UIView {
view.automaticSlidingInterval = bannerSildingInterval view.automaticSlidingInterval = bannerSildingInterval
view.register(YHAIChatBannerItemCell.self, forCellWithReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier) view.register(YHAIChatBannerItemCell.self, forCellWithReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier)
view.itemSize = CGSizeMake(KScreenWidth-40.0, YHAIChatBannerView.bannersHeight)//FSPagerView.automaticSize view.itemSize = CGSizeMake(KScreenWidth-40.0, YHAIChatBannerView.bannersHeight)//FSPagerView.automaticSize
view.layer.cornerRadius = 4.0
view.clipsToBounds = true
return view return view
}() }()
lazy var indicatorView : YHHomeBannerIndicatorView = { lazy var indicatorView: YHPageControl = {
let view = YHHomeBannerIndicatorView() let pageControl = YHPageControl(frame: .zero)
view.normalColor = .init(hex: 0xD5DAE1) let dotHeight = 3.0
view.selectedColor = .brandMainColor pageControl.spacing = 2.0
view.layer.cornerRadius = 1.0 pageControl.dotSize = CGSizeMake(5, dotHeight)
return view 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 = { lazy var layout: YHAIChatCustomFlowLayout = {
...@@ -137,26 +171,33 @@ class YHAIChatBannerView: UIView { ...@@ -137,26 +171,33 @@ class YHAIChatBannerView: UIView {
func createUI() { func createUI() {
addSubview(shadowView) addSubview(shadowView)
addSubview(bgCardView)
addSubview(bgImgV) addSubview(bgImgV)
bgImgV.addSubview(titleLabel) bgImgV.addSubview(titleLabel)
bgImgV.addSubview(descLabel) bgImgV.addSubview(descLabel)
bgImgV.addSubview(bannerView) bgImgV.addSubview(bannerView)
bannerView.addSubview(indicatorView) bgImgV.addSubview(indicatorView)
shadowView.snp.makeConstraints { make in 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.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 bgImgV.snp.makeConstraints { make in
make.top.equalTo(0) make.top.equalTo(10)
make.left.equalTo(20) make.left.equalTo(20)
make.right.equalTo(-20) make.right.equalTo(-20)
make.height.equalTo(242) make.height.equalTo(bgImgHeight)
} }
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.top.equalTo(57) make.top.equalTo(bgCardView).offset(24.0)
make.left.equalTo(20) make.left.equalTo(20)
make.height.equalTo(20) make.height.equalTo(20)
} }
...@@ -171,12 +212,12 @@ class YHAIChatBannerView: UIView { ...@@ -171,12 +212,12 @@ class YHAIChatBannerView: UIView {
make.bottom.equalTo(bgImgV) make.bottom.equalTo(bgImgV)
make.left.equalTo(0) make.left.equalTo(0)
make.right.equalTo(0) make.right.equalTo(0)
make.height.equalTo(YHAIChatBannerView.bannersHeight) make.height.equalTo(YHAIChatBannerView.bannersHeight/242.0 * bgImgHeight)
} }
indicatorView.snp.makeConstraints { make in indicatorView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.height.equalTo(2) make.height.equalTo(3)
make.bottom.equalTo(-16) make.bottom.equalTo(-16)
} }
bannerView.reloadData() bannerView.reloadData()
...@@ -186,8 +227,7 @@ class YHAIChatBannerView: UIView { ...@@ -186,8 +227,7 @@ class YHAIChatBannerView: UIView {
make.left.equalTo(0) make.left.equalTo(0)
make.right.equalTo(0) make.right.equalTo(0)
make.height.equalTo(33.0*2+10.0 + 10.0*2.0) make.height.equalTo(33.0*2+10.0 + 10.0*2.0)
make.top.equalTo(bannerView.snp.bottom).offset(6) make.top.equalTo(bgImgV.snp.bottom).offset(6)
make.bottom.equalTo(-6)
} }
} }
...@@ -228,11 +268,11 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -228,11 +268,11 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
} }
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) { func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.indicatorView.curIndicatorIndex = targetIndex self.indicatorView.currentPage = targetIndex
} }
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) { func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.indicatorView.curIndicatorIndex = pagerView.currentIndex self.indicatorView.currentPage = pagerView.currentIndex
} }
} }
......
...@@ -26,9 +26,10 @@ class YHAIChatInputShadowView: UIView { ...@@ -26,9 +26,10 @@ class YHAIChatInputShadowView: UIView {
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 12) let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 12)
layer.shadowPath = shadowPath.cgPath 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.shadowOpacity = 1
layer.shadowRadius = 6 layer.shadowRadius = 20
layer.shadowOffset = CGSize(width: 0, height: 0) layer.shadowOffset = CGSize(width: 0, height: 0)
} }
......
...@@ -25,7 +25,7 @@ class YHAIChatShadowView: UIView { ...@@ -25,7 +25,7 @@ class YHAIChatShadowView: UIView {
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 6) let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 6)
// 设置阴影属性 // 设置阴影属性
layer.shadowPath = shadowPath.cgPath 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.shadowOpacity = 1
layer.shadowRadius = 6.0 layer.shadowRadius = 6.0
layer.shadowOffset = CGSize(width: 0, height: 4) layer.shadowOffset = CGSize(width: 0, height: 4)
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
import UIKit import UIKit
import SDWebImage import SDWebImage
import Photos
import PhotosUI
class YHAIPictureMessageCell: UITableViewCell { class YHAIPictureMessageCell: UITableViewCell {
...@@ -68,16 +70,6 @@ class YHAIPictureMessageCell: UITableViewCell { ...@@ -68,16 +70,6 @@ class YHAIPictureMessageCell: UITableViewCell {
ratio = img.size.width/img.size.height ratio = img.size.width/img.size.height
} }
imgH = imgW/ratio imgH = imgW/ratio
// if imgH > 476 {
// imgH = 476
// imgW = imgH*ratio
//
// } else {
// imgW = 220
// imgH = imgW/ratio
// }
return CGSizeMake(imgW, imgH) return CGSizeMake(imgW, imgH)
} }
...@@ -86,10 +78,17 @@ class YHAIPictureMessageCell: UITableViewCell { ...@@ -86,10 +78,17 @@ class YHAIPictureMessageCell: UITableViewCell {
return v 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 = { lazy var whiteContentView: UIView = {
let v = UIView() let v = UIView()
v.layer.cornerRadius = 12.0
v.clipsToBounds = true
let tap = UITapGestureRecognizer(target: self, action: #selector(didMessageClicked)) let tap = UITapGestureRecognizer(target: self, action: #selector(didMessageClicked))
v.addGestureRecognizer(tap) v.addGestureRecognizer(tap)
return v return v
...@@ -100,13 +99,6 @@ class YHAIPictureMessageCell: UITableViewCell { ...@@ -100,13 +99,6 @@ class YHAIPictureMessageCell: UITableViewCell {
return v return v
}() }()
lazy var rightAngleView: UIView = {
let v = UIView()
v.backgroundColor = .white
v.isHidden = true
return v
}()
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
} }
...@@ -116,15 +108,20 @@ class YHAIPictureMessageCell: UITableViewCell { ...@@ -116,15 +108,20 @@ class YHAIPictureMessageCell: UITableViewCell {
setupUI() setupUI()
} }
override func layoutSubviews() {
super.layoutSubviews()
roundCorners(keepTopLeft: true)
}
func setupUI() { func setupUI() {
selectionStyle = .none selectionStyle = .none
contentView.backgroundColor = .clear contentView.backgroundColor = .clear
backgroundColor = .clear backgroundColor = .clear
contentView.addSubview(shadowView) contentView.addSubview(shadowView)
contentView.addSubview(rightAngleView)
contentView.addSubview(whiteContentView) contentView.addSubview(whiteContentView)
whiteContentView.addSubview(imgView) whiteContentView.addSubview(imgView)
whiteContentView.addSubview(downloadBtn)
whiteContentView.snp.makeConstraints { make in whiteContentView.snp.makeConstraints { make in
make.left.equalTo(20) make.left.equalTo(20)
...@@ -138,19 +135,117 @@ class YHAIPictureMessageCell: UITableViewCell { ...@@ -138,19 +135,117 @@ class YHAIPictureMessageCell: UITableViewCell {
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
shadowView.snp.makeConstraints { make in downloadBtn.snp.makeConstraints { make in
make.edges.equalTo(whiteContentView) make.width.equalTo(26)
make.height.equalTo(26)
make.left.equalTo(16)
make.bottom.equalTo(-16)
} }
rightAngleView.snp.makeConstraints { make in shadowView.snp.makeConstraints { make in
make.top.left.equalTo(whiteContentView) make.left.equalTo(whiteContentView).offset(-0)
make.width.height.equalTo(15) make.right.equalTo(whiteContentView).offset(0)
make.top.equalTo(whiteContentView).offset(-0)
make.bottom.equalTo(whiteContentView).offset(0)
} }
} }
@objc func didMessageClicked() { @objc func didMessageClicked() {
self.endEditing(true)
UIApplication.shared.yhKeyWindow()?.endEditing(true)
YHPictureReviewManager.shared.showNetWorkPicturs(curIndex: 0, arrPicturs: [imgInfo.imageUrl]) 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 { ...@@ -18,10 +18,12 @@ enum YHAITextInputStatus: Int {
class YHAITextInputView: UIView { class YHAITextInputView: UIView {
let bgColor = UIColor.init(hex: 0xF8FCFF)
var sendBlock: ((String)->())? var sendBlock: ((String)->())?
var stopSendBlock: (()->())? var stopSendBlock: (()->())?
var keyBoardChangeBlock: ((_ isShow: Bool)->())? var keyBoardChangeBlock: ((_ isShow: Bool)->())?
var disable: Bool = false
var status: YHAITextInputStatus = .enableSend { var status: YHAITextInputStatus = .enableSend {
didSet { didSet {
if status == .enableSend { if status == .enableSend {
...@@ -91,6 +93,8 @@ class YHAITextInputView: UIView { ...@@ -91,6 +93,8 @@ class YHAITextInputView: UIView {
textView.text = "" textView.text = ""
textView.isScrollEnabled = false textView.isScrollEnabled = false
self.endEditing(true) self.endEditing(true)
textLabel.isHidden = true
textView.isHidden = false
} }
@objc func didStopSendBtnClicked() { @objc func didStopSendBtnClicked() {
...@@ -101,10 +105,12 @@ class YHAITextInputView: UIView { ...@@ -101,10 +105,12 @@ class YHAITextInputView: UIView {
let v = YHAutoTextView() let v = YHAutoTextView()
v.backgroundColor = .clear v.backgroundColor = .clear
v.font = .PFSC_R(ofSize: 14) v.font = .PFSC_R(ofSize: 14)
v.textColor = .mainTextColor
v.placeHolder = "有什么问题尽管问我" v.placeHolder = "有什么问题尽管问我"
v.textChange = { v.textChange = {
[weak self] text in [weak self] text in
guard let self = self else { return } guard let self = self else { return }
self.textLabel.text = text
if status != .loading { if status != .loading {
status = text.count > 0 ? .enableSend : .disableSend status = text.count > 0 ? .enableSend : .disableSend
} }
...@@ -112,6 +118,22 @@ class YHAITextInputView: UIView { ...@@ -112,6 +118,22 @@ class YHAITextInputView: UIView {
return v 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) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
...@@ -145,13 +167,14 @@ class YHAITextInputView: UIView { ...@@ -145,13 +167,14 @@ class YHAITextInputView: UIView {
func createUI() { func createUI() {
self.backgroundColor = UIColor.init(hex: 0xF8FCFF) self.backgroundColor = self.bgColor
self.addSubview(whiteView) self.addSubview(whiteView)
whiteView.addSubview(shadowView) whiteView.addSubview(shadowView)
whiteView.addSubview(contentView) whiteView.addSubview(contentView)
contentView.addSubview(sendBtn) contentView.addSubview(sendBtn)
contentView.addSubview(loadingImgView) contentView.addSubview(loadingImgView)
contentView.addSubview(textView) contentView.addSubview(textView)
contentView.addSubview(textLabel)
status = .disableSend status = .disableSend
whiteView.snp.makeConstraints { make in whiteView.snp.makeConstraints { make in
...@@ -181,23 +204,43 @@ class YHAITextInputView: UIView { ...@@ -181,23 +204,43 @@ class YHAITextInputView: UIView {
} }
textView.snp.makeConstraints { make in textView.snp.makeConstraints { make in
make.left.equalTo(5) make.left.equalTo(16)
make.top.equalTo(11-YHAutoTextView.verticalGap) make.top.equalTo(11-YHAutoTextView.verticalGap)
make.height.equalTo(30)
make.bottom.equalTo(-(11-YHAutoTextView.verticalGap)) make.bottom.equalTo(-(11-YHAutoTextView.verticalGap))
make.right.equalTo(sendBtn.snp.left).offset(-5) 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() addKeyBoardNotify()
} }
@objc func handleKeyboardNotification(_ notification: Notification) { @objc func handleKeyboardNotification(_ notification: Notification) {
if disable {
return
}
if notification.userInfo != nil { if notification.userInfo != nil {
guard let keyboardFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as AnyObject).cgRectValue else {return } guard let keyboardFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as AnyObject).cgRectValue else {return }
let isKeyboardShow = notification.name == UIResponder.keyboardWillShowNotification let isKeyboardShow = notification.name == UIResponder.keyboardWillShowNotification
let bottomMargin = (isKeyboardShow ? -keyboardFrame.height : 0) 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 contentView.snp.updateConstraints { make in
make.bottom.equalTo(-10-(isKeyboardShow ? 0.0 : k_Height_safeAreaInsetsBottom())) make.bottom.equalTo(-10-(isKeyboardShow ? 0.0 : k_Height_safeAreaInsetsBottom()))
} }
......
...@@ -18,17 +18,24 @@ class YHAITextMessageCell: UITableViewCell { ...@@ -18,17 +18,24 @@ class YHAITextMessageCell: UITableViewCell {
var message: YHAIChatMessage = YHAIChatMessage() { var message: YHAIChatMessage = YHAIChatMessage() {
didSet { 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.backgroundColor = message.isSelf ? .brandMainColor : .white
rightAngleView.isHidden = message.getType() != .text rightAngleView.isHidden = message.getType() != .text
if message.isSelf { if message.isSelf {
whiteContentView.backgroundColor = .brandMainColor whiteContentView.backgroundColor = .brandMainColor
messageLabel.textColor = .white
whiteContentView.snp.remakeConstraints { make in whiteContentView.snp.remakeConstraints { make in
make.left.greaterThanOrEqualTo(20) make.left.greaterThanOrEqualTo(58)
make.right.equalTo(-20) make.right.equalTo(-20)
make.top.equalTo(16) make.top.equalTo(16)
make.bottom.equalTo(0) make.bottom.equalTo(0)
...@@ -45,18 +52,10 @@ class YHAITextMessageCell: UITableViewCell { ...@@ -45,18 +52,10 @@ class YHAITextMessageCell: UITableViewCell {
} else { } else {
messageLabel.text = message.body.contentText
whiteContentView.backgroundColor = .white whiteContentView.backgroundColor = .white
messageLabel.textColor = .mainTextColor
whiteContentView.snp.remakeConstraints { make in whiteContentView.snp.remakeConstraints { make in
make.left.equalTo(20) make.left.equalTo(20)
if message.getType() == .recommendText { make.right.equalTo(-20)
make.right.lessThanOrEqualTo(-20)
} else {
make.right.equalTo(-20)
}
make.top.equalTo(16) make.top.equalTo(16)
make.bottom.equalTo(0) make.bottom.equalTo(0)
} }
...@@ -167,7 +166,7 @@ class YHAITextMessageCell: UITableViewCell { ...@@ -167,7 +166,7 @@ class YHAITextMessageCell: UITableViewCell {
make.height.equalTo(37) make.height.equalTo(37)
make.width.equalTo(82) make.width.equalTo(82)
} }
copyBtn.iconInLeft(spacing: 0.0) copyBtn.iconInLeft(spacing: 2.0)
return v return v
...@@ -261,9 +260,6 @@ class YHAITextMessageCell: UITableViewCell { ...@@ -261,9 +260,6 @@ class YHAITextMessageCell: UITableViewCell {
@objc func didMessageClicked() { @objc func didMessageClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true) UIApplication.shared.yhKeyWindow()?.endEditing(true)
if message.getType() == .recommendText { messageClick?(self.message.body.contentText)
let text = message.getText()
messageClick?(text)
}
} }
} }
...@@ -194,6 +194,8 @@ class YHCardMessageCell: UITableViewCell { ...@@ -194,6 +194,8 @@ class YHCardMessageCell: UITableViewCell {
@objc func didBottomButtonClicked() { @objc func didBottomButtonClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
var type = YHAIJumpType.common var type = YHAIJumpType.common
if cardListModel.isEvaluation() { if cardListModel.isEvaluation() {
type = YHAIJumpType.evaluation type = YHAIJumpType.evaluation
......
...@@ -62,7 +62,7 @@ class YHProductItemView: UIView { ...@@ -62,7 +62,7 @@ class YHProductItemView: UIView {
let lable = UILabel() let lable = UILabel()
lable.textColor = UIColor.mainTextColor lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:14) lable.font = UIFont.PFSC_M(ofSize:16)
return lable return lable
}() }()
...@@ -91,6 +91,8 @@ class YHProductItemView: UIView { ...@@ -91,6 +91,8 @@ class YHProductItemView: UIView {
} }
@objc func didClickProductItem() { @objc func didClickProductItem() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
if let configModel = YHConfigManager.shared.reqVM.configModel,configModel.is_integral_open { if let configModel = YHConfigManager.shared.reqVM.configModel,configModel.is_integral_open {
YHAIJumpPageTool.jumpPageWithType(mode: productModel.redirectMode, path: productModel.redirectPath) { YHAIJumpPageTool.jumpPageWithType(mode: productModel.redirectMode, path: productModel.redirectPath) {
dict in dict in
...@@ -111,35 +113,35 @@ class YHProductItemView: UIView { ...@@ -111,35 +113,35 @@ class YHProductItemView: UIView {
iconImgView.snp.makeConstraints { make in iconImgView.snp.makeConstraints { make in
make.width.height.equalTo(80) make.width.height.equalTo(80)
make.left.equalTo(16) make.left.equalTo(0)
make.top.equalTo(20) make.top.equalTo(20)
make.bottom.equalTo(-20) make.bottom.equalTo(-20)
} }
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.left.equalTo(iconImgView.snp.right).offset(12) make.left.equalTo(iconImgView.snp.right).offset(12)
make.right.equalTo(-12) make.right.equalTo(0)
make.top.equalTo(iconImgView) make.top.equalTo(iconImgView)
make.height.equalTo(22) make.height.equalTo(22)
} }
tagContentView.snp.makeConstraints { make in tagContentView.snp.makeConstraints { make in
make.left.equalTo(titleLabel) make.left.equalTo(titleLabel)
make.right.equalTo(-12) make.right.equalTo(0)
make.height.equalTo(16) make.height.equalTo(16)
make.top.equalTo(titleLabel.snp.bottom).offset(4) make.top.equalTo(titleLabel.snp.bottom).offset(4)
} }
priceLabel.snp.makeConstraints { make in priceLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel) make.left.equalTo(titleLabel)
make.right.equalTo(-12) make.right.equalTo(0)
make.bottom.equalTo(iconImgView) make.bottom.equalTo(iconImgView)
make.height.equalTo(20) make.height.equalTo(20)
} }
bottomLineView.snp.makeConstraints { make in bottomLineView.snp.makeConstraints { make in
make.left.equalTo(iconImgView) make.left.equalTo(iconImgView)
make.right.equalTo(-12) make.right.equalTo(0)
make.height.equalTo(0.5) make.height.equalTo(0.5)
make.bottom.equalTo(0) make.bottom.equalTo(0)
} }
......
...@@ -111,14 +111,12 @@ class YHProductListMessageCell: UITableViewCell { ...@@ -111,14 +111,12 @@ class YHProductListMessageCell: UITableViewCell {
@objc func didMoreButtonClicked() { @objc func didMoreButtonClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true)
if let configModel = YHConfigManager.shared.reqVM.configModel,configModel.is_integral_open { if let configModel = YHConfigManager.shared.reqVM.configModel,configModel.is_integral_open {
YHAIJumpPageTool.jumpPageWithType(mode: listModel.redirectMode, path: listModel.redirectPath) { YHAIJumpPageTool.jumpPageWithType(mode: listModel.redirectMode, path: listModel.redirectPath) {
dict in dict in
} }
} }
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
......
...@@ -85,24 +85,22 @@ class YHRecommendTextMessageCell: UITableViewCell { ...@@ -85,24 +85,22 @@ class YHRecommendTextMessageCell: UITableViewCell {
whiteContentView.snp.makeConstraints { make in whiteContentView.snp.makeConstraints { make in
make.left.equalTo(20) make.left.equalTo(20)
make.right.lessThanOrEqualTo(-20) make.right.lessThanOrEqualTo(-20)
make.top.equalTo(16) make.top.equalTo(10)
make.bottom.equalTo(0) make.bottom.equalTo(0)
} }
messageLabel.snp.makeConstraints { make in messageLabel.snp.makeConstraints { make in
make.left.equalTo(16) make.left.equalTo(16)
make.right.equalTo(-16) make.right.equalTo(-16)
make.top.equalTo(16) make.top.equalTo(10)
make.bottom.equalTo(-16) make.bottom.equalTo(-10)
} }
} }
@objc func didMessageClicked() { @objc func didMessageClicked() {
UIApplication.shared.yhKeyWindow()?.endEditing(true) UIApplication.shared.yhKeyWindow()?.endEditing(true)
if message.getType() == .recommendText { let text = message.getText()
let text = message.getText() messageClick?(text)
messageClick?(text)
}
} }
} }
...@@ -8,14 +8,15 @@ ...@@ -8,14 +8,15 @@
import UIKit import UIKit
import JXSegmentedView import JXSegmentedView
import dsBridge
@preconcurrency import WebKit
//MARK: - 生命周期函数 及变量 //MARK: - 生命周期函数 及变量
class YHHomeHoldViewPageViewController: YHBaseViewController { class YHHomeHoldViewPageViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
private var needShowManagerTipsView = false private var needShowManagerTipsView = false
private var didFirstLoadYhManager = false private var didFirstLoadYhManager = false
var viewModel = YHHomePageViewModel() var viewModel = YHHomePageViewModel()
var webview = DWKWebView()
var arrItemTitles: [String] = [] var arrItemTitles: [String] = []
var arrItemVCs : [YHBaseViewController] = [] var arrItemVCs : [YHBaseViewController] = []
...@@ -69,6 +70,28 @@ class YHHomeHoldViewPageViewController: YHBaseViewController { ...@@ -69,6 +70,28 @@ class YHHomeHoldViewPageViewController: YHBaseViewController {
// getConfigData() // 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() { func getConfigData() {
viewModel.getHomeInfo {[weak self] success, error in viewModel.getHomeInfo {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
...@@ -445,9 +468,17 @@ extension YHHomeHoldViewPageViewController { ...@@ -445,9 +468,17 @@ extension YHHomeHoldViewPageViewController {
// } // }
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!! //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 // 跳转到资讯tab
@objc func didJumpToNewsTab() { @objc func didJumpToNewsTab() {
jumpToItemIndex(itemIndex: 3) jumpToItemIndex(itemIndex: 3)
......
...@@ -338,7 +338,7 @@ class YHLookCollectionViewCell: UICollectionViewCell { ...@@ -338,7 +338,7 @@ class YHLookCollectionViewCell: UICollectionViewCell {
flagImageView = { flagImageView = {
let view = LottieAnimationView(name: "live") let view = LottieAnimationView(name: "live")
view.backgroundColor = UIColor.black view.backgroundColor = UIColor.black.withAlphaComponent(0.6)
view.loopMode = .loop view.loopMode = .loop
return view 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 为空")
}
}
}
//
// 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)
}
}
}
...@@ -18,6 +18,32 @@ class YHJsApi: NSObject { ...@@ -18,6 +18,32 @@ class YHJsApi: NSObject {
} }
extension YHJsApi { 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) { @objc func disableFullScreenGestureSyn(_ tag : Any) {
DispatchQueue.main.async { DispatchQueue.main.async {
...@@ -35,6 +61,7 @@ extension YHJsApi { ...@@ -35,6 +61,7 @@ extension YHJsApi {
} }
} }
// 关闭优才测评
@objc func closeEvaluationGetResult(_ dicData: String) { @objc func closeEvaluationGetResult(_ dicData: String) {
DispatchQueue.main.async { DispatchQueue.main.async {
if let data = dicData.data(using: .utf8) { if let data = dicData.data(using: .utf8) {
......
...@@ -37,16 +37,10 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -37,16 +37,10 @@ class YHBasePlayerViewController: YHBaseViewController {
return view return view
}() }()
// 控制状态
private var isControlsVisible = true
private var controlsAutoHideTimer: Timer?
// MARK: - Lifecycle // MARK: - Lifecycle
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
//setupGestures()
//setupNotifications()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -62,8 +56,6 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -62,8 +56,6 @@ class YHBasePlayerViewController: YHBaseViewController {
gk_navBarAlpha = 1 gk_navBarAlpha = 1
gk_navigationBar.isHidden = false gk_navigationBar.isHidden = false
view.backgroundColor = .black view.backgroundColor = .black
// controlsAutoHideTimer?.invalidate()
// controlsAutoHideTimer = nil
UIApplication.shared.isIdleTimerDisabled = false UIApplication.shared.isIdleTimerDisabled = false
} }
...@@ -96,111 +88,6 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -96,111 +88,6 @@ class YHBasePlayerViewController: YHBaseViewController {
make.height.equalTo(k_Height_NavigationtBarAndStatuBar) 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 // MARK: - Orientation Support
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import AgoraRtcKit import AgoraRtcKit
import HyphenateChat import HyphenateChat
//import AVKit
import UIKit import UIKit
class YHLivePlayerViewController: YHBasePlayerViewController { class YHLivePlayerViewController: YHBasePlayerViewController {
...@@ -59,7 +60,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -59,7 +60,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
} }
vc.closeEvent = { [weak self] in vc.closeEvent = { [weak self] in
self?.leaveLiveRoom() //self?.leaveLiveRoom()
self?.closeLive() self?.closeLive()
} }
...@@ -86,12 +87,6 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -86,12 +87,6 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
let imageView = UIImageView(image: UIImage(named: "live_player_bg")) let imageView = UIImageView(image: UIImage(named: "live_player_bg"))
return imageView return imageView
}() }()
// private lazy var blurredView: YHBlurredAvatarView = {
// let view = YHBlurredAvatarView()
// view.isHidden = true
// return view
// }()
// MARK: - Initialization // MARK: - Initialization
...@@ -123,6 +118,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -123,6 +118,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
joinLiveRoom(id: liveId, callback: { _, _ in }) joinLiveRoom(id: liveId, callback: { _, _ in })
} }
setupTimer() setupTimer()
setupLifeCycleNotifications()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -275,9 +271,14 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -275,9 +271,14 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
playbackInfo?.title = liveDetail.live_title playbackInfo?.title = liveDetail.live_title
playbackInfo?.uid = UInt(liveDetail.user_id) playbackInfo?.uid = UInt(liveDetail.user_id)
messageListView.anchorName = liveDetail.hxNickname messageListView.anchorName = liveDetail.hxNickname
let isOnLive = liveDetail.getLiveState() == .onLive || liveDetail.getLiveState() == .stop
if needJoinLiveChannel { 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) 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 // 如果没有预设roomId,使用接口返回的roomId
...@@ -601,21 +602,20 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -601,21 +602,20 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
case .liveStart: case .liveStart:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true) self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .liveEnd: case .liveEnd:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false) self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .livePause: case .livePause:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false) self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
case .liveResume: case .liveResume:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false) self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .liveGoodsRefresh: case .liveGoodsRefresh:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false) self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.goodsListView?.dataSource = liveDetail.goods self.goodsListView?.dataSource = liveDetail.goods
} }
} else { } else {
printLog("YHLivePlayerViewController: 请求失败") printLog("YHLivePlayerViewController: 请求失败")
if let errorMsg = error?.errorMsg, !errorMsg.isEmpty { // if let errorMsg = error?.errorMsg, !errorMsg.isEmpty {
YHHUD.flash(message: errorMsg) // YHHUD.flash(message: errorMsg)
} // }
return
} }
} }
} }
...@@ -691,7 +691,8 @@ extension YHLivePlayerViewController: YHPlayerDelegate { ...@@ -691,7 +691,8 @@ extension YHLivePlayerViewController: YHPlayerDelegate {
// 直播开始时的特殊处理 // 直播开始时的特殊处理
break break
case .failed: case .failed:
self.showAlert(message: "播放失败,错误原因:\(reason.rawValue)") break
//self.showAlert(message: "播放失败,错误原因:\(reason.rawValue)")
default: default:
break break
} }
...@@ -713,3 +714,67 @@ extension YHLivePlayerViewController: YHPlayerDelegate { ...@@ -713,3 +714,67 @@ extension YHLivePlayerViewController: YHPlayerDelegate {
#endif #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 @@ ...@@ -9,6 +9,7 @@
import UIKit import UIKit
enum YHLiveState: Int { enum YHLiveState: Int {
case unknown = -1
case start = 0 case start = 0
case stop = 1 case stop = 1
case end = 2 case end = 2
...@@ -122,7 +123,7 @@ class YHLiveStateViewController: YHBaseViewController { ...@@ -122,7 +123,7 @@ class YHLiveStateViewController: YHBaseViewController {
view.addSubview(logImageView) view.addSubview(logImageView)
logImageView.snp.makeConstraints { make in logImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.top.equalTo(196) make.top.equalTo(240)
make.width.height.equalTo(78) make.width.height.equalTo(78)
} }
...@@ -229,7 +230,7 @@ class YHLiveStateViewController: YHBaseViewController { ...@@ -229,7 +230,7 @@ class YHLiveStateViewController: YHBaseViewController {
loginSubTitleLabel.text = "直播已结束" loginSubTitleLabel.text = "直播已结束"
messageLabel.text = "直播已结束,去首页逛逛吧~" messageLabel.text = "直播已结束,去首页逛逛吧~"
getCodeButton.isHidden = false getCodeButton.isHidden = false
case .onLive: case .onLive, .unknown:
break break
} }
} }
......
...@@ -48,7 +48,7 @@ class YHLiveDetailModel: SmartCodable { ...@@ -48,7 +48,7 @@ class YHLiveDetailModel: SmartCodable {
func getLiveState() -> YHLiveState { func getLiveState() -> YHLiveState {
switch status { switch status {
case 0: case 0:
return .onLive return .unknown
case 1: case 1:
if stream_status == 3 { if stream_status == 3 {
return .stop return .stop
...@@ -59,7 +59,7 @@ class YHLiveDetailModel: SmartCodable { ...@@ -59,7 +59,7 @@ class YHLiveDetailModel: SmartCodable {
case 3: case 3:
return .end return .end
default: 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 { ...@@ -15,13 +15,6 @@ class YHLiveMessageListView: UIView {
// MARK: - UI Components // 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 = { private lazy var tableView: UITableView = {
let view = UITableView() let view = UITableView()
view.backgroundColor = .clear view.backgroundColor = .clear
...@@ -49,12 +42,6 @@ class YHLiveMessageListView: UIView { ...@@ -49,12 +42,6 @@ class YHLiveMessageListView: UIView {
private func setupUI() { private func setupUI() {
backgroundColor = .clear backgroundColor = .clear
addSubview(tableView) 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 tableView.snp.makeConstraints { make in
make.top.equalToSuperview() make.top.equalToSuperview()
...@@ -81,6 +68,27 @@ class YHLiveMessageListView: UIView { ...@@ -81,6 +68,27 @@ class YHLiveMessageListView: UIView {
// MARK: - UITableViewDelegate & UITableViewDataSource // MARK: - UITableViewDelegate & UITableViewDataSource
extension YHLiveMessageListView: 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 { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension return UITableView.automaticDimension
} }
......
...@@ -39,7 +39,6 @@ class YHLiveShopView: UIView { ...@@ -39,7 +39,6 @@ class YHLiveShopView: UIView {
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
//backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap)) let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self tap.delegate = self
addGestureRecognizer(tap) addGestureRecognizer(tap)
...@@ -51,7 +50,6 @@ class YHLiveShopView: UIView { ...@@ -51,7 +50,6 @@ class YHLiveShopView: UIView {
} }
func setView() { func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = { centerView = {
let view = UIView() let view = UIView()
view.backgroundColor = .white view.backgroundColor = .white
...@@ -61,7 +59,6 @@ class YHLiveShopView: UIView { ...@@ -61,7 +59,6 @@ class YHLiveShopView: UIView {
centerView.snp.makeConstraints { make in centerView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(295) make.top.equalToSuperview().offset(295)
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
// make.height.equalTo(518)
} }
let headImageView = { let headImageView = {
...@@ -150,16 +147,29 @@ class YHLiveShopView: UIView { ...@@ -150,16 +147,29 @@ class YHLiveShopView: UIView {
} }
static func show(callBack: @escaping ((Int) -> Void)) -> YHLiveShopView { 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 view.backData = callBack
let window = UIApplication.shared.yhKeyWindow() let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view) window?.addSubview(view)
UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut) {
view.frame.origin.y = 0
} completion: { _ in }
return view return view
} }
@objc func dismiss() { @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 { ...@@ -283,7 +293,7 @@ class YHLiveShopViewCell: UITableViewCell {
} }
func setupUI() { func setupUI() {
//self.backgroundColor = .white self.backgroundColor = .clear
lineView = { lineView = {
let view = UIView() let view = UIView()
......
...@@ -218,7 +218,7 @@ class YHShareAlertView: UIView { ...@@ -218,7 +218,7 @@ class YHShareAlertView: UIView {
let label = UILabel() let label = UILabel()
label.numberOfLines = 0 label.numberOfLines = 0
let a: ASAttributedString = .init("银河", .font(UIFont.PFSC_B(ofSize: 13)),.foreground(UIColor.mainTextColor)) 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))) let c: ASAttributedString = .init("美好新生活从这里开始", .font(UIFont.PFSC_R(ofSize: 10)),.foreground(UIColor(hex: 0x8993a2)))
label.attributed.text = a + b + c label.attributed.text = a + b + c
return label return label
......
...@@ -137,6 +137,7 @@ enum tabBarPageType : Int { ...@@ -137,6 +137,7 @@ enum tabBarPageType : Int {
// case message //消息 // case message //消息
case mine //我的 case mine //我的
case community //社区 case community //社区
case AI // 港小宝
} }
func goTabBarBy(tabType : tabBarPageType) { func goTabBarBy(tabType : tabBarPageType) {
...@@ -147,14 +148,22 @@ func goTabBarBy(tabType : tabBarPageType) { ...@@ -147,14 +148,22 @@ func goTabBarBy(tabType : tabBarPageType) {
tabIndex = 0 tabIndex = 0
case .service: case .service:
tabIndex = 1 tabIndex = 1
case .AI:
tabIndex = 2
case .community: case .community:
tabIndex = 3 tabIndex = 3
case .mine: case .mine:
tabIndex = 4 tabIndex = 4
} }
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController { if tabType == .AI {
vc.selectedIndex = tabIndex 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