Commit 11f57f60 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 69698f8a
...@@ -470,6 +470,8 @@ ...@@ -470,6 +470,8 @@
045F28442CF608C100520F19 /* YHAIServiceListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28432CF608C100520F19 /* YHAIServiceListViewController.swift */; }; 045F28442CF608C100520F19 /* YHAIServiceListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28432CF608C100520F19 /* YHAIServiceListViewController.swift */; };
045F28462CF6C47800520F19 /* YHAIProductCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28452CF6C47800520F19 /* YHAIProductCell.swift */; }; 045F28462CF6C47800520F19 /* YHAIProductCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28452CF6C47800520F19 /* YHAIProductCell.swift */; };
045F28482CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */; }; 045F28482CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */; };
045F284A2CF6F5B100520F19 /* YHAIViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F28492CF6F5B100520F19 /* YHAIViewModel.swift */; };
045F284C2CF6F65200520F19 /* YHAIListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045F284B2CF6F65200520F19 /* YHAIListModel.swift */; };
0468D4222B493A5E00CFB916 /* YHPhoneMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */; }; 0468D4222B493A5E00CFB916 /* YHPhoneMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */; };
0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4252B495A5400CFB916 /* YHPickPhoneAddressViewController.swift */; }; 0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4252B495A5400CFB916 /* YHPickPhoneAddressViewController.swift */; };
0468D4282B50D4AF00CFB916 /* YHPrivacyAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4272B50D4AF00CFB916 /* YHPrivacyAlertView.swift */; }; 0468D4282B50D4AF00CFB916 /* YHPrivacyAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4272B50D4AF00CFB916 /* YHPrivacyAlertView.swift */; };
...@@ -1514,6 +1516,8 @@ ...@@ -1514,6 +1516,8 @@
045F28432CF608C100520F19 /* YHAIServiceListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIServiceListViewController.swift; sourceTree = "<group>"; }; 045F28432CF608C100520F19 /* YHAIServiceListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIServiceListViewController.swift; sourceTree = "<group>"; };
045F28452CF6C47800520F19 /* YHAIProductCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIProductCell.swift; sourceTree = "<group>"; }; 045F28452CF6C47800520F19 /* YHAIProductCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIProductCell.swift; sourceTree = "<group>"; };
045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIGreetCollectionReusableView.swift; sourceTree = "<group>"; }; 045F28472CF6EF9800520F19 /* YHAIGreetCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIGreetCollectionReusableView.swift; sourceTree = "<group>"; };
045F28492CF6F5B100520F19 /* YHAIViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIViewModel.swift; sourceTree = "<group>"; };
045F284B2CF6F65200520F19 /* YHAIListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIListModel.swift; sourceTree = "<group>"; };
0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPhoneMessageView.swift; sourceTree = "<group>"; }; 0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPhoneMessageView.swift; sourceTree = "<group>"; };
0468D4252B495A5400CFB916 /* YHPickPhoneAddressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPickPhoneAddressViewController.swift; sourceTree = "<group>"; }; 0468D4252B495A5400CFB916 /* YHPickPhoneAddressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPickPhoneAddressViewController.swift; sourceTree = "<group>"; };
0468D4272B50D4AF00CFB916 /* YHPrivacyAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrivacyAlertView.swift; sourceTree = "<group>"; }; 0468D4272B50D4AF00CFB916 /* YHPrivacyAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrivacyAlertView.swift; sourceTree = "<group>"; };
...@@ -3947,6 +3951,8 @@ ...@@ -3947,6 +3951,8 @@
04943BF02CF4947A00BF2255 /* M */ = { 04943BF02CF4947A00BF2255 /* M */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
045F28492CF6F5B100520F19 /* YHAIViewModel.swift */,
045F284B2CF6F65200520F19 /* YHAIListModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -6154,6 +6160,7 @@ ...@@ -6154,6 +6160,7 @@
A567E5B22BD7643D00D5D5A0 /* YHHomeBannerCollectionViewCell.swift in Sources */, A567E5B22BD7643D00D5D5A0 /* YHHomeBannerCollectionViewCell.swift in Sources */,
0430E68A2C77415D000511E2 /* YHAdopterAddModel.swift in Sources */, 0430E68A2C77415D000511E2 /* YHAdopterAddModel.swift in Sources */,
045EEF082B9F171A0022A143 /* YHBasicInfoCellModel.swift in Sources */, 045EEF082B9F171A0022A143 /* YHBasicInfoCellModel.swift in Sources */,
045F284A2CF6F5B100520F19 /* YHAIViewModel.swift in Sources */,
A59B43C92C491FB100B28379 /* YHH5WebViewVC.swift in Sources */, A59B43C92C491FB100B28379 /* YHH5WebViewVC.swift in Sources */,
0488518F2BF5FD1500C4E32D /* YHOSSManager.swift in Sources */, 0488518F2BF5FD1500C4E32D /* YHOSSManager.swift in Sources */,
A592FE952BA6D23C0062FACA /* YHCertificateEntryCell.swift in Sources */, A592FE952BA6D23C0062FACA /* YHCertificateEntryCell.swift in Sources */,
...@@ -6529,6 +6536,7 @@ ...@@ -6529,6 +6536,7 @@
04B401D92CE6E6C8005C61A9 /* YHIncomeItemOccupyingCell.swift in Sources */, 04B401D92CE6E6C8005C61A9 /* YHIncomeItemOccupyingCell.swift in Sources */,
04B401DA2CE6E6C8005C61A9 /* YHTotalIncomeCell.swift in Sources */, 04B401DA2CE6E6C8005C61A9 /* YHTotalIncomeCell.swift in Sources */,
04EA230E2BB538E9009DA928 /* YHDocumentUploadTableViewCell.swift in Sources */, 04EA230E2BB538E9009DA928 /* YHDocumentUploadTableViewCell.swift in Sources */,
045F284C2CF6F65200520F19 /* YHAIListModel.swift in Sources */,
04256DEA2C73263A00A37BA4 /* YHInfoItemSelectSheetView.swift in Sources */, 04256DEA2C73263A00A37BA4 /* YHInfoItemSelectSheetView.swift in Sources */,
0430E6822C75E068000511E2 /* YHAdopterCardOtherGuideView.swift in Sources */, 0430E6822C75E068000511E2 /* YHAdopterCardOtherGuideView.swift in Sources */,
04174D742BCD5B74000BA46D /* IMAppKey.swift in Sources */, 04174D742BCD5B74000BA46D /* IMAppKey.swift in Sources */,
......
...@@ -11,12 +11,14 @@ import JXSegmentedView ...@@ -11,12 +11,14 @@ import JXSegmentedView
class YHAIServiceListViewController: YHBaseViewController { class YHAIServiceListViewController: YHBaseViewController {
var serviceArr: [String] = ["", "", "", ""] var serviceArr: [YHEntranceconfigModel] = []
let viewModel = YHAIViewModel()
lazy var collectionView: UICollectionView = { lazy var collectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout() let flowLayout = UICollectionViewFlowLayout()
flowLayout.minimumInteritemSpacing = 20.0 flowLayout.minimumInteritemSpacing = 10.0
flowLayout.minimumLineSpacing = 28.0 flowLayout.minimumLineSpacing = 28.0
flowLayout.scrollDirection = .vertical flowLayout.scrollDirection = .vertical
...@@ -37,10 +39,21 @@ class YHAIServiceListViewController: YHBaseViewController { ...@@ -37,10 +39,21 @@ class YHAIServiceListViewController: YHBaseViewController {
view.backgroundColor = .clear view.backgroundColor = .clear
view.addSubview(collectionView) view.addSubview(collectionView)
collectionView.snp.makeConstraints { make in collectionView.snp.makeConstraints { make in
make.left.equalTo(17) make.left.equalTo(16)
make.right.equalTo(-17) make.right.equalTo(-16)
make.top.bottom.equalToSuperview() make.top.bottom.equalToSuperview()
} }
requestList()
}
func requestList() {
viewModel.getAIEntranceList {
[weak self] success, error in
guard let self = self else { return }
serviceArr.removeAll()
serviceArr.append(contentsOf: self.viewModel.listModel.entranceConfig)
self.collectionView.reloadData()
}
} }
} }
...@@ -55,7 +68,7 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV ...@@ -55,7 +68,7 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
// 返回每个单元格的大小 // 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: floor((KScreenWidth-17.0*2.0-20.0)/2.0), height: 178.0) return CGSize(width: floor((KScreenWidth-16.0*2.0-10.0)/2.0), height: 178.0)
} }
// 返回自定义单元格 // 返回自定义单元格
...@@ -63,6 +76,8 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV ...@@ -63,6 +76,8 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIProductCell.cellReuseIdentifier, for: indexPath) as! YHAIProductCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIProductCell.cellReuseIdentifier, for: indexPath) as! YHAIProductCell
if 0 <= indexPath.item && indexPath.item < serviceArr.count { if 0 <= indexPath.item && indexPath.item < serviceArr.count {
let model = serviceArr[indexPath.item]
cell.model = model
// 根据索引设置旋转 // 根据索引设置旋转
cell.rotateToRight(indexPath.item % 2 == 0) cell.rotateToRight(indexPath.item % 2 == 0)
} }
......
//
// YHAIListModel.swift
// galaxy
//
// Created by Dufet on 2024/11/27.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHAIListModel: SmartCodable {
var mainBotId: String = ""
var entranceConfig: [YHEntranceconfigModel] = []
required init() {
}
}
class YHEntranceconfigModel: SmartCodable {
var id: Int = 0
var title: String = ""
var icon: String = ""
var cover: String = ""
var description: String = ""
var btnText: String = ""
var redirectMode: Int = 0
var botId: String = ""
var redirectPath: String = ""
required init() {
}
}
//
// YHAIViewModel.swift
// galaxy
//
// Created by Dufet on 2024/11/27.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAIViewModel: NSObject {
var listModel: YHAIListModel = YHAIListModel()
func getAIEntranceList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.AIChat.aiProductList
let _ = YHNetRequest.getRequest(url: strUrl) { [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? [String : Any], let resultModel = YHAIListModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false,err)
return
}
self.listModel = resultModel
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)
}
}
}
...@@ -12,16 +12,24 @@ class YHAIProductCell: UICollectionViewCell { ...@@ -12,16 +12,24 @@ class YHAIProductCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHAIProductCell" static let cellReuseIdentifier = "YHAIProductCell"
lazy var bgImgView: UIImageView = { var model = YHEntranceconfigModel() {
let v = UIImageView(image: UIImage(named: "")) didSet {
v.layer.cornerRadius = 24.0 titleLabel.text = model.title
v.backgroundColor = .green if !model.btnText.isEmpty {
return v subtitleLabel.text = model.description
}() } else {
subtitleLabel.text = "详细了解银河产品"
}
if !model.btnText.isEmpty {
blackButton.setTitle(model.btnText, for: .normal)
} else {
blackButton.setTitle("去了解", for: .normal)
}
}
}
lazy var iconView: UIImageView = { lazy var bgImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: "")) let v = UIImageView(image: UIImage(named: ""))
v.backgroundColor = .red
return v return v
}() }()
...@@ -81,43 +89,41 @@ class YHAIProductCell: UICollectionViewCell { ...@@ -81,43 +89,41 @@ class YHAIProductCell: UICollectionViewCell {
bgImgView.addSubview(blackButton) bgImgView.addSubview(blackButton)
bgImgView.snp.makeConstraints { make in bgImgView.snp.makeConstraints { make in
make.left.right.bottom.equalTo(0) make.left.equalTo(0)
make.top.equalTo(8) make.right.equalTo(0)
} make.bottom.equalTo(0)
make.top.equalTo(0)
iconView.snp.makeConstraints { make in
make.width.equalTo(74)
make.height.equalTo(58)
make.centerX.equalToSuperview()
make.top.equalTo(-8)
} }
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.left.equalTo(17) make.left.equalTo(22)
make.right.equalTo(-17) make.right.equalTo(-22)
make.top.equalTo(iconView.snp.bottom).offset(27) make.bottom.equalTo(subtitleLabel.snp.top).offset(-3)
make.height.equalTo(20) make.height.equalTo(20)
} }
subtitleLabel.snp.makeConstraints { make in subtitleLabel.snp.makeConstraints { make in
make.left.equalTo(17) make.left.equalTo(22)
make.right.equalTo(-17) make.right.equalTo(-22)
make.top.equalTo(titleLabel.snp.bottom).offset(5) make.bottom.equalTo(blackButton.snp.top).offset(-12)
make.height.equalTo(17)
} }
blackButton.snp.makeConstraints { make in blackButton.snp.makeConstraints { make in
make.left.equalTo(17) make.left.equalTo(22)
make.top.equalTo(subtitleLabel.snp.bottom).offset(11) make.bottom.equalTo(-24)
make.height.equalTo(26) make.height.equalTo(26)
make.width.equalTo(54) make.width.equalTo(54)
} }
} }
func rotateToRight(_ isRotateRight: Bool) { func rotateToRight(_ isRotateRight: Bool) {
let degree = isRotateRight ? 2.0 : -2.0 let degree = isRotateRight ? 2.0 : -2.0
bgImgView.transform = CGAffineTransform(rotationAngle: CGFloat(degree * CGFloat.pi / 180)) // 10 度转换为弧度 let transform = CGAffineTransform(rotationAngle: CGFloat(degree * CGFloat.pi / 180)) // 2 度转换为弧度
titleLabel.transform = transform
subtitleLabel.transform = transform
blackButton.transform = transform
bgImgView.image = UIImage(named: isRotateRight ? "ai_product_left" : "ai_product_right")
} }
} }
...@@ -660,4 +660,10 @@ class YHAllApiName { ...@@ -660,4 +660,10 @@ class YHAllApiName {
static let incomeUpdate = "infoflow/order/income/update" static let incomeUpdate = "infoflow/order/income/update"
} }
struct AIChat {
static let aiProductList = "super-app/ai/agent/entrance"
static let agentChat = "super-app/ai/agent/chat"
static let getAIChatSessionId = "super-app/ai/agent/conversation"
}
} }
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "背景图样例1.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "背景图样例2.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