inleft
2024-05-18 57e3bead08715d72efaeffe90fafa179b8366473
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<template>
 
    <div class="login-block">
        <div class="login-animate  ">
            <div class="left-ear"></div>
            <div class="right-ear"></div>
            <div class="head">
                <div class="left-eye"></div>
                <div class="right-eye"></div>
                <div class="face">
                    <div class="nose"></div>
                    <div class="mouth"></div>
                </div>
            </div>
            <div class="body"></div>
            <div class="left-arm"></div>
            <div class="right-arm"></div>
        </div>
 
        <div class="login-form">
            <div class="username">
                <input type="text" name="username" autocomplete="off">
            </div>
            <div class="password ">
                <input type="password" name="password">
                <div class="pwd-eye" data-flag="hide"></div>
            </div>
            <div class="login">
                <button id="focus" @click="myLogin">SIGN IN</button>
            </div>
        </div>
    </div>
 
</template>
 
<script>
    import $ from 'jquery'
    export default {
        components: {},
        props: {},
        data() {
            return {}
        },
        mounted() {
            $(".pwd-eye").hide();
            $(".pwd-eye").click(function() {
                var flag = $(this).attr('data-flag');
 
                $(this).attr('data-flag', flag == 'show' ? 'hide' : 'show');
                if (flag == 'show') {
                    $(this).addClass('pwd-eye-show');
                    $(this).removeClass('pwd-eye-hide');
                } else {
                    $(this).removeClass('pwd-eye-show');
                    $(this).addClass('pwd-eye-hide');
                }
 
                $('input[name="password"]').attr('type', flag == 'show' ? 'password' : 'text');
 
                if (flag != 'show' && $('input[name="password"]').val() != '') {
                    $('.left-arm').addClass('show');
                    $('.mouth').addClass('show');
                    $('.right-arm').addClass('show');
                } else {
                    $('.left-arm').removeClass('show');
                    $('.mouth').removeClass('show');
                    $('.right-arm').removeClass('show');
                }
            });
 
            $('input[name="username"]').focus(function() {
                $(".login-animate").addClass('username-animate');
                $(".login-animate").removeClass('password-animate');
                var length = $(this).val().length;
                getposition(length);
            });
 
            $('input[name="username"]').bind('input', function() {
                var length = $(this).val().length;
                getposition(length);
            });
 
            function getposition(length) {
                //计算当前输入字节长度
                var face = parseFloat(1.5 / 36 * length);
                var nose = parseFloat(1 / 36 * length);
                var mouth = parseFloat(1 / 36 * length);
                var left_eye = parseFloat(2 / 36 * length);
                var right_eye = parseFloat(2 / 36 * length);
                var left_ear = parseFloat(1 / 36 * length);
                var right_ear = parseFloat(2 / 36 * length);
 
                //头部旋转
                if (length >= 0 && length <= 25) {
                    $('.head').css('-webkit-transform', "rotate(" + (10 - length / 2) + "deg)");
                }
 
                //左边为初始值
                $('.face').css('left', 0.8 + (face > 0.5 ? 0.5 : face) + 'em');
                $('.nose').css('left', 1.4 + (nose > 0.6 ? 0.6 : nose) + 'em');
                $('.mouth doe').css('left', 0.8 + (mouth > 0.8 ? 0.8 : mouth) + 'em');
 
                $('.left-eye').css('left', 0.9 + (left_eye > 0.8 ? 0.8 : left_eye) + 'em');
                $('.right-eye').css('left', 4.3 + (right_eye > 0.7 ? 0.7 : right_eye) + 'em');
 
                $('.left-ear').css('left', 1.9 - (left_ear > 0.5 ? 0.5 : left_ear) + 'em');
                $('.right-ear').css('left', 7.2 - (right_ear > 0.5 ? 0.5 : right_ear) + 'em');
                $('.right-ear').css('bottom', 3.9 + (right_ear > 0.7 ? 0.7 : right_ear) + 'em');
 
                if (length >= 2) {
                    $('.left-eye').addClass('doe');
                    $('.right-eye').addClass('doe');
                    $('.mouth').addClass('doe');
                } else {
                    $('.left-eye').removeClass('doe');
                    $('.right-eye').removeClass('doe');
                    $('.mouth').removeClass('doe');
                }
            }
 
 
            //失去焦点
            $('input[name="username"]').blur(function() {
                var length = $(this).val().length;
 
                if (length > 2) {
                    $(".left-eye").addClass('height-eys-doe');
                    $(".right-eye").addClass('height-eys-doe');
                } else {
                    $(".left-eye").removeClass('height-eys-doe');
                    $(".right-eye").removeClass('height-eys-doe');
                }
 
                $(".login-animate").removeClass('username-animate');
                $(".login-animate").removeClass('password-animate');
 
                $('.head').css('-webkit-transform', "rotate(0deg)"); //回正头部
 
 
                $('.face').attr('style', '');
                $('.nose').attr('style', '');
                $('.left-eye').attr('style', '');
                $('.right-eye').attr('style', '');
                $('.left-ear').attr('style', '');
                $('.right-ear').attr('style', '');
 
                //如果账号和密码都不为空,呈嘴巴张开,眼睛发光 && $('input[name="password"]').val().length > 0
                if ($('input[name="username"]').val().length > 0) {
                    // $(".login-animate").addClass('username-animate');
                    // $(".left-eye").addClass('doe');
                }
 
            });
 
            $('input[name="password"]').focus(function() {
                $(".pwd-eye").show();
                $(".login-animate").removeClass('username-animate');
                $(".login-animate").addClass('password-animate');
            });
 
            $('input[name="password"]').blur(function() {
                if ($(this).val() == '') {
                    $(".pwd-eye").hide();
                    $(".login-animate").removeClass('username-animate');
                    $(".login-animate").removeClass('password-animate');
                }
            });
        },
        methods: {
            myLogin() {
                this.$message.info("口令错误啦..")
            }
        }
    }
</script>
 
<style scoped="">
    @import url("../../assets/main.css");
 
    button:active {
        transform: scale(1.23);
    }
 
    button:focus {
        outline: none;
    }
 
    button.ghost {
        background: transparent;
        border-color: #fff;
    }
 
    button {
        border-radius: 20px;
        border: 1px solid #fff;
        /*background: #3dceba;*/
        background: #00b69d;
        color: #fff;
        font-size: 12px;
        font-weight: bold;
        padding: 12px 45px;
        letter-spacing: 1px;
        text-transform: uppercase;
        transition: transform 80ms ease-in;
        cursor: pointer;
        /*margin-left: calc(25%);
            position: relative;*/
    }
 
    .login {
        -webkit-animation: free_download 1s linear alternate infinite;
        animation: free_download 1s linear alternate infinite;
        padding: 0px 15px 0px;
    }
 
    @-webkit-keyframes free_download {
        0% {
            -webkit-transform: scale(0.9);
        }
 
        100% {
            -webkit-transform: scale(1);
        }
    }
 
    @keyframes free_download {
        0% {
            transform: scale(0.9);
        }
 
        100% {
            transform: scale(1);
        }
    }
</style>