首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >[javascript] elementui下login登录页界面和js验证逻辑

[javascript] elementui下login登录页界面和js验证逻辑

作者头像
唯一Chat
发布2020-05-26 23:25:10
发布2020-05-26 23:25:10
2.2K00
代码可运行
举报
文章被收录于专栏:陶士涵的菜地陶士涵的菜地
运行总次数:0
代码可运行

主要是使用了form组件

代码语言:javascript
代码运行次数:0
运行
复制
<html lang="cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="陶士涵">
    <title>GO-IMAP网页版邮箱imap工具登录页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/theme-chalk/index.css">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <style>
        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }
        html,
        body {
            height: 100%;
        }
        body {
            display: -ms-flexbox;
            display: flex;
            -ms-flex-align: center;
            align-items: center;
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #f5f5f5;
        }
        .form-signin {
            width: 100%;
            max-width: 400px;
            padding: 20px;
            margin: auto;
            background: #fff;
            -webkit-box-shadow: 0 1px 2px 0 rgba(101,129,156,.08);
            box-shadow: 0 1px 2px 0 rgba(101,129,156,.08);
        }
    </style>

</head>
<body class="text-center">
<div id="app" style="width:100%">
    <template>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="form-signin">
          <h1 class="h3 mb-3 font-weight-normal">邮箱网页版IMAP工具</h1>
          <el-form-item  prop="server">
            <el-input v-model="ruleForm.server" placeholder="IMAP服务器如imap.sina.net:143"></el-input>
          </el-form-item>
          <el-form-item  prop="email">
            <el-input v-model="ruleForm.email" placeholder="邮箱地址"></el-input>
          </el-form-item>
          <el-form-item  prop="password">
            <el-input v-model="ruleForm.password" placeholder="密码"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button :loading="loading" type="primary" @click="submitForm('ruleForm')">立即登录</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
        <p class="mt-5 mb-3 text-muted">&copy; 2020</p>
</template>           
</div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            loading:false,
            ruleForm:{
                server:'',
                email:'',
                password:'',
            },
            rules: {
                server: [
                    { required: true, message: 'IMAP服务器如"imap.sina.net:143"包含端口号', trigger: 'blur' },
                ],
                email: [
                    { required: true, message: '邮箱地址', trigger: 'blur' },
                ],
                password: [
                    { required: true, message: '邮箱密码', trigger: 'blur' },
                ],
            },
        },
        methods: {
            //提交表单
            submitForm(formName){
                let _this=this;
                this.$refs[formName].validate((valid) => {
                  if (valid) {
                    var data={}
                    data.server=_this.ruleForm.server;
                    data.email=_this.ruleForm.email;
                    data.password=_this.ruleForm.password;
                    _this.loading=true;
                    $.post("/check",data,function(data){
                        if(data.code==200){
                            _this.$message({
                              message: data.msg,
                              type: 'success'
                            });
                            window.kk="/";
                        }else{
                            _this.$message({
                              message: data.msg,
                              type: 'error'
                            });
                        }
                        _this.loading=false;
                    });
                  } else {
                    return false;
                  }
                });
            },
            //重置表单
            resetForm(formName) {
                this.loading=false;
                this.$refs[formName].resetFields();
            },
        }
    })

</script>
</html>

效果图如下:

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-05-19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档