index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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="/static/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="/static/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="/static/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="/static/images/user/icon-service.png" title="联系客服" showArrow touchable />
  36. </button>
  37. <Cell icon="/static/images/user/icon-chat.png" title="商务合作" showArrow touchable @click="navTo('/pages/home/about/contract')" />
  38. <Cell v-if="userInfo" icon="/static/images/user/icon-quit.png" title="退出登录" showArrow touchable @click="doLogout" />
  39. </CellGroup>
  40. <Touchable direction="column" center :padding="40" :gap="10" @click="showBuildInfo">
  41. <Text
  42. color="text.second"
  43. :fontSize="22"
  44. :text="`软件版本 ${AppCofig.version}`"
  45. />
  46. </Touchable>
  47. </FlexCol>
  48. </template>
  49. <script setup lang="ts">
  50. import { computed } from 'vue';
  51. import { navTo } from '@/components/utils/PageAction';
  52. import { alert, confirm } from '@/components/dialog/CommonRoot';
  53. import { DateUtils } from '@imengyu/imengyu-utils';
  54. import { useAuthStore } from '@/store/auth';
  55. import UserHead from '@/static/images/user/avatar.png';
  56. import CellGroup from '@/components/basic/CellGroup.vue';
  57. import Cell from '@/components/basic/Cell.vue';
  58. import Image from '@/components/basic/Image.vue';
  59. import H4 from '@/components/typography/H4.vue';
  60. import Height from '@/components/layout/space/Height.vue';
  61. import Touchable from '@/components/feedback/Touchable.vue';
  62. import FlexCol from '@/components/layout/FlexCol.vue';
  63. import Text from '@/components/basic/Text.vue';
  64. import AppCofig from '@/common/config/AppCofig';
  65. import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
  66. import VillageApi from '@/api/inhert/VillageApi';
  67. const authStore = useAuthStore();
  68. const userInfo = computed(() => authStore.isLogged ? authStore.userInfo : null);
  69. const isBindWx = computed(() => Boolean(userInfo.value?.openId));
  70. const volunteerInfoLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerInfo(), true);
  71. const buildTime = `${__BUILD_TIMESTAMP__}`
  72. const buildInfo = `${__BUILD_GUID__}`
  73. function showBuildInfo() {
  74. alert({
  75. title: '关于程序',
  76. content: '版本: ' + AppCofig.version +
  77. '\n构建时间:' + DateUtils.formatDate(new Date(parseInt(buildTime)), 'yyyy-MM-dd HH:mm:ss') +
  78. ' (' + buildTime + ')' +
  79. '\n构建GUID:' + buildInfo,
  80. icon: 'prompt-filling',
  81. iconColor: 'primary',
  82. width: 560,
  83. })
  84. }
  85. function goUserProfile() {
  86. userInfo.value ? navTo('/pages/user/update/profile') : navTo('/pages/user/login');
  87. }
  88. function doLogout() {
  89. confirm({
  90. content: '您确定要退出登录吗?',
  91. }).then((res) => {
  92. if (res) {
  93. authStore.logout();
  94. uni.reLaunch({ url: '/pages/user/login' });
  95. }
  96. });
  97. }
  98. </script>