2
2
<template >
3
3
<el-container class =" kefu" >
4
4
<el-header class =" kefu-header" >
5
- <el-tabs v-model =" activeName" class =" kefu-tabs" @tab-click =" handleClick" >
6
- <el-tab-pane label =" 最近浏览" name =" a" />
7
- <el-tab-pane label =" 订单列表" name =" b" />
8
- </el-tabs >
5
+ <div
6
+ :class =" { 'kefu-header-item-activation': tabActivation('会员信息') }"
7
+ class =" kefu-header-item cursor-pointer flex items-center justify-center"
8
+ @click =" handleClick('会员信息')"
9
+ >
10
+ 会员信息
11
+ </div >
12
+ <div
13
+ :class =" { 'kefu-header-item-activation': tabActivation('最近浏览') }"
14
+ class =" kefu-header-item cursor-pointer flex items-center justify-center"
15
+ @click =" handleClick('最近浏览')"
16
+ >
17
+ 最近浏览
18
+ </div >
19
+ <div
20
+ :class =" { 'kefu-header-item-activation': tabActivation('交易订单') }"
21
+ class =" kefu-header-item cursor-pointer flex items-center justify-center"
22
+ @click =" handleClick('交易订单')"
23
+ >
24
+ 交易订单
25
+ </div >
9
26
</el-header >
10
27
<el-main class =" kefu-content" >
11
28
<div v-show =" !isEmpty(conversation)" >
12
29
<el-scrollbar ref =" scrollbarRef" always @scroll =" handleScroll" >
13
30
<!-- 最近浏览 -->
14
- <ProductBrowsingHistory v-if =" activeName === 'a '" ref =" productBrowsingHistoryRef" />
15
- <!-- 订单列表 -->
16
- <OrderBrowsingHistory v-if =" activeName === 'b '" ref =" orderBrowsingHistoryRef" />
31
+ <ProductBrowsingHistory v-if =" activeTab === '最近浏览 '" ref =" productBrowsingHistoryRef" />
32
+ <!-- 交易订单 -->
33
+ <OrderBrowsingHistory v-if =" activeTab === '交易订单 '" ref =" orderBrowsingHistoryRef" />
17
34
</el-scrollbar >
18
35
</div >
19
36
<el-empty v-show =" isEmpty(conversation)" description =" 请选择左侧的一个会话后开始" />
22
39
</template >
23
40
24
41
<script lang="ts" setup>
25
- import type { TabsPaneContext } from ' element-plus'
26
42
import ProductBrowsingHistory from ' ./ProductBrowsingHistory.vue'
27
43
import OrderBrowsingHistory from ' ./OrderBrowsingHistory.vue'
28
44
import { KeFuConversationRespVO } from ' @/api/mall/promotion/kefu/conversation'
@@ -32,25 +48,26 @@ import { ElScrollbar as ElScrollbarType } from 'element-plus/es/components/scrol
32
48
33
49
defineOptions ({ name: ' MemberBrowsingHistory' })
34
50
35
- const activeName = ref (' a ' )
36
-
51
+ const activeTab = ref (' 会员信息 ' )
52
+ const tabActivation = computed (() => ( tab : string ) => activeTab . value === tab )
37
53
/** tab 切换 */
38
54
const productBrowsingHistoryRef = ref <InstanceType <typeof ProductBrowsingHistory >>()
39
55
const orderBrowsingHistoryRef = ref <InstanceType <typeof OrderBrowsingHistory >>()
40
- const handleClick = async (tab : TabsPaneContext ) => {
41
- activeName .value = tab . paneName as string
56
+ const handleClick = async (tab : string ) => {
57
+ activeTab .value = tab
42
58
await nextTick ()
43
59
await getHistoryList ()
44
60
}
45
61
46
62
/** 获得历史数据 */
47
- // TODO @puhui:不要用 a、b 哈。就订单列表、浏览列表这种噶
48
63
const getHistoryList = async () => {
49
- switch (activeName .value ) {
50
- case ' a' :
64
+ switch (activeTab .value ) {
65
+ case ' 会员信息' :
66
+ break
67
+ case ' 最近浏览' :
51
68
await productBrowsingHistoryRef .value ?.getHistoryList (conversation .value )
52
69
break
53
- case ' b ' :
70
+ case ' 交易订单 ' :
54
71
await orderBrowsingHistoryRef .value ?.getHistoryList (conversation .value )
55
72
break
56
73
default :
@@ -60,11 +77,13 @@ const getHistoryList = async () => {
60
77
61
78
/** 加载下一页数据 */
62
79
const loadMore = async () => {
63
- switch (activeName .value ) {
64
- case ' a' :
80
+ switch (activeTab .value ) {
81
+ case ' 会员信息' :
82
+ break
83
+ case ' 最近浏览' :
65
84
await productBrowsingHistoryRef .value ?.loadMore ()
66
85
break
67
- case ' b ' :
86
+ case ' 交易订单 ' :
68
87
await orderBrowsingHistoryRef .value ?.loadMore ()
69
88
break
70
89
default :
@@ -75,7 +94,7 @@ const loadMore = async () => {
75
94
/** 浏览历史初始化 */
76
95
const conversation = ref <KeFuConversationRespVO >({} as KeFuConversationRespVO ) // 用户会话
77
96
const initHistory = async (val : KeFuConversationRespVO ) => {
78
- activeName .value = ' a '
97
+ activeTab .value = ' 会员信息 '
79
98
conversation .value = val
80
99
await nextTick ()
81
100
await getHistoryList ()
@@ -95,9 +114,6 @@ const handleScroll = debounce(() => {
95
114
96
115
<style lang="scss" scoped>
97
116
.kefu {
98
- margin : 0 ;
99
- padding : 0 ;
100
- height : 100% ;
101
117
width : 300px !important ;
102
118
background-color : #fff ;
103
119
border-left : var (--el-border-color ) solid 1px ;
@@ -107,12 +123,40 @@ const handleScroll = debounce(() => {
107
123
box-shadow : 0 0 0 0 #dcdfe6 ;
108
124
display : flex ;
109
125
align-items : center ;
110
- justify-content : center ;
126
+ justify-content : space-around ;
111
127
112
128
& -title {
113
129
font-size : 18px ;
114
130
font-weight : bold ;
115
131
}
132
+
133
+ & -item {
134
+ height : 100% ;
135
+ width : 100% ;
136
+ position : relative ;
137
+
138
+ & -activation ::before {
139
+ content : ' ' ;
140
+ position : absolute ; /* 绝对定位 */
141
+ top : 0 ;
142
+ left : 0 ;
143
+ right : 0 ;
144
+ bottom : 0 ; /* 覆盖整个元素 */
145
+ border-bottom : 2px solid black ; /* 边框样式 */
146
+ pointer-events : none ; /* 确保点击事件不会被伪元素拦截 */
147
+ }
148
+
149
+ & :hover ::before {
150
+ content : ' ' ;
151
+ position : absolute ; /* 绝对定位 */
152
+ top : 0 ;
153
+ left : 0 ;
154
+ right : 0 ;
155
+ bottom : 0 ; /* 覆盖整个元素 */
156
+ border-bottom : 2px solid black ; /* 边框样式 */
157
+ pointer-events : none ; /* 确保点击事件不会被伪元素拦截 */
158
+ }
159
+ }
116
160
}
117
161
118
162
& -content {
0 commit comments