用html+jq+css代码写出post请求查询的页面新增查询额度接口:httpssvip-apicveoytopv3grants请求参数 keyssk-xxxxxxxxxxxx返回参数 keys sk-xxxx useAmount 25 今日已使用次数 activateTime 1681191668000 首次使用时间 在这个时间上添加5天 如果大于7200分钟 则会返
<!DOCTYPE html>
<html>
<head>
<title>查询额度</title>
<meta charset="utf-8">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
margin-bottom: 30px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
margin-bottom: 10px;
font-weight: bold;
}
input[type="text"] {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 20px;
width: 100%;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
.result {
margin-top: 30px;
padding: 20px;
background-color: #f1f1f1;
border-radius: 5px;
display: none;
}
.result p {
margin: 0;
font-size: 16px;
line-height: 1.5;
}
.result p:first-child {
font-weight: bold;
margin-bottom: 10px;
}
.error {
color: red;
font-size: 14px;
margin-top: 10px;
display: none;
}
</style>
</head>
<body>
<div class="container">
<h1>查询额度</h1>
<form>
<label for="keys">keys:</label>
<input type="text" id="keys" name="keys">
<button type="button" id="submit">查询</button>
</form>
<div class="result">
<p>使用次数: <span id="useAmount"></span></p>
<p>首次使用时间: <span id="activateTime"></span></p>
</div>
<div class="error"></div>
</div>
<script>
$(function() {
$('#submit').click(function() {
var keys = $('#keys').val();
if (keys == '') {
$('.error').text('请输入keys').show();
return;
}
$.post('https://svip-api.cveoy.top/v3/grants', {keys: keys}, function(data) {
$('.result #useAmount').text(data.useAmount);
$('.result #activateTime').text(new Date(parseInt(data.activateTime)).toLocaleString());
$('.result').show();
$('.error').hide();
}).fail(function(xhr, status, error) {
$('.result').hide();
$('.error').text(xhr.responseJSON.error).show();
});
});
});
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/bKim 著作权归作者所有。请勿转载和采集!