diff --git a/editRank.html b/editRank.html new file mode 100644 index 0000000..a396978 --- /dev/null +++ b/editRank.html @@ -0,0 +1,37 @@ + + + + + + + + 新增/修改結算時排名 + + + + +

新增/修改結算時排名

+
+
+ + + + + +
+
結算時排名
+
+ +
+
+

+
+ + + + + diff --git a/js/editRank.js b/js/editRank.js new file mode 100644 index 0000000..0e4fb50 --- /dev/null +++ b/js/editRank.js @@ -0,0 +1,66 @@ +var paramValue = ""; +var rankId = ""; + + +var rank = document.getElementById("rank"); + +// 在頁面載入完成後,執行獲取參數的操作 +window.onload = function () { + // 取得參數 + paramValue = getParameterByName('id'); + console.log(paramValue); + + axios.get("https://pcredive.ray650128.com/backend/api/rank/" + paramValue) + .then(function (response) { + // 在這裡處理回傳的資料 + var options = response.data; + console.log(options); + rankId = options._id; + rank.value = options.rank ?? ""; + }) + .catch(function (error) { + // 處理錯誤 + console.error(error); + }); +}; + +document.addEventListener('resize', adjustTextSize); + +document.getElementById("record-form").addEventListener("submit", function (event) { + event.preventDefault(); // 阻止表單預設提交行為 + + // 執行請求 + fillRecord(paramValue, rankId, rank.value); +}); + +function adjustTextSize() { + var screenWidth = window.innerWidth; + var fontSize = screenWidth * 0.04; + + title.fontSize = fontSize + 'px'; +} + +function getParameterByName(name) { + // 获取 URL 中的参数部分 + var url = window.location.href; + // 对 URL 进行解析 + var parsedUrl = new URL(url); + // 从解析后的 URL 中获取参数值 + return parsedUrl.searchParams.get(name); +} + +function fillRecord(recordId, rankId, rank) { + // 发送登录请求 + axios.put("https://pcredive.ray650128.com/backend/api/record/" + recordId, { + rankId: rankId, + rank: rank + }) + .then(function (response) { + window.location.href = "./index.html"; + }) + .catch(function (error) { + const message = error.response.data.message; + alert("更新失敗"); + //console.error('登入失敗:', error); + }); +} \ No newline at end of file