index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <!-- 传统村落 -->
  3. <CommonListPage
  4. :title="'传统村落'"
  5. :prevPage="{ title: '保护传承' }"
  6. :dropDownNames="[]"
  7. :pageSize="8"
  8. :rowCount="2"
  9. :rowType="2"
  10. :load="loadData"
  11. :showDetail="showDetail"
  12. :tagsData="tagsData"
  13. :defaultSelectTag="tagsData[0]?.id"
  14. />
  15. </template>
  16. <script setup lang="ts">
  17. import { onMounted, ref } from 'vue';
  18. import { useRoute, useRouter } from 'vue-router';
  19. import VillageApi from '@/api/village/VillageApi';
  20. import CommonContent from '@/api/CommonContent';
  21. const route = useRoute();
  22. const router = useRouter();
  23. async function showDetail(item: any) {
  24. if (import.meta.server)
  25. return;
  26. localStorage.setItem('VillageTemp', JSON.stringify(item));
  27. setTimeout(() => {
  28. router.push({
  29. path: '/village/detail',
  30. query: { id: item.id },
  31. })
  32. }, 200);
  33. }
  34. async function loadData(
  35. page: number,
  36. pageSize: number,
  37. selectedTag: number,
  38. searchText: string,
  39. dropDownValues: number[]
  40. ) {
  41. const res = await VillageApi.getVillageList(selectedTag);
  42. return {
  43. page: page,
  44. total: res.length,
  45. data: res
  46. .filter(p => (!searchText || searchText.includes(p.villageName)))
  47. .map((item, index) => {
  48. return {
  49. title: item.villageName,
  50. desc: item.desc,
  51. ...item,
  52. addItems: [],
  53. bottomTags: [
  54. item.levelText,
  55. item.batchText,
  56. item.historyLevelText,
  57. ],
  58. };
  59. })
  60. ,
  61. }
  62. }
  63. //子分类
  64. const tagsData = ref<{
  65. id: number,
  66. name: string,
  67. }[]>([]);
  68. onMounted(async () => {
  69. const res = await CommonContent.getCategoryList(151);
  70. const it1 = res.find(p => p.title == '国家级');
  71. const it2 = res.find(p => p.title == '省级');
  72. if (it1) it1.title = '特色村舍';
  73. if (it2) it2.title = '传统村落';
  74. tagsData.value = res.slice(1).map((p) => ({ id: p.id, name: p.title }));
  75. })
  76. </script>
  77. <style lang="scss">
  78. .shadow1 {
  79. background: linear-gradient( 180deg, #F1F1F1 0%, #FFFFFF 100%);
  80. border-radius: 12px 12px 12px 12px;
  81. border: 1px solid #FFFFFF;
  82. box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.08);
  83. }
  84. .details {
  85. color: #333;
  86. .item {
  87. cursor: pointer;
  88. margin-bottom: 15px;
  89. }
  90. .nana-simple-input {
  91. background-color: #fff;
  92. border-color: #eee;
  93. }
  94. .page-button {
  95. background-color: #ddd;
  96. color: #333;
  97. &.enable {
  98. background-color: #fff;
  99. color: #000;
  100. border-color: #333;
  101. }
  102. }
  103. }
  104. </style>