MemberBrowsingHistory.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. <script lang="ts" setup>
  16. import type { TabsPaneContext } from 'element-plus'
  17. import ProductBrowsingHistory from './ProductBrowsingHistory.vue'
  18. import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
  19. import { isEmpty } from '@/utils/is'
  20. defineOptions({ name: 'MemberBrowsingHistory' })
  21. const activeName = ref('a')
  22. /** tab 切换 */
  23. const productBrowsingHistoryRef = ref<InstanceType<typeof ProductBrowsingHistory>>()
  24. const handleClick = (tab: TabsPaneContext) => {
  25. activeName.value = tab.paneName as string
  26. getHistoryList()
  27. }
  28. /** 获得历史数据 */
  29. const getHistoryList = async () => {
  30. switch (activeName.value) {
  31. case 'a':
  32. await productBrowsingHistoryRef.value?.getHistoryList(conversation.value)
  33. break
  34. case 'b':
  35. break
  36. default:
  37. break
  38. }
  39. }
  40. /** 浏览历史初始化 */
  41. const conversation = ref<KeFuConversationRespVO>({} as KeFuConversationRespVO) // 用户会话
  42. const initHistory = async (val: KeFuConversationRespVO) => {
  43. activeName.value = 'a'
  44. conversation.value = val
  45. await getHistoryList()
  46. }
  47. defineExpose({ initHistory })
  48. </script>
  49. <style lang="scss" scoped>
  50. .header-title {
  51. border-bottom: #e4e0e0 solid 1px;
  52. }
  53. </style>