初步加入排名api呼叫
This commit is contained in:
parent
a84dd9b9c4
commit
ce69aa5129
@ -22,9 +22,13 @@
|
||||
<input type="date" id="queryDate">
|
||||
</div>
|
||||
<hr>
|
||||
<div id="rank"></div>
|
||||
<hr>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script>
|
||||
<script src="./js/index.js"></script>
|
||||
|
||||
<hr>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
35
js/index.js
35
js/index.js
@ -21,8 +21,10 @@ let tbody = document.createElement("tbody");
|
||||
generateTable();
|
||||
|
||||
getDateOfRecords();
|
||||
getDateOfRank()
|
||||
|
||||
setInterval(getDateOfRecords, 2000);
|
||||
setInterval(getDateOfRank, 2000);
|
||||
|
||||
function generateTable() {
|
||||
table.appendChild(thead);
|
||||
@ -94,7 +96,7 @@ function getDateOfRecords() {
|
||||
})
|
||||
.then(function (response) {
|
||||
const data = response.data;
|
||||
//console.log(data);
|
||||
console.log(data);
|
||||
// 清除原有的資料列
|
||||
while (tbody.firstChild) {
|
||||
tbody.removeChild(tbody.firstChild);
|
||||
@ -143,4 +145,33 @@ function getDateOfRecords() {
|
||||
.catch(function (error) {
|
||||
console.error('資料取得失敗:', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 取得刀表
|
||||
function getDateOfRank() {
|
||||
var dateSplit = dateInput.value.split("-");
|
||||
console.log(dateSplit);
|
||||
// 取得刀表
|
||||
axios.get("https://pcredive.ray650128.com/backend/api/rank/" + dateSplit[0] + "/" + dateSplit[1] + "/" + dateSplit[2], {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
const data = response.data;
|
||||
console.log(data);
|
||||
const rank = data.rank;
|
||||
if (rank !== null) {
|
||||
document.getElementById("rank").innerHTML = "<h3 class=\"centerText\">結算時排名:<a href=\"editRank.html?id=" + rank._id + "\">" + rank + "</a></h3>";
|
||||
} else {
|
||||
document.getElementById("rank").innerHTML = "<h3 class=\"centerText\">結算時排名:<a href=\"editRank.html?id=" + rank._id + "\">---</a></h3>";
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
document.getElementById("rank").innerHTML = "<h3 class=\"centerText\">結算時排名:---</h3>";
|
||||
console.error('資料取得失敗:', error);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user