Commit 226cad21 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 415fa600
......@@ -17,7 +17,8 @@ class YHAIRobotChatViewController: YHBaseViewController {
var conversationId: String = ""
var messages:[YHAIChatMessage] = []
var historyLastMessageId: String = ""
var isNeedShowBannerHeader: Bool = false
var robotType: Int = 0
let manager = YHAIRequestManager()
let viewModel = YHAIViewModel()
......@@ -225,16 +226,12 @@ class YHAIRobotChatViewController: YHBaseViewController {
func getFlowMessages() -> [String] {
return ["大学升学", "银河教育服务", "DES分数和Alevel的换算关系", "银河教育插班成功率如何?"]
if robotType == YHAYRobotType.education.rawValue {
return ["香港教育有哪些优势?", "去香港读书有哪些条件?", "申请香港学校费用是多少?", "了解银河教育插班服务流程", "了解银河教育插班录取率"]
if myTitle == "房产" {
return ["大学升学", "银河教育服务", "DES分数和Alevel的换算关系", "银河教育插班成功率如何?"]
} else if myTitle == "教育" {
return ["大学升学", "银河教育服务", "DES分数和Alevel的换算关系", "银河教育插班成功率如何?"]
} else if robotType == YHAYRobotType.sale.rawValue {
return ["优才学历加分要求是什么?", "优才现在要怎么申请?", "墨尔本大学是优才合资格大学吗?", "推荐一些优才产品"]
} else if myTitle == "销售" {
return ["大学升学", "银河教育服务", "DES分数和Alevel的换算关系", "银河教育插班成功率如何?"]
}
return []
}
......@@ -334,13 +331,13 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if !isNeedShowBannerHeader {
return UIView()
}
let view = YHAIChatBannerView()
let arr:[YHAIChatBannerItem] = [YHAIChatBannerItem(id: 0, title: "了解银河集团", desc: "香港身份生活一站式服务平台"),
YHAIChatBannerItem(id: 1, title: "香港身份智能评估", desc: "60s快速评估,了解自身条件是否符合"),
YHAIChatBannerItem(id: 2, title: "银河产品矩阵", desc: "香港身份、生活多样产品"),]
view.dataArr = arr
view.items = getFlowMessages()
view.bannerArr = self.getBannerForRobotType(robotType)
view.messages = getFlowMessages()
view.selectFlowMsgBlock = {
[weak self] text in
guard let self = self else { return }
......@@ -350,14 +347,11 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
[weak self] model in
guard let self = self else { return }
var text = ""
if model.id == 0 {
text = "银河集团,能够为我提供什么?"
} else if model.id == 1 {
text = "开始身份办理评估"
if !model.msg.isEmpty {
text = model.msg
} else if model.id == 2 {
text = "介绍一下银河的产品"
} else if !model.desc.isEmpty {
text = model.desc
}
self.sendMessage(text)
......@@ -365,15 +359,32 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return view
}
func getBannerForRobotType(_ robotType: Int) -> [YHAIChatBannerItem] {
if robotType == YHAYRobotType.sale.rawValue {
return [YHAIChatBannerItem(id: 0, title: "了解银河集团", desc: "香港身份生活一站式服务平台", msg: "银河集团,能够为我提供什么?"),
YHAIChatBannerItem(id: 1, title: "香港身份智能评估", desc: "60s快速评估,了解自身条件是否符合", msg: "开始身份办理评估"),
YHAIChatBannerItem(id: 2, title: "银河产品矩阵", desc: "香港身份、生活多样产品", msg: "介绍一下银河的产品"),]
}
if robotType == YHAYRobotType.education.rawValue {
return [YHAIChatBannerItem(id: 0, title: "幼中小学升学", desc: "去香港插班需要考核哪些"),
YHAIChatBannerItem(id: 1, title: "大学升学", desc: "DSE分数和Alevel的换算关系"),
YHAIChatBannerItem(id: 2, title: "银河教育服务", desc: "银河教育插班成功率如何?"),]
}
return []
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView()
return view
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if !isNeedShowBannerHeader {
return 1.0
}
return 360.0
}
}
extension YHAIRobotChatViewController: JXSegmentedListContainerViewListDelegate {
......
......@@ -143,9 +143,11 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
self.manager.getSubRobotChatConversationId(robotId: model.botId) {
sesseionId in
let vc = YHAIRobotChatViewController()
vc.isNeedShowBannerHeader = model.isNeedShowBannerHeader()
vc.myTitle = model.title
vc.robotId = model.botId
vc.conversationId = sesseionId
vc.robotType = model.bot_type
self.navigationController?.pushViewController(vc, animated: true)
}
}
......
......@@ -19,7 +19,7 @@ class YHAIHistoryMessage: SmartCodable {
var role: String = ""
var type: String = ""
var cardsInfo: YHAIListinfoModel?
var cardsInfo: YHAIListInfoModel?
required init() {
......
......@@ -19,6 +19,12 @@ class YHAIListModel: SmartCodable {
}
}
enum YHAYRobotType: Int {
case house = 1
case education = 2
case sale = 3
}
class YHEntranceconfigModel: SmartCodable {
var id: Int = 0
......@@ -29,8 +35,16 @@ class YHEntranceconfigModel: SmartCodable {
var btnText: String = ""
var redirectMode: Int = 0
var botId: String = ""
var bot_type: Int = 0 // 1:房产 2:教育 3:销售
var redirectPath: String = ""
func isNeedShowBannerHeader() -> Bool {
if bot_type == YHAYRobotType.education.rawValue || bot_type == YHAYRobotType.sale.rawValue {
return true
}
return false
}
required init() {
}
......
......@@ -186,7 +186,7 @@ class YHAIMessageBody: SmartCodable {
var botId: String = ""
var status: String = ""
var type: String = ""
var cardsInfo: YHAIListinfoModel?
var cardsInfo: YHAIListInfoModel?
var imageInfo: YHAIImageInfo?
func isStart() -> Bool {
......@@ -217,7 +217,7 @@ enum YHAIJumpPageType: String {
case galaxySelect = "productList" // APP-首页银河甄选
}
class YHAIListinfoModel: SmartCodable {
class YHAIListInfoModel: SmartCodable {
var title: String = ""
var icon: String = ""
......@@ -245,7 +245,8 @@ class YHAIListItemModel: SmartCodable {
var title: String = ""
var cover: String = ""
var description: String = ""
var redirectMode: Int = 0
var redirectMode: Int = 0 // 跳转模式 0: 不跳转 1:web页面跳转 2:APP跳转 3:Agent跳转
// customerVoice -> APP客户心声 productList -> APP-首页银河甄选
var redirectPath: String = ""
var tags: [YHProductTag] = []
var originalPrice: Int = 0
......
......@@ -60,6 +60,9 @@ class YHAICardItemView: UIView {
func createUI() {
let tap = UITapGestureRecognizer(target: self, action: #selector(didItemViewClicked))
self.addGestureRecognizer(tap)
self.addSubview(lineView)
self.addSubview(cardImgView)
self.addSubview(cardTitleLabel)
......@@ -91,6 +94,12 @@ class YHAICardItemView: UIView {
make.right.equalTo(-16)
make.bottom.equalTo(-16)
}
}
@objc func didItemViewClicked() {
YHAIJumpPageTool.jumpPageWithType(0, mode: cardModel.redirectMode, path: cardModel.redirectPath) {
dict in
}
}
}
......@@ -13,11 +13,13 @@ class YHAIChatBannerItem {
var id: Int = 0
var title: String = ""
var desc: String = ""
required init(id: Int = 0, title: String = "", desc: String = "") {
var msg: String = ""
required init(id: Int = 0, title: String = "", desc: String = "", msg: String = "") {
self.id = id
self.title = title
self.desc = desc
self.msg = msg
}
}
......@@ -28,9 +30,9 @@ class YHAIChatBannerView: UIView {
var selectFlowMsgBlock:((String)->())?
var selectBannerItemBlock:((YHAIChatBannerItem)->())?
var items:[String] = [] {
var messages:[String] = [] {
didSet {
layout.dataSource = items
layout.dataSource = messages
collectionView.reloadData()
}
}
......@@ -59,11 +61,11 @@ class YHAIChatBannerView: UIView {
return imagV
}()
var dataArr: [YHAIChatBannerItem] = [] {
var bannerArr: [YHAIChatBannerItem] = [] {
didSet {
// 设置为0是先停掉自动滑动定时器
bannerView.automaticSlidingInterval = 0
self.indicatorView.indicatorItems = self.dataArr.count
self.indicatorView.indicatorItems = self.bannerArr.count
bannerView.reloadData()
// 指定指示器为第一个
self.indicatorView.curIndicatorIndex = 0
......@@ -191,13 +193,13 @@ class YHAIChatBannerView: UIView {
extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.dataArr.count
return self.bannerArr.count
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier, at: index) as! YHAIChatBannerItemCell
if index < dataArr.count {
let model = dataArr[index]
if index < bannerArr.count {
let model = bannerArr[index]
cell.model = model
}
return cell
......@@ -207,8 +209,8 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
pagerView.scrollToItem(at: index, animated: true)
if 0 <= index, index < dataArr.count {
let model = dataArr[index]
if 0 <= index, index < bannerArr.count {
let model = bannerArr[index]
selectBannerItemBlock?(model)
return
}
......@@ -228,7 +230,7 @@ extension YHAIChatBannerView: UICollectionViewDelegate, UICollectionViewDataSour
// 返回单元格数量
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
return messages.count
}
// 返回每个单元格的大小
......@@ -240,15 +242,15 @@ extension YHAIChatBannerView: UICollectionViewDelegate, UICollectionViewDataSour
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerCollectionCell.cellReuseIdentifier, for: indexPath) as! YHAIChatBannerCollectionCell
if 0 <= indexPath.item && indexPath.item < items.count {
cell.titleLabel.text = items[indexPath.item]
if 0 <= indexPath.item && indexPath.item < messages.count {
cell.titleLabel.text = messages[indexPath.item]
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < items.count {
let text = items[indexPath.item]
if 0 <= indexPath.item && indexPath.item < messages.count {
let text = messages[indexPath.item]
selectFlowMsgBlock?(text)
}
}
......
......@@ -8,13 +8,56 @@
import UIKit
class YHAIJumpPageTool {
// type = 0 // 0 普通 1 测评
static func jumpPageWithType(_ type:Int = 0, mode: Int, path: String, block:(([String:Any])->())?) {
printLog("type:\(type) mdde:\(mode) path:\(path)")
if mode == 1 { //
if !path.isEmpty {
let vc = YHH5WebViewVC()
vc.url = path
if type == 1 {
vc.isPushed = false
vc.isFullScreenFlag = true
vc.isHideNavigationBar = true
vc.evaluationResultCallback = {
dict in
block?(dict)
UIViewController.current?.present(vc, animated: true)
}
} else {
UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
}
}
} else if mode == 2 {
// customerVoice -> APP客户心声 productList -> APP-首页银河甄选
if path == YHAIJumpPageType.customerHeart.rawValue {
//客户心声
let vc = YHOtherServiceViewController()
vc.classID = 5
UIViewController.current?.navigationController?.pushViewController(vc)
} else if path == YHAIJumpPageType.galaxySelect.rawValue {
// 银河甄选
let vc = YHSelectViewController()
vc.hideFlag = false
UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
}
}
}
}
class YHCardMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHCardMessageCell"
var evaluationResultCallback: ((Dictionary<String, Any>)->()) = { dic in }
var cardListModel = YHAIListinfoModel() {
var cardListModel = YHAIListInfoModel() {
didSet {
iconImgView.sd_setImage(with: URL(string: cardListModel.icon))
titleLabel.text = cardListModel.title
......@@ -99,17 +142,14 @@ class YHCardMessageCell: UITableViewCell {
}()
@objc func didBottomButtonClicked() {
if !cardListModel.redirectPath.isEmpty {
let vc = YHH5WebViewVC()
vc.isFullScreenFlag = true
vc.isHideNavigationBar = true
vc.url = cardListModel.redirectPath
vc.evaluationResultCallback = {
[weak self] dict in
guard let self = self else { return }
self.evaluationResultCallback(dict)
}
UIViewController.current?.present(vc, animated: true)
var type = 0
if cardListModel.isEvaluation() {
type = 1
}
YHAIJumpPageTool.jumpPageWithType(type, mode: cardListModel.redirectMode, path: cardListModel.redirectPath) {
dict in
self.evaluationResultCallback(dict)
}
}
......
......@@ -11,7 +11,7 @@ class YHFixProductListMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHFixProductMessageCell"
var listModel = YHAIListinfoModel() {
var listModel = YHAIListInfoModel() {
didSet {
iconImgView.sd_setImage(with: URL(string: listModel.icon))
titleLabel.text = listModel.title
......
......@@ -93,6 +93,10 @@ class YHProductItemView: UIView {
vc.url = productModel.redirectPath
UIViewController.current?.navigationController?.pushViewController(vc)
}
YHAIJumpPageTool.jumpPageWithType(0, mode: productModel.redirectMode, path: productModel.redirectPath) {
dict in
}
}
func createUI() {
......
......@@ -12,7 +12,7 @@ class YHProductListMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHProductListMessageCell"
var listModel = YHAIListinfoModel() {
var listModel = YHAIListInfoModel() {
didSet {
iconImgView.sd_setImage(with: URL(string: listModel.icon))
titleLabel.text = listModel.title
......@@ -111,11 +111,8 @@ class YHProductListMessageCell: UITableViewCell {
@objc func didMoreButtonClicked() {
if !listModel.redirectPath.isEmpty {
let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false
vc.url = listModel.redirectPath
UIViewController.current?.navigationController?.pushViewController(vc)
YHAIJumpPageTool.jumpPageWithType(0, mode: listModel.redirectMode, path: listModel.redirectPath) {
dict in
}
}
......
......@@ -120,6 +120,9 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
//6、是否展示 导航栏上的title
var showNavigationTitleFlag : Bool = true
// 是否push进来
var isPushed : Bool = true
//22、禁用全局手势
private var disableFullScreenGestureFlag : Bool = false
......@@ -519,11 +522,13 @@ extension YHH5WebViewVC {
printLog("web evaluation:\n")
printLog("\(dic)")
self.evaluationResultCallback?(dic)
self.dismiss(animated: true)
} else {
self.dismiss(animated: true)
}
if isPushed {
self.navigationController?.popViewController(animated: true)
} else {
self.dismiss(animated: true)
}
}
//22、禁用全局手势返回
......
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