Blame view

ant-design-vue-jeecg/src/views/user/modules/SystemActivationModal.vue 4.22 KB
1
2
<template>
  <div class="main">
3
    <a-form-model class="user-layout-login" @keyup.enter.native="handleSubmit" :model="model" :rules="validatorRules">
4
      <a-tabs :activeKey="customActiveKey" :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }" @change="handleTabClick">
5
        <a-tab-pane key="tab1" tab="系统激活授权"/>
6
7
      </a-tabs>
      <a-form-model-item>
8
        <a-input size="large" v-model="model.activationCode" autocomplete="false" placeholder="系统激活授权期限已到期,请输入系统激活码"/>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
      </a-form-model-item>
      <a-form-item style="margin-top:24px">
        <a-button size="large" type="primary" htmlType="submit" class="login-button" :loading="loginBtn" @click.stop.prevent="handleSubmit" :disabled="loginBtn">确定
        </a-button>
      </a-form-item>
    </a-form-model>
    <two-step-captcha v-if="requiredTwoStepCaptcha" :visible="stepCaptchaVisible" @success="stepCaptchaSuccess" @cancel="stepCaptchaCancel"></two-step-captcha>
  </div>
</template>

<script>
import Vue from 'vue'
import {ACCESS_TOKEN, ENCRYPTED_STRING} from '@/store/mutation-types'
import TwoStepCaptcha from '@/components/tools/TwoStepCaptcha'
import {getEncryptedString} from '@/utils/encryption/aesEncrypt'
import {timeFix} from '@/utils/util'
25
import {systemActivation} from '@/api/api'
26
27
28

export default {
  components: {
29
    TwoStepCaptcha
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  },
  data() {
    return {
      customActiveKey: 'tab1',
      rememberMe: true,
      loginBtn: false,
      requiredTwoStepCaptcha: false,
      stepCaptchaVisible: false,
      querySource: {},
      encryptedString: {
        key: "",
        iv: "",
      },
      model: {
44
        activationCode: ''
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
      },
    }
  },
  created() {
    Vue.ls.remove(ACCESS_TOKEN)
    this.getRouterData();
    this.rememberMe = true
  },
  methods: {
    handleTabClick(key) {
      this.customActiveKey = key
    },
    handleRememberMeChange(e) {
      this.rememberMe = e.target.checked
    },
    /**跳转到登录页面的参数-账号获取*/
    getRouterData() {
      this.$nextTick(() => {
        let temp = this.$route.params.username || this.$route.query.username || ''
        if (temp) {
          this.$refs.alogin.acceptUsername(temp)
        }
      })
    },
69
    //验证激活码
70
71
72
    handleSubmit() {
      this.loginBtn = true;
      console.log('handleSubmit start')
73
      this.handleSystemActivation(this.rememberMe)
74
    },
75
    systemActivationSuccess() {
76
77
      this.$router.push({path: "/user/login"});
      this.$notification.success({
78
        message: '激活成功,请重新登录',
79
80
      });
    },
81
    systemActivationSuccessError(message) {
82
      this.$notification.error({
83
        message: message,
84
85
86
87
88
89
90
91
92
93
94
95
96
97
      });
      this.loginBtn = false;
    },
    //获取密码加密规则
    getEncrypte() {
      var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
      if (encryptedString == null) {
        getEncryptedString().then((data) => {
          this.encryptedString = data
        });
      } else {
        this.encryptedString = encryptedString;
      }
    },
98
    handleSystemActivation(rememberMe) {
99
100
      console.log('handleSystemActivation start')
      let systemActivationModelParams = {
101
        activationCode: this.model.activationCode,
102
      }
103
104
105
106
107
108
109
110
      systemActivation(systemActivationModelParams).then((res) => {
        this.loading = false;
        if (res.success) {
          this.systemActivationSuccess();
        } else {
          this.systemActivationSuccessError(res.message);
        }
      });
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
    }
  }
}
</script>
<style lang="less" scoped>
.user-layout-login {
  label {
    font-size: 14px;
  }

  .getCaptcha {
    display: block;
    width: 100%;
    height: 40px;
  }

  .forge-password {
    font-size: 14px;
  }

  button.login-button {
    padding: 0 15px;
    font-size: 16px;
    height: 40px;
    width: 100%;
  }

  .user-login-other {
    text-align: left;
    margin-top: 24px;
    line-height: 22px;

    .item-icon {
      font-size: 24px;
      color: rgba(0, 0, 0, .2);
      margin-left: 16px;
      vertical-align: middle;
      cursor: pointer;
      transition: color .3s;

      &:hover {
        color: #1890ff;
      }
    }

    .register {
      float: right;
    }
  }

  .valid-error .ant-select-selection__placeholder {
    color: #f5222d;
  }
}
</style>