share-reg-page.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <CommonRoot>
  3. <FlexCol :gap="20" :padding="30">
  4. <Result
  5. v-if="authStore.isLogged"
  6. status="success"
  7. title="您已经是志愿者"
  8. desc="赶快去采编村社文化资源信息吧"
  9. >
  10. <Height :size="20" />
  11. <Button type="primary" @click="navTo('/pages/index')">返回首页</Button>
  12. </Result>
  13. <FlexCol v-else center :height="400">
  14. <Icon icon="smile-filling" color="primary" :size="156" />
  15. <Height :height="20" />
  16. <Text :fontSize="26" color="primary" text="欢迎注册,加入志愿者队伍" />
  17. <Height :size="40" />
  18. <!-- #ifdef MP-WEIXIN -->
  19. <Button type="primary" block text="微信登录" @click="loginWechat" />
  20. <Height :size="20" />
  21. <!-- #endif -->
  22. </FlexCol>
  23. </FlexCol>
  24. </CommonRoot>
  25. </template>
  26. <script setup lang="ts">
  27. import Button from '@/components/basic/Button.vue';
  28. import Result from '@/components/feedback/Result.vue';
  29. import FlexCol from '@/components/layout/FlexCol.vue';
  30. import Height from '@/components/layout/space/Height.vue';
  31. import Icon from '@/components/basic/Icon.vue';
  32. import Text from '@/components/basic/Text.vue';
  33. import CommonRoot from '@/components/dialog/CommonRoot.vue';
  34. import { navTo } from '@/components/utils/PageAction';
  35. import { useAuthStore } from '@/store/auth';
  36. import { closeToast, toast } from '@/components/dialog/CommonRoot';
  37. import { showError } from '@/common/composeabe/ErrorDisplay';
  38. const authStore = useAuthStore();
  39. function loginWechat() {
  40. toast({
  41. type: 'loading',
  42. content: '登录中...',
  43. })
  44. Promise.all([
  45. uni.login({ provider: 'weixin' }),
  46. uni.getUserProfile({ desc: '用于完善会员资料' }),
  47. ])
  48. .then((res) => {
  49. authStore.loginWechart(res[0].code, res[1]).then(() => {
  50. toast({
  51. type: 'success',
  52. content: '登录成功',
  53. });
  54. //collectStore.loadCollectableModules();
  55. //setTimeout(() => redirectToIndex(), 200);
  56. }).catch(showError);
  57. })
  58. .catch(showError)
  59. .finally(() => closeToast());
  60. }
  61. </script>