| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <div class="login-container">
- <el-card :body-style="{padding:0}" shadow="none">
- <div slot="header" class="clearfix">
- <span>数据资源中心</span>
- <!-- <div style="float: right; color: #666666">-->
- <!-- 服务热线:<span style="color: #FF970F;font-weight: bold">400-698-5980</span>-->
- <!-- </div>-->
- </div>
- <div style="min-height: 500px;">
- <el-row style="width: 1000px;margin: 99px auto 0 auto;overflow: hidden;">
- <el-col :span="16">
- <el-image src="http://lcadmin.tongyu99.com/statics/image/dl01.png" />
- </el-col>
- <el-col :span="8">
- <el-card shadow="always">
- <div slot="header" class="clearfix">
- <strong>用户登录</strong>
- </div>
- <el-form
- ref="loginForm"
- :model="loginForm"
- class="login-form"
- auto-complete="on"
- label-position="left"
- >
- <el-form-item prop="username">
- <el-input
- ref="username"
- v-model="loginForm.username"
- placeholder="请输入手机号/邮箱"
- name="username"
- type="text"
- auto-complete="on"
- >
- <span slot="prepend" class="svg-container el-icon-user-solid" />
- </el-input>
- </el-form-item>
- <el-form-item prop="password">
- <el-input
- :key="passwordType"
- ref="password"
- v-model="loginForm.password"
- :type="passwordType"
- placeholder="请输入登录密码"
- name="password"
- auto-complete="on"
- @keyup.enter.native="handleLogin"
- >
- <span slot="prepend" class="svg-container el-icon-lock" />
- <span slot="append" class="show-pwd" @click="showPwd">
- <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
- </span>
- </el-input>
- </el-form-item>
- <el-row>
- <el-col :span="16">
- <el-form-item prop="password">
- <el-input
- ref="captcha"
- v-model="loginForm.captcha"
- placeholder="请输入验证码"
- name="captcha"
- type="text"
- >
- <span slot="prepend" class="svg-container el-icon-warning" />
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8" style="text-align: right">
- <el-image
- v-if="captcha && captcha!==''"
- :src="captcha"
- style="width: 80px"
- class="show-pwd"
- @click="refreshCaptcha"
- />
- </el-col>
- </el-row>
- <el-button
- :loading="loading"
- type="primary"
- style="width: 100%; margin-bottom: 30px"
- @click.native.prevent="handleLogin"
- >
- 登录
- </el-button>
- </el-form>
- </el-card>
- </el-col>
- </el-row>
- </div>
- </el-card>
- <div class="footer">
- ©2022 智慧旅游 版权所有 All Rights Reserved.
- </div>
- </div>
- </template>
- <script>
- import { getCaptcha } from '@/api/oauth'
- export default {
- name: 'Login',
- data() {
- return {
- loginForm: {
- username: '',
- password: '',
- captcha: ''
- },
- loading: false,
- passwordType: 'password',
- redirect: undefined,
- token: '',
- captcha: ''
- }
- },
- watch: {
- $route: {
- handler: function(route) {
- this.redirect = route.query && route.query.redirect
- },
- immediate: true
- }
- },
- created() {
- this.refreshCaptcha()
- },
- methods: {
- refreshCaptcha() {
- getCaptcha().then((v) => {
- console.log(v)
- this.token = v.token
- this.captcha = v.captcha
- })
- },
- showPwd() {
- if (this.passwordType === 'password') {
- this.passwordType = ''
- } else {
- this.passwordType = 'password'
- }
- this.$nextTick(() => {
- this.$refs.password.focus()
- })
- },
- handleLogin() {
- this.$refs.loginForm.validate((valid) => {
- if (valid) {
- this.loading = true
- this.$store
- .dispatch('user/login', { ...this.loginForm, token: this.token })
- .then(() => {
- this.$router.push({ path: this.redirect || '/' })
- this.loading = false
- })
- .catch(() => {
- this.loading = false
- })
- } else {
- console.log('error submit!!')
- return false
- }
- })
- }
- }
- }
- </script>
- <style lang="css">
- .footer {
- height: 68px;
- line-height: 68px;
- color: #333;
- text-align: center;
- background: #eaeaea;
- font-size: 12px;
- }
- .footer a {
- color: #333;
- }
- .footer a:hover {
- color: #f08200;
- }
- </style>
|