index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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]">
  26. <HomeLargeTitle title="村社名片" :active="tab === 'card'" @click="tab = 'card'" />
  27. <Width :width="30" />
  28. <HomeLargeTitle title="乡源树" titleColorAnim :active="tab === 'tree'" @click="tab = 'tree'">
  29. <template #icon>
  30. <Image src="https://xy.wenlvti.net/app_static/images/village/TreeIconAmin1.gif" :width="34" :height="50" mode="heightFix" />
  31. </template>
  32. </HomeLargeTitle>
  33. </FlexRow>
  34. <Card v-if="tab === 'card'" @goTree="tab = 'tree'" />
  35. <Tree v-if="tab === 'tree'" />
  36. </template>
  37. <Popup
  38. v-model:show="showMyFollowPopup"
  39. closeable
  40. position="bottom"
  41. round
  42. size="80vh"
  43. >
  44. <VillageMyFollow @goDetails="onSelectVillage" />
  45. </Popup>
  46. <Height :height="150" />
  47. </FlexCol>
  48. <Around v-else />
  49. <Height :height="200" />
  50. </CommonRoot>
  51. </template>
  52. <script setup lang="ts">
  53. import { computed, onMounted, ref } from 'vue';
  54. import { useVillageStore } from '@/store/village';
  55. import { useFollow } from './composeabe/Follow';
  56. import { navTo } from '@/components/utils/PageAction';
  57. import type { VillageListItem } from '@/api/light/LightVillageApi';
  58. import FlexCol from '@/components/layout/FlexCol.vue';
  59. import Height from '@/components/layout/space/Height.vue';
  60. import Image from '@/components/basic/Image.vue';
  61. import FlexRow from '@/components/layout/FlexRow.vue';
  62. import Card from './introd/card.vue';
  63. import Tree from './introd/tree.vue';
  64. import StatusBarSpace from '@/components/layout/space/StatusBarSpace.vue';
  65. import Button from '@/components/basic/Button.vue';
  66. import Popup from '@/components/dialog/Popup.vue';
  67. import Text from '@/components/basic/Text.vue';
  68. import CommonRoot from '@/components/dialog/CommonRoot.vue';
  69. import Width from '@/components/layout/space/Width.vue';
  70. import VillageMyFollow from '../components/VillageMyFollow.vue';
  71. import HomeLargeTitle from '@/common/components/parts/HomeLargeTitle.vue';
  72. import Around from './recommed/around.vue';
  73. import FrameButton from '@/common/components/FrameButton.vue';
  74. const tab = ref('card');
  75. const villageStore = useVillageStore();
  76. const showMyFollowPopup = ref(false);
  77. const { isFollowed, onFollow, onUnFollow } = useFollow();
  78. const props = withDefaults(defineProps<{
  79. showSwitch?: boolean;
  80. }>(), {
  81. showSwitch: false,
  82. });
  83. const isLight = computed(() => {
  84. return villageStore.currentVillage?.isLight ?? false;
  85. });
  86. onMounted(() => {
  87. if (!props.showSwitch) {
  88. uni.setNavigationBarTitle({
  89. title: villageStore.currentVillage?.name || '未选择村庄',
  90. });
  91. }
  92. });
  93. function handleGoApply() {
  94. navTo('/pages/home/light/submit', {
  95. villageId: villageStore.currentVillage?.id ?? undefined,
  96. unit: (villageStore.currentVillage?.city as string) + (villageStore.currentVillage?.district as string) + (villageStore.currentVillage?.township as string),
  97. regionId: villageStore.currentVillage?.region ?? undefined,
  98. });
  99. }
  100. function onSelectVillage(village: VillageListItem) {
  101. villageStore.setCurrentVillage(village);
  102. showMyFollowPopup.value = false;
  103. }
  104. </script>