【新增】客服会话所属会员足迹展示组件
parent
fe48f87f37
commit
eeb76bb4c2
|
@ -78,7 +78,7 @@
|
||||||
</MessageItem>
|
</MessageItem>
|
||||||
<!-- 订单消息 -->
|
<!-- 订单消息 -->
|
||||||
<MessageItem :content-type="KeFuMessageContentTypeEnum.ORDER" :message="item">
|
<MessageItem :content-type="KeFuMessageContentTypeEnum.ORDER" :message="item">
|
||||||
<OrderItem :message="item" />
|
<OrderItem :message="item" class="max-w-70%" />
|
||||||
</MessageItem>
|
</MessageItem>
|
||||||
</div>
|
</div>
|
||||||
<el-avatar
|
<el-avatar
|
||||||
|
|
|
@ -5,10 +5,14 @@
|
||||||
<el-tab-pane label="最近浏览" name="a" />
|
<el-tab-pane label="最近浏览" name="a" />
|
||||||
<el-tab-pane label="订单列表" name="b" />
|
<el-tab-pane label="订单列表" name="b" />
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
<!-- 最近浏览 -->
|
<div>
|
||||||
<ProductBrowsingHistory v-if="activeName === 'a'" ref="productBrowsingHistoryRef" />
|
<el-scrollbar ref="scrollbarRef" always height="calc(100vh - 400px)" @scroll="handleScroll">
|
||||||
<!-- 订单列表 -->
|
<!-- 最近浏览 -->
|
||||||
<template v-if="activeName === 'b'"></template>
|
<ProductBrowsingHistory v-if="activeName === 'a'" ref="productBrowsingHistoryRef" />
|
||||||
|
<!-- 订单列表 -->
|
||||||
|
<OrderBrowsingHistory v-if="activeName === 'b'" ref="orderBrowsingHistoryRef" />
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-empty v-show="isEmpty(conversation)" description="请选择左侧的一个会话后开始" />
|
<el-empty v-show="isEmpty(conversation)" description="请选择左侧的一个会话后开始" />
|
||||||
</template>
|
</template>
|
||||||
|
@ -16,17 +20,22 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { TabsPaneContext } from 'element-plus'
|
import type { TabsPaneContext } from 'element-plus'
|
||||||
import ProductBrowsingHistory from './ProductBrowsingHistory.vue'
|
import ProductBrowsingHistory from './ProductBrowsingHistory.vue'
|
||||||
|
import OrderBrowsingHistory from './OrderBrowsingHistory.vue'
|
||||||
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
|
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
|
||||||
import { isEmpty } from '@/utils/is'
|
import { isEmpty } from '@/utils/is'
|
||||||
|
import { debounce } from 'lodash-es'
|
||||||
|
import { ElScrollbar as ElScrollbarType } from 'element-plus/es/components/scrollbar'
|
||||||
|
|
||||||
defineOptions({ name: 'MemberBrowsingHistory' })
|
defineOptions({ name: 'MemberBrowsingHistory' })
|
||||||
|
|
||||||
const activeName = ref('a')
|
const activeName = ref('a')
|
||||||
/** tab 切换 */
|
/** tab 切换 */
|
||||||
const productBrowsingHistoryRef = ref<InstanceType<typeof ProductBrowsingHistory>>()
|
const productBrowsingHistoryRef = ref<InstanceType<typeof ProductBrowsingHistory>>()
|
||||||
const handleClick = (tab: TabsPaneContext) => {
|
const orderBrowsingHistoryRef = ref<InstanceType<typeof OrderBrowsingHistory>>()
|
||||||
|
const handleClick = async (tab: TabsPaneContext) => {
|
||||||
activeName.value = tab.paneName as string
|
activeName.value = tab.paneName as string
|
||||||
getHistoryList()
|
await nextTick()
|
||||||
|
await getHistoryList()
|
||||||
}
|
}
|
||||||
/** 获得历史数据 */
|
/** 获得历史数据 */
|
||||||
const getHistoryList = async () => {
|
const getHistoryList = async () => {
|
||||||
|
@ -35,6 +44,20 @@ const getHistoryList = async () => {
|
||||||
await productBrowsingHistoryRef.value?.getHistoryList(conversation.value)
|
await productBrowsingHistoryRef.value?.getHistoryList(conversation.value)
|
||||||
break
|
break
|
||||||
case 'b':
|
case 'b':
|
||||||
|
await orderBrowsingHistoryRef.value?.getHistoryList(conversation.value)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 加载下一页数据 */
|
||||||
|
const loadMore = async () => {
|
||||||
|
switch (activeName.value) {
|
||||||
|
case 'a':
|
||||||
|
await productBrowsingHistoryRef.value?.loadMore()
|
||||||
|
break
|
||||||
|
case 'b':
|
||||||
|
await orderBrowsingHistoryRef.value?.loadMore()
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
@ -45,9 +68,20 @@ const conversation = ref<KeFuConversationRespVO>({} as KeFuConversationRespVO) /
|
||||||
const initHistory = async (val: KeFuConversationRespVO) => {
|
const initHistory = async (val: KeFuConversationRespVO) => {
|
||||||
activeName.value = 'a'
|
activeName.value = 'a'
|
||||||
conversation.value = val
|
conversation.value = val
|
||||||
|
await nextTick()
|
||||||
await getHistoryList()
|
await getHistoryList()
|
||||||
}
|
}
|
||||||
defineExpose({ initHistory })
|
defineExpose({ initHistory })
|
||||||
|
|
||||||
|
/** 处理消息列表滚动事件(debounce 限流) */
|
||||||
|
const scrollbarRef = ref<InstanceType<typeof ElScrollbarType>>()
|
||||||
|
const handleScroll = debounce(() => {
|
||||||
|
const wrap = scrollbarRef.value?.wrapRef
|
||||||
|
// 触底重置
|
||||||
|
if (Math.abs(wrap!.scrollHeight - wrap!.clientHeight - wrap!.scrollTop) < 1) {
|
||||||
|
loadMore()
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<template>
|
||||||
|
<OrderItem v-for="item in list" :key="item.id" :order="item" class="mb-10px" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import OrderItem from '@/views/mall/promotion/kefu/components/message/OrderItem.vue'
|
||||||
|
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
|
||||||
|
import { getOrderPage } from '@/api/mall/trade/order'
|
||||||
|
import { concat } from 'lodash-es'
|
||||||
|
|
||||||
|
defineOptions({ name: 'OrderBrowsingHistory' })
|
||||||
|
|
||||||
|
const list = ref<any>([]) // 列表
|
||||||
|
const total = ref(0) // 总数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
userId: 0
|
||||||
|
})
|
||||||
|
const skipGetMessageList = computed(() => {
|
||||||
|
// 已加载到最后一页的话则不触发新的消息获取
|
||||||
|
return total.value > 0 && Math.ceil(total.value / queryParams.pageSize) === queryParams.pageNo
|
||||||
|
}) // 跳过消息获取
|
||||||
|
/** 获得浏览记录 */
|
||||||
|
const getHistoryList = async (val: KeFuConversationRespVO) => {
|
||||||
|
queryParams.userId = val.userId
|
||||||
|
const res = await getOrderPage(queryParams)
|
||||||
|
total.value = res.total
|
||||||
|
list.value = res.list
|
||||||
|
}
|
||||||
|
/** 加载下一页数据 */
|
||||||
|
const loadMore = async () => {
|
||||||
|
if (skipGetMessageList.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
queryParams.pageNo += 1
|
||||||
|
const res = await getOrderPage(queryParams)
|
||||||
|
total.value = res.total
|
||||||
|
concat(list.value, res.list)
|
||||||
|
}
|
||||||
|
defineExpose({ getHistoryList, loadMore })
|
||||||
|
</script>
|
|
@ -16,23 +16,40 @@
|
||||||
import { getBrowseHistoryPage } from '@/api/mall/product/history'
|
import { getBrowseHistoryPage } from '@/api/mall/product/history'
|
||||||
import ProductItem from '@/views/mall/promotion/kefu/components/message/ProductItem.vue'
|
import ProductItem from '@/views/mall/promotion/kefu/components/message/ProductItem.vue'
|
||||||
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
|
import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
|
||||||
|
import { concat } from 'lodash-es'
|
||||||
|
|
||||||
defineOptions({ name: 'ProductBrowsingHistory' })
|
defineOptions({ name: 'ProductBrowsingHistory' })
|
||||||
|
|
||||||
const list = ref<any>([]) // 列表
|
const list = ref<any>([]) // 列表
|
||||||
|
const total = ref(0) // 总数
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
pageNum: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
userId: 0,
|
userId: 0,
|
||||||
userDeleted: false
|
userDeleted: false
|
||||||
})
|
})
|
||||||
|
const skipGetMessageList = computed(() => {
|
||||||
|
// 已加载到最后一页的话则不触发新的消息获取
|
||||||
|
return total.value > 0 && Math.ceil(total.value / queryParams.pageSize) === queryParams.pageNo
|
||||||
|
}) // 跳过消息获取
|
||||||
/** 获得浏览记录 */
|
/** 获得浏览记录 */
|
||||||
const getHistoryList = async (val: KeFuConversationRespVO) => {
|
const getHistoryList = async (val: KeFuConversationRespVO) => {
|
||||||
queryParams.userId = val.userId
|
queryParams.userId = val.userId
|
||||||
const res = await getBrowseHistoryPage(queryParams)
|
const res = await getBrowseHistoryPage(queryParams)
|
||||||
|
total.value = res.total
|
||||||
list.value = res.list
|
list.value = res.list
|
||||||
}
|
}
|
||||||
defineExpose({ getHistoryList })
|
/** 加载下一页数据 */
|
||||||
|
const loadMore = async () => {
|
||||||
|
if (skipGetMessageList.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
queryParams.pageNo += 1
|
||||||
|
const res = await getBrowseHistoryPage(queryParams)
|
||||||
|
total.value = res.total
|
||||||
|
concat(list.value, res.list)
|
||||||
|
}
|
||||||
|
defineExpose({ getHistoryList, loadMore })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div :key="getMessageContent.id" class="order-list-card-box mt-14px max-w-70%">
|
<div :key="getMessageContent.id" class="order-list-card-box mt-14px">
|
||||||
<div class="order-card-header flex items-center justify-between p-x-20px">
|
<div class="order-card-header flex items-center justify-between p-x-20px">
|
||||||
<div class="order-no">订单号:{{ getMessageContent.no }}</div>
|
<div class="order-no">订单号:{{ getMessageContent.no }}</div>
|
||||||
<div :class="formatOrderColor(getMessageContent)" class="order-state font-16">
|
<div :class="formatOrderColor(getMessageContent)" class="order-state font-16">
|
||||||
|
@ -32,13 +32,17 @@
|
||||||
import { fenToYuan } from '@/utils'
|
import { fenToYuan } from '@/utils'
|
||||||
import ProductItem from './ProductItem.vue'
|
import ProductItem from './ProductItem.vue'
|
||||||
import { KeFuMessageRespVO } from '@/api/mall/promotion/kefu/message'
|
import { KeFuMessageRespVO } from '@/api/mall/promotion/kefu/message'
|
||||||
|
import { isEmpty } from '@/utils/is'
|
||||||
|
|
||||||
defineOptions({ name: 'OrderItem' })
|
defineOptions({ name: 'OrderItem' })
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
message: KeFuMessageRespVO
|
message?: KeFuMessageRespVO
|
||||||
|
order?: any
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const getMessageContent = computed(() => JSON.parse(props.message.content))
|
const getMessageContent = computed(() =>
|
||||||
|
isEmpty(props.order) ? JSON.parse(props!.message!.content) : props.order
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化订单状态的颜色
|
* 格式化订单状态的颜色
|
||||||
|
|
Loading…
Reference in New Issue