deviceOrder.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. console.log('pageChange', data)
  22. currentPage.value = data
  23. }
  24. async function getList() {
  25. window.scrollTo(0, 0)
  26. let params = {
  27. type: '',
  28. pageNum: currentPage.value,
  29. pageSize: pageSize.value
  30. }
  31. let res = await getUserOrder(params)
  32. console.log('getUserOrder', res)
  33. pageSize.value = res.pageSize
  34. total.value = res.total || 0
  35. list.value = res.list
  36. }
  37. </script>
  38. <template>
  39. <div>
  40. <div v-if="total">
  41. <div class="order-item" v-for="(item, i) in list" :key="item.orderSn">
  42. <OrderItem :item="item" :i="i" />
  43. </div>
  44. </div>
  45. <div class="scene-nothing" v-else>
  46. <img :src="`${$cdn}images/nothing.png`" alt />
  47. <div>
  48. {{ $t('manage.myOrders.norecord') }}
  49. <a class="gotoBuy" @click="$router.push({ name: 'mallHome' })">{{
  50. $t('manage.gotoBuy')
  51. }}</a>
  52. </div>
  53. </div>
  54. <div class="paging" v-if="total">
  55. <Paging
  56. @clickHandle="pageChange"
  57. @maxPage="(data) => (maxPage = data)"
  58. :current="currentPage"
  59. :total="total"
  60. :equable="pageSize"
  61. />
  62. </div>
  63. </div>
  64. </template>
  65. <style lang="less" scoped>
  66. .scene-nothing {
  67. text-align: center;
  68. padding: 42px 0 210px 0;
  69. img {
  70. padding-bottom: 22px;
  71. margin: 0 auto;
  72. }
  73. div {
  74. font-size: 16px;
  75. color: #969696;
  76. }
  77. }
  78. </style>