OrderBrowsingHistory.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <OrderItem v-for="item in list" :key="item.id" :order="item" class="mb-10px" />
  3. </template>
  4. <script lang="ts" setup>
  5. import OrderItem from '@/views/mall/promotion/kefu/components/message/OrderItem.vue'
  6. import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
  7. import { getOrderPage } from '@/api/mall/trade/order'
  8. import { concat } from 'lodash-es'
  9. defineOptions({ name: 'OrderBrowsingHistory' })
  10. const list = ref<any>([]) // 列表
  11. const total = ref(0) // 总数
  12. const queryParams = reactive({
  13. pageNo: 1,
  14. pageSize: 10,
  15. userId: 0
  16. })
  17. const skipGetMessageList = computed(() => {
  18. // 已加载到最后一页的话则不触发新的消息获取
  19. return total.value > 0 && Math.ceil(total.value / queryParams.pageSize) === queryParams.pageNo
  20. }) // 跳过消息获取
  21. /** 获得浏览记录 */
  22. const getHistoryList = async (val: KeFuConversationRespVO) => {
  23. queryParams.userId = val.userId
  24. const res = await getOrderPage(queryParams)
  25. total.value = res.total
  26. list.value = res.list
  27. }
  28. /** 加载下一页数据 */
  29. const loadMore = async () => {
  30. if (skipGetMessageList.value) {
  31. return
  32. }
  33. queryParams.pageNo += 1
  34. const res = await getOrderPage(queryParams)
  35. total.value = res.total
  36. concat(list.value, res.list)
  37. }
  38. defineExpose({ getHistoryList, loadMore })
  39. </script>