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