charles
2024-05-21 5ffbec0a33a49c698699646ab71ddb3ad1ea310c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
    <div class="login-container">
        <div class="login-form">
            <div class="title">登录</div>
            <div class="form">
                <el-form :model="user" :rules="rules" ref="loginForm"  class="demo-ruleForm">
                    <el-form-item label="" prop="name" class="user-name">
                        <el-input placeholder="用户" v-model="user.name"></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="password" class="user-pwd">
                        <el-input type="password"show-password  placeholder="密码" v-model="user.password"></el-input>
                    </el-form-item>
                    <!--<el-form-item label="" prop="code" class="user-code">
                        <el-input placeholder="验证码" v-model="user.code">
                            <template slot="append">
                                <img class="login-code" :src="captcha" @click="getCaptchaData"/>
                            </template>
                        </el-input>
                    </el-form-item>-->
                    <el-form-item label="" class="user-button">
                        <el-button type="primary" @click="submit">登录</el-button>
                    </el-form-item>
                </el-form>
                <!--<div style="text-align: right" class="user-text">
                    <span>注册</span><span>|</span><span>忘记密码</span>
                </div>-->
            </div>
        </div>
    </div>
</template>
 
<script>
    import {getCaptchaApi} from '@/api';
    export default {
        name: "Login",
        data(){
            return {
                captchaId:"",
                captcha:"",
                user:{
                    name:'',
                    password:'',
                    code:''
                },
                rules: {
                    name: [
                        {
                            required: true,
                            message: "请输入用户名",
                            trigger: "blur",
                        },
                    ],
                    password: [
                        {
                            required: true,
                            message: "请输入密码",
                            trigger: "blur",
                        },
                    ],
                    code: [
                        {
                            required: true,
                            message: "请输入验证码",
                            trigger: "blur",
                        },
                    ],
                },
            }
        },
        methods:{
            async getCaptchaData(){
                const {code,data} =await getCaptchaApi();
                if (code == 200) {
                    this.captchaId = data.captchaId;
                    this.captcha = data.picPath;
                }
            },
            submit(){
                this.$refs.loginForm.validate((valid) => {
                   if(valid){
                       if(this.user.name==="admin" && this.user.password==="admin"){
                           this.$message.success("登录成功");
                           setTimeout(()=>{
                               this.$router.push('/home/audioAnalysis',()=>{})
                           },500);
                       }else{
                           this.$message.error("用户名或者密码错误,请重新输入!");
                       }
                   }
                });
            }
        },
        mounted(){
            this.getCaptchaData();
        }
    }
</script>
 
<style lang="scss" scoped>
    .login-container{
        height: 100vh;
        width: 100vw;
        background: url("@/assets/images/login/audio-login.png") no-repeat 0px 0px;
        background-size: cover;
        .login-form{
            width: 431px;
            height: 340px;
            left: 8%;
            top: calc(50% - 260px);
            position: absolute;
            background: #fafbff;
            opacity: .9;
            border-radius: 24px;
            padding: 35px 36px;
            text-align: center;
            font-size: 36px;
            line-height: 48px;
            color: #181f30;
            .form{
                margin-top: 20px;
                .user-name,.user-pwd,.user-code,.user-button{
                    width: 359px;
                    margin: 30px auto;
                    ::v-deep{
                        .el-input__inner{
                            height: 48px;
                        }
                        .el-button{
                            width: 359px;
                            height: 48px;
                            font-size: 16px;
                            line-height: 20px;
                            font-family: PingFangSC-Medium,sans-serif;
                        }
                        .el-button--primary {
                            color: #fff;
                            background-color: #2a78fb!important;
                            border-color: #2a78fb!important;
                        }
                    }
                }
                .login-code{
                    width: 100px;
                }
                .user-text{
                    margin-top: -20px;
                    span{
                        font-family: PingFangSC-Medium, sans-serif;
                        color: #181f30 !important;
                        font-size: 14px;
                        line-height: 20px;
                        font-weight: bold;
                        &:hover{
                            cursor: pointer;
                        }
                    }
                    span:nth-child(3){
                        margin-right: 40px;
                    }
                }
            }
        }
    }
</style>