face_registration.ftl
4.17 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
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
<div class="layui-row">
<div class="layui-col-xs7 layui-col-md-offset3">
<div style="width: 1024px;height: 80px;background-color: #383939">
<div style="margin-left: 100px;height: 80px;text-align:left;line-height:80px;font-size: 40px;color: #E51C23">
人脸识别系统
</div>
</div>
<div style="width: 1024px;height: 80px;background-color: #101010">
<div style="display:inline;margin-left: 20px;height: 80px;text-align:left;line-height:80px;font-size: 36px;color: #E51C23">
基础资料
</div>
<#--<div style="display:inline;margin-left: 116px;height: 80px;text-align:left;line-height:80px;font-size: 36px;color: #E51C23">-->
<#--注册-->
<#--</div>-->
</div>
<div style="width: 1024px;height:600px;background-color: #383939">
<a href="#">
<div id="imageDiv" class="layui-col-xs8"
style="width: 600px;height: 550px;background-image :url(/images/v2_pgf70f.png); background-repeat: no-repeat;background-position: center center;background-size: cover; /* 覆盖:图片成比例填满盒子。可用于适配 */
background-size: contain;">
</div>
</a>
<div class="layui-col-xs4" style="height: 824px;margin-left: 0px" id="registerDiv">
<div style="color: #FFFFFF;font-size: 30px;margin-left: 50px;margin-top: 29px;text-align: left">
身份信息
</div>
<form class="form-horizontal form" role="from">
<div style="color:#FFFFFF;height: 50px;margin-top:20px;margin-left:20px;margin-right:20px;background-color: #5A5B5B;border-radius:5px">
<label style="margin-left: 20px;height: 50px;line-height:50px;font-size: 21px;text-align: right;float: left">姓名:</label>
<input style="width:180px;margin-left: auto;height: 50px;font-size: 21px;background-color: #5A5B5B;color:#FFFFFF;border: 0px;"
type="text" name="name">
</div>
<input type="file" name="file" id="chooseFile" onchange="chooseFileChange()" style="display:none;"/>
<button class="submitInp" type="submit"
style="color:#FFFFFF;height: 30px;display:block;margin:0 auto;margin-top:100px;width:100px;background-color: #3F51B5;border-radius:5px;text-align: center;line-height: 30px;font-size: 20px">
注册
</button>
</form>
</div>
</div>
</div>
</div>
<script>
$("#imageDiv").click(function () {
$("#chooseFile").click();
});
function chooseFileChange() {
$("#imageDiv").css("background-image", 'url(' + URL.createObjectURL($("#chooseFile")[0].files[0]) + ')');
}
$('.submitInp').click(function () {
var formData = new FormData();
var a = $('#registerDiv .form').serializeArray();
for (var item in a) {
formData.append(a[item].name, a[item].value)
}
formData.append("groupId", "101")
if (formData.get("name") == "") {
alert("请输入名字")
return;
}
if (formData.get("groupId") == "") {
alert("请输入库Id")
return;
}
var file = $("#chooseFile")[0].files[0];
if (file == undefined) {
alert("请先选择有人脸的照片")
return;
}
formData.append("file", file);
$.ajax({
type: "post",
url: "/faceAdd",
data: formData,
contentType: false,
processData: false,
async: false,
success: function (text) {
var res = JSON.stringify(text)
if (text.code == 0) {
alert("注册成功")
} else {
alert(text.message)
}
},
error: function (error) {
alert(JSON.stringify(error))
}
});
});
</script>