login.php
2.38 KB
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
<?php
$this->load->view('common/header', ['styles' => [
'/resource/login.css'
]]);
?>
<body>
<div class="login_box">
<div class="login">
<div class="login_logo">
<img src="/resource/logo.png">
</div>
<div class="login_name">
<p>后台管理系统</p>
</div>
<form action=" " id="edit">
<input name="username" type="text" placeholder="用户名">
<input name="password" type="password" placeholder="密码">
</form>
<!-- <input value="登录" type="submit">-->
<input value="登录" type="button" class="btn btn-primary btn-xs" onclick="save()">
</div>
<div class="copyright">
版权所有©2018 杭州XX网络有限公司
<br />
(推荐IE10以上浏览器或谷歌浏览器或firefox浏览器, 获得更快响应速度)
</div>
</div>
<?php $this->load->view('common/footer'); ?>
<script>
function save() {
//获得款中的节点
var targetUrl = $("#edit").attr("action");//需要填写目的url
var data = $("#edit").serializeJson();
var newData = {
username:data['nameZh'],
password:data['id']
};
$.ajax({
type: 'post',
url: apiBaseUrl + targetUrl,
cache: false,
data: JSON.stringify(newData),
dataType: 'json',
contentType: "application/json; charset=UTF-8",
success: function (data) {
// console.log(data);
if (data.msg) {
layer.alert(data.msg);
} else if (data.code != 0) {
layer.alert('操作失败');
} else {
layer.msg('操作成功');
// $.session.set('user_id', data['id']);
window.parent.reload();
layer_close();
}
if (data.code) {
setTimeout(function () {
window.parent.reload();
layer_close();
}, 500);
}
},
error: function () {
layer.alert("操作失败")
}
});
// layer_close();
}
</script>
</body>
</html>