Skip to content

Commit f0ba8ff

Browse files
author
puhui999
committed
【新增】客服会话所属会员足迹展示组件
1 parent 14cb120 commit f0ba8ff

File tree

6 files changed

+130
-7
lines changed

6 files changed

+130
-7
lines changed

src/api/mall/product/history.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import request from '@/config/axios'
2+
3+
/**
4+
* 获得商品浏览记录分页
5+
* @param params 请求参数
6+
*/
7+
export const getBrowseHistoryPage = (params: any) => {
8+
return request.get({ url: '/product/browse-history/page', params })
9+
}

src/views/mall/promotion/kefu/components/KeFuConversationList.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
</div>
2222
<div class="ml-10px w-100%">
2323
<div class="flex justify-between items-center w-100%">
24-
<span>{{ item.userNickname }}</span>
24+
<span class="username">{{ item.userNickname }}</span>
2525
<span class="color-[#989EA6]">
26-
{{ formatDate(item.lastMessageTime) }}
26+
{{ formatPast(item.lastMessageTime, 'YYYY-mm-dd') }}
2727
</span>
2828
</div>
2929
<!-- 最后聊天内容 -->
@@ -70,7 +70,7 @@
7070
<script lang="ts" setup>
7171
import { KeFuConversationApi, KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
7272
import { useEmoji } from './tools/emoji'
73-
import { formatDate } from '@/utils/formatTime'
73+
import { formatPast } from '@/utils/formatTime'
7474
import { KeFuMessageContentTypeEnum } from './tools/constants'
7575
import { useAppStore } from '@/store/modules/app'
7676
@@ -185,6 +185,16 @@ watch(showRightMenu, (val) => {
185185
background-color: #fff;
186186
transition: border-left 0.05s ease-in-out; /* 设置过渡效果 */
187187
188+
.username {
189+
min-width: 0;
190+
max-width: 60%;
191+
overflow: hidden;
192+
text-overflow: ellipsis;
193+
display: -webkit-box;
194+
-webkit-box-orient: vertical;
195+
-webkit-line-clamp: 1;
196+
}
197+
188198
.last-message {
189199
width: 200px;
190200
overflow: hidden; // 隐藏超出的文本
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<div v-show="!isEmpty(conversation)" class="kefu">
3+
<div class="header-title h-60px flex justify-center items-center">他的足迹</div>
4+
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
5+
<el-tab-pane label="最近浏览" name="a" />
6+
<el-tab-pane label="订单列表" name="b" />
7+
</el-tabs>
8+
<!-- 最近浏览 -->
9+
<ProductBrowsingHistory v-if="activeName === 'a'" ref="productBrowsingHistoryRef" />
10+
<!-- 订单列表 -->
11+
<template v-if="activeName === 'b'"></template>
12+
</div>
13+
<el-empty v-show="isEmpty(conversation)" description="请选择左侧的一个会话后开始" />
14+
</template>
15+
16+
<script lang="ts" setup>
17+
import type { TabsPaneContext } from 'element-plus'
18+
import ProductBrowsingHistory from './ProductBrowsingHistory.vue'
19+
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
20+
import { isEmpty } from '@/utils/is'
21+
22+
defineOptions({ name: 'MemberBrowsingHistory' })
23+
24+
const activeName = ref('a')
25+
/** tab 切换 */
26+
const productBrowsingHistoryRef = ref<InstanceType<typeof ProductBrowsingHistory>>()
27+
const handleClick = (tab: TabsPaneContext) => {
28+
activeName.value = tab.paneName as string
29+
getHistoryList()
30+
}
31+
/** 获得历史数据 */
32+
const getHistoryList = async () => {
33+
switch (activeName.value) {
34+
case 'a':
35+
await productBrowsingHistoryRef.value?.getHistoryList(conversation.value)
36+
break
37+
case 'b':
38+
break
39+
default:
40+
break
41+
}
42+
}
43+
/** 浏览历史初始化 */
44+
const conversation = ref<KeFuConversationRespVO>({} as KeFuConversationRespVO) // 用户会话
45+
const initHistory = async (val: KeFuConversationRespVO) => {
46+
activeName.value = 'a'
47+
conversation.value = val
48+
await getHistoryList()
49+
}
50+
defineExpose({ initHistory })
51+
</script>
52+
53+
<style lang="scss" scoped>
54+
.header-title {
55+
border-bottom: #e4e0e0 solid 1px;
56+
}
57+
</style>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<ProductItem
3+
v-for="item in list"
4+
:key="item.id"
5+
:picUrl="item.picUrl"
6+
:price="item.price"
7+
:skuText="item.introduction"
8+
:title="item.spuName"
9+
:titleWidth="400"
10+
class="mb-10px"
11+
priceColor="#FF3000"
12+
/>
13+
</template>
14+
15+
<script lang="ts" setup>
16+
import { getBrowseHistoryPage } from '@/api/mall/product/history'
17+
import ProductItem from '@/views/mall/promotion/kefu/components/message/ProductItem.vue'
18+
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
19+
20+
defineOptions({ name: 'ProductBrowsingHistory' })
21+
22+
const list = ref<any>([]) // 列表
23+
const queryParams = reactive({
24+
pageNum: 1,
25+
pageSize: 10,
26+
userId: 0,
27+
userDeleted: false
28+
})
29+
/** 获得浏览记录 */
30+
const getHistoryList = async (val: KeFuConversationRespVO) => {
31+
queryParams.userId = val.userId
32+
const res = await getBrowseHistoryPage(queryParams)
33+
list.value = res.list
34+
}
35+
defineExpose({ getHistoryList })
36+
</script>
37+
38+
<style lang="scss" scoped></style>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import KeFuConversationList from './KeFuConversationList.vue'
22
import KeFuMessageList from './KeFuMessageList.vue'
3+
import MemberBrowsingHistory from './history/MemberBrowsingHistory.vue'
34

4-
export { KeFuConversationList, KeFuMessageList }
5+
export { KeFuConversationList, KeFuMessageList, MemberBrowsingHistory }

src/views/mall/promotion/kefu/index.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<template>
22
<el-row :gutter="10">
33
<!-- 会话列表 -->
4-
<el-col :span="8">
4+
<el-col :span="6">
55
<ContentWrap>
66
<KeFuConversationList ref="keFuConversationRef" @change="handleChange" />
77
</ContentWrap>
88
</el-col>
99
<!-- 会话详情(选中会话的消息列表) -->
10-
<el-col :span="16">
10+
<el-col :span="12">
1111
<ContentWrap>
1212
<KeFuMessageList ref="keFuChatBoxRef" @change="getConversationList" />
1313
</ContentWrap>
1414
</el-col>
15+
<!-- 会员足迹(选中会话的会员足迹) -->
16+
<el-col :span="6">
17+
<ContentWrap>
18+
<MemberBrowsingHistory ref="memberBrowsingHistoryRef" />
19+
</ContentWrap>
20+
</el-col>
1521
</el-row>
1622
</template>
1723

1824
<script lang="ts" setup>
19-
import { KeFuConversationList, KeFuMessageList } from './components'
25+
import { KeFuConversationList, KeFuMessageList, MemberBrowsingHistory } from './components'
2026
import { WebSocketMessageTypeConstants } from './components/tools/constants'
2127
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
2228
import { getAccessToken } from '@/utils/auth'
@@ -81,8 +87,10 @@ const getConversationList = () => {
8187
8288
/** 加载指定会话的消息列表 */
8389
const keFuChatBoxRef = ref<InstanceType<typeof KeFuMessageList>>()
90+
const memberBrowsingHistoryRef = ref<InstanceType<typeof MemberBrowsingHistory>>()
8491
const handleChange = (conversation: KeFuConversationRespVO) => {
8592
keFuChatBoxRef.value?.getNewMessageList(conversation)
93+
memberBrowsingHistoryRef.value?.initHistory(conversation)
8694
}
8795
8896
/** 初始化 */

0 commit comments

Comments
 (0)