list.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <CommonListPage
  3. ref="list"
  4. title="传统村落"
  5. itemType="image-large-2"
  6. detailsPage="custom"
  7. showTotal
  8. :dropDownNames="dropdownNames"
  9. :load="loadData"
  10. :tabs="tabs"
  11. :startTabIndex="0"
  12. :loadMounted="false"
  13. @goCustomDetails="goDetails"
  14. />
  15. </template>
  16. <script setup lang="ts">
  17. import CommonListPage, { type DropDownNames } from '@/pages/article/common/CommonListPage.vue';
  18. import { onMounted, ref } from 'vue';
  19. import VillageApi from '@/api/inhert/VillageApi';
  20. import { navTo } from '@imengyu/imengyu-utils/dist/uniapp/PageAction';
  21. import CommonContent from '@/api/CommonContent';
  22. import { waitTimeOut } from '@imengyu/imengyu-utils';
  23. const dropdownNames = ref<DropDownNames[]>([]);
  24. const list = ref();
  25. async function loadData(
  26. page: number,
  27. pageSize: number,
  28. searchText: string,
  29. dropDownValues: number[],
  30. tabSelect: number,
  31. ) {
  32. const list = page == 1 ? await VillageApi.getVallageList(tabSelect) : [];
  33. list.filter((p) => !searchText || p.title.includes(searchText)).forEach((p) => {
  34. p.desc = p.desc;
  35. p.badge = p.district;
  36. p.bottomTags = [
  37. p.levelText,
  38. p.batchText,
  39. p.historyLevelText,
  40. ];
  41. })
  42. return { list: list, total: list.length }
  43. }
  44. function goDetails(item: any) {
  45. uni.setStorageSync('VillageTemp', JSON.stringify(item));
  46. navTo('details', { id: item.id })
  47. }
  48. const tabs = ref<{id: number, name: string}[]>();
  49. onMounted(async () => {
  50. const res = await CommonContent.getCategoryList(151);
  51. const it1 = res.find(p => p.title == '国家级');
  52. const it2 = res.find(p => p.title == '省级');
  53. if (it1) it1.title = '特色村舍';
  54. if (it2) it2.title = '传统村落';
  55. tabs.value = res.slice(1).map((p) => ({ id: p.id, name: p.title }));
  56. await waitTimeOut(400);
  57. list.value.load();
  58. })
  59. </script>