123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <div class="aui-wrapper aui-page__login">
- <div class="aui-content__wrapper">
- <el-row>
- <el-col class="aui-content" :span="24" :offset="5">
- <!--<div class="login-header">-->
- <!--<h2 class="login-brand">{{ $t('brand.lg') }}</h2>-->
- <!--</div>-->
- <div class="login-body">
- <!--<h3 class="login-title">{{ $t('login.title') }}</h3>-->
- <img src="~@/assets/img/logo.png" style="width:50%;margin-bottom: 40px;">
- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" status-icon>
- <el-form-item prop="username">
- <el-input v-model="dataForm.username" :placeholder="$t('login.username')">
- <span slot="prefix" class="el-input__icon">
- <svg class="icon-svg" aria-hidden="true"><use xlink:href="#icon-user"></use></svg>
- </span>
- </el-input>
- </el-form-item>
- <el-form-item prop="password">
- <el-input v-model="dataForm.password" type="password" :placeholder="$t('login.password')">
- <span slot="prefix" class="el-input__icon">
- <svg class="icon-svg" aria-hidden="true"><use xlink:href="#icon-lock"></use></svg>
- </span>
- </el-input>
- </el-form-item>
- <el-form-item prop="validCode">
- <el-row :gutter="20">
- <el-col :span="14">
- <el-input v-model="dataForm.validCode" :placeholder="$t('login.captcha')">
- <span slot="prefix" class="el-input__icon">
- <svg class="icon-svg" aria-hidden="true"><use xlink:href="#icon-safetycertificate"></use></svg>
- </span>
- </el-input>
- </el-col>
- <el-col :span="10" class="login-captcha">
- <img :src="captchaPath" @click="getCaptcha()">
- </el-col>
- </el-row>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="dataFormSubmitHandle()" class="w-percent-100">{{ $t('login.title') }}</el-button>
- </el-form-item>
- </el-form>
- </div>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
- <script>
- import Cookies from 'js-cookie'
- import debounce from 'lodash/debounce'
- import { messages } from '@/i18n'
- import { getUUID } from '@/utils'
- export default {
- data () {
- return {
- i18nMessages: messages,
- captchaPath: '',
- dataForm: {
- username: '',
- password: '',
- deviceId: '',
- validCode: ''
- }
- }
- },
- computed: {
- dataRule () {
- return {
- username: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- password: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- validCode: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ]
- }
- }
- },
- created () {
- this.getCaptcha()
- },
- methods: {
- // 获取验证码
- getCaptcha () {
- this.dataForm.deviceId = getUUID()
- this.captchaPath = `${window.SITE_CONFIG['apiURL']}/validata/code/${this.dataForm.deviceId}`
- },
- // 表单提交
- dataFormSubmitHandle: debounce(function () {
- this.$refs['dataForm'].validate((valid) => {
- if (!valid) {
- return false
- }
- this.$http.post('/idaas/sso/login', this.dataForm).then(({ data: res }) => {
- if (res.code !== 0) {
- this.getCaptcha()
- return this.$message.error(res.msg)
- }
- Cookies.set('token', res.sessionToken)
-
- // 发送用户登录成功MQ消息
- this.$http.get('/mq/user/login').then(({ data: res }) => {
- if (res.code !== 0) {
- return this.$message.error(res.msg)
- }
- }).catch(() => {})
-
- this.$router.replace({ name: 'home' })
- }).catch(() => {})
- })
- }, 1000, { 'leading': true, 'trailing': false })
- }
- }
- </script>
- <style scoped>
- .aui-page__login .aui-content{
- padding: 0!important;
- }
- </style>
|