|
@@ -0,0 +1,91 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+ <head>
|
|
|
+ <meta charset="UTF-8" />
|
|
|
+ <meta
|
|
|
+ name="viewport"
|
|
|
+ content="width=device-width, initial-scale=1.0" />
|
|
|
+ <title>Document</title>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <div>
|
|
|
+ 机器码:<input
|
|
|
+ id="input1"
|
|
|
+ type="text" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ 类型:
|
|
|
+ <input
|
|
|
+ type="radio"
|
|
|
+ id="option1"
|
|
|
+ name="group1"
|
|
|
+ value="dz" />
|
|
|
+ <label for="option1">调证</label>
|
|
|
+ <input
|
|
|
+ type="radio"
|
|
|
+ id="option2"
|
|
|
+ name="group1"
|
|
|
+ value="sp" />
|
|
|
+ <label for="option2">审批</label>
|
|
|
+ </div>
|
|
|
+ <button id="submit">生成License</button
|
|
|
+ ><button id="copy">复制License</button>
|
|
|
+ <div id="result"></div>
|
|
|
+ </body>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ const getLicense = () => {
|
|
|
+ const machineCode = document.querySelector("#input1").value;
|
|
|
+ const type = document.querySelector('input[name="group1"]:checked').value;
|
|
|
+ console.log(machineCode, type);
|
|
|
+ if (machineCode && type) {
|
|
|
+ fetch(
|
|
|
+ `http://221.226.175.250:2230/license/create?machineCode=${machineCode}&type=${type}`,
|
|
|
+ {
|
|
|
+ method: "get",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then((res) => {
|
|
|
+ return res.text();
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ const result = document.querySelector("#result");
|
|
|
+ result.innerText = res;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const copyText = async (val, callback) => {
|
|
|
+ if (navigator.clipboard && navigator.permissions) {
|
|
|
+ await navigator.clipboard.writeText(val);
|
|
|
+ if (callback) callback();
|
|
|
+ } else {
|
|
|
+ const textArea = document.createElement("textArea");
|
|
|
+ textArea.value = val;
|
|
|
+ textArea.style.width = 0;
|
|
|
+ textArea.style.position = "fixed";
|
|
|
+ textArea.style.left = "-999px";
|
|
|
+ textArea.style.top = "10px";
|
|
|
+ textArea.setAttribute("readonly", "readonly");
|
|
|
+ document.body.appendChild(textArea);
|
|
|
+ textArea.select();
|
|
|
+ document.execCommand("copy");
|
|
|
+ document.body.removeChild(textArea);
|
|
|
+ if (callback) callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const handleCopyText = ()=>{
|
|
|
+ const result = document.querySelector("#result").innerText.trim();
|
|
|
+ if(result){
|
|
|
+ copyText(result,()=>{
|
|
|
+ alert('复制成功,复制内容为:' + result)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ window.onload = () => {
|
|
|
+ const btn = document.querySelector("#submit");
|
|
|
+ const btn2 = document.querySelector("#copy");
|
|
|
+ btn.addEventListener("click", getLicense);
|
|
|
+ btn2.addEventListener("click", handleCopyText);
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+</html>
|