index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <FlexCol>
  3. <Image
  4. mode="aspectFill"
  5. src="https://mn.wenlvti.net/app_static/xiangyuan/images/index-banner.jpg"
  6. width="100%"
  7. />
  8. <FlexCol :padding="30">
  9. <SubTitle title="我的村社" />
  10. <RequireLogin unLoginMessage="欢迎您成为志愿者!在这之前您需要登录或者注册完善基础信息后才能投稿和查看我认领的村社哦">
  11. <Result
  12. v-if="notVolunteerError"
  13. status="warning"
  14. title="您还不是志愿者"
  15. subTitle="请联系管理员认领,或者绑定已有志愿者账号"
  16. >
  17. <FlexCol center>
  18. <Height :size="20" />
  19. <Button type="primary" text="绑定已有志愿者账号" @click="navTo('/pages/dig/sharereg/bind')" />
  20. </FlexCol>
  21. </Result>
  22. <SimplePageContentLoader
  23. v-else
  24. :loader="villageListLoader"
  25. :showEmpty="villageListLoader.content.value?.length == 0"
  26. :emptyView="{
  27. text: '你还没有认领的村社,请联系管理员认领',
  28. button: false,
  29. }"
  30. >
  31. <FlexCol :gap="10">
  32. <FlexRow
  33. v-for="item in villageListLoader.content.value"
  34. :key="item.id"
  35. backgroundColor="white"
  36. :radius="20"
  37. :padding="20"
  38. align="center"
  39. justify="space-between"
  40. >
  41. <FlexRow align="center" :gap="20">
  42. <Image
  43. mode="aspectFill"
  44. :src="item.image"
  45. round
  46. :width="80"
  47. :height="80"
  48. />
  49. <H3>{{ item.villageName }}</H3>
  50. </FlexRow>
  51. <ButtonGroup direction="row" align="center" :gap="0">
  52. <BubbleBox :items="[
  53. {
  54. icon: 'edit-filling',
  55. text: '管理',
  56. onClick: () => goManagePage(item),
  57. },
  58. {
  59. icon: 'edit-filling',
  60. text: '采编',
  61. onClick: () => goSubmitDigPage(item),
  62. },
  63. {
  64. icon: 'browse',
  65. text: '我的投稿',
  66. onClick: () => goMyDigPage(item),
  67. },
  68. ]">
  69. <Button v-if="authStore.isAdmin" icon="edit-filling" size="small">采编/管理</Button>
  70. </BubbleBox>
  71. <BubbleBox :items="[
  72. {
  73. icon: 'edit-filling',
  74. text: '采编',
  75. onClick: () => goSubmitDigPage(item),
  76. },
  77. {
  78. icon: 'browse',
  79. text: '我的投稿',
  80. onClick: () => goMyDigPage(item),
  81. },
  82. ]">
  83. <Button v-if="!authStore.isAdmin" icon="edit-filling" size="small">采编</Button>
  84. </BubbleBox>
  85. <Button type="primary" size="small" icon="edit-filling" @click="showOnlinePreviewDialog = true">线上展示</Button>
  86. </ButtonGroup>
  87. </FlexRow>
  88. </FlexCol>
  89. </SimplePageContentLoader>
  90. </RequireLogin>
  91. <Height :height="20" />
  92. <SubTitle v-if="authStore.isLogged" title="我的贡献" />
  93. <FlexRow v-if="authStore.isLogged" backgroundColor="white" :radius="20" :padding="[40,20]">
  94. <FlexCol :flex="1" :gap="10" center>
  95. <Text :fontSize="60" fontFamily="Rockwell" color="primary">{{ volunteerInfoLoader.content.value?.points || 0 }}</Text>
  96. <Text>文化积分</Text>
  97. </FlexCol>
  98. <FlexCol :flex="1" :gap="10" center>
  99. <Text :fontSize="60" fontFamily="Rockwell" color="primary">Lv.{{ volunteerInfoLoader.content.value?.level || 1 }}</Text>
  100. <Text>等级</Text>
  101. </FlexCol>
  102. </FlexRow>
  103. </FlexCol>
  104. <Dialog
  105. v-model:show="showOnlinePreviewDialog"
  106. :showConfirm="false"
  107. >
  108. <FlexCol :padding="[40,20]" :gap="10" center>
  109. <Image src="https://mn.wenlvti.net/app_static/xiangyuan/images/home/UnOpenIcon.png" width="300" mode="widthFix" />
  110. <Text textAlign="center">尊敬的用户,您未开通线上村史的使用权限,开通后即可使用!</Text>
  111. <Button size="large" type="primary" @click="showOnlinePreviewDialog = false">去开通</Button>
  112. </FlexCol>
  113. </Dialog>
  114. </FlexCol>
  115. </template>
  116. <script setup lang="ts">
  117. import { ref, watch } from 'vue';
  118. import { navTo } from '@/components/utils/PageAction';
  119. import { useAuthStore } from '@/store/auth';
  120. import { useCollectStore } from '@/store/collect';
  121. import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
  122. import { checkIsNotVolunteerError } from './forms/bind';
  123. import VillageApi, { VillageListItem } from '@/api/inhert/VillageApi';
  124. import RequireLogin from '@/common/components/RequireLogin.vue';
  125. import SimplePageContentLoader from '@/common/components/SimplePageContentLoader.vue';
  126. import Button from '@/components/basic/Button.vue';
  127. import Image from '@/components/basic/Image.vue';
  128. import SubTitle from '@/components/display/title/SubTitle.vue';
  129. import FlexCol from '@/components/layout/FlexCol.vue';
  130. import FlexRow from '@/components/layout/FlexRow.vue';
  131. import H3 from '@/components/typography/H3.vue';
  132. import Text from '@/components/basic/Text.vue';
  133. import Height from '@/components/layout/space/Height.vue';
  134. import ButtonGroup from '@/components/basic/ButtonGroup.vue';
  135. import BubbleBox from '@/components/feedback/BubbleBox.vue';
  136. import Result from '@/components/feedback/Result.vue';
  137. import Dialog from '@/components/dialog/Dialog.vue';
  138. const showOnlinePreviewDialog = ref(false);
  139. const authStore = useAuthStore();
  140. const collectStore = useCollectStore();
  141. const notVolunteerError = ref(false);
  142. const villageListLoader = useSimpleDataLoader(async () => await VillageApi.getClaimedVallageList(), true);
  143. const volunteerInfoLoader = useSimpleDataLoader(async () => {
  144. try {
  145. const res = await VillageApi.getVolunteerInfo()
  146. notVolunteerError.value = false;
  147. return res;
  148. } catch (error) {
  149. notVolunteerError.value = checkIsNotVolunteerError(error);
  150. throw error;
  151. }
  152. }, true);
  153. const rankListLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerRanklist(), true);
  154. watch(() => authStore.isLogged, (newVal) => {
  155. if (newVal) {
  156. villageListLoader.loadData();
  157. volunteerInfoLoader.loadData();
  158. rankListLoader.loadData();
  159. }
  160. })
  161. function goSubmitDigPage(item: VillageListItem) {
  162. navTo('./dig/details', {
  163. name: item.villageName,
  164. villageId: item.villageId,
  165. villageVolunteerId: item.villageVolunteerId,
  166. points: volunteerInfoLoader.content.value?.points,
  167. level: volunteerInfoLoader.content.value?.level,
  168. })
  169. }
  170. function goManagePage(item: VillageListItem) {
  171. navTo('./dig/admin/index', {
  172. id: item.villageId,
  173. name: item.villageName,
  174. villageId: item.villageId,
  175. villageVolunteerId: item.villageVolunteerId,
  176. points: volunteerInfoLoader.content.value?.points,
  177. level: volunteerInfoLoader.content.value?.level,
  178. })
  179. }
  180. function goMyDigPage(item: VillageListItem) {
  181. navTo('./dig/forms/submits', {
  182. villageName: item.villageName,
  183. villageId: item.villageId,
  184. villageVolunteerId: item.villageVolunteerId,
  185. })
  186. }
  187. function goPreviewDigPage(item: VillageListItem) {
  188. navTo('./dig/admin/preview', {
  189. villageName: item.villageName,
  190. villageId: item.villageId,
  191. villageVolunteerId: item.villageVolunteerId,
  192. })
  193. }
  194. </script>