index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. <DebugButton />
  41. <view class="test">
  42. <official-account-publish path="/pages/index" @error="onError"></official-account-publish>
  43. </view>
  44. </FlexCol>
  45. </template>
  46. <script setup lang="ts">
  47. import { computed } from 'vue';
  48. import { navTo } from '@/components/utils/PageAction';
  49. import { confirm } from '@/components/dialog/CommonRoot';
  50. import { useAuthStore } from '@/store/auth';
  51. import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
  52. import UserHead from '@/static/images/user/avatar.png';
  53. import CellGroup from '@/components/basic/CellGroup.vue';
  54. import Cell from '@/components/basic/Cell.vue';
  55. import Image from '@/components/basic/Image.vue';
  56. import H4 from '@/components/typography/H4.vue';
  57. import Height from '@/components/layout/space/Height.vue';
  58. import Touchable from '@/components/feedback/Touchable.vue';
  59. import FlexCol from '@/components/layout/FlexCol.vue';
  60. import AppCofig from '@/common/config/AppCofig';
  61. import VillageApi from '@/api/inhert/VillageApi';
  62. import DebugButton from './debug/DebugButton.vue';
  63. const authStore = useAuthStore();
  64. const userInfo = computed(() => authStore.isLogged ? authStore.userInfo : null);
  65. const isBindWx = computed(() => Boolean(userInfo.value?.openId));
  66. const volunteerInfoLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerInfo(), true);
  67. function onError(e: any) {
  68. console.error(e);
  69. }
  70. function goUserProfile() {
  71. userInfo.value ? navTo('/pages/user/update/profile') : navTo('/pages/user/login');
  72. }
  73. function doLogout() {
  74. confirm({
  75. content: '您确定要退出登录吗?',
  76. }).then((res) => {
  77. if (res) {
  78. authStore.logout();
  79. if (AppCofig.requireLogin)
  80. uni.reLaunch({ url: '/pages/user/login' });
  81. }
  82. });
  83. }
  84. </script>
  85. <style scoped lang="scss">
  86. .test {
  87. width: 100%;
  88. min-height: 50rpx;
  89. }
  90. </style>