list.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="d-flex flex-column bg-base" style="min-height: 100vh;">
  3. <view class="d-flex flex-col p-2">
  4. <uni-search-bar
  5. v-model="searchValue"
  6. radius="100"
  7. bgColor="#fff"
  8. placeholder="搜索特色村社"
  9. clearButton="auto"
  10. cancelButton="none"
  11. @confirm="doSearch"
  12. />
  13. </view>
  14. <view class="d-flex flex-row flex-wrap justify-between p-2">
  15. <view
  16. v-for="item in listLoader.list.value"
  17. :key="item.id"
  18. class="width-1-2"
  19. >
  20. <Box2LineLargeImageUserShadow
  21. classNames="ml-2 mb-3"
  22. titleColor="title-text"
  23. :image="item.image"
  24. :title="item.name"
  25. @click="goDetails(item)"
  26. />
  27. </view>
  28. </view>
  29. <SimplePageListLoader :loader="listLoader" />
  30. </view>
  31. </template>
  32. <script setup lang="ts">
  33. import { onMounted, ref, watch } from 'vue';
  34. import { useSimplePageListLoader } from '@/common/composeabe/SimplePageListLoader';
  35. import { navTo } from '@/common/utils/PageAction';
  36. import SimplePageListLoader from '@/common/components/SimplePageListLoader.vue';
  37. import Box2LineLargeImageUserShadow from '@/pages/parts/Box2LineLargeImageUserShadow.vue';
  38. import VillageApi from '@/api/inhert/VillageApi';
  39. const searchValue = ref('');
  40. const listLoader = useSimplePageListLoader<{
  41. id: number,
  42. image: string,
  43. name: string
  44. }>(8, async (page, pageSize) => {
  45. const res = await VillageApi.getVallageList();
  46. return res.map((item) => {
  47. return {
  48. ...item,
  49. name: item.villageName,
  50. }
  51. })
  52. });
  53. function doSearch() {
  54. listLoader.loadData(undefined, true);
  55. }
  56. function goDetails(item: any) {
  57. uni.setStorageSync('VillageTemp', JSON.stringify(item));
  58. navTo('details', { id: item.id })
  59. }
  60. onMounted(() => {
  61. doSearch();
  62. })
  63. </script>