index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <FlexCol :padding="[40,30,50,30]">
  3. <FlexRow align="center">
  4. <Image
  5. :src="userInfo?.avatar || UserHead"
  6. mode="aspectFill"
  7. class="avatar"
  8. width="100rpx"
  9. height="100rpx"
  10. round
  11. />
  12. <Width :width="20" />
  13. <Touchable v-if="userInfo" direction="column" touchable @click="navTo('/pages/user/update/profile')" :flex="1">
  14. <H4>{{ userInfo.nickname }}</H4>
  15. <text class="extra"><text class="label">守护编号</text><text>{{ userInfo.id }}</text><text class="label point-label">积分</text><text>{{ userInfo.totalCheckins }}</text></text>
  16. </Touchable>
  17. <Touchable v-else direction="column" touchable @click="navTo('/pages/user/login')" :flex="1">
  18. <H4 class="nickname">请登录</H4>
  19. </Touchable>
  20. <Width :width="20" />
  21. <Icon icon="arrow-right" />
  22. </FlexRow>
  23. <Height :height="50" />
  24. <CellGroup v-if="userInfo">
  25. <Cell icon="https://mn.wenlvti.net/uploads/20250313/cbc47d0b9cad7891e6154359952858c6.png" title="退出登录" showArrow touchable @click="doLogout" />
  26. </CellGroup>
  27. </FlexCol>
  28. </template>
  29. <script setup lang="ts">
  30. import { useAuthStore } from '@/store/auth';
  31. import { computed } from 'vue';
  32. import UserHead from '@/static/images/home/UserHead.png';
  33. import CellGroup from '@/components/basic/CellGroup.vue';
  34. import Cell from '@/components/basic/Cell.vue';
  35. import FlexRow from '@/components/layout/FlexRow.vue';
  36. import Image from '@/components/basic/Image.vue';
  37. import Icon from '@/components/basic/Icon.vue';
  38. import H4 from '@/components/typography/H4.vue';
  39. import Width from '@/components/layout/space/Width.vue';
  40. import Height from '@/components/layout/space/Height.vue';
  41. import { confirm } from '@/components/utils/DialogAction';
  42. import { navTo } from '@/components/utils/PageAction';
  43. import Touchable from '@/components/feedback/Touchable.vue';
  44. import FlexCol from '@/components/layout/FlexCol.vue';
  45. const authStore = useAuthStore();
  46. const userInfo = computed(() => authStore.userInfo);
  47. function doLogout() {
  48. confirm({
  49. content: '您确定要退出登录吗?',
  50. }).then((res) => {
  51. if (res)
  52. authStore.logout();
  53. });
  54. }
  55. </script>