workcase web ai聊天
This commit is contained in:
@@ -118,7 +118,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, onMounted } from 'vue'
|
||||
import WorkcaseCreator from '@/components/WorkcaseCreator/WorkcaseCreator.uvue'
|
||||
import { guestAPI, aiChatAPI } from '@/api'
|
||||
import { guestAPI, aiChatAPI, workcaseChatAPI } from '@/api'
|
||||
import type { TbWorkcaseDTO } from '@/types'
|
||||
import { AGENT_ID } from '@/config'
|
||||
// 前端消息展示类型
|
||||
@@ -478,21 +478,42 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 联系人工客服
|
||||
function contactHuman() {
|
||||
uni.showModal({
|
||||
title: '联系人工客服',
|
||||
content: '客服电话:400-123-4567\n工作时间:9:00-18:00\n\n是否拨打电话?',
|
||||
confirmText: '拨打',
|
||||
cancelText: '取消',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: '400-123-4567'
|
||||
})
|
||||
}
|
||||
// 联系人工客服 - 创建聊天室并进入
|
||||
async function contactHuman() {
|
||||
uni.showLoading({ title: '正在连接客服...' })
|
||||
try {
|
||||
// 创建聊天室
|
||||
const res = await workcaseChatAPI.createChatRoom({
|
||||
guestId: userInfo.value.userId || userInfo.value.wechatId,
|
||||
guestName: userInfo.value.username || '访客',
|
||||
roomName: `${userInfo.value.username || '访客'}的咨询`,
|
||||
roomType: 'guest',
|
||||
status: 'active',
|
||||
aiSessionId: chatId.value || ''
|
||||
})
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.success && res.data) {
|
||||
const roomId = res.data.roomId
|
||||
console.log('创建聊天室成功:', roomId)
|
||||
// 跳转到聊天室页面
|
||||
uni.navigateTo({
|
||||
url: `/pages/chatRoom/chatRoom/chatRoom?roomId=${roomId}&roomName=${encodeURIComponent(res.data.roomName || '人工客服')}`
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '连接客服失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (error: any) {
|
||||
uni.hideLoading()
|
||||
console.error('创建聊天室失败:', error)
|
||||
uni.showToast({
|
||||
title: '连接客服失败,请稍后重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 处理快速问题
|
||||
|
||||
Reference in New Issue
Block a user