index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <CommonRoot>
  3. <FlexCol v-if="showSwitch" position="fixed" :left="0" :top="0" :right="0" :zIndex="200">
  4. <StatusBarSpace />
  5. <FlexRow gap="gap.lg" :padding="30">
  6. <BubbleTip
  7. v-model:show="showFollowTip"
  8. position="bottom"
  9. crossPosition="left"
  10. arrowOffsetX="-50rpx"
  11. content="点此可以查看我关注的村社"
  12. @contentClick="handleCloseFollowTip(true)"
  13. @close="handleCloseFollowTip(false)"
  14. >
  15. <Button
  16. icon="https://xy.wenlvti.net/app_static/images/home/IconSwitch.png"
  17. :text="villageStore.currentVillage?.name || '未选择村社'"
  18. :textColor="topTab === 'village' ? 'text.titleLight' : 'text.content'"
  19. size="medium"
  20. @click="showMyFollowPopup = true"
  21. />
  22. </BubbleTip>
  23. <!-- <Button
  24. :textColor="topTab === 'around' ? 'text.titleLight' : 'text.content'"
  25. text="周边村社"
  26. size="medium"
  27. @click="topTab = 'around'"
  28. /> -->
  29. </FlexRow>
  30. </FlexCol>
  31. <Height :height="40" />
  32. <template v-if="delayShow">
  33. <FlexCol v-if="topTab === 'village' && villageStore.currentVillage" gap="gap.md">
  34. <FlexRow center :padding="[0,30]">
  35. <HomeLargeTitle title="村社名片" :active="tab === 'card'" @click="tab = 'card'" />
  36. <Width :width="30" />
  37. <HomeLargeTitle title="乡源树" titleColorAnim :active="tab === 'tree'" @click="tab = 'tree'">
  38. <template #icon>
  39. <Image src="https://xy.wenlvti.net/app_static/images/village/TreeIconAmin2.gif" :width="34" :height="50" mode="heightFix" />
  40. </template>
  41. </HomeLargeTitle>
  42. <Width :width="30" />
  43. </FlexRow>
  44. <Card
  45. v-if="tab === 'card'"
  46. ref="cardRef"
  47. @goTree="tab = 'tree'"
  48. @goJoin="joinDialog?.show()"
  49. />
  50. <Tree
  51. v-if="tab === 'tree'"
  52. ref="treeRef"
  53. />
  54. <Height :height="150" />
  55. </FlexCol>
  56. <FlexCol v-else-if="topTab === 'village'" gap="gap.md">
  57. <FlexCol center :padding="[60,0]" gap="gap.md">
  58. <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
  59. <Text text="还未选择一个村社" fontConfig="primaryTitle" />
  60. <Text text="欢迎关注或者认领村社,认领自己家乡参与建设,或四处看看" fontConfig="contentText" />
  61. <Height :height="20" />
  62. <FlexRow gap="gap.lg">
  63. <FrameButton text="去认领村社" @click="handleGoSuscribe" primary />
  64. </FlexRow>
  65. </FlexCol>
  66. <Height :height="150" />
  67. </FlexCol>
  68. <!-- <Around
  69. v-else
  70. @selectVillage="onSelectVillage"
  71. /> -->
  72. </template>
  73. <LoadingPage v-else />
  74. <Height :height="200" />
  75. <Popup
  76. v-model:show="showMyFollowPopup"
  77. closeable
  78. position="bottom"
  79. round
  80. size="80vh"
  81. >
  82. <scroll-view scroll-y style="height: 100%">
  83. <VillageMyFollow @goDetails="onSelectVillage" />
  84. </scroll-view>
  85. </Popup>
  86. <JoinDialog
  87. ref="joinDialog"
  88. v-if="villageStore.currentVillage"
  89. :villageId="villageStore.currentVillage.id"
  90. />
  91. </CommonRoot>
  92. </template>
  93. <script setup lang="ts">
  94. import { onMounted, ref, watch } from 'vue';
  95. import { useVillageStore } from '@/store/village';
  96. import { useFollow } from './composeabe/Follow';
  97. import { isDevEnv } from '@/common/config/AppCofig';
  98. import { waitTimeOut } from '@imengyu/imengyu-utils';
  99. import type { VillageListItem } from '@/api/light/LightVillageApi';
  100. import FlexCol from '@/components/layout/FlexCol.vue';
  101. import Height from '@/components/layout/space/Height.vue';
  102. import Image from '@/components/basic/Image.vue';
  103. import FlexRow from '@/components/layout/FlexRow.vue';
  104. import Card from './introd/card.vue';
  105. import Tree from './introd/tree.vue';
  106. import StatusBarSpace from '@/components/layout/space/StatusBarSpace.vue';
  107. import Button from '@/components/basic/Button.vue';
  108. import Popup from '@/components/dialog/Popup.vue';
  109. import Text from '@/components/basic/Text.vue';
  110. import CommonRoot from '@/components/dialog/CommonRoot.vue';
  111. import Width from '@/components/layout/space/Width.vue';
  112. import VillageMyFollow from '../components/VillageMyFollow.vue';
  113. import HomeLargeTitle from '@/common/components/parts/HomeLargeTitle.vue';
  114. import Around from './recommed/around.vue';
  115. import FrameButton from '@/common/components/FrameButton.vue';
  116. import JoinDialog from './dialogs/JoinDialog.vue';
  117. import BubbleTip from '@/components/feedback/BubbleTip.vue';
  118. import MemoryTimeOut from '@/components/composeabe/MemoryTimeOut';
  119. import LoadingPage from '@/components/display/loading/LoadingPage.vue';
  120. const topTab = ref<'village' | 'around'>('village');
  121. const tab = ref('card');
  122. const delayShow = ref(false);
  123. const villageStore = useVillageStore();
  124. const { isFollowed } = useFollow();
  125. const showMyFollowPopup = ref(false);
  126. const joinDialog = ref<InstanceType<typeof JoinDialog>>();
  127. const cardRef = ref<InstanceType<typeof Card>>();
  128. const treeRef = ref<InstanceType<typeof Tree>>();
  129. const props = withDefaults(defineProps<{
  130. showSwitch?: boolean;
  131. }>(), {
  132. showSwitch: false,
  133. });
  134. const emit = defineEmits(['goHome']);
  135. const showFollowTipTimeout = new MemoryTimeOut('FollowTip', 1000 * 3600 * 30);//30h
  136. const showFollowTip = ref(false);
  137. function handleShowFollowTip() {
  138. if (showFollowTipTimeout.isTimeout()) {
  139. showFollowTip.value = true;
  140. }
  141. }
  142. function handleCloseFollowTip(open: boolean) {
  143. showFollowTipTimeout.recordTime();
  144. if (open)
  145. showMyFollowPopup.value = true;
  146. }
  147. function handleGoSuscribe() {
  148. emit('goHome');
  149. }
  150. function onSelectVillage(village: VillageListItem) {
  151. topTab.value = 'village';
  152. villageStore.setCurrentVillage(village);
  153. uni.pageScrollTo({ scrollTop: 0 });
  154. showMyFollowPopup.value = false;
  155. }
  156. watch(() => villageStore.currentVillage?.id, (newVal) => {
  157. if (newVal && topTab.value === 'around')
  158. topTab.value = 'village';
  159. tab.value = 'card';
  160. handleTestGoTree();
  161. handleShowFollowTip();
  162. });
  163. watch(() => isFollowed.value, (newVal) => {
  164. handleShowFollowTip();
  165. });
  166. onMounted(async () => {
  167. if (!props.showSwitch) {
  168. uni.setNavigationBarTitle({
  169. title: villageStore.currentVillage?.name || '未选择村庄',
  170. });
  171. }
  172. await waitTimeOut(100);
  173. delayShow.value = true;
  174. await waitTimeOut(1000);
  175. handleTestGoTree();
  176. });
  177. function handleTestGoTree() {
  178. if (isDevEnv) {
  179. //tab.value = 'tree';
  180. }
  181. }
  182. defineExpose({
  183. onPageBack: (name: string, data: Record<string, unknown>) => {
  184. cardRef.value?.onPageBack(name, data);
  185. treeRef.value?.onPageBack(name, data);
  186. },
  187. goTreePage: () => {
  188. tab.value = 'tree';
  189. },
  190. goCollectPage: () => {
  191. tab.value = 'card';
  192. uni.pageScrollTo({
  193. scrollTop: 1000
  194. })
  195. },
  196. })
  197. </script>