forget.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <script type="text/html" template>
  2. <link rel="stylesheet" href="{{ layui.setter.base }}style/login.css?v={{ layui.admin.v }}-1" media="all">
  3. </script>
  4. <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
  5. <div class="layadmin-user-login-main">
  6. <div class="layadmin-user-login-box layadmin-user-login-header">
  7. <h2>layuiAdmin</h2>
  8. <p>layui 官方出品的单页面后台管理模板系统</p>
  9. </div>
  10. <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
  11. <script type="text/html" template>
  12. {{# if(layui.router().search.type === 'resetpass'){ }}
  13. <div class="layui-form-item">
  14. <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
  15. <input type="password" name="password" id="LAY-user-login-password" lay-verify="pass" placeholder="新密码" class="layui-input">
  16. </div>
  17. <div class="layui-form-item">
  18. <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-repass"></label>
  19. <input type="password" name="repass" id="LAY-user-login-repass" lay-verify="required" placeholder="确认密码" class="layui-input">
  20. </div>
  21. <div class="layui-form-item">
  22. <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-forget-resetpass">重置新密码</button>
  23. </div>
  24. {{# } else { }}
  25. <div class="layui-form-item">
  26. <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone" for="LAY-user-login-cellphone"></label>
  27. <input type="text" name="cellphone" id="LAY-user-login-cellphone" lay-verify="phone" placeholder="请输入注册时的手机号" class="layui-input">
  28. </div>
  29. <div class="layui-form-item">
  30. <div class="layui-row">
  31. <div class="layui-col-xs7">
  32. <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
  33. <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
  34. </div>
  35. <div class="layui-col-xs5">
  36. <div style="margin-left: 10px;">
  37. <img src="https://www.oschina.net/action/user/captcha" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode">
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="layui-form-item">
  43. <div class="layui-row">
  44. <div class="layui-col-xs7">
  45. <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-smscode"></label>
  46. <input type="text" name="vercode" id="LAY-user-login-smscode" lay-verify="required" placeholder="短信验证码" class="layui-input">
  47. </div>
  48. <div class="layui-col-xs5">
  49. <div style="margin-left: 10px;">
  50. <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid" id="LAY-user-forget-getsmscode">获取验证码</button>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="layui-form-item">
  56. <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-forget-submit">找回密码</button>
  57. </div>
  58. {{# } }}
  59. </script>
  60. </div>
  61. </div>
  62. <div class="layui-trans layadmin-user-login-footer">
  63. <p>© 2018 <a href="http://www.layui.com/" target="_blank">layui.com</a></p>
  64. <p>
  65. <span><a href="http://www.layui.com/admin/#get" target="_blank">获取授权</a></span>
  66. <span><a href="http://www.layui.com/admin/pro/" target="_blank">在线演示</a></span>
  67. <span><a href="http://www.layui.com/admin/" target="_blank">前往官网</a></span>
  68. </p>
  69. </div>
  70. </div>
  71. <script>
  72. layui.use(['admin', 'form', 'user'], function(){
  73. var $ = layui.$
  74. ,setter = layui.setter
  75. ,admin = layui.admin
  76. ,form = layui.form
  77. ,router = layui.router();
  78. form.render();
  79. //发送短信验证码
  80. admin.sendAuthCode({
  81. elem: '#LAY-user-forget-getsmscode'
  82. ,elemPhone: '#LAY-user-login-cellphone'
  83. ,elemVercode: '#LAY-user-login-vercode'
  84. ,ajax: {
  85. url: './json/user/sms.js' //实际使用请改成服务端真实接口
  86. }
  87. });
  88. //找回密码下一步
  89. form.on('submit(LAY-user-forget-submit)', function(obj){
  90. var field = obj.field;
  91. //请求接口
  92. admin.req({
  93. url: './json/user/forget.js' //实际使用请改成服务端真实接口
  94. ,data: field
  95. ,done: function(res){
  96. location.hash = router.href + '/type=resetpass';
  97. }
  98. });
  99. return false;
  100. });
  101. //重置密码
  102. form.on('submit(LAY-user-forget-resetpass)', function(obj){
  103. var field = obj.field;
  104. //确认密码
  105. if(field.password !== field.repass){
  106. return layer.msg('两次密码输入不一致');
  107. }
  108. //请求接口
  109. admin.req({
  110. url: './json/user/resetpass.js' //实际使用请改成服务端真实接口
  111. ,data: field
  112. ,done: function(res){
  113. layer.msg('密码已成功重置', {
  114. offset: '15px'
  115. ,icon: 1
  116. ,time: 1000
  117. }, function(){
  118. location.hash = '/user/login'; //跳转到登入页
  119. });
  120. }
  121. });
  122. return false;
  123. });
  124. });
  125. </script>