dig.vue 8.5 KB

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