2020-04-14

    <div class="login-wrap">

        <div class="ms-login">

            <div class="ms-title">新人后台管理系统</div>

            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="ms-content">

                <el-form-item prop="username">

                    <el-input v-model="ruleForm.username" placeholder="请输入用户名">

                        <el-button slot="prepend" ><i class="fa fa-user-o" aria-hidden="true"></i> </el-button>

                    </el-input>

                </el-form-item>

                <el-form-item prop="password">

                    <el-input type="password" placeholder="请输入密码" v-model="ruleForm.password" @keyup.enter.native="submitForm('ruleForm')">

                        <el-button slot="prepend" ><i class="fa fa-key" aria-hidden="true"></i></el-button>

                    </el-input>

                </el-form-item>

                <!-- <el-form-item prop="code" class="item">

                    <el-input  placeholder="请输入验证码" v-model="ruleForm.code" >

                    </el-input>

                </el-form-item>

                <img id="verify" :src="url" @click="updateImg()" /> -->

                <div class="login-btn">

                    <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>

                </div>

                <!-- <p class="login-tips">Tips : 用户名和密码随便填。</p> -->

            </el-form>

        </div>

    </div>

</template>

<script>

import { setTimeout } from 'timers';

    export default {

        data: function(){

            return {

                ruleForm: {

                    username: '',

                    password: '',

                    // code:''

                },

                rules: {

                    username: [

                        { required: true, message: '请输入用户名', trigger: 'blur' }

                    ],

                    password: [

                        { required: true, message: '请输入密码', trigger: 'blur' }

                    ],

                    // code:[

                    //     { required: true, message: '请输入验证码', trigger: 'blur' }

                    // ],

                }

            }

        },

        computed:{

            // url(){

            //     return Url+"/admin/login/checkVerify";

            // }

        },

        methods: {

            submitForm(formName) {//登录验证

                var that =this;

                this.$refs[formName].validate((valid) => {

                    if (valid) {

                        this.$axios({

                            url:Url+'/api/login',

                            method:'post',

                            data:{

                                username:this.ruleForm.username,

                                password:this.ruleForm.password,

                                code:this.ruleForm.code

                            }

                        }).then((res)=>{

                            console.log(res)

                                if(res.data.code==200){

                                     this.$message.success({

                                         message:'登录成功',

                                         duration:1000

                                     });

                                     sessionStorage.setItem('ms_username',this.ruleForm.username);  

                                     sessionStorage.setItem('role_id',res.data.data)

                                    setTimeout(function(){

                                        that.$router.push('/');

                                    },1000)

                                }else{

                                    this.$message.error({

                                         message:res.data.msg,

                                         duration:2000

                                     });

                                    // that.updateImg()

                                }

                            })

                    } else {

                        console.log('error submit!!');

                        return false;

                    }

                });

            }

            // updateImg(){

            //     $('#verify').attr('src',Url+'/admin/login/checkVerify?tm='+Math.random());

            // }

        }

    }

</script>

<style scoped>

    .login-wrap{

        position: relative;

        width:100%;

        height:100%;

        background-image: url(../../assets/img/banner.jpg);

        background-size: 100% 100%;

        background-repeat: no-repeat;

        background-position: center;

    }

    .ms-title{

        width:100%;

        line-height: 50px;

        text-align: center;

        font-size:20px;

        color: #fff;

        border-bottom: 1px solid #ddd;

    }

    .ms-login{

        position: absolute;

        left:50%;

        top:50%;

        width:350px;

        margin:-190px 0 0 -175px;

        border-radius: 5px;

        background: rgba(255,255,255, 0.3);

        overflow: hidden;

    }

    .ms-content{

        padding: 30px 30px;

    }

    .login-btn{

        text-align: center;

    }

    .login-btn button{

        width:100%;

        height:36px;

        margin-bottom: 10px;

    }

    .login-tips{

        font-size:12px;

        line-height:30px;

        color:#fff;

    }

    .item /deep/{

        display: inline-block;

        width: 180px;

    }

    #verify{

        /* margin-top: 10px; */

        float: right;

    }

</style>




©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • #!/usr/bin/env python # -*- coding: utf-8 -*- #coding=utf...
    BoyT9阅读 1,702评论 0 0
  • title: "R_basic"author: "Mande Xue"date: "2020/4/14"outpu...
    德先森的书阅读 1,481评论 0 0
  • 班级: L3-B 姓名:Kitty 学号:20193000603 日期: 2020/4/14 作业序:...
    Kitty陈阅读 2,325评论 4 0
  • 班级:L3-B 姓名:Sakura 学号:20193000628 日期:2020/4./14 作业序号(...
    糖糖的Sakura阅读 876评论 0 0
  • 1、认识26个英文字母; 2.音标 2.1四个前元音: 2.2举例: 3、经典口语习语、词组、谚语: 4、地道情景...
    执着_7fb1阅读 5,043评论 0 0

友情链接更多精彩内容