Commit 10398c03 authored by Steven杜宇's avatar Steven杜宇

// AI

parent cfa0dbf4
......@@ -672,6 +672,9 @@
04BE392C2CF8917100BD31DB /* YHAIThinkingMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE392B2CF8917100BD31DB /* YHAIThinkingMessageCell.swift */; };
04BE392E2CF964A200BD31DB /* YHProductListMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE392D2CF964A200BD31DB /* YHProductListMessageCell.swift */; };
04BE39302CF964F800BD31DB /* YHProductItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE392F2CF964F800BD31DB /* YHProductItemView.swift */; };
04BE39322CF9AB0900BD31DB /* YHCardMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39312CF9AB0900BD31DB /* YHCardMessageCell.swift */; };
04BE39342CF9AFAE00BD31DB /* YHFixProductMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39332CF9AFAE00BD31DB /* YHFixProductMessageCell.swift */; };
04BE39362CF9AFF200BD31DB /* YHFixProductItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */; };
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; };
04C693642B723B56004C1758 /* YHMySettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693632B723B56004C1758 /* YHMySettingCell.swift */; };
04C85DDF2C364FE9008B20D6 /* YHAboutUsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */; };
......@@ -1726,6 +1729,9 @@
04BE392B2CF8917100BD31DB /* YHAIThinkingMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIThinkingMessageCell.swift; sourceTree = "<group>"; };
04BE392D2CF964A200BD31DB /* YHProductListMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHProductListMessageCell.swift; sourceTree = "<group>"; };
04BE392F2CF964F800BD31DB /* YHProductItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHProductItemView.swift; sourceTree = "<group>"; };
04BE39312CF9AB0900BD31DB /* YHCardMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardMessageCell.swift; sourceTree = "<group>"; };
04BE39332CF9AFAE00BD31DB /* YHFixProductMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFixProductMessageCell.swift; sourceTree = "<group>"; };
04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFixProductItemView.swift; sourceTree = "<group>"; };
04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.swift; sourceTree = "<group>"; };
04C693632B723B56004C1758 /* YHMySettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingCell.swift; sourceTree = "<group>"; };
04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsCell.swift; sourceTree = "<group>"; };
......@@ -3973,12 +3979,15 @@
children = (
04943BF32CF4954800BF2255 /* YHAIMessageCell.swift */,
04BE392B2CF8917100BD31DB /* YHAIThinkingMessageCell.swift */,
04BE392D2CF964A200BD31DB /* YHProductListMessageCell.swift */,
04BE39332CF9AFAE00BD31DB /* YHFixProductMessageCell.swift */,
04BE39312CF9AB0900BD31DB /* YHCardMessageCell.swift */,
045F28452CF6C47800520F19 /* YHAIProductCell.swift */,
04943BF52CF49E3E00BF2255 /* YHAITextInputView.swift */,
045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */,
04BE39292CF85F8900BD31DB /* YHAITabIndicatorView.swift */,
04BE392D2CF964A200BD31DB /* YHProductListMessageCell.swift */,
04BE392F2CF964F800BD31DB /* YHProductItemView.swift */,
04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -5943,6 +5952,7 @@
04256DF42C73626900A37BA4 /* YHServiceSelectAlertView.swift in Sources */,
04F5F8702C1AC4C2004A463C /* YHHKEventWebViewController.swift in Sources */,
045EEE892B9F171A0022A143 /* YHPreviewBaseViewController.swift in Sources */,
04BE39342CF9AFAE00BD31DB /* YHFixProductMessageCell.swift in Sources */,
045EEEA42B9F171A0022A143 /* YHImageResultViewController.swift in Sources */,
045EEE812B9F171A0022A143 /* YHPreviewQuestionAndAnswerModel.swift in Sources */,
049D62C02C6F1E6700E811A1 /* YHFamilyInfoWarmTipsView.swift in Sources */,
......@@ -6441,6 +6451,7 @@
04CA2C012CB7CEDC00F36DE7 /* YHResignUploadDocDetailViewController.swift in Sources */,
04A671622BA058DE00C1FB91 /* YHCertificateEditSheetView.swift in Sources */,
04F4A52C2CB8F8190026D469 /* YHResignAppointedScheduleRiskTipsView.swift in Sources */,
04BE39322CF9AB0900BD31DB /* YHCardMessageCell.swift in Sources */,
04AD317D2C295AE800DF5655 /* YHUserInfoSettingViewModel.swift in Sources */,
04943BF62CF49E3E00BF2255 /* YHAITextInputView.swift in Sources */,
045A08C22C37EB8B00BCBABA /* YHMyFileListNoneCell.swift in Sources */,
......@@ -6695,6 +6706,7 @@
045EEF1F2B9F171A0022A143 /* YHDatePickView.swift in Sources */,
04B401E42CE76B10005C61A9 /* YHIncomeInputMoneyCell.swift in Sources */,
04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */,
04BE39362CF9AFF200BD31DB /* YHFixProductItemView.swift in Sources */,
04912F942CB921C300CC3105 /* YHResignAppointContainerViewController.swift in Sources */,
045EEE972B9F171A0022A143 /* YHPreviewInfoWorkExpView.swift in Sources */,
04B401EC2CE84CBD005C61A9 /* YHIncomeTypePopViewSelectCell.swift in Sources */,
......
......@@ -33,7 +33,8 @@ class YHAIChatViewController: YHBaseViewController {
tableView.register(YHAIMessageCell.self, forCellReuseIdentifier: YHAIMessageCell.cellReuseIdentifier)
tableView.register(YHAIThinkingMessageCell.self, forCellReuseIdentifier: YHAIThinkingMessageCell.cellReuseIdentifier)
tableView.register(YHProductListMessageCell.self, forCellReuseIdentifier: YHProductListMessageCell.cellReuseIdentifier)
tableView.register(YHFixProductListMessageCell.self, forCellReuseIdentifier: YHFixProductListMessageCell.cellReuseIdentifier)
tableView.register(YHCardMessageCell.self, forCellReuseIdentifier: YHCardMessageCell.cellReuseIdentifier)
return tableView
}()
......@@ -165,6 +166,17 @@ extension YHAIChatViewController: UITableViewDelegate, UITableViewDataSource {
cell.listModel = listModel
}
return cell
} else if msgType == .fixProductList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFixProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHFixProductListMessageCell
if let listModel = msg.body.getFixProductList() {
cell.listModel = listModel
}
return cell
} else if msgType == .card {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as! YHCardMessageCell
return cell
}
}
......
......@@ -17,8 +17,9 @@ enum YHAIMessageType: Int {
case thinking = -1
case none = 0
case text = 1
case card = 2
case fixProductList = 2
case productList = 3
case card = 4
}
class YHAIMessage: CustomStringConvertible {
......@@ -83,6 +84,9 @@ class YHAIMessage: CustomStringConvertible {
if type == YHAIMessageType.text.rawValue {
return .text
}
if type == YHAIMessageType.fixProductList.rawValue {
return .fixProductList
}
if type == YHAIMessageType.productList.rawValue {
return .productList
}
......@@ -133,6 +137,22 @@ class YHAIMessageBody: SmartCodable {
return nil
}
func getFixProductList() -> YHFixProductListModel? {
do {
if let jsonData = contentText.data(using: .utf8) {
let dataDict = try JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any]
let dict = dataDict ?? [:]
if contentType == YHAIMessageType.fixProductList.rawValue {
if let productList = YHFixProductListModel.deserialize(from: dict) {
return productList
}
}
}
} catch {
}
return nil
}
required init() {
......@@ -179,3 +199,33 @@ class YHProductTag: SmartCodable {
}
}
class YHFixProductListModel: SmartCodable {
var icon: String = ""
var title: String = ""
var description: String = ""
var btn_text: String = ""
var redirect_mode: Int = 0
var redirect_path: String = ""
var list: [YHFixProductItemModel] = []
required init() {
}
}
class YHFixProductItemModel: SmartCodable {
var title: String = ""
var cover: String = ""
var description: String = ""
var redirect_mode: Int = 0
var redirect_path: String = ""
required init() {
}
}
//
// YHCardMessageCell.swift
// galaxy
//
// Created by Dufet on 2024/11/29.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHCardMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHProductListMessageCell"
var whiteContentView: UIView = {
let v = UIView()
v.backgroundColor = .white
v.layer.cornerRadius = 4.0
v.clipsToBounds = true
return v
}()
lazy var iconImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: ""))
return v
}()
lazy var titleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_B(ofSize:16)
lable.text = "港小宝"
return lable
}()
lazy var subtitleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.init(hex: 0x8993A2)
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:12)
lable.text = "为您推荐以下优才产品"
return lable
}()
lazy var lineView: UIView = {
let v = UIView()
v.backgroundColor = .init(hex: 0xE9ECF0)
return v
}()
lazy var cardImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: ""))
return v
}()
lazy var cardTitleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_B(ofSize:16)
lable.numberOfLines = 0
lable.text = "深圳银河湾体验中心"
return lable
}()
lazy var describeLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.init(hex: 0x8993A2)
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:12)
lable.numberOfLines = 0
lable.text = "位于深圳市福田区沙头街道本元大厦26B,周一至周六 9:30-19:00开放预约(法定节假日除外)"
return lable
}()
lazy var bottomBtn: UIButton = {
let btn = UIButton()
btn.setTitle("预约到访", for: .normal)
btn.setTitleColor(UIColor.white, for: .normal)
btn.backgroundColor = .brandMainColor
btn.titleLabel?.font = .PFSC_M(ofSize: 14)
btn.layer.cornerRadius = 6.0
btn.addTarget(self, action: #selector(didBottomButtonClicked), for: .touchUpInside)
return btn
}()
@objc func didBottomButtonClicked() {
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
selectionStyle = .none
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(iconImgView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(subtitleLabel)
whiteContentView.addSubview(lineView)
whiteContentView.addSubview(cardImgView)
whiteContentView.addSubview(cardTitleLabel)
whiteContentView.addSubview(describeLabel)
whiteContentView.addSubview(bottomBtn)
whiteContentView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(16)
make.bottom.equalTo(0)
}
iconImgView.snp.makeConstraints { make in
make.width.height.equalTo(36)
make.top.equalTo(20)
make.left.equalTo(16)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(iconImgView)
make.left.equalTo(iconImgView.snp.right).offset(8)
make.height.equalTo(24)
make.right.equalTo(-16)
}
subtitleLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.top.equalTo(titleLabel.snp.bottom).offset(0)
make.height.equalTo(20)
make.right.equalTo(-16)
}
lineView.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(subtitleLabel.snp.bottom).offset(10)
make.height.equalTo(0.5)
}
cardImgView.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(lineView.snp.bottom).offset(16)
make.height.equalTo(303)
}
cardTitleLabel.snp.makeConstraints { make in
make.top.equalTo(cardImgView.snp.bottom).offset(10)
make.left.equalTo(16)
make.right.equalTo(-16)
}
describeLabel.snp.makeConstraints { make in
make.top.equalTo(cardTitleLabel.snp.bottom).offset(4)
make.left.equalTo(16)
make.right.equalTo(-16)
}
bottomBtn.snp.makeConstraints { make in
make.top.equalTo(describeLabel.snp.bottom).offset(16)
make.left.equalTo(16)
make.right.equalTo(-16)
make.bottom.equalTo(-16)
make.height.equalTo(44)
}
}
}
//
// YHFixProductItemView.swift
// galaxy
//
// Created by Dufet on 2024/11/29.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
class YHFixProductItemView: UIView {
var productModel = YHFixProductItemModel() {
didSet {
iconImgView.sd_setImage(with: URL(string: productModel.cover), placeholderImage: UIImage(named: ""))
titleLabel.text = productModel.title
subtitleLabel.text = productModel.description
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var bottomLineView: UIView = {
let v = UIView()
v.backgroundColor = .init(hex: 0xE9ECF0)
return v
}()
lazy var iconImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: ""))
return v
}()
lazy var titleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:14)
lable.text = "高才A香港企明星(7)"
return lable
}()
lazy var subtitleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:14)
lable.text = "高才A香港企明星(7)"
return lable
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func didClickProductItem() {
if !productModel.redirect_path.isEmpty {
let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false
vc.url = productModel.redirect_path
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
func createUI() {
let tap = UITapGestureRecognizer(target: self, action: #selector(didClickProductItem))
self.addGestureRecognizer(tap)
self.addSubview(iconImgView)
self.addSubview(titleLabel)
self.addSubview(subtitleLabel)
self.addSubview(bottomLineView)
iconImgView.snp.makeConstraints { make in
make.width.height.equalTo(70)
make.left.equalTo(16)
make.top.equalTo(20)
make.bottom.equalTo(-16)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(iconImgView.snp.right).offset(12)
make.right.equalTo(-16)
make.top.equalTo(iconImgView)
make.height.equalTo(42)
}
subtitleLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.right.equalTo(-16)
make.bottom.equalTo(iconImgView)
make.height.equalTo(17)
}
bottomLineView.snp.makeConstraints { make in
make.left.equalTo(iconImgView)
make.right.equalTo(-16)
make.height.equalTo(0.5)
make.bottom.equalTo(0)
}
}
}
//
// YHFixProductMessageCell.swift
// galaxy
//
// Created by Dufet on 2024/11/29.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFixProductListMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHFixProductMessageCell"
var listModel = YHFixProductListModel() {
didSet {
iconImgView.sd_setImage(with: URL(string: listModel.icon))
titleLabel.text = listModel.title
subtitleLabel.text = listModel.description
listView.removeSubviews()
var lastItemView:YHFixProductItemView? = nil
for (_, item) in listModel.list.enumerated() {
let productView = YHFixProductItemView()
productView.productModel = item
listView.addSubview(productView)
productView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
if let lastItemView = lastItemView {
make.top.equalTo(lastItemView.snp.bottom)
} else {
make.top.equalTo(0)
}
}
lastItemView = productView
}
if listModel.list.count > 0 {
if let lastItemView = lastItemView {
listView.addSubview(moreBtn)
moreBtn.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(lastItemView.snp.bottom)
make.height.equalTo(40)
}
moreBtn.iconInRight(with: 0)
}
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
var whiteContentView: UIView = {
let v = UIView()
v.backgroundColor = .white
v.layer.cornerRadius = 4.0
v.clipsToBounds = true
return v
}()
lazy var iconImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: ""))
return v
}()
lazy var titleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.mainTextColor
lable.textAlignment = .left
lable.font = UIFont.PFSC_B(ofSize:16)
lable.text = "港小宝"
return lable
}()
lazy var subtitleLabel:UILabel = {
let lable = UILabel()
lable.textColor = UIColor.init(hex: 0x8993A2)
lable.textAlignment = .left
lable.font = UIFont.PFSC_R(ofSize:12)
lable.text = "为您推荐以下优才产品"
return lable
}()
lazy var lineView: UIView = {
let v = UIView()
v.backgroundColor = .init(hex: 0xE9ECF0)
return v
}()
lazy var listView: UIView = {
let v = UIView()
return v
}()
lazy var moreBtn: UIButton = {
let btn = UIButton()
btn.setTitle("查看更多", for: .normal)
btn.setTitleColor(UIColor.init(hex: 0xB9C1CC), for: .normal)
btn.setImage(UIImage(named: "my_doc_right_arrow"), for: .normal)
btn.titleLabel?.font = .PFSC_R(ofSize: 12)
btn.addTarget(self, action: #selector(didMoreButtonClicked), for: .touchUpInside)
return btn
}()
@objc func didMoreButtonClicked() {
if !listModel.redirect_path.isEmpty {
let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false
vc.url = listModel.redirect_path
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
selectionStyle = .none
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(iconImgView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(subtitleLabel)
whiteContentView.addSubview(lineView)
whiteContentView.addSubview(listView)
whiteContentView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(16)
make.bottom.equalTo(0)
}
iconImgView.snp.makeConstraints { make in
make.width.height.equalTo(36)
make.top.equalTo(20)
make.left.equalTo(16)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(iconImgView)
make.left.equalTo(iconImgView.snp.right).offset(8)
make.height.equalTo(24)
make.right.equalTo(-16)
}
subtitleLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.top.equalTo(titleLabel.snp.bottom).offset(0)
make.height.equalTo(20)
make.right.equalTo(-16)
}
lineView.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(subtitleLabel.snp.bottom).offset(10)
make.height.equalTo(0.5)
}
listView.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(lineView.snp.bottom).offset(0)
make.bottom.equalTo(0)
}
}
}
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