From cef720fa99610d2dffe38ae1e976194abf2fb7d3 Mon Sep 17 00:00:00 2001 From: Raymond Yang Date: Thu, 3 Aug 2023 22:39:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=8A=A0=E5=85=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8E=92=E5=90=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- editRank.html | 37 ++++++++++++++++++++++++++++ js/editRank.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 editRank.html create mode 100644 js/editRank.js 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