index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <CommonRoot>
  3. <FlexCol v-if="showSwitch" position="absolute" :left="0" :top="0">
  4. <StatusBarSpace />
  5. <Button
  6. @click="showMyFollowPopup = true"
  7. icon="https://xy.wenlvti.net/app_static/images/home/IconSwitch.png"
  8. :text="villageStore.currentVillage?.name || '未选择村庄'"
  9. type="custom"
  10. color="transparent"
  11. />
  12. </FlexCol>
  13. <FlexCol v-if="villageStore.currentVillage" gap="gap.md">
  14. <FlexCol v-if="!isLight" center :padding="[60,0]" gap="gap.md">
  15. <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
  16. <Text text="本村暂未点亮" fontConfig="primaryTitle" />
  17. <Text text="您可以申请成为志愿者,点亮村庄" fontConfig="contentText" />
  18. <Height :height="20" />
  19. <FlexRow gap="gap.lg">
  20. <FrameButton :text="isFollowed ? '已关注' : '先关注村庄'" @click="isFollowed ? onUnFollow() : onFollow()" />
  21. <FrameButton text="去申请点亮" @click="handleGoApply()" primary />
  22. </FlexRow>
  23. </FlexCol>
  24. <template v-else>
  25. <FlexRow center :padding="[0,30]" gap="gap.md">
  26. <HomeLargeTitle title="村社名片" :active="tab === 'card'" @click="tab = 'card'" />
  27. <HomeLargeTitle title="乡源树" :active="tab === 'tree'" @click="tab = 'tree'">
  28. <template #icon>
  29. <Image src="https://xy.wenlvti.net/app_static/images/village/TreeIconAmin.gif" :width="45" :height="46" mode="heightFix" />
  30. </template>
  31. </HomeLargeTitle>
  32. </FlexRow>
  33. <Card v-if="tab === 'card'" />
  34. <Tree v-if="tab === 'tree'" />
  35. </template>
  36. <Popup
  37. v-model:show="showMyFollowPopup"
  38. closeable
  39. position="bottom"
  40. round
  41. size="80vh"
  42. >
  43. <VillageMyFollow @goDetails="onSelectVillage" />
  44. </Popup>
  45. <Height :height="150" />
  46. </FlexCol>
  47. <Around v-else />
  48. </CommonRoot>
  49. </template>
  50. <script setup lang="ts">
  51. import { computed, onMounted, ref } from 'vue';
  52. import { useVillageStore } from '@/store/village';
  53. import FlexCol from '@/components/layout/FlexCol.vue';
  54. import Height from '@/components/layout/space/Height.vue';
  55. import Image from '@/components/basic/Image.vue';
  56. import HomeLargeTitle from '@/common/components/parts/HomeLargeTitle.vue';
  57. import FlexRow from '@/components/layout/FlexRow.vue';
  58. import Card from './introd/card.vue';
  59. import Tree from './introd/tree.vue';
  60. import StatusBarSpace from '@/components/layout/space/StatusBarSpace.vue';
  61. import Button from '@/components/basic/Button.vue';
  62. import Popup from '@/components/dialog/Popup.vue';
  63. import VillageMyFollow from '../components/VillageMyFollow.vue';
  64. import type { VillageListItem } from '@/api/light/LightVillageApi';
  65. import Around from './recommed/around.vue';
  66. import Text from '@/components/basic/Text.vue';
  67. import FrameButton from '@/common/components/FrameButton.vue';
  68. import CommonRoot from '@/components/dialog/CommonRoot.vue';
  69. import { navTo } from '@/components/utils/PageAction';
  70. import { useFollow } from './composeabe/Follow';
  71. const tab = ref('card');
  72. const villageStore = useVillageStore();
  73. const showMyFollowPopup = ref(false);
  74. const { isFollowed, onFollow, onUnFollow } = useFollow();
  75. const props = withDefaults(defineProps<{
  76. showSwitch?: boolean;
  77. }>(), {
  78. showSwitch: false,
  79. });
  80. const isLight = computed(() => {
  81. return villageStore.currentVillage?.isLight ?? false;
  82. });
  83. onMounted(() => {
  84. if (!props.showSwitch) {
  85. uni.setNavigationBarTitle({
  86. title: villageStore.currentVillage?.name || '未选择村庄',
  87. });
  88. }
  89. });
  90. function handleGoApply() {
  91. navTo('/pages/home/light/submit', {
  92. villageId: villageStore.currentVillage?.id ?? undefined,
  93. unit: (villageStore.currentVillage?.city as string) + (villageStore.currentVillage?.district as string) + (villageStore.currentVillage?.township as string),
  94. regionId: villageStore.currentVillage?.region ?? undefined,
  95. });
  96. }
  97. function onSelectVillage(village: VillageListItem) {
  98. villageStore.setCurrentVillage(village);
  99. showMyFollowPopup.value = false;
  100. }
  101. </script>