64 lines
2.5 KiB
JavaScript
64 lines
2.5 KiB
JavaScript
layui.use(['form'], function () {
|
|
var form = layui.form;
|
|
|
|
form.on('submit(submit)', function (data) {
|
|
var index = layer.load(2, {tiem: 999999});
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/api/",
|
|
data: data.field,
|
|
dataType: "json",
|
|
success: function (data) {
|
|
if (data.status === 0) {
|
|
let ipInfo = "";
|
|
ipInfo += " <tr>\n" +
|
|
" <td>IP:<span style='margin-left: 3px'> " + data.result.ip + "</span></td>\n" +
|
|
" </tr>\n";
|
|
|
|
ipInfo += " <tr>\n" +
|
|
" <td>国:<span style='margin-left: 3px'> " + data.result.ad_info.nation + "</span></td>\n" +
|
|
" </tr>\n";
|
|
|
|
ipInfo += " <tr>\n" +
|
|
" <td>省:<span style='margin-left: 3px'> " + data.result.ad_info.province + "</span></td>\n" +
|
|
" </tr>\n";
|
|
|
|
ipInfo += " <tr>\n" +
|
|
" <td>市:<span style='margin-left: 3px'> " + data.result.ad_info.city + "</span></td>\n" +
|
|
" </tr>\n";
|
|
|
|
ipInfo += " <tr>\n" +
|
|
" <td>区:<span style='margin-left: 3px'> " + data.result.ad_info.district + "</span></td>\n" +
|
|
" </tr>\n";
|
|
|
|
ipInfo += " <tr>\n" +
|
|
" <td>经纬度:<span style='margin-left: 3px'> " + data.result.location.lat + "," + data.result.location.lng + "</span></td>\n" +
|
|
" </tr>\n";
|
|
|
|
let head = "";
|
|
let html = "<table class=\"layui-table\">\n" +
|
|
" <thead>\n" +
|
|
" </thead>\n" +
|
|
" <tbody>\n" + ipInfo +
|
|
" </tbody>\n" +
|
|
"</table>";
|
|
console.log(html);
|
|
layer.open({
|
|
title: 'IP地址查询',
|
|
content: head + html,
|
|
btn: '确定',
|
|
btnAlign: 'c'
|
|
});
|
|
layer.close(index);
|
|
} else {
|
|
layer.msg(data.message, {icon: 2});
|
|
layer.close(index);
|
|
}
|
|
},
|
|
error: function () {
|
|
layer.close(index);
|
|
layer.alert('查询失败!');
|
|
}
|
|
});
|
|
})
|
|
}); |