支持客服入口按业务场景分流到客服分组
联系客服支持 scene(general/mohong),按用户与场景复用会话;摸大红入口走摸大红分组选人。
This commit is contained in:
@@ -2,18 +2,22 @@
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Search, Tickets } from '@element-plus/icons-vue'
|
||||
import { Search, Service, Tickets } from '@element-plus/icons-vue'
|
||||
import MohongProductCard from '@/features/mohong/components/MohongProductCard.vue'
|
||||
import { ensureSupportChat } from '@/features/chats/api/chats'
|
||||
import {
|
||||
fetchMohongCategories,
|
||||
fetchMohongProducts,
|
||||
type MohongCategory,
|
||||
type MohongProduct,
|
||||
} from '@/features/mohong/api/mohong'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
import { readError } from '@/shared/utils/error'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const session = useSessionStore()
|
||||
const supportLoading = ref(false)
|
||||
const loading = ref(false)
|
||||
const loadingMore = ref(false)
|
||||
const products = ref<MohongProduct[]>([])
|
||||
@@ -147,6 +151,23 @@ const activeCategoryName = () => {
|
||||
if (!activeCategoryId.value) return '全部'
|
||||
return categories.value.find(c => c.id === activeCategoryId.value)?.name || '全部'
|
||||
}
|
||||
|
||||
async function handleSupportClick() {
|
||||
if (!session.isLoggedIn) {
|
||||
router.push({ path: '/login', query: { redirect: route.fullPath } })
|
||||
return
|
||||
}
|
||||
if (supportLoading.value) return
|
||||
supportLoading.value = true
|
||||
try {
|
||||
const chat = await ensureSupportChat('mohong')
|
||||
router.push(`/messages/${chat.id}`)
|
||||
} catch {
|
||||
ElMessage.error('联系客服失败,请稍后重试')
|
||||
} finally {
|
||||
supportLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -171,6 +192,15 @@ const activeCategoryName = () => {
|
||||
<el-icon><Tickets /></el-icon>
|
||||
<span>我的订单</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="toolbar-btn outline"
|
||||
:disabled="supportLoading"
|
||||
@click="handleSupportClick"
|
||||
>
|
||||
<el-icon><Service /></el-icon>
|
||||
<span>{{ supportLoading ? '接入中' : '联系客服' }}</span>
|
||||
</button>
|
||||
<button type="button" class="toolbar-btn outline" @click="router.push('/')">
|
||||
租号大厅
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user