reg.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. <div class="layui-form-item">
  12. <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone" for="LAY-user-login-cellphone"></label>
  13. <input type="text" name="cellphone" id="LAY-user-login-cellphone" lay-verify="phone" placeholder="手机" class="layui-input">
  14. </div>
  15. <div class="layui-form-item">
  16. <div class="layui-row">
  17. <div class="layui-col-xs7">
  18. <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
  19. <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="验证码" class="layui-input">
  20. </div>
  21. <div class="layui-col-xs5">
  22. <div style="margin-left: 10px;">
  23. <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid" id="LAY-user-reg-getsmscode">获取验证码</button>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="layui-form-item">
  29. <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
  30. <input type="password" name="password" id="LAY-user-login-password" lay-verify="pass" placeholder="密码" class="layui-input">
  31. </div>
  32. <div class="layui-form-item">
  33. <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-repass"></label>
  34. <input type="password" name="repass" id="LAY-user-login-repass" lay-verify="required" placeholder="确认密码" class="layui-input">
  35. </div>
  36. <div class="layui-form-item">
  37. <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-nickname"></label>
  38. <input type="text" name="nickname" id="LAY-user-login-nickname" lay-verify="nickname" placeholder="昵称" class="layui-input">
  39. </div>
  40. <div class="layui-form-item">
  41. <input type="checkbox" name="agreement" lay-skin="primary" title="同意用户协议" checked>
  42. </div>
  43. <div class="layui-form-item">
  44. <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-reg-submit">注 册</button>
  45. </div>
  46. <div class="layui-trans layui-form-item layadmin-user-login-other">
  47. <label>社交账号注册</label>
  48. <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
  49. <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
  50. <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>
  51. <a lay-href="/user/login" class="layadmin-user-jump-change layadmin-link layui-hide-xs">用已有帐号登入</a>
  52. <a lay-href="/user/login" class="layadmin-user-jump-change layadmin-link layui-hide-sm layui-show-xs-inline-block">登入</a>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="layui-trans layadmin-user-login-footer">
  57. <p>© 2018 <a href="http://www.layui.com/" target="_blank">layui.com</a></p>
  58. <p>
  59. <span><a href="http://www.layui.com/admin/#get" target="_blank">获取授权</a></span>
  60. <span><a href="http://www.layui.com/admin/pro/" target="_blank">在线演示</a></span>
  61. <span><a href="http://www.layui.com/admin/" target="_blank">前往官网</a></span>
  62. </p>
  63. </div>
  64. </div>
  65. <script>
  66. layui.use(['admin', 'form', 'user'], function(){
  67. var $ = layui.$
  68. ,setter = layui.setter
  69. ,admin = layui.admin
  70. ,form = layui.form
  71. ,router = layui.router();
  72. form.render();
  73. //发送短信验证码
  74. admin.sendAuthCode({
  75. elem: '#LAY-user-reg-getsmscode'
  76. ,elemPhone: '#LAY-user-login-cellphone'
  77. ,elemVercode: '#LAY-user-login-vercode'
  78. ,ajax: {
  79. url: './json/user/sms.js' //实际使用请改成服务端真实接口
  80. }
  81. });
  82. //提交
  83. form.on('submit(LAY-user-reg-submit)', function(obj){
  84. var field = obj.field;
  85. //确认密码
  86. if(field.password !== field.repass){
  87. return layer.msg('两次密码输入不一致');
  88. }
  89. //是否同意用户协议
  90. if(!field.agreement){
  91. return layer.msg('你必须同意用户协议才能注册');
  92. }
  93. //请求接口
  94. admin.req({
  95. url: './json/user/reg.js' //实际使用请改成服务端真实接口
  96. ,data: field
  97. ,done: function(res){
  98. layer.msg('注册成功', {
  99. offset: '15px'
  100. ,icon: 1
  101. ,time: 1000
  102. }, function(){
  103. location.hash = '/user/login'; //跳转到登入页
  104. });
  105. }
  106. });
  107. return false;
  108. });
  109. });
  110. </script>