Browse Source

推广码复制

neo 1 year ago
parent
commit
9466ce03ab
1 changed files with 20 additions and 5 deletions
  1. 20 5
      views/welcome.tpl

+ 20 - 5
views/welcome.tpl

@@ -18,25 +18,39 @@
18
     <input type="text" id="token" value={{.token}} hidden=true>
18
     <input type="text" id="token" value={{.token}} hidden=true>
19
     <div class="x-body layui-anim layui-anim-up">
19
     <div class="x-body layui-anim layui-anim-up">
20
         <blockquote class="layui-elem-quote">欢迎{{.rolename}}:
20
         <blockquote class="layui-elem-quote">欢迎{{.rolename}}:
21
-            <span class="x-red">{{.username}}</span>!当前时间:{{.sysTime}}</blockquote>
21
+            <span class="x-red">{{.username}}</span>!当前时间:{{.sysTime}}
22
+        </blockquote>
22
     </div>
23
     </div>
23
     <div class="x-body layui-anim layui-anim-up">
24
     <div class="x-body layui-anim layui-anim-up">
24
         <blockquote class="layui-elem-quote">
25
         <blockquote class="layui-elem-quote">
25
-            推广码<input id="sharecode" style="width:128px;" type="text" class="layui-input">
26
-            <br>
27
-            <input value="刷新" class="layui-btn" style="width:128px;" type="button" onclick="randCode()">
26
+            推广码: <input id="sharecode" type="text" />
27
+            {{"         "}}
28
+            <input value="复制" class="layui-btn" type="button" onclick="copyToClip()" />
28
             <br>
29
             <br>
29
             <br>
30
             <br>
31
+            <input value="刷新" class="layui-btn" style="width:128px;" type="button" onclick="randCode()" />
32
+            {{"         "}}
30
             <input value="更新" class="layui-btn" style="width:128px;" type="button" onclick="UpdateShareCode()">
33
             <input value="更新" class="layui-btn" style="width:128px;" type="button" onclick="UpdateShareCode()">
31
         </blockquote>
34
         </blockquote>
32
     </div>
35
     </div>
33
 
36
 
34
     <script language="JavaScript">
37
     <script language="JavaScript">
38
+      var currShareCode = ""
35
       function InitParams(sharecode) {
39
       function InitParams(sharecode) {
36
         if (sharecode.length > 0) {
40
         if (sharecode.length > 0) {
37
             document.getElementById("sharecode").value = sharecode;
41
             document.getElementById("sharecode").value = sharecode;
42
+            currShareCode = sharecode
38
         }
43
         }
39
       }
44
       }
45
+      function copyToClip() {
46
+        var aux = document.createElement("input");
47
+        aux.setAttribute("value", currShareCode);
48
+        document.body.appendChild(aux);
49
+        aux.select();
50
+        document.execCommand("copy");
51
+        document.body.removeChild(aux);
52
+        layer.msg('复制成功!',{icon:1,time:1000});
53
+      }
40
 
54
 
41
       var randChats = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
55
       var randChats = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
42
       function generateMixed(n) {
56
       function generateMixed(n) {
@@ -49,7 +63,8 @@
49
       }
63
       }
50
       // 随机兑换码
64
       // 随机兑换码
51
       function randCode() {
65
       function randCode() {
52
-        document.getElementById("sharecode").value = generateMixed(6);
66
+        currShareCode = generateMixed(6)
67
+        document.getElementById("sharecode").value = currShareCode;
53
       }
68
       }
54
       
69
       
55
       function UpdateShareCode () {
70
       function UpdateShareCode () {