Commit 71efa68f by 胡悦

新功能(接待详情页): 添加AI智能导师面板至详情页

新增common API模块的getAiagent接口获取AI智能体配置信息
集成webview组件展示AI导师窗口并更新页面布局样式
完善AI地址拼接、webview通信及样式设置逻辑
移除未使用的Tags、QualityTable组件及冗余代码
更新Quality组件参数,添加标签切换交互逻辑
1 parent c18d6260
...@@ -254,6 +254,10 @@ module.exports = { ...@@ -254,6 +254,10 @@ module.exports = {
...data ...data
}) })
}, },
// 获取指定 AI 智能体
getAiagent(data) {
return http.shukeRequest('linkwe-gateway/reception/aiAgent/getByCode', data, 'GET', false)
},
// 预警消息 // 预警消息
getWarningPage(data) { getWarningPage(data) {
return http.post({ return http.post({
......
...@@ -49,25 +49,19 @@ ...@@ -49,25 +49,19 @@
</view> </view>
<view class="component-box"> <view class="component-box">
<dialogue :class="['component-item', { hide: tabId != 1 }]" :batchId="pageData.batchId" :qualityData="qualityData" :totalDuration="pageData.totalDuration" ref="dialogueRef" :qualityAudio="qualityAudio" @seek="seek" @onPlay="onPlay" @onPause="onPause" @changeOperate="isOperate = $event" /> <dialogue :class="['component-item', { hide: tabId != 1 }]" :batchId="pageData.batchId" :qualityData="qualityData" :totalDuration="pageData.totalDuration" ref="dialogueRef" :qualityAudio="qualityAudio" @seek="seek" @onPlay="onPlay" @onPause="onPause" @changeOperate="isOperate = $event" />
<quality :qualityData="qualityData" :class="['component-item', { hide: tabId != 2 }]" ref="qualityRef" :qualityAudio="qualityAudio" @seek="seek" @onPlay="onPlay" @onPause="onPause" @changeOperate="isOperate = $event" /> <quality :qualityData="qualityData" :class="['component-item', { hide: tabId != 2 }]" ref="qualityRef" :qualityAudio="qualityAudio" @seek="seek" @onPlay="onPlay" @onPause="onPause" @changeOperate="isOperate = $event" @tabClick="tabClick" :disabled="isResponding || isRecording" :disabledText="disabledText" />
</view> </view>
</view> </view>
</view> </view>
<view class="reception-right-box"> <view class="reception-right-box">
<template v-if="qualityLoading"> <view class="AI-window" v-if="AIUrl">
<view class="nothing flex"> <view class="AI-title flex">AI导师</view>
<view class="sprite-icon icon-quality-no-data"></view> <web-view :src="AIUrl" @load="handleWebviewLoad" @message="handlerMessage"></web-view>
分析中,稍等...
</view> </view>
</template>
<template v-else-if="qualityData.length">
<tags :tags="tags" />
<quality-table :qualityData="qualityData" />
</template>
<template v-else> <template v-else>
<view class="nothing flex"> <view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view> <view class="sprite-icon icon-quality-no-data"></view>
暂无质检数据 分析中,稍等...
</view> </view>
</template> </template>
</view> </view>
...@@ -79,8 +73,6 @@ ...@@ -79,8 +73,6 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import Dialogue from './components/Dialogue.vue' import Dialogue from './components/Dialogue.vue'
import Quality from './components/Quality.vue' import Quality from './components/Quality.vue'
import Tags from './components/Tags.vue'
import QualityTable from './components/QualityTable.vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import utils from "@/utils/utils"; import utils from "@/utils/utils";
...@@ -92,10 +84,8 @@ const RECEPTION_STATUS_MAP = { ...@@ -92,10 +84,8 @@ const RECEPTION_STATUS_MAP = {
export default { export default {
components: { components: {
QualityTable,
Dialogue, Dialogue,
Quality, Quality
Tags
}, },
mixins: [], mixins: [],
data () { data () {
...@@ -120,8 +110,14 @@ export default { ...@@ -120,8 +110,14 @@ export default {
status: 'pause', status: 'pause',
isOperate: true, isOperate: true,
showPlayControl: false, showPlayControl: false,
tags: [], qualityLoading: false,
qualityLoading: false AIUrl: '',
wv: null,
webviewStyleTimer: null,
pendingAIMessage: '',
disabledText: '',
isResponding: false,
isRecording: false
} }
}, },
onLoad (options) { onLoad (options) {
...@@ -135,6 +131,7 @@ export default { ...@@ -135,6 +131,7 @@ export default {
data.totalDuration = (data.receptionEndTime - data.receptionStartTime) data.totalDuration = (data.receptionEndTime - data.receptionStartTime)
data.batchId = data.id data.batchId = data.id
_this.pageData = Object.freeze(data || {}) _this.pageData = Object.freeze(data || {})
_this.getAiagent()
if (data.batchId) _this.findCheckResultListByReceptionId(data.batchId) if (data.batchId) _this.findCheckResultListByReceptionId(data.batchId)
_this.setAudio(data.recordUrl) _this.setAudio(data.recordUrl)
} catch (err) { } catch (err) {
...@@ -147,6 +144,7 @@ export default { ...@@ -147,6 +144,7 @@ export default {
}, },
onUnload () { onUnload () {
this.qualityAudio.stop() this.qualityAudio.stop()
if (this.webviewStyleTimer) clearTimeout(this.webviewStyleTimer)
}, },
computed: { computed: {
dialogueRef () { dialogueRef () {
...@@ -317,26 +315,22 @@ export default { ...@@ -317,26 +315,22 @@ export default {
}) })
if (!res) return if (!res) return
const tags = []
res.forEach(item => { res.forEach(item => {
// 1. 格式化分数 // 1. 格式化分数
this.__formatScore(item) this.__formatScore(item)
// 2. 处理标签 // 2. 处理命中话术
tags.push(`${item.tagGroupName}-${item.tagName}`)
// 3. 处理命中话术
this.__processHitText(item) this.__processHitText(item)
// 4. 获取推荐话术 // 3. 获取推荐话术
const scriptRec = this.__getScriptRec(item) const scriptRec = this.__getScriptRec(item)
// 5. 处理对话详情 // 4. 处理对话详情
this.__processConversationDetails(item, scriptRec) this.__processConversationDetails(item, scriptRec)
}) })
this.tags = Object.freeze(tags)
this.qualityData = Object.freeze(res) this.qualityData = Object.freeze(res)
if (res[0]) this.tabClick(res[0])
} catch (err) { } catch (err) {
uni.$logger.error('findCheckResultListByReceptionId error'+err.message) uni.$logger.error('findCheckResultListByReceptionId error'+err.message)
} finally { } finally {
...@@ -346,6 +340,102 @@ export default { ...@@ -346,6 +340,102 @@ export default {
desensitizePhoneNumber (customerPhone) { desensitizePhoneNumber (customerPhone) {
return customerPhone?.replace(customerPhone.slice(3, 7), '****') || '' return customerPhone?.replace(customerPhone.slice(3, 7), '****') || ''
}, },
async getAiagent () {
uni.showLoading({ mask: true })
try {
const userInfo = uni.$storage.get('userInfo') || {}
const accountPhone = userInfo.phone || userInfo.mobile || userInfo.username || userInfo.userName
const result = await uni.$api.commonApi.getAiagent({
agentCode: 'AI9'
})
const data = Array.isArray(result) ? result[0] : result
if (!data?.agentUrl) throw new Error('未获取到智能体信息')
const brand = {
1: '问界',
2: '比亚迪',
3: '其他'
}[userInfo.channelType] || '其他'
const params = [
['no_header', 1],
['businessType', 1],
['one_id', userInfo.uuid || userInfo.userId || ''],
['platformType', 1],
['domain', data.domainName],
['presuppositionProblem', ''],
['brandType', 1001],
['phone', accountPhone || ''],
['brand', brand],
['date', dayjs().format('YYYY-MM-DD')],
['queryType', 1]
]
if (data.taskStatus) params.push(['practice_status', data.taskStatus])
const query = params
.map(([key, value]) => `${key}=${encodeURIComponent(value == null ? '' : value)}`)
.join('&')
this.AIUrl = `${data.agentUrl}${data.agentUrl.includes('?') ? '&' : '?'}${query}`
this.$nextTick(() => this.setWebviewStyle())
} catch (err) {
uni.hideLoading()
uni.$logger.error(`getAiagent error: ${err.message || err}`)
uni.showToast({
title: '获取智能体失败',
icon: 'none'
})
}
},
setWebviewStyle () {
let retryCount = 0
const setStyle = () => {
const currentWebview = this.$scope?.$getAppWebview?.()
const [wv] = currentWebview?.children?.() || []
if (wv) {
this.wv = wv
wv.setStyle({
left: '40.85%',
top: '16.65%',
height: '78.17%',
width: '56.52%'
})
if (this.pendingAIMessage) this.sendAiMessage(this.pendingAIMessage)
return
}
retryCount += 1
if (retryCount < 60) this.webviewStyleTimer = setTimeout(setStyle, 50)
}
this.webviewStyleTimer = setTimeout(setStyle, 100)
},
tabClick (item) {
const message = item.sumScore > item.score ? item.tagGroupName : ''
this.pendingAIMessage = message
if (this.wv) this.sendAiMessage(message)
},
sendAiMessage (message) {
const event = JSON.stringify({
type: 'reset_chat',
payload: { message }
})
this.wv.evalJS(`sendMessage(${event})`)
},
handleWebviewLoad () {
uni.hideLoading()
},
handlerMessage ({ detail }) {
uni.hideLoading()
const [data = {}] = detail?.data || []
if (typeof data.isResponding === 'boolean') this.isResponding = data.isResponding
if (typeof data.isRecording === 'boolean') this.isRecording = data.isRecording
if (data.isResponding || data.isRecording) {
this.disabledText = data.isResponding
? '请等待内容生成后再切换其他质检点'
: '请等待录音结束后再切换其他质检点'
} else {
this.disabledText = ''
}
},
// async share () { // async share () {
// try { // try {
// const { // const {
...@@ -590,10 +680,23 @@ export default { ...@@ -590,10 +680,23 @@ export default {
width: toRpx(1326); width: toRpx(1326);
border-radius: toRpx(32); border-radius: toRpx(32);
opacity: 1; opacity: 1;
background: #ffffff; background: #f5f9ff;
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto; position: relative;
padding: 0 toRpx(40); .AI-window {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
.AI-title {
height: toRpx(96);
font-size: toRpx(36);
font-weight: 500;
justify-content: center;
color: #333333;
}
}
.nothing { .nothing {
width: 100%; width: 100%;
height: 100%; height: 100%;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!