card.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <FlexCol :padding="[30,30,0,30]" gap="gap.lg">
  3. <!-- 卡片背景 -->
  4. <BackgroundBox
  5. color1="#eecaa0"
  6. color2="white"
  7. color2Position="85%"
  8. color3="white"
  9. radius="radius.lg"
  10. direction="column"
  11. :padding="[35,30]"
  12. gap="gap.lg"
  13. >
  14. <!-- 标题 -->
  15. <FlexRow justify="space-between" align="flex-end" width="100%">
  16. <FlexCol gap="gap.md">
  17. <Text :text="villageInfoLoader.content.value?.title" fontConfig="primaryTitle" />
  18. </FlexCol>
  19. <FlexRow center gap="gap.lg">
  20. <BubbleTip
  21. v-model:show="showFollowTip"
  22. content="关注我,方便下次进入"
  23. @contentClick="isFollowed ? undefined : onFollow()"
  24. @close="handleCloseFollowTip"
  25. >
  26. <Button
  27. icon="https://xy.wenlvti.net/app_static/images/village/IconJoin.png"
  28. radius="radius.lgr"
  29. @click="isFollowed ? onUnFollow() : onFollow()"
  30. >
  31. {{ isFollowed ? '已关注' : '关注' }}
  32. </Button>
  33. </BubbleTip>
  34. <FlexRow
  35. v-if="isJoined"
  36. gap="gap.md"
  37. radius="radius.lgr"
  38. backgroundColor="background.tertiary"
  39. >
  40. <Avatar
  41. :src="authStore.userInfo?.avatar"
  42. :size="65"
  43. defaultAvatar="https://xy.wenlvti.net/app_static/images/mine/DefaultAvatar.png"
  44. />
  45. <FlexCol gap="gap.sm" :padding="[0,30,0,0]">
  46. <Text :text="displayMyName" fontSize="23" :lines="1" :maxWidth="200" fontConfig="lightImportantTitle" />
  47. <IconButton icon="edit-filling" size="26" @click="changeNickRef?.show()">
  48. <Text text="改昵称" fontSize="22" fontConfig="subText" />
  49. </IconButton>
  50. </FlexCol>
  51. </FlexRow>
  52. <Button
  53. v-else
  54. icon="https://xy.wenlvti.net/app_static/images/village/IconFollow.png"
  55. radius="radius.lgr"
  56. text="加入"
  57. @click="handleGoJoin()"
  58. />
  59. </FlexRow>
  60. </FlexRow>
  61. <!-- 简介 -->
  62. <TextEllipsis
  63. fontConfig="secondText"
  64. :lines="2"
  65. :expandable="(villageInfoLoader.content.value?.desc as string || '').length > 80"
  66. :text="(villageInfoLoader.content.value?.desc as string) || '暂无简介,欢迎您来编写完善!'"
  67. />
  68. <!-- 状态与申请 -->
  69. <FlexRow
  70. backgroundColor="background.tertiary"
  71. radius="radius.md"
  72. padding="space.md"
  73. justify="space-between"
  74. >
  75. <FlexRow align="center">
  76. <FlexCol gap="gap.md">
  77. <Text :text="`${villageInfoLoader.content.value?.levelText || '默认级别'}`" fontConfig="secondText" />
  78. <Text :text="`存储空间内存:${villageInfoLoader.content.value?.sizeText || ''}`" fontConfig="secondText" />
  79. </FlexCol>
  80. </FlexRow>
  81. <FlexRow align="center" gap="gap.md">
  82. <IconButton icon="help-filling" @click="navTo('/pages/article/details', { id: 7021, modelId: 18, showRecommend: false })" />
  83. <Button
  84. icon="https://xy.wenlvti.net/app_static/images/village/IconUser.png"
  85. radius="radius.lgr"
  86. :padding="[10, 30]"
  87. backgroundColor="white"
  88. @click="upgradeRef?.show()"
  89. >
  90. 升级村社
  91. </Button>
  92. </FlexRow>
  93. </FlexRow>
  94. <!-- 图片 -->
  95. <VillageGallery
  96. v-if="villageInfoLoader.content.value"
  97. ref="villageGalleryRef"
  98. :villageId="villageStore.currentVillage?.id ?? 0"
  99. @goGallery="handleGoGallery"
  100. />
  101. <!-- 地址 -->
  102. <FlexRow justify="space-between" align="center">
  103. <FlexRow align="center" gap="gap.sm">
  104. <Icon name="https://xy.wenlvti.net/app_static/images/village/IconMap.png" size="fontSize.md" />
  105. <Text :text="villageInfoLoader.content.value?.address" fontConfig="contentText" />
  106. </FlexRow>
  107. <Button size="mini" icon="picture" text="村社相册" @click="handleGoGallery" />
  108. </FlexRow>
  109. <VillageMiniMap
  110. v-if="villageInfoLoader.content.value"
  111. :lonlat="{
  112. longitude: villageInfoLoader.content.value.longitude,
  113. latitude: villageInfoLoader.content.value.latitude
  114. }"
  115. :currentNoticeContent="currentNoticeContent"
  116. />
  117. <FlexRow justify="space-between" align="center">
  118. <FlexRow center gap="gap.lg" flexBasis="50%">
  119. <Text text="村社排名" fontConfig="contentText" />
  120. <Text text="No." fontConfig="lightTitle" />
  121. <Text :text="villageInfoLoader.content.value?.rankText" fontConfig="primaryTitle" />
  122. </FlexRow>
  123. <FlexRow center gap="gap.lg" flexBasis="50%">
  124. <Text text="村社等级" fontConfig="contentText" />
  125. <Text :text="`${villageInfoLoader.content.value?.level}级`" fontConfig="primaryTitle" />
  126. </FlexRow>
  127. </FlexRow>
  128. <FlexRow backgroundColor="background.tertiary" radius="radius.md" :padding="[30, 20]">
  129. <Touchable direction="column" center gap="gap.sm" flexBasis="25%" @click="navTo('/pages/home/village/task/index')">
  130. <Text text="乡源光" fontConfig="secondText" />
  131. <Text :text="villageInfoLoader.content.value?.light || '0'" fontConfig="importantTitle" />
  132. <Button type="text" size="mini" text="做任务" @click="navTo('/pages/home/village/task/index')" />
  133. </Touchable>
  134. <Divider type="vertical" />
  135. <FlexCol center gap="gap.sm" flexBasis="25%">
  136. <Touchable direction="column" center @click="navTo('/pages/home/village/volunteer/list', { villageId: villageStore.currentVillage?.id ?? undefined })">
  137. <Text text="乡源人数" fontConfig="contentText" />
  138. <Text :text="villageInfoLoader.content.value?.memberCount|| '0'" fontConfig="importantTitle" />
  139. </Touchable>
  140. <WxButton openType="share">
  141. <Button type="text" size="mini" text="邀请加入" @click="navTo('/pages/home/village/task/index')" />
  142. </WxButton>
  143. </FlexCol>
  144. <Divider type="vertical" />
  145. <Touchable direction="column" center gap="gap.sm" flexBasis="25%" @click="navTo('/pages/home/village/follow/list', {
  146. villageId: villageStore.currentVillage?.id ?? undefined,
  147. })">
  148. <Text text="关注人数" fontConfig="contentText" />
  149. <Text :text="villageInfoLoader.content.value?.followerCount|| '0'" fontConfig="importantTitle" />
  150. <Height :size="36" />
  151. </Touchable>
  152. <Divider type="vertical" />
  153. <Button
  154. :padding="0"
  155. type="text"
  156. size="small"
  157. textColor="text.title"
  158. text="新手上路"
  159. rightIcon="arrow-right"
  160. @click="handleGoNew()"
  161. />
  162. </FlexRow>
  163. </BackgroundBox>
  164. <!-- 排行榜 -->
  165. <HomeTitle
  166. title="排行榜"
  167. showMore
  168. @moreClicked="navTo('/pages/home/village/rank/volunteer', {
  169. villageId: villageStore.currentVillage?.id ?? undefined,
  170. })"
  171. />
  172. <!-- <RoundTags v-model:active="rankActiveTag" :tags="['乡源果', '乡源光', '文化积分' ]" /> -->
  173. <VillageUserRankList
  174. :list="villageUserRankListLoader.content.value ?? []"
  175. :scoreSuffix="rankActiveTag"
  176. @goDetails="navTo('/pages/home/village/volunteer/detail', { id: $event.id })"
  177. />
  178. <!-- 魅力乡源 -->
  179. <HomeTitle title="魅力乡源" showMore @moreClicked="handleGoCollect()">
  180. <template #right>
  181. <FlexRow align="center" gap="gap.md">
  182. <FrameButton
  183. text="管理"
  184. size="small"
  185. primary
  186. @click="handleGoDigManage()"
  187. />
  188. <FrameButton
  189. text="共编村史"
  190. icon="https://xy.wenlvti.net/app_static/images/village/IconHistory.png"
  191. size="small"
  192. @click="handleGoCollect()"
  193. />
  194. <Width :size="15" />
  195. </FlexRow>
  196. </template>
  197. </HomeTitle>
  198. <ProvideVar :vars="{
  199. GridItemIconSize: 90,
  200. GridItemBackgroundColor: 'transparent',
  201. GridItemPaddingHorizontal: 0,
  202. GridItemPaddingVertical: 8,
  203. }">
  204. <Grid :borderGrid="false" :mainAxisCount="4">
  205. <GridItem title="村社概况" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeIntrod.png" touchable @click="handleGoCollect(11, '村社概况')" />
  206. <GridItem title="自然风光" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeEnvirounment.png" touchable @click="handleGoCollect(13, '自然风光')" />
  207. <GridItem title="历史沿革" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeHistory.png" touchable @click="handleGoCollect(2, '历史沿革')" />
  208. <GridItem title="特色产业" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeIndustry.png" touchable @click="handleGoCollect(9, '特色产业' )" />
  209. <GridItem title="文艺活动" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeActivity.png" touchable @click="handleGoCollect(12, '文艺活动')" />
  210. <GridItem title="非遗展示" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeShow.png" touchable @click="handleGoCollect(10, '非遗展示')" />
  211. <GridItem title="民俗风采" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeFolkloreVibe.png" touchable @click="handleGoCollect(8, '民俗风采')" />
  212. <GridItem title="历史人物" icon="https://xy.wenlvti.net/app_static/images/village/IconGoods.png" touchable @click="handleGoCollect(7, '历史人物')" />
  213. </Grid>
  214. </ProvideVar>
  215. <!-- 活力乡源 -->
  216. <HomeTitle title="活力乡源" />
  217. <ProvideVar :vars="{
  218. GridItemIconSize: 90,
  219. GridItemBackgroundColor: 'transparent',
  220. GridItemPaddingHorizontal: 0,
  221. GridItemPaddingVertical: 8,
  222. }">
  223. <Grid :borderGrid="false" :mainAxisCount="4">
  224. <GridItem title="乡源荣光" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeHornor.png" touchable @click="handleGoCollect(23, '乡源荣光')" />
  225. <GridItem title="乡源好物" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeGoods.png" touchable @click="navTo('/pages/home/village/goods/index', { villageId: villageStore.currentVillage?.id ?? undefined })" />
  226. <GridItem title="乡源树" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeTree.png" touchable @click="emit('goTree')" />
  227. <!-- <GridItem title="政贤连心" icon="https://xy.wenlvti.net/app_static/images/village/IconGovAffairs.png" touchable @click="navTo('/pages/home/village/gov/index')" /> -->
  228. <GridItem title="互动游戏" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeGame.png" touchable @click="navTo('/pages/home/village/games/index')" />
  229. </Grid>
  230. </ProvideVar>
  231. <!-- 文脉乡源 -->
  232. <HomeTitle title="文脉乡源">
  233. <template #right>
  234. <FlexRow align="center" gap="gap.md">
  235. <BubbleTip
  236. v-model:show="showManageTip"
  237. position="bottom"
  238. crossPosition="left"
  239. arrowOffsetX="-140rpx"
  240. content="村社贴图太乱?点这里整理"
  241. @contentClick="handleCloseManageTip(true)"
  242. @close="handleCloseManageTip(false)"
  243. >
  244. <FrameButton
  245. text="管理"
  246. size="small"
  247. primary
  248. @click="handleGoOfficalManage()"
  249. />
  250. </BubbleTip>
  251. <FrameButton
  252. text="乡源AI帮你写"
  253. size="small"
  254. icon="https://xy.wenlvti.net/app_static/images/village/IconLargeHistory.png"
  255. @click="handleGoPublish()"
  256. />
  257. </FlexRow>
  258. </template>
  259. </HomeTitle>
  260. <RoundTags v-model:active="listActiveTag" :tags="['广场', '老味道', '老手艺', '老物件', '老故事']" />
  261. </FlexCol>
  262. <OfficialAccountPublishWrap
  263. :topic="recommendTagName"
  264. @publishsuccess="onPublishSuccess"
  265. @empty="isOfficialEmpty=true"
  266. />
  267. <UpgradeDialog
  268. ref="upgradeRef"
  269. v-if="villageStore.currentVillage"
  270. :villageId="villageStore.currentVillage.id"
  271. />
  272. <ChangeNickDialog
  273. v-if="villageStore.currentVillage"
  274. :villageId="villageStore.currentVillage.id"
  275. ref="changeNickRef"
  276. />
  277. <Popup
  278. :show="showUnLight"
  279. :zIndex="100"
  280. size="40%"
  281. position="bottom"
  282. backgroundColor="transparent"
  283. >
  284. <FlexCol center>
  285. <BackgroundBox
  286. backgroundImage="https://xy.wenlvti.net/app_static/images/village/BoxDialog.png"
  287. :backgroundCutBorder="48"
  288. :backgroundCutBorderSize="48"
  289. :padding="40"
  290. direction="column"
  291. center
  292. width="600rpx"
  293. gap="gap.md"
  294. >
  295. <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
  296. <Text :text="`${villageStore.currentVillage?.name}暂未点亮`" fontConfig="primaryTitle" />
  297. <Text text="等你的加入,快来为家乡建设做贡献吧" fontConfig="contentText" />
  298. <Height :height="20" />
  299. <FlexRow gap="gap.lg">
  300. <FrameButton :text="isFollowed ? '已关注' : '先关注村社'" @click="isFollowed ? onUnFollow() : onFollow()" />
  301. <FrameButton text="去申请点亮" @click="handleGoJoin" primary />
  302. </FlexRow>
  303. </BackgroundBox>
  304. <Height :size="300" />
  305. </FlexCol>
  306. </Popup>
  307. </template>
  308. <script setup lang="ts">
  309. import { computed, ref, watch } from 'vue';
  310. import { useUserTools } from '@/common/composeabe/UserTools';
  311. import { useOfficialAccount } from '../../composeabe/OfficialAccount';
  312. import { useAuthStore } from '@/store/auth';
  313. import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
  314. import { useVillageStore } from '@/store/village';
  315. import { useRequireLogin } from '@/common/composeabe/RequireLogin';
  316. import { useFollow } from '../composeabe/Follow';
  317. import { useGetNotice } from '../composeabe/GetNotice';
  318. import { assertNotNull, FormatUtils, waitTimeOut } from '@imengyu/imengyu-utils';
  319. import { navTo } from '@/components/utils/PageAction';
  320. import { confirm } from '@/components/dialog/CommonRoot';
  321. import HomeTitle from '@/common/components/parts/HomeTitle.vue';
  322. import Icon from '@/components/basic/Icon.vue';
  323. import Text from '@/components/basic/Text.vue';
  324. import BackgroundBox from '@/components/display/block/BackgroundBox.vue';
  325. import Touchable from '@/components/feedback/Touchable.vue';
  326. import FlexCol from '@/components/layout/FlexCol.vue';
  327. import FlexRow from '@/components/layout/FlexRow.vue';
  328. import VillageMiniMap from '../../components/VillageMiniMap.vue';
  329. import Divider from '@/components/display/Divider.vue';
  330. import RoundTags from '@/common/components/parts/RoundTags.vue';
  331. import VillageUserRankList from '../../components/VillageUserRankList.vue';
  332. import ProvideVar from '@/components/theme/ProvideVar.vue';
  333. import Grid from '@/components/layout/grid/Grid.vue';
  334. import GridItem from '@/components/layout/grid/GridItem.vue';
  335. import LightVillageApi from '@/api/light/LightVillageApi';
  336. import OfficialAccountPublishWrap from '@/common/components/OfficialAccountPublishWrap.vue';
  337. import UpgradeDialog from '../dialogs/UpgradeDialog.vue';
  338. import VillageGallery from '../components/VillageGallery.vue';
  339. import WxButton from '@/components/basic/WxButton.vue';
  340. import Height from '@/components/layout/space/Height.vue';
  341. import IconButton from '@/components/basic/IconButton.vue';
  342. import Button from '@/components/basic/Button.vue';
  343. import BubbleTip from '@/components/feedback/BubbleTip.vue';
  344. import MemoryTimeOut from '@/components/composeabe/MemoryTimeOut';
  345. import TextEllipsis from '@/components/display/TextEllipsis.vue';
  346. import OfficialApi from '@/api/light/OfficialApi';
  347. import FrameButton from '@/common/components/FrameButton.vue';
  348. import Width from '@/components/layout/space/Width.vue';
  349. import Popup from '@/components/dialog/Popup.vue';
  350. import Image from '@/components/basic/Image.vue';
  351. import Avatar from '@/components/display/Avatar.vue';
  352. import ChangeNickDialog from '../dialogs/ChangeNickDialog.vue';
  353. const emit = defineEmits<{
  354. (e: 'goTree'): void;
  355. (e: 'goJoin'): void;
  356. }>();
  357. const authStore = useAuthStore();
  358. const { getIsVolunteer } = useUserTools();
  359. const { requireLogin } = useRequireLogin();
  360. const { onPublishSuccess } = useOfficialAccount(() => {
  361. return {
  362. villageId: villageStore.currentVillage?.id ?? 0,
  363. userId: authStore.userId,
  364. tag: recommendTagName.value,
  365. };
  366. });
  367. const villageStore = useVillageStore();
  368. const { isFollowed, onFollow, onUnFollow } = useFollow();
  369. const { getIsJoinedVillage } = useUserTools();
  370. const isOfficialEmpty = ref(false);
  371. const isJoined = ref(false);
  372. const villageInfoLoader = useSimpleDataLoader(async () => {
  373. const village = villageStore.currentVillage;
  374. try {
  375. if (village)
  376. isJoined.value = await getIsJoinedVillage(village.id);
  377. } catch {
  378. isJoined.value = false;
  379. }
  380. handleShowFollowTip();
  381. isOfficialEmpty.value = false;
  382. showUnLight.value = !villageStore.currentVillage?.isLight;
  383. setTimeout(() => {
  384. handleManageFollowTip();
  385. }, 3000);
  386. return {
  387. title: village?.name || '',
  388. desc: village?.desc || '',
  389. address: village?.address,
  390. sizeText: `${FormatUtils.formatSize(village?.storageUsed || 0)}已用/${FormatUtils.formatSize(village?.storageLimit || 0)}空间`,
  391. level: village?.level.toString() || '',
  392. levelText: village?.levelText || '',
  393. rankText: village?.rank.toString() || '',
  394. light: village?.light || 0,
  395. memberCount: village?.volunteerCount || 0,
  396. followerCount: village?.followCount || 0,
  397. images: village?.images || [],
  398. longitude: village?.longitude || 0,
  399. latitude: village?.latitude || 0,
  400. };
  401. });
  402. const isLight = computed(() => {
  403. return villageStore.currentVillage?.isLight ?? false;
  404. });
  405. const displayMyName = computed(() => {
  406. const villageInfoInList = villageStore.myJoinedVillages.find(v => v.id === villageStore.currentVillage?.id);
  407. return villageInfoInList?.villageNickname || authStore.userInfo?.nickname || authStore.userInfo?.username || '暂无昵称';
  408. });
  409. const rankActiveTag = ref('文化积分');
  410. const listActiveTag = ref('广场');
  411. const villageUserRankListLoader = useSimpleDataLoader(async () => {
  412. const res = (await LightVillageApi.getVolunteerRankList({
  413. num: 3,
  414. village_id: villageStore.currentVillage?.id ?? undefined,
  415. }))
  416. .map((item, i) => ({
  417. id: item.id,
  418. image: item.avatar ?? '',
  419. title: item.name,
  420. rank: i + 1,
  421. score: item.points,
  422. }));
  423. return res
  424. });
  425. const showFollowTipTimeout = new MemoryTimeOut('FollowTip', 1000 * 3600);//1h
  426. const showFollowTip = ref(false);
  427. function handleShowFollowTip() {
  428. if (!isFollowed.value && showFollowTipTimeout.isTimeout()) {
  429. showFollowTip.value = true;
  430. }
  431. }
  432. function handleCloseFollowTip() {
  433. showFollowTipTimeout.recordTime();
  434. }
  435. const showUnLight = ref(false);
  436. const showManageTipTimeout = new MemoryTimeOut('VillageManageTip', 1000 * 3600 * 20);//30h
  437. const showManageTip = ref(false);
  438. function handleManageFollowTip() {
  439. if (showManageTipTimeout.isTimeout() && !isOfficialEmpty.value)
  440. showManageTip.value = true;
  441. }
  442. function handleCloseManageTip(goComp: boolean) {
  443. showManageTipTimeout.recordTime();
  444. }
  445. watch(rankActiveTag, () => {
  446. villageUserRankListLoader.reload();
  447. });
  448. const recommendTagName = computed(() => {
  449. return '亮乡源·' + villageInfoLoader.content.value?.title + '·' + listActiveTag.value;
  450. });
  451. function handleGoJoin() {
  452. if (isJoined.value)
  453. return;
  454. emit('goJoin');
  455. }
  456. function handleGoNew() {
  457. navTo('/pages/article/common/list', {
  458. modelId: 18,
  459. mainBodyColumnId: 356,
  460. title: '新手上路',
  461. });
  462. }
  463. function handleGoCollect(collectModuleId?: number, title?: string) {
  464. if (!collectModuleId) {
  465. navTo('/pages/dig/details', {
  466. villageId: villageStore.currentVillage?.id ?? undefined,
  467. name: villageInfoLoader.content.value?.title,
  468. });
  469. return;
  470. }
  471. navTo('/pages/dig/forms/list-ordinary', {
  472. villageId: villageStore.currentVillage?.id ?? undefined,
  473. collectModuleId: collectModuleId,
  474. title: title,
  475. });
  476. }
  477. function handleGoPublish() {
  478. requireLogin(async () => {
  479. navTo('/pages/home/chat/dependent/post/publish', {
  480. tag: recommendTagName.value,
  481. villageId: villageStore.currentVillage?.id ?? undefined,
  482. });
  483. }, '登录后以便发布文章使用更多功能哦!');
  484. }
  485. function handleGoGallery() {
  486. navTo('/pages/home/village/gallery/index', {
  487. villageId: villageStore.currentVillage?.id ?? 0 ,
  488. maxCount: villageStore.currentVillage?.imageLimit || 3,
  489. });
  490. }
  491. async function handleGoOfficalManage() {
  492. assertNotNull(villageStore.currentVillage?.id)
  493. const isAdmin = await OfficialApi.checkTopicRule(villageStore.currentVillage.id);
  494. if (!isAdmin) {
  495. const goUpgrade = await confirm({
  496. title: '提示',
  497. content: '您还不是管理员,无法管理贴图哦。您可以联系村社管理员将你添加为管理员,若当前村社暂无管理员,您可以点击“去升级”将您升级为管理员。',
  498. confirmText: '去升级',
  499. cancelText: '取消',
  500. });
  501. if (goUpgrade) {
  502. navTo('/pages/home/village/upgrade/my-upgrade-management', {
  503. villageId: villageStore.currentVillage.id,
  504. });
  505. }
  506. return;
  507. }
  508. navTo('/pages/home/village/post/management-list', {
  509. villageId: villageStore.currentVillage.id,
  510. topic: recommendTagName.value,
  511. });
  512. }
  513. async function handleGoDigManage() {
  514. assertNotNull(villageStore.currentVillage?.id)
  515. const isAdmin = (authStore.isAdmin || await OfficialApi.checkTopicRule(villageStore.currentVillage.id));
  516. if (!isAdmin) {
  517. const goUpgrade = await confirm({
  518. title: '提示',
  519. content: '您还不是管理员,您可以联系村社管理员将你添加为管理员,若当前村社暂无管理员,您可以点击“去升级”将您升级为管理员。',
  520. confirmText: '去升级',
  521. cancelText: '取消',
  522. });
  523. if (goUpgrade) {
  524. navTo('/pages/home/village/upgrade/my-upgrade-management', {
  525. villageId: villageStore.currentVillage.id,
  526. });
  527. }
  528. return;
  529. }
  530. navTo('/pages/dig/details', {
  531. name: villageStore.currentVillage.title,
  532. villageId: villageStore.currentVillage.id,
  533. });
  534. }
  535. const { currentNoticeContent, noticeListLoader } = useGetNotice(() => villageStore.currentVillage?.id || 0);
  536. const upgradeRef = ref<InstanceType<typeof UpgradeDialog>>();
  537. const villageGalleryRef = ref<InstanceType<typeof VillageGallery>>();
  538. const changeNickRef = ref<InstanceType<typeof ChangeNickDialog>>();
  539. watch(() => villageStore.currentVillage, async () => {
  540. await waitTimeOut(100);
  541. await villageInfoLoader.reload();
  542. await waitTimeOut(100);
  543. await villageUserRankListLoader.reload();
  544. await waitTimeOut(100);
  545. await noticeListLoader.reload();
  546. }, { immediate: true });
  547. defineExpose({
  548. onPageBack: (name: string, data: Record<string, unknown>) => {
  549. if (name === 'refreshVillageGrallery') {
  550. villageGalleryRef.value?.refresh();
  551. } else if (name === 'showVillageUpgrade') {
  552. upgradeRef.value?.show();
  553. } else if (name === 'refreshOfficialAccount') {
  554. const tag = listActiveTag.value;
  555. listActiveTag.value = '';
  556. setTimeout(() => listActiveTag.value = tag, 100);
  557. }
  558. },
  559. });
  560. </script>