123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <template>
- <div id="login">
- <el-row>
- <el-col :span="24" class="main">
- <div class="w_1200">
- <el-col :span="24" class="one">
- <el-col :span="24" class="txt">商城管理登陆</el-col>
- <el-col :span="24" class="form">
- <el-form :model="form" :rules="rules" ref="form">
- <el-form-item label="" prop="account">
- <el-input placeholder="账号" v-model="form.account" @keyup.enter.native="onSubmit('form')">
- <i slot="prefix" class="el-input__icon el-icon-user-solid"></i>
- </el-input>
- </el-form-item>
- <el-form-item label="" prop="password">
- <el-input placeholder="密码" v-model="form.password" type="password" auto-complete="off" @keyup.enter.native="onSubmit('form')">
- <i slot="prefix" class="el-input__icon el-icon-lock"></i>
- </el-input>
- </el-form-item>
- <el-form-item class="btn">
- <el-button type="primary" @click="onSubmit('form')">登录</el-button>
- </el-form-item>
- </el-form>
- </el-col>
- <el-col :span="24" class="other">
- <el-button type="text" style="color: blue; font-size: 14px" @click="toReset()">忘记密码?</el-button>
- </el-col>
- </el-col>
- </div>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: maU } = createNamespacedHelpers('admin');
- const { mapActions: admins } = createNamespacedHelpers('admins');
- const _ = require('lodash');
- export default {
- name: 'login',
- props: {},
- components: {},
- data: function () {
- return {
- form: {},
- rules: {
- account: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
- password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
- },
- };
- },
- created() {},
- methods: {
- ...maU(['login']),
- ...admins(['email']),
- onSubmit(formName) {
- this.$refs[formName].validate(async (valid) => {
- if (valid) {
- const res = await this.login(this.form);
- if (!res) {
- this.$message({ type: `error`, message: `登陆失败` });
- } else {
- if (res.errcode !== 0) {
- this.$message({ type: 'error', message: `${res.errmsg}` });
- } else {
- this.$router.push({ path: '/' });
- }
- }
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- async toReset() {
- if (this.form.account == undefined || this.form.account == '') {
- this.$message.error('请输入账号');
- } else {
- this.$confirm('忘记密码,是否确认重置密码?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- }).then(async () => {
- const res = await this.email({ account: this.form.account });
- if (this.$checkRes(res)) {
- this.$message({ type: `success`, message: `重置密码成功` });
- }
- });
- }
- },
- },
- computed: {
- ...mapState(['user']),
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- watch: {
- test: {
- deep: true,
- immediate: true,
- handler(val) {},
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .main {
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100vh;
- overflow: hidden;
- background: url('~@/assets/login-background.jpg');
- background-repeat: no-repeat;
- background-size: 100%;
- .one {
- background-color: #ffffff;
- border-radius: 5px;
- padding: 10px 20px;
- margin: 70% 0 0 0;
- .txt {
- text-align: center;
- font-size: 20px;
- font-weight: bold;
- margin: 15px 0;
- }
- .form {
- .btn {
- text-align: center;
- .el-button {
- width: 100%;
- }
- }
- }
- .other {
- text-align: center;
- }
- }
- }
- </style>
|