1
81041
2019-06-20 ab3c4acf83f54f8449ca8664c4a2bb79bd30f297
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<template>
    <div class="page" data-name="login-screen">
        <div class="top1000">
            <input type="text" name="username" />
            <input type="password" name="password" />
        </div>
        <div class="page-content" id="vLoginContent">
            <h3 class="login-title center">蓄电池智能远程运维系统</h3>
            <!-- 验证码登陆面板 -->
            <div class="hdw-dialog" v-show="verify.isshow" id="lVerify-dialog">
                <div class="hdw-dialog-container">
                    <div class="hdw-dialog-bg" v-on:click="hideVertify"></div>
                    <div class="hdw-dialog-content hdw-dialog-width270-125">
                        <div class="hdw-dialog-content-container">
                            <div id="lVerify" ></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="login-form">
                <div class="form-item">
                    <label for="username" class="label text-color-white">用户名:</label>
                    <div class="form-item-block">
                        <div class="form-item-input">
                            <input type="text" name="username" v-model="userinfo.name"  placeholder="请输入用户名">
                        </div>
                        <span class="icon f7-icons color-blue">person</span>
                    </div>
                </div>
                <div class="form-item">
                    <label for="username" class="label text-color-white">密码:</label>
                    <div class="form-item-block">
                        <div class="form-item-input">
                            <input type="password" name="password" v-model="userinfo.pwd" placeholder="请输入密码">
                        </div>
                        <span class="icon f7-icons color-blue">lock_fill</span>
                    </div>
                </div>
                <div class="form-item" style="font-size: 16px;">
                    <input type="checkbox" name="memory" value="1" v-model="picked" /><span class="text-color-white">记住密码</span>
                    <div class="msg" v-show="msginfo.isshow">${msginfo.msg}</div>
                </div>
                <div class="form-item" style="font-size: 16px;">
                    <button class="button button-fill color-white text-color-black" v-on:click="showVertify" style="height: 40px;font-weight: bold;">登陆</button>
                </div>
            </div>
        </div>
    </div>
</template>
<style scoped>
    .top1000 {
        position: fixed;
        top: -1000px;
    }
    .page-content {
        padding: 16px;
        background-image: url('./my/images/tieta.jpg');
        background-size: 100% 100%;
    }
    .login-title {
        color: #fff;
    }
    .form-item {
        margin-bottom: 12px;
    }
    .form-item .label{
        font-weight: bold;
    }
    .form-item-block {
        position: relative;
        margin-top: 8px;
        padding: 12px 4px;
        background-color: #FFFFFF;
        border-radius: 8px;
    }
    .form-item-block .icon {
        font-size: 20px;
    }
    .form-item-block .form-item-input {
        position: absolute;
        left: 32px;
        right: 0;
        height: 25px;
    }
    .form-item-block .form-item-input input {
        width: 100%;
        height: 100%;
    }
    .text-color-white {
        color: #FFFFFF;
    }
    .button:active {
        color: #fff;
        background-color: gray;
    }
    .msg {
        float: right;
        margin-top: 4px;
        font-size: 14px;
        color: #FF0000;
    }
    .msg.hide {
        display: none;
    }
    .msg.success {
        color: blue;
    }
    .hdw-dialog {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: none;
        z-index: 9999;
    }
    
    .hdw-dialog.hdw-dialog-hide {
        display: none;
    }
    
    .hdw-dialog .hdw-dialog-container {
        position: relative;
        width: 100%;
        height: 100%;
        background-color: none;
    }
    .hdw-dialog-bg {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #000000;
        opacity: .1;
        z-index: 0;
    }
    .hdw-dialog-content {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #FFFFFF;
        z-index: 1;
    }
    .hdw-dialog-content.hdw-dialog-width500-300 {
        width: 500px;
        height: 300px;
        left: 50%;
        margin-left: -250px;
        top: 50%;
        margin-top: -150px;
    }
    .hdw-dialog-content.hdw-dialog-width270-125 {
        width: 270px;
        height: 125px;
        left: 50%;
        margin-left: -135px;
        top: 50%;
        margin-top: -63px;
    }
    
    .hdw-dialog-content-container {
        position: relative;
    }
</style>
<script>
    return {
        data: function() {
            return {
                vContent: ''
            }
        },
        methods: {
            login: function() {
                var self = this;
                var vContent = this.vContent;
                var user = vContent.userinfo.name;
                var password = vContent.userinfo.pwd;
                password = hex_md5(password);
                var memory = vContent.picked?1:0;
                // 请求后台
                $.post(
                    "../LoginAction_login",
                    "uinf.UName="+user+"&uinf.Upassword="+password+"&uinf.UId="+memory,
                    function(data) {
                        data = eval("(" + data.result + ")");
                        console.log(data);
                        if (data.code == 0) {
                            vContent.msginfo.isshow = true;
                            vContent.msginfo.msg = data.msg;
                        } else {
                            //window.locationion.href = "index.html";
                            initAppView();
                        }
                });
            }
        },
        on: {
            pageInit: function() {
                var self = this;
                // 定义vue监测
                var vContent = this.vContent = new Vue({
                    el: '#vLoginContent',
                    delimiters: ['${', '}'],
                    data: {
                        userinfo: {
                            name: '',
                            pwd: ''
                        },
                        msginfo: {
                            isshow: false,
                            msg: '未知'
                        },
                        picked: '1',
                        verify: {
                            isshow: false
                        }
                    },
                    methods: {
                        showVertify: function() {
                            var userinfo = this.userinfo;
                            if(userinfo.name.trim() == '') {
                                this.msginfo.isshow = true;
                                this.msginfo.msg = '请输入用户名';
                            }else if(userinfo.pwd.trim() == ''){
                                this.msginfo.isshow = true;
                                this.msginfo.msg = '请输入密码';
                            }else {
                                this.verify.isshow = true;
                                initVerify();
                            }
                            
                        },
                        hideVertify: function() {
                            this.verify.isshow = false;
                        }
                    },
                    watch: {
                        userinfo: {
                            handler:function(newValue, oldValue) {
                                this.msginfo.isshow = false;
                            },
                            deep: true
                        }
                    }
                    
                });
                
                // 初始化验证
                function initVerify() {
                    // 清空内容
                    $('#lVerify').text('');
                    // 配置拖动验证图像
                    $('#lVerify').pointsVerify({
                        defaultNum : 4,    //默认的文字数量
                        checkNum : 2,    //校对的文字数量
                        vSpace : 5,    //间隔
                        imgName : ['verify2.jpg'],
                        imgSize : {
                            width: '270px',
                            height: '178px',
                        },
                        blockSize : {
                            width: '40px',
                            height: '40px',
                        },
                        barSize : {
                            width : '270px',
                            height : '40px',
                        },
                        ready : function() {
                                
                        },
                        success : function() {
                            vContent.verify.isshow = false;
                            self.login();    // 验证用户
                        },
                        error : function() {
                            // alert('验证失败!');
                        }
                    });
                 }
            }
        }
    }
</script>