deviceOrder.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <script setup>
  2. import { ref, watch, onMounted, computed } from 'vue'
  3. import { getUserOrder } from '@/api/user'
  4. import Paging from '@/components/pc/Paging/index.vue'
  5. import OrderItem from './OrderItem.vue'
  6. const pageSize = ref(5)
  7. const currentPage = ref(1)
  8. const total = ref(0)
  9. const list = ref([])
  10. const maxPage = ref(0)
  11. const showInvoice = ref(false)
  12. const currentI = ref('')
  13. const currentItem = ref('')
  14. watch(currentPage.value, () => {
  15. getList()
  16. })
  17. onMounted(() => {
  18. getList()
  19. })
  20. function pageChange(data) {
  21. currentPage.value = data
  22. }
  23. async function getList() {
  24. window.scrollTo(0, 0)
  25. let params = {
  26. type: '',
  27. pageNum: currentPage.value,
  28. pageSize: pageSize.value
  29. }
  30. let res = await getUserOrder(params)
  31. console.log('getUserOrder', res)
  32. pageSize.value = res.pageSize
  33. total.value = res.total || 0
  34. list.value = res.list
  35. }
  36. </script>
  37. <template>
  38. <div>
  39. <div v-if="total">
  40. <div class="order-item" v-for="(item, i) in list" :key="item.orderSn">
  41. <OrderItem :item="item" :i="i" />
  42. </div>
  43. </div>
  44. <div class="scene-nothing" v-else>
  45. <img :src="`${$cdn}images/nothing.png`" alt />
  46. <div>
  47. {{ $t('manage.myOrders.norecord') }}
  48. <a class="gotoBuy" @click="$router.push({ name: 'mallHome' })">{{
  49. $t('manage.gotoBuy')
  50. }}</a>
  51. </div>
  52. </div>
  53. <div class="paging" v-if="total">
  54. <Paging
  55. @clickHandle="pageChange"
  56. @maxPage="(data) => (maxPage = data)"
  57. :current="currentPage"
  58. :total="total"
  59. :equable="pageSize"
  60. />
  61. </div>
  62. </div>
  63. </template>
  64. <style lang="less" scoped>
  65. .scene-nothing {
  66. text-align: center;
  67. padding: 42px 0 210px 0;
  68. img {
  69. padding-bottom: 22px;
  70. margin: 0 auto;
  71. }
  72. div {
  73. font-size: 16px;
  74. color: #969696;
  75. }
  76. }
  77. </style>