welcome.tpl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 onload="InitParams({{.sharecode}})">
  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;" 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. function InitParams(sharecode) {
  34. if (sharecode.length > 0) {
  35. document.getElementById("sharecode").value = sharecode;
  36. }
  37. }
  38. 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'];
  39. function generateMixed(n) {
  40. var res = "";
  41. for(var i = 0; i < n ; i ++) {
  42. var id = Math.ceil(Math.random()*(randChats.length-1));
  43. res += randChats[id];
  44. }
  45. return res;
  46. }
  47. // 随机兑换码
  48. function randCode() {
  49. document.getElementById("sharecode").value = generateMixed(6);
  50. }
  51. function UpdateShareCode () {
  52. var token = document.getElementById("token").value;
  53. var sharecode = document.getElementById("sharecode").value;
  54. if (sharecode.length != 6){
  55. alert("兑换码长度错误!6位大写字母");
  56. return;
  57. }
  58. // 兑换码字符检查
  59. for (var i = 0; i < sharecode.length; i ++){
  60. var isMatch = false
  61. for (var j = 0; j < randChats.length; j ++) {
  62. if (sharecode[i] == randChats[j]){
  63. isMatch = true;
  64. break;
  65. }
  66. }
  67. if (isMatch == false){
  68. alert("兑换码错误!请使用大写字母");
  69. return;
  70. }
  71. }
  72. var text = "token=" + encodeURI(token);
  73. text += "&sharecode=" + encodeURI(sharecode);
  74. $.ajax({
  75. type:"post",
  76. url:"/welcome?" + text,
  77. success:function (data) {
  78. // alert(data.status);
  79. if (data.status){
  80. window.location.href="/welcome";
  81. }else{
  82. if (data.info){
  83. alert(data.info);
  84. }else{
  85. window.location.href="/accountlogin";
  86. }
  87. }
  88. }
  89. });
  90. }
  91. </script>
  92. </body>
  93. </html>