支持客服入口按业务场景分流到客服分组
联系客服支持 scene(general/mohong),按用户与场景复用会话;摸大红入口走摸大红分组选人。
This commit is contained in:
@@ -3,17 +3,21 @@ import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import MobileBottomNav from '@/components/MobileBottomNav.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 { formatCent } from '@/shared/utils/money'
|
||||
import { readError } from '@/shared/utils/error'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const session = useSessionStore()
|
||||
const supportLoading = ref(false)
|
||||
const loading = ref(false)
|
||||
const products = ref<MohongProduct[]>([])
|
||||
const categories = ref<MohongCategory[]>([])
|
||||
@@ -153,6 +157,23 @@ function markCoverFailed(id: number) {
|
||||
function showCover(item: MohongProduct) {
|
||||
return Boolean(item.cover_url) && !failedCover.value[item.id]
|
||||
}
|
||||
|
||||
async function handleSupportClick() {
|
||||
if (!session.isLoggedIn) {
|
||||
router.push({ path: '/m/login', query: { redirect: route.fullPath } })
|
||||
return
|
||||
}
|
||||
if (supportLoading.value) return
|
||||
supportLoading.value = true
|
||||
try {
|
||||
const chat = await ensureSupportChat('mohong')
|
||||
router.push(`/m/chats/${chat.id}`)
|
||||
} catch {
|
||||
showToast({ message: '联系客服失败,请稍后重试', icon: 'cross' })
|
||||
} finally {
|
||||
supportLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -170,6 +191,14 @@ function showCover(item: MohongProduct) {
|
||||
@input="onSearchInput"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="orders-btn"
|
||||
:disabled="supportLoading"
|
||||
@click="handleSupportClick"
|
||||
>
|
||||
{{ supportLoading ? '...' : '客服' }}
|
||||
</button>
|
||||
<button type="button" class="orders-btn" @click="router.push('/mohong/orders')">订单</button>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user