dig.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <FlexCol>
  3. <FlexCol :padding="30">
  4. <HomeLargeTitle title="挖掘" />
  5. <ImageSwiper
  6. :images="appConfiguration?.banners.dig"
  7. width="100%"
  8. :height="400"
  9. radius="radius.md"
  10. :innerStyle="{
  11. border: '1px solid #fff',
  12. overflow: 'hidden',
  13. }"
  14. />
  15. <HomeTitle title="我的村社" />
  16. <RequireLogin unLoginMessage="欢迎您成为志愿者!在这之前您需要登录或者注册完善基础信息后才能投稿和查看我认领的村社哦">
  17. <FlexCol
  18. v-if="notVolunteerError"
  19. gap="gap.lg"
  20. padding="padding.md"
  21. center
  22. >
  23. <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
  24. <CommonDivider />
  25. <Text
  26. textAlign="center"
  27. text="认领属于你的村庄,参与建设家乡 或者先随便看看,了解更多乡村故事"
  28. fontConfig="contentSpeicalText"
  29. />
  30. <FlexRow justify="space-around" gap="gap.md">
  31. <FrameButton primary text="去认领村庄" @click="navTo('/pages/home/light/submit-map', {
  32. city: currentCity,
  33. })" width="220rpx" />
  34. </FlexRow>
  35. </FlexCol>
  36. <SimplePageContentLoader
  37. v-else
  38. :loader="villageListLoader"
  39. :showEmpty="villageListLoader.content.value?.length == 0"
  40. :emptyView="{
  41. text: '您点亮的村社正在审核中,审核通过后您可以查看和管理',
  42. button: false,
  43. }"
  44. >
  45. <FlexCol :gap="10">
  46. <FlexRow
  47. v-for="item in villageListLoader.content.value"
  48. :key="item.id"
  49. radius="radius.md"
  50. :padding="20"
  51. align="center"
  52. justify="space-between"
  53. :innerStyle="{
  54. border: '1px solid #fff',
  55. }"
  56. >
  57. <FlexRow align="center" :gap="20">
  58. <Image
  59. mode="aspectFill"
  60. :src="item.image"
  61. round
  62. :width="80"
  63. :height="80"
  64. />
  65. <H3>{{ item.villageName }}</H3>
  66. </FlexRow>
  67. <ButtonGroup direction="row" align="center" :gap="0">
  68. <BubbleBox :items="[
  69. {
  70. icon: 'edit-filling',
  71. text: '管理',
  72. onClick: () => goManagePage(item),
  73. },
  74. {
  75. icon: 'edit-filling',
  76. text: '采编',
  77. onClick: () => goSubmitDigPage(item),
  78. },
  79. ]">
  80. <Button v-if="authStore.isAdmin" icon="edit-filling" size="small">采编/管理</Button>
  81. </BubbleBox>
  82. <Button v-if="!authStore.isAdmin" icon="edit-filling" size="small" @click="goSubmitDigPage(item)">采编</Button>
  83. <Button type="primary" size="small" icon="edit-filling" @click="goMyDigPage(item)">我的投稿</Button>
  84. </ButtonGroup>
  85. </FlexRow>
  86. </FlexCol>
  87. </SimplePageContentLoader>
  88. </RequireLogin>
  89. <Height :height="20" />
  90. <HomeTitle v-if="authStore.isLogged" title="我的贡献" />
  91. <BackgroundBox
  92. v-if="authStore.isLogged"
  93. backgroundImage="https://xy.wenlvti.net/app_static/images/village/BoxMid.png"
  94. :backgroundCutBorder="32"
  95. :backgroundCutBorderSize="36"
  96. :padding="[40,20]"
  97. direction="row"
  98. >
  99. <FlexCol :flex="1" :gap="10" center>
  100. <Text fontConfig="lightGoldTitle">{{ volunteerInfoLoader.content.value?.points || 0 }}</Text>
  101. <Touchable direction="row" align="center" :gap="10" @click="navTo('/pages/dig/about/point')">
  102. <Text>文化积分</Text>
  103. <Icon icon="help-filling" color="primary" :size="40" />
  104. </Touchable>
  105. </FlexCol>
  106. <FlexCol :flex="1" :gap="10" center>
  107. <Text fontConfig="lightGoldTitle">Lv.{{ volunteerInfoLoader.content.value?.level || 1 }}</Text>
  108. <Text>等级</Text>
  109. </FlexCol>
  110. </BackgroundBox>
  111. </FlexCol>
  112. </FlexCol>
  113. </template>
  114. <script setup lang="ts">
  115. import { ref, watch } from 'vue';
  116. import { navTo } from '@/components/utils/PageAction';
  117. import { useAuthStore } from '@/store/auth';
  118. import { useCollectStore } from '@/store/collect';
  119. import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
  120. import { useStorageVar } from '@/components/composeabe/StorageVar';
  121. import { injectAppConfiguration } from '@/api/system/useAppConfiguration';
  122. import VillageApi, { VillageListItem } from '@/api/inhert/VillageApi';
  123. import RequireLogin from '@/common/components/RequireLogin.vue';
  124. import SimplePageContentLoader from '@/components/loader/SimplePageContentLoader.vue';
  125. import Button from '@/components/basic/Button.vue';
  126. import Image from '@/components/basic/Image.vue';
  127. import FlexCol from '@/components/layout/FlexCol.vue';
  128. import FlexRow from '@/components/layout/FlexRow.vue';
  129. import H3 from '@/components/typography/H3.vue';
  130. import Text from '@/components/basic/Text.vue';
  131. import Height from '@/components/layout/space/Height.vue';
  132. import ButtonGroup from '@/components/basic/ButtonGroup.vue';
  133. import BubbleBox from '@/components/feedback/BubbleBox.vue';
  134. import HomeTitle from '@/common/components/parts/HomeTitle.vue';
  135. import HomeLargeTitle from '@/common/components/parts/HomeLargeTitle.vue';
  136. import type { RequestApiError } from '@imengyu/imengyu-utils';
  137. import FrameButton from '@/common/components/FrameButton.vue';
  138. import CommonDivider from '@/common/components/CommonDivider.vue';
  139. import Touchable from '@/components/feedback/Touchable.vue';
  140. import Icon from '@/components/basic/Icon.vue';
  141. import BackgroundBox from '@/components/display/block/BackgroundBox.vue';
  142. import ImageSwiper from '@/common/components/parts/ImageSwiper.vue';
  143. const authStore = useAuthStore();
  144. const collectStore = useCollectStore();
  145. const appConfiguration = injectAppConfiguration();
  146. const { value: currentCity } = useStorageVar('currentCityName', '');
  147. const notVolunteerError = ref(false);
  148. const villageListLoader = useSimpleDataLoader(async () => await VillageApi.getClaimedVallageList(), true);
  149. const volunteerInfoLoader = useSimpleDataLoader(async () => {
  150. try {
  151. const res = await VillageApi.getVolunteerInfo()
  152. notVolunteerError.value = false;
  153. return res;
  154. } catch (error) {
  155. notVolunteerError.value = checkIsNotVolunteerError(error);
  156. throw error;
  157. }
  158. }, true);
  159. const rankListLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerRanklist(), true);
  160. function checkIsNotVolunteerError(e: unknown) {
  161. return (e as RequestApiError).errorMessage.includes('请认领')
  162. }
  163. watch(() => authStore.isLogged, (newVal) => {
  164. if (newVal) {
  165. villageListLoader.reload();
  166. volunteerInfoLoader.reload();
  167. rankListLoader.reload();
  168. }
  169. })
  170. function goSubmitDigPage(item: VillageListItem) {
  171. navTo('./dig/details', {
  172. name: item.villageName,
  173. villageId: item.villageId,
  174. villageVolunteerId: item.villageVolunteerId,
  175. points: volunteerInfoLoader.content.value?.points,
  176. level: volunteerInfoLoader.content.value?.level,
  177. })
  178. }
  179. function goManagePage(item: VillageListItem) {
  180. navTo('./dig/admin/index', {
  181. id: item.villageId,
  182. name: item.villageName,
  183. villageId: item.villageId,
  184. villageVolunteerId: item.villageVolunteerId,
  185. points: volunteerInfoLoader.content.value?.points,
  186. level: volunteerInfoLoader.content.value?.level,
  187. })
  188. }
  189. function goMyDigPage(item: VillageListItem) {
  190. navTo('./dig/forms/submits', {
  191. villageName: item.villageName,
  192. villageId: item.villageId,
  193. villageVolunteerId: item.villageVolunteerId,
  194. })
  195. }
  196. function goPreviewDigPage(item: VillageListItem) {
  197. navTo('./dig/admin/preview', {
  198. villageName: item.villageName,
  199. villageId: item.villageId,
  200. villageVolunteerId: item.villageVolunteerId,
  201. })
  202. }
  203. </script>