index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <FlexCol :padding="[40,30,50,30]">
  3. <HomeLargeTitle title="我的" />
  4. <Touchable
  5. direction="row"
  6. align="center"
  7. justify="space-between"
  8. touchable
  9. :gap="25"
  10. :padding="[0,30]"
  11. @click="goUserProfile"
  12. >
  13. <FlexRow align="center" :gap="25">
  14. <Image
  15. :src="userInfo?.avatar || UserHead"
  16. :defaultImage="UserHead"
  17. :failedImage="UserHead"
  18. mode="aspectFill"
  19. class="avatar"
  20. width="75rpx"
  21. height="75rpx"
  22. :showFailed="false"
  23. round
  24. />
  25. <H4 v-if="userInfo">{{ userInfo.nickname }}</H4>
  26. <H4 v-else>欢迎登录</H4>
  27. </FlexRow>
  28. <Icon icon="arrow-right" size="30" />
  29. </Touchable>
  30. <ProvideVar :vars="{
  31. GridItemIconSize: 90,
  32. GridItemBackgroundColor: 'transparent',
  33. GridItemPaddingHorizontal: 0,
  34. }">
  35. <Grid :borderGrid="false" :mainAxisCount="4">
  36. <GridItem title="乡源等级" icon="https://xy.wenlvti.net/app_static/images/mine/IconLevel.png" touchable />
  37. <GridItem title="我的成就" icon="https://xy.wenlvti.net/app_static/images/mine/IconArchive.png" touchable />
  38. <GridItem title="任务中心" icon="https://xy.wenlvti.net/app_static/images/mine/IconTask.png" touchable />
  39. <GridItem title="积分商城" icon="https://xy.wenlvti.net/app_static/images/mine/IconShop.png" touchable />
  40. </Grid>
  41. </ProvideVar>
  42. <ProvideVar :vars="{
  43. CellBackground: 'background.tertiary',
  44. CellBottomBorder: false,
  45. }">
  46. <CellGroup round>
  47. <Cell v-if="userInfo" icon="https://xy.wenlvti.net/app_static/images/mine/IconMyArticle.png" title="我的投稿" showArrow touchable @click="navTo('/pages/dig/forms/submits', {
  48. villageVolunteerId: volunteerInfoLoader.content.value?.id || 0
  49. })" />
  50. <Cell icon="https://xy.wenlvti.net/app_static/images/mine/IconMyRecord.png" title="福泽记录" showArrow touchable @click="requireLogin(() => navTo('/pages/home/bless/my-orders'), '登录后查看我的福泽记录哦')" />
  51. <Cell icon="https://xy.wenlvti.net/app_static/images/mine/IconMyReward.png" title="兑换记录" showArrow touchable />
  52. <Cell icon="https://xy.wenlvti.net/app_static/images/mine/IconAbout.png" title="关于我们" showArrow touchable @click="navTo('/pages/home/about/about')" />
  53. <button open-type="contact" class="remove-button-style">
  54. <Cell icon="https://xy.wenlvti.net/app_static/images/mine/IconContract.png" title="联系客服" showArrow touchable />
  55. </button>
  56. <Cell v-if="userInfo" icon="https://xy.wenlvti.net/app_static/images/mine/IconQuit.png" title="退出登录" showArrow touchable @click="doLogout" />
  57. </CellGroup>
  58. </ProvideVar>
  59. <DebugButton />
  60. </FlexCol>
  61. </template>
  62. <script setup lang="ts">
  63. import { computed } from 'vue';
  64. import { navTo } from '@/components/utils/PageAction';
  65. import { confirm } from '@/components/dialog/CommonRoot';
  66. import { useAuthStore } from '@/store/auth';
  67. import { useRequireLogin } from '@/common/composeabe/RequireLogin';
  68. import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
  69. import CellGroup from '@/components/basic/CellGroup.vue';
  70. import Cell from '@/components/basic/Cell.vue';
  71. import Image from '@/components/basic/Image.vue';
  72. import H4 from '@/components/typography/H4.vue';
  73. import Height from '@/components/layout/space/Height.vue';
  74. import Touchable from '@/components/feedback/Touchable.vue';
  75. import FlexCol from '@/components/layout/FlexCol.vue';
  76. import AppCofig from '@/common/config/AppCofig';
  77. import VillageApi from '@/api/inhert/VillageApi';
  78. import DebugButton from './debug/DebugButton.vue';
  79. import FlexRow from '@/components/layout/FlexRow.vue';
  80. import Icon from '@/components/basic/Icon.vue';
  81. import HomeLargeTitle from '@/common/components/parts/HomeLargeTitle.vue';
  82. import ProvideVar from '@/components/theme/ProvideVar.vue';
  83. import Grid from '@/components/layout/grid/Grid.vue';
  84. import GridItem from '@/components/layout/grid/GridItem.vue';
  85. const UserHead = 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/avatar.png';
  86. const authStore = useAuthStore();
  87. const userInfo = computed(() => authStore.isLogged ? authStore.userInfo : null);
  88. const volunteerInfoLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerInfo(), true);
  89. const { requireLogin } = useRequireLogin();
  90. function goUserProfile() {
  91. userInfo.value ? navTo('/pages/user/update/profile') : navTo('/pages/user/login');
  92. }
  93. function doLogout() {
  94. confirm({
  95. content: '您确定要退出登录吗?',
  96. }).then((res) => {
  97. if (res) {
  98. authStore.logout();
  99. if (AppCofig.requireLogin)
  100. uni.reLaunch({ url: '/pages/user/login' });
  101. }
  102. });
  103. }
  104. </script>