card.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. <template>
  2. <DynamicX
  3. :page="page"
  4. :injectScriptGlobal="pageScriptGlobal"
  5. >
  6. <template #default="{ page, context }">
  7. <DynamicXNodeChild :node="page">
  8. <template #nodeRender="{ node }">
  9. <FlexCol v-if="node.type === 'Card:Basic'" gap="gap.md">
  10. <!-- 标题 -->
  11. <FlexRow justify="space-between" gap="gap.lg" wrap align="center" width="100%">
  12. <FlexRow gap="gap.md">
  13. <Text
  14. :text="title"
  15. :lines="1"
  16. :fontSize="40"
  17. wordBreak="break-all"
  18. fontConfig="primaryTitle"
  19. />
  20. </FlexRow>
  21. <FlexRow flex="1" justify="space-between" align="center" gap="gap.lg">
  22. <IconButton icon="cascades" :size="40" @click="shareQRDialog?.show()" />
  23. <FlexRow align="center" gap="gap.lg">
  24. <BubbleTip
  25. v-model:show="showFollowTip"
  26. content="关注我,方便下次进入"
  27. @contentClick="isFollowed ? undefined : onFollow()"
  28. @close="handleCloseFollowTip"
  29. >
  30. <Button
  31. :icon="isFollowed ? 'success' : 'https://xy.wenlvti.net/app_static/images/village/IconJoin.png'"
  32. radius="radius.lgr"
  33. :text="isFollowed ? (title.length < 5 ? '已关注' : '') : '关注'"
  34. :padding="[15, 10]"
  35. :iconProps="{ size: 38 }"
  36. @click="isFollowed ? onUnFollow() : onFollow()"
  37. />
  38. </BubbleTip>
  39. <FlexRow
  40. v-if="isJoined"
  41. gap="gap.md"
  42. radius="radius.lgr"
  43. backgroundColor="background.tertiary"
  44. >
  45. <Avatar
  46. :src="authStore.userInfo?.avatar"
  47. :size="65"
  48. defaultAvatar="https://xy.wenlvti.net/app_static/images/mine/DefaultAvatar.png"
  49. />
  50. <FlexCol position="relative" gap="gap.sm" :padding="[0,30,0,0]">
  51. <FlexRow align="center" :gap="10">
  52. <Text :text="displayMyName" fontSize="23" :lines="1" :maxWidth="150" fontConfig="lightImportantTitle" />
  53. <Button
  54. v-if="isStaff"
  55. :innerStyle="{ position: 'absolute', right: 0, top: 0, transform: 'translate(5%,-50%)' }"
  56. text="管理" size="mini" radius="radius.md" type="danger"
  57. @click="staffInfoRef?.show()"
  58. />
  59. </FlexRow>
  60. <IconButton icon="edit-filling" size="26" @click="changeNickRef?.show()">
  61. <Text text="改昵称" :wrap="false" fontSize="22" fontConfig="subText" />
  62. </IconButton>
  63. </FlexCol>
  64. </FlexRow>
  65. <Button
  66. v-else
  67. icon="https://xy.wenlvti.net/app_static/images/village/IconFollow.png"
  68. radius="radius.lgr"
  69. text="加入"
  70. @click="handleGoJoin()"
  71. />
  72. </FlexRow>
  73. </FlexRow>
  74. </FlexRow>
  75. <!-- 简介 -->
  76. <TextEllipsis
  77. fontConfig="secondText"
  78. :outerProps="{ direction: 'row', width: '490rpx' }"
  79. :lines="1"
  80. :expandable="(villageInfoLoader.content.value?.desc as string || '').length > 20"
  81. :text="(villageInfoLoader.content.value?.desc as string) || '暂无简介,欢迎您来编写完善!'"
  82. wordBreak="break-all"
  83. @expand="descOpen = true;"
  84. @collapse="descOpen = false;"
  85. />
  86. </FlexCol>
  87. <template v-else-if="node.type === 'Card:Level'">
  88. <!-- 状态与申请 -->
  89. <FlexRow
  90. backgroundColor="background.tertiary"
  91. radius="radius.md"
  92. padding="space.md"
  93. justify="space-between"
  94. >
  95. <FlexRow align="center">
  96. <FlexCol gap="gap.md">
  97. <FlexRow gap="gap.lg" align="center">
  98. <Icon v-if="villageInfoLoader.content.value?.vipLevel === 4" name="https://xy.wenlvti.net/app_static/images/village/IconGov.png" :size="70" />
  99. <Text :text="`${villageInfoLoader.content.value?.vipLevelText || '默认级别'}`" fontConfig="secondText" />
  100. </FlexRow>
  101. <Text v-if="villageInfoLoader.content.value?.sizeLimit" :text="`存储空间:${villageInfoLoader.content.value?.sizeText || ''}`" :fontSize="22" fontConfig="secondText" />
  102. <Text v-else text="无限存储空间" :fontSize="22" fontConfig="secondText" />
  103. </FlexCol>
  104. </FlexRow>
  105. <FlexRow align="center" gap="gap.md">
  106. <IconButton icon="help-filling" @click="navTo('/pages/article/details', { id: 7021, modelId: 18, showRecommend: false })" />
  107. <Button
  108. v-if="(villageInfoLoader.content.value?.vipLevel || 0) < 4"
  109. icon="https://xy.wenlvti.net/app_static/images/village/IconUser.png"
  110. radius="radius.lgr"
  111. :padding="[10, 30]"
  112. backgroundColor="white"
  113. text="升级村社"
  114. @click="upgradeRef?.show()"
  115. />
  116. </FlexRow>
  117. </FlexRow>
  118. </template>
  119. <template v-else-if="node.type === 'Card:Gallery'">
  120. <!-- 图片 -->
  121. <VillageGallery
  122. v-if="villageInfoLoader.content.value"
  123. ref="villageGalleryRef"
  124. :villageId="villageStore.currentVillage?.id ?? 0"
  125. @goGallery="handleGoGallery"
  126. />
  127. </template>
  128. <template v-else-if="node.type === 'Card:AddressAndMap'">
  129. <!-- 地图 -->
  130. <VillageMiniMap
  131. v-if="villageInfoLoader.content.value"
  132. :lonlat="{
  133. longitude: villageInfoLoader.content.value.longitude,
  134. latitude: villageInfoLoader.content.value.latitude
  135. }"
  136. :currentNoticeContent="currentNoticeContent"
  137. >
  138. <FlexRow position="absolute" :inset="{ l: 13, r: 13, b: 13 }" center :zIndex="100">
  139. <FlexRow align="center" gap="gap.sm" backgroundColor="background.tertiary" radius="radius.lg" padding="padding.sm">
  140. <Icon name="https://xy.wenlvti.net/app_static/images/village/IconMap.png" size="fontSize.md" />
  141. <Text :text="villageInfoLoader.content.value?.address" :maxWidth="550" fontConfig="contentText" fontSize="fontSize.sm" />
  142. </FlexRow>
  143. </FlexRow>
  144. </VillageMiniMap>
  145. </template>
  146. <template v-else-if="node.type === 'Card:Static'">
  147. <!-- 村社状态信息 -->
  148. <FlexRow justify="space-between" align="center">
  149. <FlexRow center gap="gap.lg" flexBasis="50%">
  150. <Text text="村社排名" fontConfig="contentText" />
  151. <Text text="No." fontConfig="lightTitle" />
  152. <Text :text="villageInfoLoader.content.value?.rankText" fontConfig="primaryTitle" />
  153. </FlexRow>
  154. <FlexRow center gap="gap.lg" flexBasis="50%">
  155. <Text text="村社等级" fontConfig="contentText" />
  156. <Text :text="`${villageInfoLoader.content.value?.level}级`" fontConfig="primaryTitle" />
  157. </FlexRow>
  158. </FlexRow>
  159. <Height height="gap.md" />
  160. <FlexRow backgroundColor="background.tertiary" radius="radius.md" :padding="[30, 20]">
  161. <Touchable direction="column" center gap="gap.sm" flexBasis="25%" @click="navTo('/pages/home/village/task/index')">
  162. <Text text="乡源光" fontConfig="secondText" fontSize="fontSize.sm" />
  163. <Text :text="villageInfoLoader.content.value?.light || '0'" fontConfig="importantTitle" />
  164. <Button type="text" size="mini" text="做任务" @click="navTo('/pages/home/village/task/index')" />
  165. </Touchable>
  166. <Divider type="vertical" />
  167. <FlexCol center gap="gap.sm" flexBasis="25%">
  168. <Touchable direction="column" center @click="navTo('/pages/home/village/volunteer/list', { villageId: villageStore.currentVillage?.id ?? undefined })">
  169. <Text text="乡源人数" fontConfig="contentText" fontSize="fontSize.sm" />
  170. <Text :text="villageInfoLoader.content.value?.memberCount|| '0'" fontConfig="importantTitle" />
  171. </Touchable>
  172. <WxButton openType="share">
  173. <Button type="text" size="mini" text="邀请加入" @click="navTo('/pages/home/village/task/index')" />
  174. </WxButton>
  175. </FlexCol>
  176. <Divider type="vertical" />
  177. <Touchable direction="column" center gap="gap.sm" flexBasis="25%" @click="navTo('/pages/home/village/follow/list', {
  178. villageId: villageStore.currentVillage?.id ?? undefined,
  179. })">
  180. <Text text="关注人数" fontConfig="contentText" fontSize="fontSize.sm" />
  181. <Text :text="villageInfoLoader.content.value?.followerCount|| '0'" fontConfig="importantTitle" />
  182. <Height :size="36" />
  183. </Touchable>
  184. <Divider type="vertical" />
  185. <Button
  186. :padding="0"
  187. type="text"
  188. size="small"
  189. textColor="text.title"
  190. rightIcon="arrow-right"
  191. @click="handleGoNew()"
  192. >
  193. <FlexCol>
  194. <Text text="新手" fontConfig="contentText" />
  195. <Text text="上路" fontConfig="contentText" />
  196. </FlexCol>
  197. </Button>
  198. </FlexRow>
  199. </template>
  200. <template v-else-if="node.type === 'Block:Rank'">
  201. <!-- 排行榜 -->
  202. <HomeTitle
  203. :title="node.props?.title"
  204. showMore
  205. @moreClicked="navTo('/pages/home/village/rank/volunteer', {
  206. villageId: villageStore.currentVillage?.id ?? undefined,
  207. })"
  208. />
  209. <Height height="gap.md" />
  210. <VillageUserRankList
  211. :list="villageUserRankListLoader.content.value ?? []"
  212. scoreSuffix="文化积分"
  213. @goDetails="navTo('/pages/home/village/volunteer/detail', { id: $event.id })"
  214. />
  215. </template>
  216. <template v-else-if="node.type === 'Block:Collect'">
  217. <!-- 魅力乡源 -->
  218. <HomeTitle
  219. :title="node.props?.title"
  220. showMore
  221. @moreClicked="handleGoCollect()"
  222. >
  223. <template #right>
  224. <FlexRow align="center" gap="gap.md">
  225. <FrameButton
  226. text="管理"
  227. size="small"
  228. primary
  229. @click="handleGoDigManage()"
  230. />
  231. <FrameButton
  232. text="共编村史"
  233. icon="https://xy.wenlvti.net/app_static/images/village/IconHistory.png"
  234. size="small"
  235. @click="handleGoCollect()"
  236. />
  237. <Width :size="15" />
  238. </FlexRow>
  239. </template>
  240. </HomeTitle>
  241. <Height height="gap.md" />
  242. <ProvideVar :vars="{
  243. GridItemIconSize: 90,
  244. GridItemBackgroundColor: 'transparent',
  245. GridItemPaddingHorizontal: 0,
  246. GridItemPaddingVertical: 8,
  247. }">
  248. <Grid :borderGrid="false" :mainAxisCount="4">
  249. <GridItem title="村社概况" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeIntrod.png" touchable @click="handleGoCollect(11, '村社概况')" />
  250. <GridItem title="自然风光" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeEnvirounment.png" touchable @click="handleGoCollect(13, '自然风光')" />
  251. <GridItem title="历史沿革" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeHistory.png" touchable @click="handleGoCollect(2, '历史沿革')" />
  252. <GridItem title="特色产业" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeIndustry.png" touchable @click="handleGoCollect(9, '特色产业' )" />
  253. <GridItem title="文艺活动" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeActivity.png" touchable @click="handleGoCollect(12, '文艺活动')" />
  254. <GridItem title="非遗展示" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeShow.png" touchable @click="handleGoCollect(10, '非遗展示')" />
  255. <GridItem title="民俗风采" icon="https://xy.wenlvti.net/app_static/images/village/IconLargeFolkloreVibe.png" touchable @click="handleGoCollect(8, '民俗风采')" />
  256. <GridItem title="历史人物" icon="https://xy.wenlvti.net/app_static/images/village/IconGoods.png" touchable @click="handleGoCollect(7, '历史人物')" />
  257. </Grid>
  258. </ProvideVar>
  259. </template>
  260. <template v-else-if="node.type === 'Block:Games'">
  261. <!-- 活力乡源 -->
  262. <HomeTitle :title="node.props?.title" />
  263. <Height height="gap.md" />
  264. <ProvideVar :vars="{
  265. GridItemIconSize: 90,
  266. GridItemBackgroundColor: 'transparent',
  267. GridItemPaddingHorizontal: 0,
  268. GridItemPaddingVertical: 8,
  269. }">
  270. <Grid :borderGrid="false" :mainAxisCount="4">
  271. <GridItem
  272. v-for="item in node.props?.items"
  273. :key="item.title"
  274. :title="item.title"
  275. :icon="item.icon"
  276. touchable
  277. @click="() => context.getScriptEngine().execute(item.handler, node.getNodeScriptContext?.())"
  278. />
  279. </Grid>
  280. </ProvideVar>
  281. </template>
  282. <template v-else-if="node.type === 'Block:Official'">
  283. <!-- 文脉乡源 -->
  284. <HomeTitle :title="node.props?.title">
  285. <template #right>
  286. <FlexRow align="center" gap="gap.md">
  287. <BubbleTip
  288. v-model:show="showManageTip"
  289. position="bottom"
  290. crossPosition="right"
  291. arrowOffsetX="180rpx"
  292. content="村社贴图太乱?点这里整理"
  293. @contentClick="handleCloseManageTip(true)"
  294. @close="handleCloseManageTip(false)"
  295. >
  296. <FrameButton
  297. text="管理"
  298. size="small"
  299. primary
  300. @click="handleGoOfficalManage()"
  301. />
  302. </BubbleTip>
  303. <FrameButton
  304. text="乡源AI帮你写"
  305. size="small"
  306. icon="https://xy.wenlvti.net/app_static/images/village/IconLargeHistory.png"
  307. @click="handleGoPublish()"
  308. />
  309. </FlexRow>
  310. </template>
  311. </HomeTitle>
  312. <Height height="gap.md" />
  313. <RoundTags
  314. v-model:active="listActiveTag"
  315. :tags="node.props?.tags"
  316. />
  317. <Height height="gap.md" />
  318. <OfficialAccountPublishWrap
  319. :topic="recommendTagName"
  320. :path="recommendPath"
  321. @publishsuccess="onPublishSuccess"
  322. @empty="isOfficialEmpty=true"
  323. />
  324. </template>
  325. </template>
  326. </DynamicXNodeChild>
  327. </template>
  328. </DynamicX>
  329. <UpgradeDialog
  330. ref="upgradeRef"
  331. v-if="villageStore.currentVillage"
  332. :villageId="villageStore.currentVillage.id"
  333. />
  334. <ChangeNickDialog
  335. v-if="villageStore.currentVillage"
  336. :villageId="villageStore.currentVillage.id"
  337. :currentNick="displayMyName"
  338. ref="changeNickRef"
  339. />
  340. <StaffInfoDialog
  341. v-if="villageStore.currentVillage && staffInfo"
  342. :villageId="villageStore.currentVillage.id"
  343. :staffEndTime="staffInfo.staffEndTime"
  344. :staffSource="staffInfo.staffSource"
  345. :staffTimeType="staffInfo.staffTimeType"
  346. ref="staffInfoRef"
  347. />
  348. <ShareQRDialog
  349. v-if="villageStore.currentVillage"
  350. :villageId="villageStore.currentVillage.id"
  351. ref="shareQRDialog"
  352. />
  353. <Popup
  354. :show="showUnLight"
  355. :zIndex="100"
  356. size="45%"
  357. position="bottom"
  358. backgroundColor="transparent"
  359. >
  360. <FlexCol center>
  361. <BackgroundBox
  362. backgroundImage="https://xy.wenlvti.net/app_static/images/village/BoxDialog.png"
  363. :backgroundCutBorder="48"
  364. :backgroundCutBorderSize="48"
  365. :padding="40"
  366. direction="column"
  367. center
  368. width="600rpx"
  369. gap="gap.md"
  370. >
  371. <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
  372. <Text :text="`${villageStore.currentVillage?.name}暂未点亮`" fontConfig="primaryTitle" />
  373. <Text text="等你的加入,快来为家乡建设做贡献吧" fontConfig="contentText" />
  374. <Height :height="20" />
  375. <FlexRow gap="gap.lg">
  376. <FrameButton :text="isFollowed ? '已关注' : '先关注村社'" @click="isFollowed ? onUnFollow() : onFollow()" />
  377. <FrameButton text="去申请点亮" @click="handleGoJoin" primary />
  378. </FlexRow>
  379. </BackgroundBox>
  380. <Height :size="300" />
  381. </FlexCol>
  382. </Popup>
  383. </template>
  384. <script setup lang="ts">
  385. import { computed, reactive, ref, watch } from 'vue';
  386. import { useUserTools } from '@/common/composeabe/UserTools';
  387. import { useOfficialAccount } from '../../composeabe/OfficialAccount';
  388. import { useAuthStore } from '@/store/auth';
  389. import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
  390. import { useVillageStore } from '@/store/village';
  391. import { useRequireLogin } from '@/common/composeabe/RequireLogin';
  392. import { useFollow } from '../composeabe/Follow';
  393. import { useGetNotice } from '../composeabe/GetNotice';
  394. import { assertNotNull, FormatUtils, waitTimeOut } from '@imengyu/imengyu-utils';
  395. import { navTo } from '@/components/utils/PageAction';
  396. import { alert, confirm } from '@/components/dialog/CommonRoot';
  397. import HomeTitle from '@/common/components/parts/HomeTitle.vue';
  398. import Icon from '@/components/basic/Icon.vue';
  399. import Text from '@/components/basic/Text.vue';
  400. import BackgroundBox from '@/components/display/block/BackgroundBox.vue';
  401. import Touchable from '@/components/feedback/Touchable.vue';
  402. import FlexCol from '@/components/layout/FlexCol.vue';
  403. import FlexRow from '@/components/layout/FlexRow.vue';
  404. import VillageMiniMap from '../../components/VillageMiniMap.vue';
  405. import Divider from '@/components/display/Divider.vue';
  406. import RoundTags from '@/common/components/parts/RoundTags.vue';
  407. import VillageUserRankList from '../../components/VillageUserRankList.vue';
  408. import ProvideVar from '@/components/theme/ProvideVar.vue';
  409. import Grid from '@/components/layout/grid/Grid.vue';
  410. import GridItem from '@/components/layout/grid/GridItem.vue';
  411. import LightVillageApi from '@/api/light/LightVillageApi';
  412. import OfficialAccountPublishWrap from '@/common/components/OfficialAccountPublishWrap.vue';
  413. import UpgradeDialog from '../dialogs/UpgradeDialog.vue';
  414. import VillageGallery from '../components/VillageGallery.vue';
  415. import WxButton from '@/components/basic/WxButton.vue';
  416. import Height from '@/components/layout/space/Height.vue';
  417. import IconButton from '@/components/basic/IconButton.vue';
  418. import Button from '@/components/basic/Button.vue';
  419. import BubbleTip from '@/components/feedback/BubbleTip.vue';
  420. import MemoryTimeOut from '@/components/composeabe/MemoryTimeOut';
  421. import TextEllipsis from '@/components/display/TextEllipsis.vue';
  422. import OfficialApi from '@/api/light/OfficialApi';
  423. import FrameButton from '@/common/components/FrameButton.vue';
  424. import Width from '@/components/layout/space/Width.vue';
  425. import Popup from '@/components/dialog/Popup.vue';
  426. import Image from '@/components/basic/Image.vue';
  427. import Avatar from '@/components/display/Avatar.vue';
  428. import ChangeNickDialog from '../dialogs/ChangeNickDialog.vue';
  429. import StaffInfoDialog from '../dialogs/StaffInfoDialog.vue';
  430. import ShareQRDialog from '../dialogs/ShareQRDialog.vue';
  431. import DynamicX from '@/components/dynamic/DynamicX.vue';
  432. import type { DynamicXPage } from '@/components/dynamic/DynamicX';
  433. import DynamicXNodeChild from '@/components/dynamic/x/DynamicXNodeChild.vue';
  434. import Badge from '@/components/display/Badge.vue';
  435. import { isDevEnv } from '@/common/config/AppCofig';
  436. const emit = defineEmits<{
  437. (e: 'goTree'): void;
  438. (e: 'goJoin'): void;
  439. }>();
  440. const authStore = useAuthStore();
  441. const { getIsVolunteer } = useUserTools();
  442. const { requireLogin } = useRequireLogin();
  443. const { onPublishSuccess, makeOfficialPublishLinkPathAndParams } = useOfficialAccount(() => {
  444. return {
  445. villageId: villageStore.currentVillage?.id ?? 0,
  446. userId: authStore.userId,
  447. tag: recommendTagName.value,
  448. };
  449. });
  450. const villageStore = useVillageStore();
  451. const { isFollowed, onFollow, onUnFollow } = useFollow();
  452. const { getIsJoinedVillage } = useUserTools();
  453. const isOfficialEmpty = ref(false);
  454. const isJoined = ref(false);
  455. const villageInfoLoader = useSimpleDataLoader(async () => {
  456. const village = villageStore.currentVillage;
  457. try {
  458. if (village)
  459. isJoined.value = await getIsJoinedVillage(village.id);
  460. } catch (e) {
  461. console.error(e);
  462. isJoined.value = false;
  463. }
  464. handleShowFollowTip();
  465. isOfficialEmpty.value = false;
  466. showUnLight.value = !villageStore.currentVillage?.isLight;
  467. setTimeout(() => {
  468. handleManageFollowTip();
  469. }, 3000);
  470. return {
  471. title: village?.name || '',
  472. desc: village?.desc || '',
  473. address: village?.address,
  474. sizeText: `${FormatUtils.formatSize(village?.storageUsed || 0)}/${FormatUtils.formatSize(village?.storageLimit || 0)}`,
  475. sizeLimit: (village?.storageLimit || 0) >= 0,
  476. level: village?.level || 1,
  477. vipLevel: village?.vipLevel || 0,
  478. vipLevelText: village?.vipName ? `已升级 · ${village?.vipName}` : '',
  479. rankText: village?.rank.toString() || '',
  480. light: village?.light || 0,
  481. memberCount: village?.volunteerCount || 0,
  482. followerCount: village?.followCount || 0,
  483. images: village?.images || [],
  484. longitude: village?.longitude || 0,
  485. latitude: village?.latitude || 0,
  486. };
  487. });
  488. const isLight = computed(() => villageStore.currentVillage?.isLight ?? false);
  489. const title = computed(() => villageInfoLoader.content.value?.title || '');
  490. const extraInfoInList = computed(() => villageStore.myJoinedVillages.find(v => v.id === villageStore.currentVillage?.id));
  491. const displayMyName = computed(() => extraInfoInList.value?.villageNickname || authStore.userInfo?.nickname || authStore.userInfo?.username || '暂无昵称');
  492. const staffInfo = computed(() => extraInfoInList.value ? {
  493. type: extraInfoInList.value.type as string,
  494. staffEndTime: extraInfoInList.value.staffEndTime as Date,
  495. staffSource: extraInfoInList.value.staffSource as number,
  496. staffTimeType: extraInfoInList.value.staffTimeType as number,
  497. } : null);
  498. const isStaff = computed(() => staffInfo.value?.type === 'staff');
  499. const shareQRDialog = ref<InstanceType<typeof ShareQRDialog>>();
  500. const descOpen = ref(false);
  501. const listActiveTag = ref('广场');
  502. const villageUserRankListLoader = useSimpleDataLoader(async () => {
  503. const res = (await LightVillageApi.getVolunteerRankList({
  504. num: 3,
  505. village_id: villageStore.currentVillage?.id ?? undefined,
  506. }))
  507. .map((item, i) => ({
  508. id: item.id,
  509. image: item.avatar ?? '',
  510. title: item.name,
  511. rank: i + 1,
  512. score: item.points,
  513. }));
  514. return res
  515. });
  516. const showFollowTipTimeout = new MemoryTimeOut('FollowTip', 1000 * 3600);//1h
  517. const showFollowTip = ref(false);
  518. function handleShowFollowTip() {
  519. if (!isFollowed.value && isLight.value && showFollowTipTimeout.isTimeout()) {
  520. showFollowTip.value = true;
  521. }
  522. }
  523. function handleCloseFollowTip() {
  524. showFollowTipTimeout.recordTime();
  525. }
  526. const showUnLight = ref(false);
  527. const showManageTipTimeout = new MemoryTimeOut('VillageManageTip', 1000 * 3600 * 20);//30h
  528. const showManageTip = ref(false);
  529. function handleManageFollowTip() {
  530. if (showManageTipTimeout.isTimeout() && !isOfficialEmpty.value)
  531. showManageTip.value = true;
  532. }
  533. function handleCloseManageTip(goComp: boolean) {
  534. showManageTipTimeout.recordTime();
  535. }
  536. const recommendTagName = computed(() => {
  537. return '亮乡源·' + villageInfoLoader.content.value?.title + '·' + listActiveTag.value;
  538. });
  539. const recommendPath = computed(() => {
  540. return makeOfficialPublishLinkPathAndParams('/pages/index');
  541. });
  542. function handleGoJoin() {
  543. if (isJoined.value)
  544. return;
  545. requireLogin(async () => emit('goJoin'), '登录后就可以加入村社啦');
  546. }
  547. function handleGoNew() {
  548. navTo('/pages/article/common/list', {
  549. modelId: 18,
  550. mainBodyColumnId: 356,
  551. title: '新手上路',
  552. });
  553. }
  554. function handleGoCollect(collectModuleId?: number, title?: string) {
  555. if (!collectModuleId) {
  556. navTo('/pages/dig/details', {
  557. villageId: villageStore.currentVillage?.id ?? undefined,
  558. name: villageInfoLoader.content.value?.title,
  559. });
  560. return;
  561. }
  562. navTo('/pages/dig/forms/list-ordinary', {
  563. villageId: villageStore.currentVillage?.id ?? undefined,
  564. collectModuleId: collectModuleId,
  565. title: title,
  566. });
  567. }
  568. function handleGoPublish() {
  569. requireLogin(async () => {
  570. navTo('/pages/home/chat/dependent/post/publish', {
  571. tag: recommendTagName.value,
  572. villageId: villageStore.currentVillage?.id ?? undefined,
  573. });
  574. }, '登录后以便发布文章使用更多功能哦!');
  575. }
  576. function handleGoGallery() {
  577. navTo('/pages/home/village/gallery/index', {
  578. villageId: villageStore.currentVillage?.id ?? 0 ,
  579. maxCount: villageStore.currentVillage?.imageLimit || 3,
  580. });
  581. }
  582. const staffInfoRef = ref<InstanceType<typeof StaffInfoDialog>>();
  583. async function checkIsStaff(needTopic?: boolean) {
  584. assertNotNull(villageStore.currentVillage?.id)
  585. if (isDevEnv)
  586. return true;
  587. const isAdmin = needTopic ?
  588. await OfficialApi.checkTopicRule(villageStore.currentVillage.id)
  589. : (authStore.isAdmin || isStaff.value);
  590. if (!isAdmin) {
  591. if (needTopic && (isStaff.value || authStore.isAdmin)) {
  592. alert({
  593. title: '提示',
  594. content: '您暂无管理贴图权限,无法管理贴图哦。可联系客服询问原因。',
  595. });
  596. } else {
  597. const goUpgrade = await confirm({
  598. title: '提示',
  599. content: '您还不是管理员,无法管理'
  600. + (needTopic ? '贴图' : '内容')
  601. + '。您可以联系村社管理员将你添加为管理员,若当前村社暂无管理员,您可以点击“去升级”将您升级为管理员。',
  602. confirmText: '去升级',
  603. cancelText: '取消',
  604. });
  605. if (goUpgrade) {
  606. navTo('/pages/home/village/upgrade/my-upgrade-management', {
  607. villageId: villageStore.currentVillage.id,
  608. });
  609. }
  610. }
  611. return false;
  612. }
  613. return true;
  614. }
  615. async function handleGoOfficalManage() {
  616. assertNotNull(villageStore.currentVillage?.id)
  617. if (!await checkIsStaff(true))
  618. return;
  619. navTo('/pages/home/village/post/management-list', {
  620. villageId: villageStore.currentVillage.id,
  621. topic: recommendTagName.value,
  622. });
  623. }
  624. async function handleGoEdit() {
  625. assertNotNull(villageStore.currentVillage?.id)
  626. if (!await checkIsStaff())
  627. return;
  628. navTo('/pages/home/village/introd/edit', {
  629. villageId: villageStore.currentVillage.id,
  630. });
  631. }
  632. async function handleGoDigManage() {
  633. assertNotNull(villageStore.currentVillage?.id)
  634. if (!await checkIsStaff())
  635. return;
  636. navTo('/pages/dig/details', {
  637. name: villageStore.currentVillage.title,
  638. villageId: villageStore.currentVillage.id,
  639. });
  640. }
  641. const { currentNoticeContent, noticeListLoader } = useGetNotice(() => villageStore.currentVillage?.id || 0);
  642. const upgradeRef = ref<InstanceType<typeof UpgradeDialog>>();
  643. const villageGalleryRef = ref<InstanceType<typeof VillageGallery>>();
  644. const changeNickRef = ref<InstanceType<typeof ChangeNickDialog>>();
  645. const pageScriptGlobal = reactive({
  646. handleGoGallery,
  647. handleGoEdit,
  648. handleGoDigManage,
  649. handleGoCollect,
  650. getVillageId: () => villageStore.currentVillage?.id ?? 0,
  651. navTo,
  652. emit,
  653. });
  654. const page : DynamicXPage = {
  655. name: 'VILLAGE',
  656. type: 'page',
  657. nodes: [
  658. {
  659. name: 'VILLAGE:CONTENT',
  660. type: 'flex',
  661. props: {
  662. direction: 'column',
  663. padding: [30,30,0,30],
  664. gap: "gap.lg"
  665. },
  666. nodes: [
  667. {
  668. name: 'VILLAGE:CONTENT:Basic',
  669. type: 'BackgroundBox',
  670. props: {
  671. color1: "#eecaa0",
  672. color2: "white",
  673. color2Position: "85%",
  674. color3: "white",
  675. radius: "radius.lg",
  676. direction: "column",
  677. padding: [35,30],
  678. gap: "gap.lg",
  679. },
  680. nodes: [
  681. {
  682. type: 'Card:Basic',
  683. },
  684. {
  685. type: 'Card:Level',
  686. },
  687. {
  688. type: 'Card:Gallery',
  689. },
  690. {
  691. type: 'Card:AddressAndMap',
  692. },
  693. {
  694. type: 'flex',
  695. props: {
  696. direction: 'row',
  697. justify: "center" ,
  698. align: "center",
  699. gap:"gap.md",
  700. },
  701. nodes: [
  702. {
  703. type: 'button',
  704. props: {
  705. size: "mini",
  706. icon: "picture",
  707. text: "村社相册",
  708. },
  709. events: {
  710. click: 'globalContext.handleGoGallery()',
  711. },
  712. },
  713. {
  714. type: 'button',
  715. props: {
  716. size: "mini",
  717. icon: "edit-filling",
  718. text: "编辑简介",
  719. },
  720. events: {
  721. click: 'globalContext.handleGoEdit()',
  722. },
  723. },
  724. {
  725. type: 'button',
  726. props: {
  727. size: "mini",
  728. icon: "fabulous",
  729. text: "主页换肤",
  730. },
  731. events: {
  732. click: 'globalContext.handleGoDigManage()',
  733. },
  734. },
  735. ],
  736. },
  737. {
  738. type: 'Card:Static',
  739. },
  740. ],
  741. },
  742. {
  743. name: 'VILLAGE:CONTENT:Rank',
  744. type: 'Block:Rank',
  745. props: {
  746. title: '排行榜',
  747. },
  748. },
  749. {
  750. name: 'VILLAGE:CONTENT:Collect',
  751. type: 'Block:Collect',
  752. props: {
  753. title: '魅力乡源',
  754. },
  755. },
  756. {
  757. name: 'VILLAGE:CONTENT:Games',
  758. type: 'Block:Games',
  759. props: {
  760. title: '活力乡源',
  761. items: [
  762. {
  763. title: '乡源荣光',
  764. icon: 'https://xy.wenlvti.net/app_static/images/village/IconLargeHornor.png',
  765. handler: 'globalContext.handleGoCollect(23, \'乡源荣光\')',
  766. },
  767. {
  768. title: '乡源好物',
  769. icon: 'https://xy.wenlvti.net/app_static/images/village/IconLargeGoods.png',
  770. handler: 'globalContext.navTo("/pages/home/village/goods/index", { villageId: globalContext.getVillageId() })',
  771. },
  772. {
  773. title: '乡源树',
  774. icon: 'https://xy.wenlvti.net/app_static/images/village/IconLargeTree.png',
  775. handler: 'globalContext.emit("goTree")',
  776. },
  777. {
  778. title: '互动游戏',
  779. icon: 'https://xy.wenlvti.net/app_static/images/village/IconLargeGame.png',
  780. handler: 'globalContext.navTo("/pages/home/village/games/index")',
  781. },
  782. ]
  783. },
  784. },
  785. {
  786. name: 'VILLAGE:CONTENT:Official',
  787. type: 'Block:Official',
  788. props: {
  789. title: '文脉乡源',
  790. tags: [
  791. '广场', '美食', '美景',
  792. '故事',
  793. '老手艺', '老物件'
  794. ]
  795. },
  796. },
  797. ],
  798. },
  799. ],
  800. };
  801. watch(() => villageStore.currentVillage, async () => {
  802. await waitTimeOut(100);
  803. await villageInfoLoader.reload();
  804. await waitTimeOut(100);
  805. await villageUserRankListLoader.reload();
  806. await waitTimeOut(100);
  807. await noticeListLoader.reload();
  808. }, { immediate: true });
  809. defineExpose({
  810. onPageBack: (name: string, data: Record<string, unknown>) => {
  811. if (name === 'refreshVillageGrallery') {
  812. villageGalleryRef.value?.refresh();
  813. } else if (name === 'refreshOfficialAccount') {
  814. const tag = listActiveTag.value;
  815. listActiveTag.value = '';
  816. setTimeout(() => listActiveTag.value = tag, 100);
  817. } else if (name === 'showVillageUpgrade') {
  818. upgradeRef.value?.show();
  819. } else if (name === 'backShowVillageJoin') {
  820. handleGoJoin();
  821. }
  822. },
  823. });
  824. </script>