step3.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <Result status="success" title="更改密码成功" :sub-title="getSubTitle">
  3. <template #extra>
  4. <a-button key="console" type="primary" @click="finish"> 返回登录 </a-button>
  5. </template>
  6. </Result>
  7. </template>
  8. <script lang="ts">
  9. import { defineComponent, ref, computed, unref, onMounted, watchEffect, watch } from 'vue';
  10. import { Form, Input, Button, Result } from 'ant-design-vue';
  11. import { useI18n } from '/@/hooks/web/useI18n';
  12. import { useLoginState } from '../login/useLogin';
  13. import { useCountdown } from '/@/components/CountDown/src/useCountdown';
  14. import { propTypes } from '/@/utils/propTypes';
  15. export default defineComponent({
  16. name: 'Step3',
  17. components: {
  18. Button,
  19. Form,
  20. FormItem: Form.Item,
  21. Input,
  22. Result,
  23. },
  24. props: {
  25. accountInfo: {
  26. type: Object,
  27. default: () => ({}),
  28. },
  29. count: propTypes.number.def(5),
  30. },
  31. emits: ['finish'],
  32. setup(props, { emit }) {
  33. const { t } = useI18n();
  34. const { accountInfo } = props;
  35. const { handleBackLogin } = useLoginState();
  36. const { currentCount, start } = useCountdown(props.count);
  37. const getSubTitle = computed(() => {
  38. return t('sys.login.subTitleText', [unref(currentCount)]);
  39. });
  40. /**
  41. * 倒计时
  42. */
  43. watchEffect(() => {
  44. if (unref(currentCount) === 1) {
  45. setTimeout(() => {
  46. finish();
  47. }, 500);
  48. }
  49. });
  50. /**
  51. * 结束回调
  52. */
  53. function finish() {
  54. handleBackLogin();
  55. emit('finish');
  56. }
  57. onMounted(() => {
  58. start();
  59. });
  60. return {
  61. getSubTitle,
  62. finish,
  63. };
  64. },
  65. });
  66. </script>