Feat(云灵AI):县域AI和平台AI逻辑区分

This commit is contained in:
lifizer
2026-06-02 10:50:02 +08:00
parent 758d3a2127
commit e05ceb0f68
9 changed files with 311 additions and 231 deletions
+9 -5
View File
@@ -112,6 +112,10 @@ export default {
keyboardHeight: {
type: Number,
default: 0
},
voiceException: {
type: String,
default: '没有听清您说了什么,请再说一遍'
}
},
data() {
@@ -262,11 +266,11 @@ export default {
fail: err => {
console.log(err)
uni.hideLoading()
_this.$toast('没有听清您说了什么,请再说一遍')
_this.$toast(_this.voiceException)
}
})
} else {
_this.$toast('没有听清您说了什么,请再说一遍')
_this.$toast(_this.voiceException)
}
})
}
@@ -282,7 +286,7 @@ export default {
_this.getTransResultReq()
}).catch(() => {
uni.hideLoading()
_this.$toast('没有听清您说了什么,请再说一遍')
_this.$toast(_this.voiceException)
})
},
getTransResultReq() {
@@ -296,7 +300,7 @@ export default {
uni.hideLoading()
_this.clearIntervalFn()
if (data === '__NULL__') {
_this.$toast('没有听清您说了什么,请再说一遍')
_this.$toast(_this.voiceException)
} else {
if (data.length > 0) {
const prompt = data[0].Text
@@ -308,7 +312,7 @@ export default {
}
}).catch(() => {
uni.hideLoading()
_this.$toast('没有听清您说了什么,请再说一遍')
_this.$toast(_this.voiceException)
})
}, 1000)
},
+18 -3
View File
@@ -112,7 +112,8 @@
<script>
import {
getChatList,
deleteChatListByType
deleteChatListByType,
getCountyAiChatList
} from '@/api/chat/index'
export default {
name: 'AiHistoryList',
@@ -125,6 +126,10 @@ export default {
formModule: {
type: String,
default: ''
},
countyId: {
type: String,
default: ''
}
},
data() {
@@ -142,7 +147,17 @@ export default {
this.getChatListReq()
},
getChatListReq() {
getChatList().then(res => {
let reqFn = null
let params = {}
if (this.countyId) {
reqFn = getCountyAiChatList
params = {
countyId: this.countyId
}
} else {
reqFn = getChatList
}
reqFn(params).then(res => {
const { success, data } = res
if (success) {
this.todayList = data['今天'] || []
@@ -160,7 +175,7 @@ export default {
})
},
historyItemClick(item) {
const paramsStr = `?chatNumber=${item.chatNumber}&title=${item.title}&click=1`
const paramsStr = `?chatNumber=${item.chatNumber}&title=${item.title}&click=1&countyId=${this.countyId}`
if (!this.formModule) {
uni.navigateTo({
url: '/aiChat/views/history' + paramsStr
+85 -62
View File
@@ -3,8 +3,15 @@ import {
getCompletionsV3,
deleteChatItemByConversationId,
// getAnalyzeKeywordsV1,
getAnalyzeKeywordsChangeV3
getAnalyzeKeywordsChangeV3,
getSseCountyAiConfigV1,
getCountyAiCompletionsV1,
getGiftRecommendOptions
} from '@/api/chat/index'
import {
getExceptionConfig,
getBottomNavigationConfigList
} from '@/api/public'
import {
postCartAdd
} from '@/api/store'
@@ -21,35 +28,7 @@ export const chatMixinsV2 = {
token: cookie.get('login_status'),
userInfo: cookie.get('userInfo'),
webUrl: this.$VUE_APP_RESOURCES_URL,
bottomTools: [
{
name: '我要送礼',
icon: 'https://resource.xdd618.com/3/20260526/1779781836792_icon-50.png',
navType: 'prompt',
promptContent: '我要送礼,请给我推荐一些平台的礼品',
url: '',
giftCardEnabled: 1,
display: true
},
{
name: '订单查询',
icon: 'https://resource.xdd618.com/3/20260526/1779781836793_icon-51.png',
navType: 'prompt',
promptContent: '帮我查询我的待发货、待收货订单信息',
url: '',
giftCardEnabled: 0,
display: true
},
{
name: '拍照识图',
icon: 'https://resource.xdd618.com/3/20260526/1779781836794_icon-52.png',
navType: 'url',
promptContent: '',
url: '/aiChat/views/imageRecognition',
giftCardEnabled: 0,
display: true
}
],
bottomTools: [],
scrollData: {},
scrollTop: 0,
isScrollToBottom: false,
@@ -63,31 +42,17 @@ export const chatMixinsV2 = {
loading: false,
chatNumber: '',
infoResData: {},
chatMessageList: [
/*
{
type: -2,
isError: false,
showCursor: false,
conversationId: '',
prompt: '',
nodes: '-------------监听 WebSocket 接受到服务器的消息事件',
content: '-------------监听 WebSocket 接受到服务器的消息事件',
listQuestion: [
'监听 WebSocket 接受到服务器的消息事件',
'监听 WebSocket 接受到服务器的消息事件',
'监听 WebSocket 接受到服务器的消息事件'
]
}
*/
],
errorMsg: Object.freeze('您提的问题未能理解,云灵思想跑偏啦,重新整理一下问题或者重新提问,让云灵再试试!'),
chatMessageList: [],
audioAyy: [],
isPlayAudio: false,
audioContext: null,
audioPlayId: '',
showGiftBtn: false,
buyLoading: false
buyLoading: false,
exceptionConfig: {
model_exception: '您提的问题未能理解,云灵思想跑偏啦,重新整理一下问题或者重新提问,让云灵再试试!',
voice_exception: ''
}
}
},
computed: {
@@ -137,7 +102,37 @@ export const chatMixinsV2 = {
},
methods: {
createdCallbak() {
console.log('页面初始话回调')
this.$nextTick(() => {
this.scrollToBottomHandle()
getExceptionConfig().then(res => {
const { success, data } = res
if (success) {
this.exceptionConfig = data || {}
}
})
// 县域AI没有底部快捷操作和送礼配置
if (!this.countyId) {
getBottomNavigationConfigList().then(res => {
const { success, data } = res
if (success) {
this.bottomTools = data || []
this.bottomTools.forEach(item => {
item.display = true
})
}
})
getGiftRecommendOptions().then(res => {
const { success, data } = res
if (success) {
this.giftBuyOptions = data || {}
}
})
}
this.extraReqFn()
})
},
extraReqFn() {
console.log('首页/历史详情页面单独请求接口逻辑')
},
inputFocusHandle(value) {
this.onFocus = value === 1
@@ -263,21 +258,49 @@ export const chatMixinsV2 = {
})
_this.loading = true
_this.showCursor = false
getSseConfigV1({
'chatNumber': _this.chatNumber,
prompt
}).then(resConfig => {
let reqFn = null
let postData = {}
if (_this.countyId) {
reqFn = getSseCountyAiConfigV1
postData = {
'countyId': _this.countyId,
'chatNumber': _this.chatNumber,
prompt
}
} else {
reqFn = getSseConfigV1
postData = {
'chatNumber': _this.chatNumber,
prompt
}
}
reqFn(postData).then(resConfig => {
const conversationId = resConfig.data.conversationId
_this.chatNumber = resConfig.data.chatNumber || ''
_this.chatMessageList[_this.chatMessageListLength - 1].showCursor = true
_this.chatMessageList[_this.chatMessageListLength - 1].conversationId = conversationId
if (conversationId) {
_this.initWebSocket(conversationId, () => {
getCompletionsV3({
conversationId,
ws: true,
isNoNeedPublicErrorNotification: 1
}).then(sseRes => {
let completionsReqFn = null
let completionsPostData = {}
if (_this.countyId) {
completionsReqFn = getCountyAiCompletionsV1
completionsPostData = {
conversationId,
countyId: _this.countyId,
ws: true,
isNoNeedPublicErrorNotification: 1
}
} else {
completionsReqFn = getCompletionsV3
completionsPostData = {
conversationId,
ws: true,
isNoNeedPublicErrorNotification: 1
}
}
completionsReqFn(completionsPostData).then(sseRes => {
console.log(sseRes)
// _this.closeWsFn()
}).catch(err => {
@@ -576,8 +599,8 @@ export const chatMixinsV2 = {
},
chatErrorSetContent() {
this.chatMessageList[this.chatMessageListLength - 1].isError = true
this.chatMessageList[this.chatMessageListLength - 1].content = this.errorMsg
this.chatMessageList[this.chatMessageListLength - 1].nodes = this.errorMsg
this.chatMessageList[this.chatMessageListLength - 1].content = this.exceptionConfig.model_exception
this.chatMessageList[this.chatMessageListLength - 1].nodes = this.exceptionConfig.model_exception
this.closeWsFn()
},
closeWsFn() {
+17 -4
View File
@@ -365,6 +365,7 @@
</view>
</view>
<view
v-if="!countyId"
:class="{
'focus': onFocus
}"
@@ -411,6 +412,7 @@
ref="bottomSend"
:loading="loading"
:keyboard-height="keyboardHeight"
:voice-exception="exceptionConfig.voice_exception"
@send="streamReq"
@history="historyViewHandle"
@focus="inputFocusHandle"
@@ -418,10 +420,12 @@
<AiHistoryList
ref="historyView"
:status-bar-height="statusBarHeight"
:county-id="countyId"
form-module="history"
@enter-history="audioStopHandle"
/>
<ProductWindow
v-if="!countyId"
ref="attrWindow"
:attr="attr"
:cart-num="cart_num"
@@ -445,7 +449,8 @@ import BottomSend from '../components/bottomSend.vue'
import OrderItem from '../components/orderItem.vue'
import ProductWindow from '@/components/ProductWindow'
import {
historyChatMessage
historyChatMessage,
getCountyAiHistoryChatMessage
} from '@/api/chat/index'
import { formatAiMsgContent } from '../utils/aiChat'
export default {
@@ -459,19 +464,27 @@ export default {
mixins: [chatMixinsV2, goCartMixin],
data() {
return {
pageTitle: ''
pageTitle: '',
countyId: ''
}
},
onLoad(options) {
this.chatNumber = options.chatNumber
this.pageTitle = options.title
this.pageTitle = options.title || ''
this.countyId = options.countyId || ''
this.pageTitle = this.pageTitle.length > 8 ? (this.pageTitle.substring(0, 8) + '...') : this.pageTitle
this.init()
},
methods: {
init() {
this.loading = true
historyChatMessage({
let reqFn = null
if (this.countyId) {
reqFn = getCountyAiHistoryChatMessage
} else {
reqFn = historyChatMessage
}
reqFn({
chatNumber: this.chatNumber
}).then(res => {
const { success, data = [] } = res
+121 -155
View File
@@ -40,12 +40,20 @@
conversationId: '123'
})">播放</button> -->
<block v-if="chatMessageListLength < 1">
<view class="home-wrap">
<view
:class="{
'county-home-wrap': !!countyId
}"
class="home-wrap"
>
<view class="home-focus-wrap">
<view class="focus-guide-wrap">
<view class="guide-left">
<image
:src="webUrl + '/aiChat/logo-transition.png'"
:class="{
'county-avatar': !!countyId
}"
class="avatar avatar-bounce"
mode="widthFix"
/>
@@ -99,7 +107,8 @@
</swiper-item>
</swiper>
</view> -->
<view v-if="!showGiftSteps" class="topic-wrap">
<!-- 大家都在问 -->
<view v-if="!showGiftSteps && !countyId" class="topic-wrap">
<view class="title">
<view class="title-left">大家都在问</view>
<view class="title-right" @click="loadData('click')">
@@ -133,6 +142,24 @@
</view>
</view>
</view>
<!-- 县域 -->
<view v-if="!showGiftSteps && countyId" class="county-tools-wrap">
<view class="list-cont">
<view
v-for="(item, index) in countyTools"
:key="index"
class="list-item"
@click="countyToolItemClickHandle(item)"
>
<image
:src="item.icon"
class="icon"
mode="widthFix"
/>
<view class="name">{{ item.name }}</view>
</view>
</view>
</view>
<!-- 在这里实现送礼步骤 -->
<view v-if="showGiftSteps" class="gift-steps-wrap">
<view class="gift-step-title">{{ giftBuyOptions[currentGiftStepIndex].title }}</view>
@@ -518,6 +545,7 @@
</view>
</view>
<view
v-if="!countyId"
:class="{
'focus': onFocus
}"
@@ -567,6 +595,7 @@
ref="bottomSend"
:loading="loading"
:keyboard-height="keyboardHeight"
:voice-exception="exceptionConfig.voice_exception"
@send="streamReq"
@add="createNewHandle"
@history="historyViewHandle"
@@ -575,9 +604,11 @@
<AiHistoryList
ref="historyView"
:status-bar-height="statusBarHeight"
:county-id="countyId"
@enter-history="audioStopHandle"
/>
<ProductWindow
v-if="!countyId"
ref="attrWindow"
:attr="attr"
:cart-num="cart_num"
@@ -600,6 +631,9 @@ import {
getAiSystemInfoSetting,
getAiSystemInfoTopic
} from '@/api/public'
import {
getCountyAiDetail
} from '@/api/chat/index'
import AiHistoryList from '../components/historyList'
import BottomSend from '../components/bottomSend.vue'
import OrderItem from '../components/orderItem.vue'
@@ -616,6 +650,7 @@ export default {
data() {
return {
cityName: '',
countyId: '',
animationWidth: '150%',
animationStr: '',
settingInfo: {},
@@ -626,153 +661,13 @@ export default {
currentGiftStepIndex: 0,
giftSelections: {},
giftBudget: '',
giftBuyOptions: [
{
"id": 1,
"sort": 1,
"title": "礼品是送给谁的呢?",
"type": "option_card",
"status": 1,
"createTime": 1779777608000,
"updateTime": 1779850697000,
"options": [
{
"id": 1,
"configId": 1,
"optionName": "送长辈",
"sort": 1,
"createTime": 1779777924000
},
{
"id": 2,
"configId": 1,
"optionName": "送朋友",
"sort": 2,
"createTime": 1779777924000
},
{
"id": 3,
"configId": 1,
"optionName": "送同事",
"sort": 3,
"createTime": 1779777924000
},
{
"id": 4,
"configId": 1,
"optionName": "送亲戚",
"sort": 4,
"createTime": 1779777924000
},
{
"id": 5,
"configId": 1,
"optionName": "送爱人",
"sort": 5,
"createTime": 1779777924000
},
{
"id": 6,
"configId": 1,
"optionName": "送领导",
"sort": 6,
"createTime": 1779777924000
}
]
},
{
"id": 2,
"sort": 2,
"title": "有什么特别的场合吗?",
"type": "option_card",
"status": 1,
"createTime": 1779777608000,
"updateTime": 1779789421000,
"options": [
{
"id": 11,
"configId": 2,
"optionName": "生日",
"sort": 1,
"createTime": 1779789420000
},
{
"id": 12,
"configId": 2,
"optionName": "节日",
"sort": 2,
"createTime": 1779789420000
},
{
"id": 13,
"configId": 2,
"optionName": "乔迁",
"sort": 3,
"createTime": 1779789420000
},
{
"id": 14,
"configId": 2,
"optionName": "感谢",
"sort": 4,
"createTime": 1779789420000
}
]
},
{
"id": 3,
"sort": 3,
"title": "对礼品类型有什么偏好?",
"type": "option_card",
"status": 1,
"createTime": 1779777608000,
"updateTime": 1779789393000,
"options": [
{
"id": 7,
"configId": 3,
"optionName": "特色礼盒",
"sort": 1,
"createTime": 1779789393000
},
{
"id": 8,
"configId": 3,
"optionName": "商务",
"sort": 2,
"createTime": 1779789393000
},
{
"id": 9,
"configId": 3,
"optionName": "茶叶",
"sort": 3,
"createTime": 1779789393000
},
{
"id": 10,
"configId": 3,
"optionName": "精美实惠",
"sort": 4,
"createTime": 1779789393000
}
]
},
{
"id": 4,
"sort": 4,
"title": "预算大概在什么范围?",
"type": "price_input",
"status": 1,
"createTime": 1779777608000,
"updateTime": 1779777608000,
"options": []
}
]
giftBuyOptions: [],
countyTools: []
}
},
onLoad(options) {
this.cityName = options.cityName || ''
this.countyId = options.countyId || ''
},
onShow() {
// 1-新对话,2-我要送礼
@@ -792,18 +687,31 @@ export default {
}
},
methods: {
createdCallbak() {
extraReqFn() {
this.$nextTick(() => {
this.scrollToBottomHandle()
getAiSystemInfoSetting().then(res => {
const { success, data } = res
if (success) {
this.settingInfo = data
this.animationWidth = `${data.systemTopicDivMaxWidth * 750}rpx`
this.animationStr = `TranslateXSwiper-${data.systemTopicDivMaxWidth * 10} ${data.systemTopicDivScrollDuration}s infinite linear alternate`
}
})
this.loadData()
if (this.countyId) {
getCountyAiDetail({
countyId: this.countyId
}).then(res => {
const { success, data } = res
if (success) {
this.settingInfo.helloMessageTitle = data.title || ''
this.settingInfo.helloMessageContent = data.introduction || ''
this.countyTools = data.modules || []
}
})
} else {
getAiSystemInfoSetting().then(res => {
const { success, data } = res
if (success) {
this.settingInfo = data
this.animationWidth = `${data.systemTopicDivMaxWidth * 750}rpx`
this.animationStr = `TranslateXSwiper-${data.systemTopicDivMaxWidth * 10} ${data.systemTopicDivScrollDuration}s infinite linear alternate`
}
})
this.loadData()
}
})
},
loadData(type = '') {
@@ -881,6 +789,19 @@ export default {
} else {
this.createNewHandle()
}
},
countyToolItemClickHandle(item) {
if (item.moduleType === 'prompt') {
this.streamReq({
prompt: item.promptContent,
init: 0
})
}
if (item.moduleType === 'url') {
uni.navigateTo({
url: item.url
})
}
}
}
}
@@ -937,6 +858,9 @@ export default {
display: block;
width: 430rpx;
}
.county-avatar {
width: 360rpx;
}
.avatar-bounce {
animation: bounce 2s infinite ease-in-out;
}
@@ -1032,4 +956,46 @@ export default {
}
}
.county-home-wrap {
justify-content: flex-start;
.guide-right {
.content {
color: #666;
}
}
}
.county-tools-wrap {
width: 100%;
padding: 40rpx 0 0 0;
.list-cont {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
width: 100%;
padding: 0 60rpx;
box-sizing: border-box;
.list-item {
display: flex;
align-items: center;
flex-direction: column;
width: 28%;
padding: 20rpx 0 12rpx 0;
margin: 0 0 24rpx 0;
border-radius: 12rpx;
background-color: #fff;
box-shadow: 0 0 12rpx rgba(0, 0, 0, 0.1);
.icon {
display: block;
width: 60rpx;
height: 60rpx;
margin: 0 8rpx 0 0;
}
.name {
padding: 8rpx 0 0 0;
font-size: 28rpx;
color: #333;
}
}
}
}
</style>