index.vue 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <FlexCol :padding="[40,30,50,30]">
  3. <Touchable
  4. direction="column"
  5. justify="center"
  6. align="center"
  7. touchable
  8. :gap="25"
  9. @click="goUserProfile"
  10. >
  11. <Image
  12. :src="userInfo?.avatar || UserHead"
  13. :defaultImage="UserHead"
  14. :failedImage="UserHead"
  15. mode="aspectFill"
  16. class="avatar"
  17. width="100rpx"
  18. height="100rpx"
  19. :showFailed="false"
  20. round
  21. />
  22. <H4 v-if="userInfo">{{ userInfo.nickname }}</H4>
  23. <H4 v-else>欢迎登录</H4>
  24. <H4 v-if="userInfo">{{ userInfo.mobile }}</H4>
  25. </Touchable>
  26. <Height :height="50" />
  27. <CellGroup round>
  28. <Cell v-if="userInfo" icon="https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/icon-edit.png" title="我的投稿" showArrow touchable @click="navTo('/pages/dig/forms/submits', {
  29. villageVolunteerId: volunteerInfoLoader.content.value?.id || 0
  30. })" />
  31. <Cell v-if="userInfo" icon="https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/icon-profile.png" title="编辑资料" showArrow touchable @click="goUserProfile" />
  32. <Cell v-if="userInfo && !isBindWx" icon="wechat" title="绑定微信" showArrow touchable @click="navTo('/pages/dig/sharereg/bind-wx')" />
  33. <Cell icon="https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/icon-function.png" title="关于我们" showArrow touchable @click="navTo('/pages/home/about/about')" />
  34. <button open-type="contact" class="remove-button-style">
  35. <Cell icon="https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/icon-service.png" title="联系客服" showArrow touchable />
  36. </button>
  37. <Cell icon="https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/icon-chat.png" title="商务合作" showArrow touchable @click="navTo('/pages/home/about/contract')" />
  38. <Cell v-if="userInfo" icon="https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/icon-quit.png" title="退出登录" showArrow touchable @click="doLogout" />
  39. </CellGroup>
  40. <DebugButton />
  41. </FlexCol>
  42. </template>
  43. <script setup lang="ts">
  44. import { computed } from 'vue';
  45. import { navTo } from '@/components/utils/PageAction';
  46. import { confirm } from '@/components/dialog/CommonRoot';
  47. import { useAuthStore } from '@/store/auth';
  48. import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
  49. import CellGroup from '@/components/basic/CellGroup.vue';
  50. import Cell from '@/components/basic/Cell.vue';
  51. import Image from '@/components/basic/Image.vue';
  52. import H4 from '@/components/typography/H4.vue';
  53. import Height from '@/components/layout/space/Height.vue';
  54. import Touchable from '@/components/feedback/Touchable.vue';
  55. import FlexCol from '@/components/layout/FlexCol.vue';
  56. import AppCofig from '@/common/config/AppCofig';
  57. import VillageApi from '@/api/inhert/VillageApi';
  58. import DebugButton from './debug/DebugButton.vue';
  59. const UserHead = 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/avatar.png';
  60. const authStore = useAuthStore();
  61. const userInfo = computed(() => authStore.isLogged ? authStore.userInfo : null);
  62. const isBindWx = computed(() => Boolean(userInfo.value?.openId));
  63. const volunteerInfoLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerInfo(), true);
  64. function goUserProfile() {
  65. userInfo.value ? navTo('/pages/user/update/profile') : navTo('/pages/user/login');
  66. }
  67. function doLogout() {
  68. confirm({
  69. content: '您确定要退出登录吗?',
  70. }).then((res) => {
  71. if (res) {
  72. authStore.logout();
  73. if (AppCofig.requireLogin)
  74. uni.reLaunch({ url: '/pages/user/login' });
  75. }
  76. });
  77. }
  78. </script>