| | |
| | | <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="code" v-if="captchaEnabled"> |
| | | <el-input |
| | | size="large" |
| | | v-model="registerForm.code" |
| | | auto-complete="off" |
| | | placeholder="验证码" |
| | | style="width: 63%" |
| | | @keyup.enter="handleRegister" |
| | | > |
| | | <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template> |
| | | </el-input> |
| | | <div class="register-code"> |
| | | <img :src="codeUrl" @click="getCode" class="register-code-img"/> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item style="width:100%;"> |
| | | <el-button |
| | | :loading="loading" |
| | |
| | | |
| | | <script setup> |
| | | import { ElMessageBox } from "element-plus" |
| | | import { getCodeImg, register } from "@/api/login" |
| | | import { register } from "@/api/login" |
| | | import defaultSettings from '@/settings' |
| | | import { usePasswordRule } from "@/utils/passwordRule" |
| | | |
| | |
| | | const registerForm = ref({ |
| | | username: "", |
| | | password: "", |
| | | confirmPassword: "", |
| | | code: "", |
| | | uuid: "" |
| | | confirmPassword: "" |
| | | }) |
| | | |
| | | const equalToPassword = (rule, value, callback) => { |
| | |
| | | confirmPassword: [ |
| | | { required: true, trigger: "blur", message: "请再次输入您的密码" }, |
| | | { required: true, validator: equalToPassword, trigger: "blur" } |
| | | ], |
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }] |
| | | ] |
| | | } |
| | | |
| | | const codeUrl = ref("") |
| | | const loading = ref(false) |
| | | const captchaEnabled = ref(true) |
| | | |
| | | function handleRegister() { |
| | | proxy.$refs.registerRef.validate(valid => { |
| | |
| | | }).catch(() => {}) |
| | | }).catch(() => { |
| | | loading.value = false |
| | | if (captchaEnabled) { |
| | | getCode() |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function getCode() { |
| | | getCodeImg().then(res => { |
| | | captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled |
| | | if (captchaEnabled.value) { |
| | | codeUrl.value = "data:image/gif;base64," + res.img |
| | | registerForm.value.uuid = res.uuid |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getCode() |
| | | </script> |
| | | |
| | | <style lang='scss' scoped> |
| | |
| | | text-align: center; |
| | | color: #bfbfbf; |
| | | } |
| | | .register-code { |
| | | width: 33%; |
| | | height: 40px; |
| | | float: right; |
| | | img { |
| | | cursor: pointer; |
| | | vertical-align: middle; |
| | | } |
| | | } |
| | | .el-register-footer { |
| | | height: 40px; |
| | | line-height: 40px; |
| | |
| | | font-family: Arial; |
| | | font-size: 12px; |
| | | letter-spacing: 1px; |
| | | } |
| | | .register-code-img { |
| | | height: 40px; |
| | | padding-left: 12px; |
| | | } |
| | | </style> |