login.ftl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>${(systemInfo.systemTitle)!} - 登陆</title>
  7. <link href="login/css/bootstrap.min.css" rel="stylesheet">
  8. <link href="login/css/font-awesome.css" rel="stylesheet">
  9. <link href="login/css/animate.css" rel="stylesheet">
  10. <link href="login/css/ladda-themeless.min.css" rel="stylesheet">
  11. <link href="login/css/style.css" rel="stylesheet">
  12. <style>
  13. @media (max-width: 768px) {
  14. #login_img_div {
  15. display: none;
  16. }
  17. }
  18. .colorred{
  19. color: red !important;
  20. }
  21. .submiting{
  22. background-color: #eeeeee !important;
  23. color: #9c9c9c !important;
  24. }
  25. .margintop15{
  26. margin-top: 15px;
  27. }
  28. .nomarginbottom{
  29. margin-bottom: 0px;
  30. }
  31. </style>
  32. </head>
  33. <body class="gray-bg">
  34. <div class="loginColumns animated fadeInDown" style="max-width: 1000px;">
  35. <div class="row">
  36. <div id="login_img_div" class="col-md-7 col-sm-7 col-lg-7">
  37. <img width="100%" src="login/images/login.jpg" height="350">
  38. </div>
  39. <div class="col-md-5 col-sm-5 col-lg-5">
  40. <div class="ibox-content" style="height: 350px;">
  41. <p>&nbsp;</p>
  42. <h1>登录</h1>
  43. <form class="m-t" id="loginform">
  44. <div class="form-group has-feedback">
  45. <label>用户名</label>
  46. <input type="text" name="username" class="form-control" placeholder="Username" autocomplete="off">
  47. <span class="glyphicon glyphicon-user form-control-feedback"></span>
  48. </div>
  49. <div class="form-group has-feedback nomarginbottom">
  50. <label>密码</label>
  51. <input type="password" name="password" class="form-control" placeholder="Password" autocomplete="off">
  52. <span class="glyphicon glyphicon-lock form-control-feedback"></span>
  53. </div>
  54. <#if (systemInfo.verCode)?? && systemInfo.verCode == "true">
  55. <#if (systemInfo.slide)?? && systemInfo.slide == "true">
  56. <div class="form-group nomarginbottom margintop15">
  57. <div id="embed-captcha"></div>
  58. <p id="wait" class="show">正在加载验证码......</p>
  59. <p id="notice" style="color: #ff0000" class="hide">请先拖动验证码到相应位置</p>
  60. </div>
  61. </#if>
  62. <#if (systemInfo.slide)?? && systemInfo.slide == "false">
  63. <div class="form-group nomarginbottom margintop15">
  64. <input type="text" name="verCode" onkeyup="verCodeText(this)" oninput="verCodeText(this)" maxlength="4" style="width: 60%;display: initial;" class="form-control" placeholder="验证码" autocomplete="off"/>
  65. <img id="verCodeId" src="" alt="" title="看不清换一张" onclick="getVerCode()" style="vertical-align:middle;" />
  66. <span id="isvercodeimg"></span>
  67. <input type="hidden" id="idvercode" autocomplete="off">
  68. </div>
  69. </#if>
  70. </#if>
  71. <label id="msg" style="color: #FFFFFF">.</label>
  72. <button type="button" id="submit" onclick="login()" class="ladda-button btn btn-primary block full-width m-b" data-style="zoom-in">登录</button>
  73. </form>
  74. </div>
  75. </div>
  76. </div>
  77. <hr/>
  78. <div class="row">
  79. <div class="col-md-7 col-sm-7 col-lg-7">${(systemInfo.systemTitle)!} </div>
  80. <div class="col-md-5 col-sm-5 col-lg-5 text-right">
  81. <small>${(systemInfo.systemFooter)!}</small>
  82. </div>
  83. </div>
  84. </div>
  85. <script src="login/js/jquery-2.1.1.js"></script>
  86. <script src="login/js/spin.min.js"></script>
  87. <script src="login/js/ladda.min.js"></script>
  88. <script src="login/js/ladda.jquery.min.js"></script>
  89. <script src="login/js/login.js"></script>
  90. <#if (systemInfo.slide)?? && systemInfo.slide == "true">
  91. <script src="login/js/gt.js"></script>
  92. </#if>
  93. <script>
  94. $(function () {
  95. <#if (systemInfo.verCode)?? && systemInfo.verCode == "true">
  96. <#if (systemInfo.slide)?? && systemInfo.slide == "true">
  97. // 滑动图片验证码
  98. verCodeImg();
  99. </#if>
  100. <#if (systemInfo.slide)?? && systemInfo.slide == "false">
  101. // 验证码图片
  102. getVerCode();
  103. </#if>
  104. </#if>
  105. });
  106. <#if (systemInfo.verCode)?? && systemInfo.verCode == "true">
  107. <#if (systemInfo.slide)?? && systemInfo.slide == "false">
  108. //验证码校验
  109. function verCodeText(dom){
  110. $("#isvercodeimg").html("");//验证码验证图片清除
  111. var verCode = $(dom).val()||"";
  112. //只能输入字母和数字
  113. $(dom).val(verCode.replace(/[^0-9a-zA-Z]/g,''));
  114. verCode = $(dom).val()||"";
  115. if(verCode.length > 4){
  116. verCode = verCode.substring(0,4);
  117. $(dom).val(verCode);
  118. }
  119. if(verCode.length == 4){
  120. isVerCode(verCode);
  121. }
  122. }
  123. //获得验证码
  124. function getVerCode(){
  125. $.ajax({
  126. type: "post",
  127. async: false, //同步执行
  128. url: "verCode",
  129. dataType: "json", //返回数据形式为json
  130. success: function(result) {
  131. //if (result.success) {
  132. $("#verCodeId").attr("src","data:image/png;base64,"+result.verCode);
  133. $("input[name='verCode']").val("");//验证码清空
  134. $("#isvercodeimg").html("");//验证码验证图片清除
  135. //}
  136. }
  137. });
  138. }
  139. //即时校验验证码
  140. function isVerCode(verCode){
  141. $.ajax({
  142. type: "post",
  143. async: false, //同步执行
  144. url: "isVerCode?verCode="+verCode,
  145. dataType: "json", //返回数据形式为json
  146. success: function(result) {
  147. if (result.success) {
  148. $("#idvercode").val("yes");
  149. $("#isvercodeimg").html("<img src='login/images/ok.png'/>");
  150. }else{
  151. $("#idvercode").val("");
  152. $("#isvercodeimg").html("<img src='login/images/cancel.png'/>");
  153. }
  154. }
  155. });
  156. }
  157. </#if>
  158. <#if (systemInfo.slide)?? && systemInfo.slide == "true">
  159. // 滑动图片验证码
  160. function verCodeImg(){
  161. var handlerEmbed = function (captchaObj) {
  162. $("#submit").click(function (e) {
  163. var validate = captchaObj.getValidate();
  164. if (!validate) {
  165. // $("#notice")[0].className = "show";
  166. showMsg($("#notice").html());
  167. setTimeout(function () {
  168. hideMsg();
  169. // $("#notice")[0].className = "hide";
  170. }, 2000);
  171. e.preventDefault();
  172. }
  173. });
  174. // 将验证码加到id为captcha的元素里
  175. captchaObj.appendTo("#embed-captcha");
  176. captchaObj.onReady(function () {
  177. $("#wait")[0].className = "hide";
  178. });
  179. // 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
  180. };
  181. $.ajax({
  182. // 获取id,challenge,success(是否启用failback)
  183. url: "verCodeImg",
  184. type: "get",
  185. dataType: "json",
  186. success: function (data) {
  187. // 使用initGeetest接口
  188. // 参数1:配置参数
  189. // 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件
  190. initGeetest({
  191. gt: data.gt,
  192. challenge: data.challenge,
  193. width: "100%",
  194. product: "popup", // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
  195. offline: !data.success // 表示用户后台检测极验服务器是否宕机,一般不需要关注
  196. }, handlerEmbed);
  197. }
  198. });
  199. }
  200. </#if>
  201. </#if>
  202. document.onkeydown = function (e) { // 回车提交表单
  203. // 兼容FF和IE和Opera
  204. var theEvent = window.event || e;
  205. var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
  206. if (code == 13) {
  207. login();
  208. }
  209. }
  210. function showMsg(msg) {
  211. $("#msg").addClass("colorred").html(msg);
  212. }
  213. function hideMsg() {
  214. $("#msg").removeClass("colorred");
  215. }
  216. //登录信息校验
  217. function checkSearchForm() {
  218. var userName = $("input[name='username']").val() || "";
  219. if (userName == "") {
  220. showMsg("用户名不能为空!");
  221. return false;
  222. }
  223. var userPass = $("input[name='password']").val() || "";
  224. if (userPass == "") {
  225. showMsg("密码不能为空!");
  226. return false;
  227. }
  228. <#if (systemInfo.verCode)?? && systemInfo.verCode == "true">
  229. <#if (systemInfo.slide)?? && systemInfo.slide == "false">
  230. var verCode = $("input[name='verCode']").val()||"";
  231. if(verCode == ""){
  232. showMsg("验证码不能为空!");
  233. return false;
  234. }
  235. var isvercode = $("#idvercode").val()||"";
  236. if(isvercode != "yes"){
  237. showMsg("验证码错误!");
  238. return false;
  239. }
  240. </#if>
  241. </#if>
  242. return true;
  243. }
  244. </script>
  245. </body>
  246. </html>