Commit 2f5db187 authored by Steven杜宇's avatar Steven杜宇

// AI

parent de123c79
...@@ -110,9 +110,6 @@ target 'galaxy' do ...@@ -110,9 +110,6 @@ target 'galaxy' do
#Realm #Realm
pod 'RealmSwift', '20.0.0' pod 'RealmSwift', '20.0.0'
pod 'Realm', '20.0.0' pod 'Realm', '20.0.0'
#调试工具
pod 'LLDebugToolSwift', '1.3.8.1', :configurations => ['Debug']
end end
......
...@@ -687,6 +687,8 @@ ...@@ -687,6 +687,8 @@
04BE394E2CFD92C100BD31DB /* YHAIChatInputShadowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE394D2CFD92C100BD31DB /* YHAIChatInputShadowView.swift */; }; 04BE394E2CFD92C100BD31DB /* YHAIChatInputShadowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE394D2CFD92C100BD31DB /* YHAIChatInputShadowView.swift */; };
04BE39502CFD9B5900BD31DB /* YHAIChatDataBaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE394F2CFD9B5800BD31DB /* YHAIChatDataBaseManager.swift */; }; 04BE39502CFD9B5900BD31DB /* YHAIChatDataBaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE394F2CFD9B5800BD31DB /* YHAIChatDataBaseManager.swift */; };
04BE39522CFDA19000BD31DB /* YHAIChatDataBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39512CFDA19000BD31DB /* YHAIChatDataBaseModel.swift */; }; 04BE39522CFDA19000BD31DB /* YHAIChatDataBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39512CFDA19000BD31DB /* YHAIChatDataBaseModel.swift */; };
04BE39542CFEA62000BD31DB /* YHAICardItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39532CFEA62000BD31DB /* YHAICardItemView.swift */; };
04BE39582CFED3F700BD31DB /* YHAIHistoryMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39572CFED3F700BD31DB /* YHAIHistoryMessage.swift */; };
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; }; 04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; };
04C693642B723B56004C1758 /* YHMySettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693632B723B56004C1758 /* YHMySettingCell.swift */; }; 04C693642B723B56004C1758 /* YHMySettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693632B723B56004C1758 /* YHMySettingCell.swift */; };
04C85DDF2C364FE9008B20D6 /* YHAboutUsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */; }; 04C85DDF2C364FE9008B20D6 /* YHAboutUsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */; };
...@@ -1756,6 +1758,8 @@ ...@@ -1756,6 +1758,8 @@
04BE394D2CFD92C100BD31DB /* YHAIChatInputShadowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatInputShadowView.swift; sourceTree = "<group>"; }; 04BE394D2CFD92C100BD31DB /* YHAIChatInputShadowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatInputShadowView.swift; sourceTree = "<group>"; };
04BE394F2CFD9B5800BD31DB /* YHAIChatDataBaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatDataBaseManager.swift; sourceTree = "<group>"; }; 04BE394F2CFD9B5800BD31DB /* YHAIChatDataBaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatDataBaseManager.swift; sourceTree = "<group>"; };
04BE39512CFDA19000BD31DB /* YHAIChatDataBaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatDataBaseModel.swift; sourceTree = "<group>"; }; 04BE39512CFDA19000BD31DB /* YHAIChatDataBaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatDataBaseModel.swift; sourceTree = "<group>"; };
04BE39532CFEA62000BD31DB /* YHAICardItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAICardItemView.swift; sourceTree = "<group>"; };
04BE39572CFED3F700BD31DB /* YHAIHistoryMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIHistoryMessage.swift; sourceTree = "<group>"; };
04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.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>"; }; 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>"; }; 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsCell.swift; sourceTree = "<group>"; };
...@@ -3994,6 +3998,7 @@ ...@@ -3994,6 +3998,7 @@
045F28492CF6F5B100520F19 /* YHAIViewModel.swift */, 045F28492CF6F5B100520F19 /* YHAIViewModel.swift */,
045F284B2CF6F65200520F19 /* YHAIListModel.swift */, 045F284B2CF6F65200520F19 /* YHAIListModel.swift */,
04BE39272CF848F300BD31DB /* YHAIMessageModel.swift */, 04BE39272CF848F300BD31DB /* YHAIMessageModel.swift */,
04BE39572CFED3F700BD31DB /* YHAIHistoryMessage.swift */,
04BE39512CFDA19000BD31DB /* YHAIChatDataBaseModel.swift */, 04BE39512CFDA19000BD31DB /* YHAIChatDataBaseModel.swift */,
04BE394F2CFD9B5800BD31DB /* YHAIChatDataBaseManager.swift */, 04BE394F2CFD9B5800BD31DB /* YHAIChatDataBaseManager.swift */,
); );
...@@ -4013,6 +4018,7 @@ ...@@ -4013,6 +4018,7 @@
045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */, 045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */,
04BE39292CF85F8900BD31DB /* YHAITabIndicatorView.swift */, 04BE39292CF85F8900BD31DB /* YHAITabIndicatorView.swift */,
04BE392F2CF964F800BD31DB /* YHProductItemView.swift */, 04BE392F2CF964F800BD31DB /* YHProductItemView.swift */,
04BE39532CFEA62000BD31DB /* YHAICardItemView.swift */,
04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */, 04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */,
04BE39432CFAB46100BD31DB /* YHAIChatBannerView.swift */, 04BE39432CFAB46100BD31DB /* YHAIChatBannerView.swift */,
04BE39452CFAB5F100BD31DB /* YHAIChatBannerItemCell.swift */, 04BE39452CFAB5F100BD31DB /* YHAIChatBannerItemCell.swift */,
...@@ -5921,6 +5927,7 @@ ...@@ -5921,6 +5927,7 @@
04F2434B2C9BB70300DF2C74 /* YHHKRecordsSummaryItemCell.swift in Sources */, 04F2434B2C9BB70300DF2C74 /* YHHKRecordsSummaryItemCell.swift in Sources */,
046A95312C6EFB980059326A /* YHFamilyMemberRiskWarningAlertView.swift in Sources */, 046A95312C6EFB980059326A /* YHFamilyMemberRiskWarningAlertView.swift in Sources */,
A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */, A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */,
04BE39582CFED3F700BD31DB /* YHAIHistoryMessage.swift in Sources */,
A5ACE9452B4564F7002C94D2 /* YHHUDContainerView.swift in Sources */, A5ACE9452B4564F7002C94D2 /* YHHUDContainerView.swift in Sources */,
04912F642CB6885D00CC3105 /* YHResignFamilyMemberInfoCell.swift in Sources */, 04912F642CB6885D00CC3105 /* YHResignFamilyMemberInfoCell.swift in Sources */,
045EEEFD2B9F171A0022A143 /* YHSheetPickerViewType.swift in Sources */, 045EEEFD2B9F171A0022A143 /* YHSheetPickerViewType.swift in Sources */,
...@@ -6379,6 +6386,7 @@ ...@@ -6379,6 +6386,7 @@
04CE1AD72C2AD91F001CB80A /* YHActivityDetailViewController.swift in Sources */, 04CE1AD72C2AD91F001CB80A /* YHActivityDetailViewController.swift in Sources */,
045EEE9E2B9F171A0022A143 /* YHWorkExampleModel.swift in Sources */, 045EEE9E2B9F171A0022A143 /* YHWorkExampleModel.swift in Sources */,
045EEE8A2B9F171A0022A143 /* YHPreviewOtherInformationViewController.swift in Sources */, 045EEE8A2B9F171A0022A143 /* YHPreviewOtherInformationViewController.swift in Sources */,
04BE39542CFEA62000BD31DB /* YHAICardItemView.swift in Sources */,
04F2433B2C9ACED700DF2C74 /* YHHKRecordsSummaryVC.swift in Sources */, 04F2433B2C9ACED700DF2C74 /* YHHKRecordsSummaryVC.swift in Sources */,
044F39402CB7CB6B007CA277 /* YHVisaRenewalTroubleshootingGuideVC.swift in Sources */, 044F39402CB7CB6B007CA277 /* YHVisaRenewalTroubleshootingGuideVC.swift in Sources */,
043D2C8A2C0EEF3F00172438 /* YHOrderSearchViewController.swift in Sources */, 043D2C8A2C0EEF3F00172438 /* YHOrderSearchViewController.swift in Sources */,
......
...@@ -17,8 +17,6 @@ import SensorsAnalyticsSDK ...@@ -17,8 +17,6 @@ import SensorsAnalyticsSDK
import AGConnectCore import AGConnectCore
import AGConnectCredential import AGConnectCredential
import AGConnectAppLinking import AGConnectAppLinking
import LLDebugToolSwift
import LLDebugTool
@main @main
class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
...@@ -26,11 +24,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { ...@@ -26,11 +24,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Thread.sleep(forTimeInterval: 0.5) // 应产品同学Nick要求 启动页时间展示长点 Thread.sleep(forTimeInterval: 0.5) // 应产品同学Nick要求 启动页时间展示长点
#if DEBUG
LLDebugTool.shared().startWorking()
#else
#endif
setupAudionConfig() setupAudionConfig()
//初始化 神策sdk //初始化 神策sdk
......
...@@ -46,29 +46,23 @@ class YHAIChatConfiguration { ...@@ -46,29 +46,23 @@ class YHAIChatConfiguration {
} else if msgType == .productList { } else if msgType == .productList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHProductListMessageCell let cell = tableView.dequeueReusableCell(withIdentifier: YHProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHProductListMessageCell
if let listModel = msg.body.getProductList() { if let listModel = msg.body.cardsInfo {
cell.listModel = listModel cell.listModel = listModel
} }
return cell return cell
} else if msgType == .fixProductList { } else if msgType == .fixProductList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFixProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHFixProductListMessageCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFixProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHFixProductListMessageCell
if let listModel = msg.body.getFixProductList() { if let listModel = msg.body.cardsInfo {
cell.listModel = listModel cell.listModel = listModel
} }
return cell return cell
} else if msgType == .cardList { } else if msgType == .cardList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as! YHCardMessageCell let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as! YHCardMessageCell
return cell if let listModel = msg.body.cardsInfo {
cell.cardListModel = listModel
} else { }
print("无法识别该消息,请升级APP版本")
print("contentType: \(msg)")
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
msg.body.contentType = YHMessageType.none.rawValue
msg.body.contentText = "无法识别该消息,请升级APP版本"
cell.message = msg
return cell return cell
} }
......
...@@ -126,10 +126,6 @@ class YHAIMainChatViewController: YHBaseViewController { ...@@ -126,10 +126,6 @@ class YHAIMainChatViewController: YHBaseViewController {
if done { if done {
print("RESPONSE-DONE") print("RESPONSE-DONE")
self.bottomInputView.status = self.bottomInputView.textView.text.isEmpty ? .disableSend : .enableSend self.bottomInputView.status = self.bottomInputView.textView.text.isEmpty ? .disableSend : .enableSend
let dbMsgs = messages.map {
return YHAIChatDBMessage.createMessage($0)
}
YHAIChatDataBaseManager.shared.addDBMessages(dbMsgs)
} }
self.scrollToBottom() self.scrollToBottom()
} }
......
...@@ -15,9 +15,11 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -15,9 +15,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
var robotId: String = "" var robotId: String = ""
var conversationId: String = "" var conversationId: String = ""
var messages:[YHAIChatMessage] = [] var messages:[YHAIChatMessage] = []
var historyLastMessageId: String = ""
let manager = YHAIRequestManager() let manager = YHAIRequestManager()
let viewModel = YHAIViewModel()
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped) let tableView = UITableView(frame:.zero, style:.grouped)
...@@ -33,6 +35,9 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -33,6 +35,9 @@ class YHAIRobotChatViewController: YHBaseViewController {
tableView.delegate = self tableView.delegate = self
tableView.dataSource = self tableView.dataSource = self
YHAIChatConfiguration.defaultConfig.registerMessageGroupCells(tableView) YHAIChatConfiguration.defaultConfig.registerMessageGroupCells(tableView)
tableView.es.addYHPullToRefresh {
self.getHistoryMessages(false)
}
return tableView return tableView
}() }()
...@@ -81,8 +86,6 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -81,8 +86,6 @@ class YHAIRobotChatViewController: YHBaseViewController {
IQKeyboardManager.shared.enable = false IQKeyboardManager.shared.enable = false
view.backgroundColor = .clear view.backgroundColor = .clear
view.addSubview(bgImgView) view.addSubview(bgImgView)
let historyMsgs = YHAIChatDataBaseManager.shared.readHistoryUIMessages()
messages.append(contentsOf: historyMsgs)
gk_navTitle = "新港生活规划师" gk_navTitle = "新港生活规划师"
gk_navTitleColor = .mainTextColor gk_navTitleColor = .mainTextColor
...@@ -109,6 +112,8 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -109,6 +112,8 @@ class YHAIRobotChatViewController: YHBaseViewController {
bottomInputView.snp.makeConstraints { make in bottomInputView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
} }
getHistoryMessages(true)
} }
func scrollToBottom() { func scrollToBottom() {
...@@ -135,18 +140,27 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -135,18 +140,27 @@ class YHAIRobotChatViewController: YHBaseViewController {
if done { if done {
print("RESPONSE-DONE") print("RESPONSE-DONE")
self.bottomInputView.status = self.bottomInputView.textView.text.isEmpty ? .disableSend : .enableSend self.bottomInputView.status = self.bottomInputView.textView.text.isEmpty ? .disableSend : .enableSend
let dbMsgs = messages.map {
return YHAIChatDBMessage.createMessage($0)
}
messages.map {
print("-----------------7")
print("\($0)")
}
// YHAIChatDataBaseManager.shared.addDBMessages(dbMsgs)
} }
self.scrollToBottom() self.scrollToBottom()
} }
} }
func getHistoryMessages(_ isLoading: Bool) {
if isLoading {
YHHUD.show(.progress(message: "加载中..."))
}
viewModel.getHistoryChatMessages(boltId: robotId, conversationId: conversationId, messageId: historyLastMessageId) {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
messages.removeAll()
let results = self.viewModel.historyMessages.map {
return $0.convertToChatMessage()
}
messages.append(contentsOf: results)
self.tableView.reloadData()
}
}
} }
extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSource { extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSource {
......
//
// YHAIHistoryMessage.swift
// galaxy
//
// Created by Dufet on 2024/12/3.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHAIHistoryMessage: SmartCodable {
var botId: String = ""
var chatId: String = ""
var contentText: String = ""
var contentType: Int = 0
var messageId: String = ""
var role: String = ""
var type: String = ""
required init() {
}
func convertToChatMessage() -> YHAIChatMessage {
let msg = YHAIChatMessage()
msg.uuid = self.messageId
let body = YHAIMessageBody()
body.contentType = self.contentType
body.contentText = self.contentText
body.botId = self.botId
body.chatId = self.chatId
body.type = self.type
msg.body = body
msg.setFinished()
msg.updateBodyToData()
return msg
}
}
...@@ -99,7 +99,6 @@ class YHAIChatMessage: CustomStringConvertible { ...@@ -99,7 +99,6 @@ class YHAIChatMessage: CustomStringConvertible {
} }
func dicToJSONString(dict: [String: Any]) -> String { func dicToJSONString(dict: [String: Any]) -> String {
if let jsonData = try? JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted) { if let jsonData = try? JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted) {
return String(data: jsonData, encoding: .utf8) ?? "" return String(data: jsonData, encoding: .utf8) ?? ""
...@@ -148,19 +147,19 @@ class YHAIChatMessage: CustomStringConvertible { ...@@ -148,19 +147,19 @@ class YHAIChatMessage: CustomStringConvertible {
} }
var description: String { var description: String {
return "uudi:\(uuid)\n, id: \(id)\n, event: \(event)\n, data: \(data)\n dataDict: \(dataDict)\n dataBody: \(body)\n \n" return "uudi:\(uuid)\n id: \(id)\n event: \(event)\n data:\(data)\n \n"
} }
} }
class YHAIMessageBody: SmartCodable, CustomStringConvertible { class YHAIMessageBody: SmartCodable {
// {"contentType":1, "contentText":"11月爆款楼盘。", "botId":"7441190609433755702", "status":"delta", "type":"answer", "chatId":"7442585762052194356"
var contentType: Int = 0 var contentType: Int = 0
var contentText: String = "" var contentText: String = ""
var chatId: String = ""
var botId: String = "" var botId: String = ""
var status: String = "" var status: String = ""
var type: String = "" var type: String = ""
var chatId: String = "" var cardsInfo: YHAIListinfoModel?
func isStart() -> Bool { func isStart() -> Bool {
if status == "start" { if status == "start" {
...@@ -175,90 +174,44 @@ class YHAIMessageBody: SmartCodable, CustomStringConvertible { ...@@ -175,90 +174,44 @@ class YHAIMessageBody: SmartCodable, CustomStringConvertible {
} }
return false return false
} }
var productListModel: YHProductListModel = YHProductListModel()
func getProductList() -> YHProductListModel? {
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.productList.rawValue {
if let productList = YHProductListModel.deserialize(from: dict) {
return productList
}
}
}
} catch {
}
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
}
func getCardList() -> 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.cardList.rawValue {
if let productList = YHFixProductListModel.deserialize(from: dict) {
return productList
}
}
}
} catch {
}
return nil
}
required init() { required init() {
} }
var description: String { // var description: String {
return "contentType:\(contentType)\n, contentText: \(contentText)\n, type: \(type)\n, status: \(status))\n" // return "contentType:\(contentType)\n contentText: \(contentText)\n type: \(type)\n status: \(status))\n"
} // }
} }
class YHProductListModel: SmartCodable { class YHAIListinfoModel: SmartCodable {
var icon: String = ""
var title: String = "" var title: String = ""
var icon: String = ""
var description: String = "" var description: String = ""
var btn_text: String = "" var btnText: String = ""
var redirect_mode: Int = 0 var list: [YHAIListItemModel] = []
var redirect_path: String = "" var redirectMode: Int = 0
var list: [YHProductItemModel] = [] var redirectPath: String = ""
var businessType: String = ""
// 是否是测评
func isEvaluation() -> Bool {
return businessType == "evaluation"
}
required init() { required init() {
} }
} }
class YHProductItemModel: SmartCodable { class YHAIListItemModel: SmartCodable {
var title: String = "" var title: String = ""
var cover: String = "" var cover: String = ""
var redirect_mode: Int = 0 var description: String = ""
var redirect_path: String = "" var redirectMode: Int = 0
var redirectPath: String = ""
var tags: [YHProductTag] = [] var tags: [YHProductTag] = []
var original_price: Int = 0 var original_price: Int = 0
var discount_price: Int = 0 var discount_price: Int = 0
...@@ -278,48 +231,7 @@ class YHProductTag: SmartCodable { ...@@ -278,48 +231,7 @@ 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 YHCardListModel: 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() {
}
}
...@@ -14,6 +14,7 @@ class YHAIViewModel: NSObject { ...@@ -14,6 +14,7 @@ class YHAIViewModel: NSObject {
var listModel: YHAIListModel = YHAIListModel() var listModel: YHAIListModel = YHAIListModel()
var sessionId: String = "" var sessionId: String = ""
var historyMessages: [YHAIHistoryMessage] = []
func getAIEntranceList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) { func getAIEntranceList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
...@@ -69,5 +70,39 @@ class YHAIViewModel: NSObject { ...@@ -69,5 +70,39 @@ class YHAIViewModel: NSObject {
callBackBlock(false,err) callBackBlock(false,err)
} }
} }
func getHistoryChatMessages(boltId: String, conversationId: String, messageId: String, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.AIChat.chatHistory
let params:[String : Any] = [
"boltId" : boltId,
"conversationId" : conversationId,
"messageId" : messageId
]
let _ = YHNetRequest.getRequest(url: strUrl, params:params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [Any], let arr = [YHAIHistoryMessage].deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false, err)
return
}
self.historyMessages = arr
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)
}
}
} }
//
// YHAICardItemView.swift
// galaxy
//
// Created by Dufet on 2024/12/3.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAICardItemView: UIView {
var cardModel = YHAIListItemModel() {
didSet {
cardImgView.sd_setImage(with: URL(string: cardModel.cover), placeholderImage: UIImage(named: "global_default_image"))
cardTitleLabel.text = cardModel.title
describeLabel.text = cardModel.description
}
}
lazy var lineView: UIView = {
let v = UIView()
v.backgroundColor = .init(hex: 0xE9ECF0)
return v
}()
lazy var cardImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: "global_default_image"))
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 = "卡片描述文字"
return lable
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func createUI() {
self.addSubview(lineView)
self.addSubview(cardImgView)
self.addSubview(cardTitleLabel)
self.addSubview(describeLabel)
lineView.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(0)
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)
make.bottom.equalTo(-16)
}
}
}
...@@ -89,7 +89,6 @@ class YHAIChatCustomFlowLayout: UICollectionViewFlowLayout { ...@@ -89,7 +89,6 @@ class YHAIChatCustomFlowLayout: UICollectionViewFlowLayout {
guard let _ = collectionView else { return .zero } guard let _ = collectionView else { return .zero }
let width = max(firstLineX, secondLineX) let width = max(firstLineX, secondLineX)
let size = CGSize(width: width, height: cellHeight*2.0 + verticalGap) let size = CGSize(width: width, height: cellHeight*2.0 + verticalGap)
print("XXXX:\(size)")
return size return size
} }
......
...@@ -11,6 +11,38 @@ import UIKit ...@@ -11,6 +11,38 @@ import UIKit
class YHCardMessageCell: UITableViewCell { class YHCardMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHCardMessageCell" static let cellReuseIdentifier = "YHCardMessageCell"
var cardListModel = YHAIListinfoModel() {
didSet {
iconImgView.sd_setImage(with: URL(string: cardListModel.icon))
titleLabel.text = cardListModel.title
subtitleLabel.text = cardListModel.description
bottomBtn.setTitle(cardListModel.title, for: .normal)
listView.removeSubviews()
var lastItemView:YHAICardItemView? = nil
for (index, item) in cardListModel.list.enumerated() {
let productView = YHAICardItemView()
productView.cardModel = 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)
}
if index == cardListModel.list.count-1 {
make.bottom.equalTo(0)
}
}
lastItemView = productView
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
var whiteContentView: UIView = { var whiteContentView: UIView = {
let v = UIView() let v = UIView()
...@@ -43,40 +75,14 @@ class YHCardMessageCell: UITableViewCell { ...@@ -43,40 +75,14 @@ class YHCardMessageCell: UITableViewCell {
return lable return lable
}() }()
lazy var lineView: UIView = { lazy var listView: UIView = {
let v = UIView() let v = UIView()
v.backgroundColor = .init(hex: 0xE9ECF0)
return v 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 = { lazy var bottomBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setTitle("预约到访", for: .normal) btn.setTitle("", for: .normal)
btn.setTitleColor(UIColor.white, for: .normal) btn.setTitleColor(UIColor.white, for: .normal)
btn.backgroundColor = .brandMainColor btn.backgroundColor = .brandMainColor
btn.titleLabel?.font = .PFSC_M(ofSize: 14) btn.titleLabel?.font = .PFSC_M(ofSize: 14)
...@@ -114,10 +120,7 @@ class YHCardMessageCell: UITableViewCell { ...@@ -114,10 +120,7 @@ class YHCardMessageCell: UITableViewCell {
whiteContentView.addSubview(iconImgView) whiteContentView.addSubview(iconImgView)
whiteContentView.addSubview(titleLabel) whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(subtitleLabel) whiteContentView.addSubview(subtitleLabel)
whiteContentView.addSubview(lineView) whiteContentView.addSubview(listView)
whiteContentView.addSubview(cardImgView)
whiteContentView.addSubview(cardTitleLabel)
whiteContentView.addSubview(describeLabel)
whiteContentView.addSubview(bottomBtn) whiteContentView.addSubview(bottomBtn)
shadowView.snp.makeConstraints { make in shadowView.snp.makeConstraints { make in
...@@ -152,34 +155,13 @@ class YHCardMessageCell: UITableViewCell { ...@@ -152,34 +155,13 @@ class YHCardMessageCell: UITableViewCell {
make.right.equalTo(-16) make.right.equalTo(-16)
} }
lineView.snp.makeConstraints { make in listView.snp.makeConstraints { make in
make.left.equalTo(16) make.left.right.equalToSuperview()
make.right.equalTo(-16)
make.top.equalTo(subtitleLabel.snp.bottom).offset(10) 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 bottomBtn.snp.makeConstraints { make in
make.top.equalTo(describeLabel.snp.bottom).offset(16) make.top.equalTo(listView.snp.bottom).offset(0)
make.left.equalTo(16) make.left.equalTo(16)
make.right.equalTo(-16) make.right.equalTo(-16)
make.bottom.equalTo(-16) make.bottom.equalTo(-16)
......
...@@ -10,7 +10,7 @@ import AttributedString ...@@ -10,7 +10,7 @@ import AttributedString
class YHFixProductItemView: UIView { class YHFixProductItemView: UIView {
var productModel = YHFixProductItemModel() { var productModel = YHAIListItemModel() {
didSet { didSet {
iconImgView.sd_setImage(with: URL(string: productModel.cover), placeholderImage: UIImage(named: "")) iconImgView.sd_setImage(with: URL(string: productModel.cover), placeholderImage: UIImage(named: ""))
titleLabel.text = productModel.title titleLabel.text = productModel.title
...@@ -59,10 +59,10 @@ class YHFixProductItemView: UIView { ...@@ -59,10 +59,10 @@ class YHFixProductItemView: UIView {
} }
@objc func didClickProductItem() { @objc func didClickProductItem() {
if !productModel.redirect_path.isEmpty { if !productModel.redirectPath.isEmpty {
let vc = YHH5WebViewVC() let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false vc.isFullScreenFlag = false
vc.url = productModel.redirect_path vc.url = productModel.redirectPath
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
} }
} }
......
...@@ -11,7 +11,7 @@ class YHFixProductListMessageCell: UITableViewCell { ...@@ -11,7 +11,7 @@ class YHFixProductListMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHFixProductMessageCell" static let cellReuseIdentifier = "YHFixProductMessageCell"
var listModel = YHFixProductListModel() { var listModel = YHAIListinfoModel() {
didSet { didSet {
iconImgView.sd_setImage(with: URL(string: listModel.icon)) iconImgView.sd_setImage(with: URL(string: listModel.icon))
titleLabel.text = listModel.title titleLabel.text = listModel.title
...@@ -110,10 +110,10 @@ class YHFixProductListMessageCell: UITableViewCell { ...@@ -110,10 +110,10 @@ class YHFixProductListMessageCell: UITableViewCell {
@objc func didMoreButtonClicked() { @objc func didMoreButtonClicked() {
if !listModel.redirect_path.isEmpty { if !listModel.redirectPath.isEmpty {
let vc = YHH5WebViewVC() let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false vc.isFullScreenFlag = false
vc.url = listModel.redirect_path vc.url = listModel.redirectPath
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
} }
} }
......
...@@ -11,7 +11,7 @@ import AttributedString ...@@ -11,7 +11,7 @@ import AttributedString
class YHProductItemView: UIView { class YHProductItemView: UIView {
var productModel = YHProductItemModel() { var productModel = YHAIListItemModel() {
didSet { didSet {
iconImgView.sd_setImage(with: URL(string: productModel.cover), placeholderImage: UIImage(named: "global_default_image")) iconImgView.sd_setImage(with: URL(string: productModel.cover), placeholderImage: UIImage(named: "global_default_image"))
titleLabel.text = productModel.title titleLabel.text = productModel.title
...@@ -87,10 +87,10 @@ class YHProductItemView: UIView { ...@@ -87,10 +87,10 @@ class YHProductItemView: UIView {
} }
@objc func didClickProductItem() { @objc func didClickProductItem() {
if !productModel.redirect_path.isEmpty { if !productModel.redirectPath.isEmpty {
let vc = YHH5WebViewVC() let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false vc.isFullScreenFlag = false
vc.url = productModel.redirect_path vc.url = productModel.redirectPath
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
} }
} }
......
...@@ -12,7 +12,7 @@ class YHProductListMessageCell: UITableViewCell { ...@@ -12,7 +12,7 @@ class YHProductListMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHProductListMessageCell" static let cellReuseIdentifier = "YHProductListMessageCell"
var listModel = YHProductListModel() { var listModel = YHAIListinfoModel() {
didSet { didSet {
iconImgView.sd_setImage(with: URL(string: listModel.icon)) iconImgView.sd_setImage(with: URL(string: listModel.icon))
titleLabel.text = listModel.title titleLabel.text = listModel.title
...@@ -111,10 +111,10 @@ class YHProductListMessageCell: UITableViewCell { ...@@ -111,10 +111,10 @@ class YHProductListMessageCell: UITableViewCell {
@objc func didMoreButtonClicked() { @objc func didMoreButtonClicked() {
if !listModel.redirect_path.isEmpty { if !listModel.redirectPath.isEmpty {
let vc = YHH5WebViewVC() let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false vc.isFullScreenFlag = false
vc.url = listModel.redirect_path vc.url = listModel.redirectPath
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
} }
} }
......
...@@ -665,6 +665,7 @@ class YHAllApiName { ...@@ -665,6 +665,7 @@ class YHAllApiName {
static let agentChat = "super-app/ai/agent/chat" static let agentChat = "super-app/ai/agent/chat"
static let getAIChatSessionId = "super-app/ai/agent/conversation" static let getAIChatSessionId = "super-app/ai/agent/conversation"
static let cancelAIChat = "super-app/ai/agent/chat-cancel" static let cancelAIChat = "super-app/ai/agent/chat-cancel"
static let chatHistory = "super-app/ai/agent/chat-details"
} }
} }
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