welcome.tpl 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>欢迎页面-X-admin2.0</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  9. <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  10. <link rel="stylesheet" href="./static/css/font.css">
  11. <link rel="stylesheet" href="./static/css/xadmin.css">
  12. <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  13. <script src="./static/lib/layui/layui.js" charset="utf-8"></script>
  14. <script type="text/javascript" src="./static/js/xadmin.js"></script>
  15. </head>
  16. <body>
  17. <input type="text" id="token" value={{.token}} hidden=true>
  18. <div class="x-body layui-anim layui-anim-up">
  19. <blockquote class="layui-elem-quote">欢迎{{.rolename}}:
  20. <span class="x-red">{{.username}}</span>!当前时间:{{.sysTime}}</blockquote>
  21. </div>
  22. <div class="x-body layui-anim layui-anim-up">
  23. <blockquote class="layui-elem-quote">推广码:
  24. <input id="sharecode" style="width:128px;" value={{.sharecode}} type="text" class="layui-input">
  25. <br>
  26. <input value="刷新" class="layui-btn" style="width:128px;" type="button" onclick="randCode()">
  27. <br>
  28. <br>
  29. <input value="更新" class="layui-btn" style="width:128px;" type="button" onclick="UpdateShareCode()">
  30. </blockquote>
  31. </div>
  32. <script language="JavaScript">
  33. 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'];
  34. function generateMixed(n) {
  35. var res = "";
  36. for(var i = 0; i < n ; i ++) {
  37. var id = Math.ceil(Math.random()*(randChats.length-1));
  38. res += randChats[id];
  39. }
  40. return res;
  41. }
  42. // 随机兑换码
  43. function randCode() {
  44. document.getElementById("sharecode").value = generateMixed(6);
  45. }
  46. function UpdateShareCode () {
  47. var token = document.getElementById("token").value;
  48. var sharecode = document.getElementById("sharecode").value;
  49. if (sharecode.length != 6){
  50. alert("兑换码长度错误!6位大写字母");
  51. return;
  52. }
  53. // 兑换码字符检查
  54. for (var i = 0; i < sharecode.length; i ++){
  55. var isMatch = false
  56. for (var j = 0; j < randChats.length; j ++) {
  57. if (sharecode[i] == randChats[j]){
  58. isMatch = true;
  59. break;
  60. }
  61. }
  62. if (isMatch == false){
  63. alert("兑换码错误!请使用大写字母");
  64. return;
  65. }
  66. }
  67. var text = "token=" + encodeURI(token);
  68. text += "&sharecode=" + encodeURI(sharecode);
  69. $.ajax({
  70. type:"post",
  71. url:"/welcome?" + text,
  72. success:function (data) {
  73. // alert(data.status);
  74. if (data.status){
  75. window.location.href="/welcome";
  76. }else{
  77. if (data.info){
  78. alert(data.info);
  79. }else{
  80. window.location.href="/accountlogin";
  81. }
  82. }
  83. }
  84. });
  85. }
  86. </script>
  87. </body>
  88. </html>