permanent.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="temporary">
  3. <ui-search v-model="searchKey" :placeholder="'请输入展览名称'"></ui-search>
  4. <div class="searchNone" v-if="list.length === 0">
  5. <img src="@/assets/images/resource/searchNone.svg" alt="" />
  6. <p>暂时没有数据</p>
  7. </div>
  8. <ul
  9. v-else
  10. v-infinite-scroll="getData"
  11. infinite-scroll-disabled="busy"
  12. :infinite-scroll-immediate-check="true"
  13. infinite-scroll-distance="30"
  14. :key="ran"
  15. >
  16. <li v-for="(item, i) in list" :key="i">
  17. <exItem :exData="item" />
  18. </li>
  19. </ul>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { defineEmits, onMounted, watch, nextTick, ref } from "vue";
  24. import exItem from "@/components/exItem";
  25. import { getExhibitionList } from "@/config/api";
  26. const searchKey = ref("");
  27. const busy = ref(false);
  28. const list = ref([]);
  29. let paging = ref({
  30. pageSize: 10,
  31. pageNum: 1,
  32. current: 1,
  33. });
  34. watch(searchKey, () => {
  35. getData(true);
  36. });
  37. const getData = (reset = null) => {
  38. if (reset) {
  39. list.value = [];
  40. busy.value = false;
  41. }
  42. if (busy.value) {
  43. return;
  44. }
  45. getExhibitionList(
  46. {
  47. pageNum: paging.value.pageNum,
  48. pageSize: paging.value.pageSize,
  49. museumId: 1,
  50. searchKey: searchKey.value,
  51. type: "long",
  52. },
  53. (data) => {
  54. if (data.data.total <= list.value.length) {
  55. busy.value = true;
  56. return;
  57. }
  58. list.value = list.value.concat(data.data.records);
  59. paging.value.pageNum += 1;
  60. }
  61. );
  62. };
  63. onMounted(() => {
  64. getData();
  65. });
  66. </script>
  67. <style lang="scss" scoped>
  68. .temporary {
  69. width: 1400px;
  70. margin: 62px auto;
  71. .slebar {
  72. display: flex;
  73. > div {
  74. margin-left: 20px;
  75. }
  76. }
  77. > ul {
  78. width: 100%;
  79. > li {
  80. width: 100%;
  81. position: relative;
  82. &::after {
  83. content: "";
  84. display: inline-block;
  85. background: #d9c791;
  86. height: 1px;
  87. width: 110%;
  88. position: absolute;
  89. bottom: 0;
  90. left: 50%;
  91. transform: translateX(-50%);
  92. }
  93. }
  94. }
  95. }
  96. </style>