人人商城

forget.html 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {php define('MUI', true);}
  2. {template 'common/header'}
  3. <script>
  4. $(function(){
  5. $(document).on('input propertychange', '.js-mobile-val', function(){
  6. var mobile_value = $(this).val();
  7. var register_mode = $("#register_mode").val();
  8. if (register_mode == 'mobile' && mobile_value.length != '11') {
  9. $('.js-check-mobile').removeClass('send-code');
  10. }
  11. if (register_mode == 'email' && !/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(mobile_value)) {
  12. $('.js-check-mobile').removeClass('send-code');
  13. }
  14. if (register_mode == 'random' && !(mobile_value.length == '11' || /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(mobile_value))) {
  15. $('.js-check-mobile').removeClass('send-code');
  16. }
  17. $.post("{php echo url('auth/login/mobile_exist')}", {'mobile' : mobile_value, 'find_mode':register_mode}, function(data) {
  18. data = $.parseJSON(data);
  19. if (data.message.errno == '1') {
  20. $('.js-check-mobile').addClass('send-code');
  21. } else if (data.message.errno == '2'){
  22. $('.js-check-mobile').removeClass('send-code');
  23. util.toast('账号不存在', '', 'error');
  24. return;
  25. }
  26. });
  27. });
  28. $(document).on('click', '.send-code', function(){
  29. var username = $('#sendcode input[name="username"]').val();
  30. option = {
  31. 'btnElement' : $('.send-code'),
  32. 'showElement' : $('.js-timer'),
  33. 'btnTips' : '<a class="send-code">重新获取验证码</a>',
  34. 'successCallback' : function(ret, message){
  35. if (ret == '0') {
  36. util.toast(message);
  37. $('#sendcode').hide();
  38. $('#codeverify').show();
  39. } else {
  40. util.toast(message);
  41. $('#sendcode').show();
  42. $('#codeverify').hide();
  43. return;
  44. }
  45. }
  46. };
  47. util.sendCode(username, option);
  48. });
  49. $(document).on('click', '.check-verify', function(){
  50. var code = $('#codeverify input[name="code"]').val();
  51. if (!code) {
  52. util.toast('未填写验证码', '', 'error');
  53. return;
  54. }
  55. if (code.length < 6) {
  56. util.toast('验证码少于六位', '', 'error');
  57. return;
  58. }
  59. var username = $('#sendcode input[name="username"]').val();
  60. $.post("{php echo url('auth/forget/verifycode')}", {'code' : code, 'username' : username}, function(dat){
  61. dat = $.parseJSON(dat);
  62. if(dat.type != 'success') {
  63. util.toast(dat.message, '', 'error');
  64. return;
  65. } else {
  66. $('#codeverify').hide();
  67. $('#reset').show();
  68. $('#reset .js-reset').text(username);
  69. return;
  70. }
  71. });
  72. });
  73. $(document).on('click', '.resetpassword', function(){
  74. var password = $('#reset input[name="password"]').val();
  75. var repassword = $('#reset input[name="repassword"]').val();
  76. if(password == '' || repassword == '') {
  77. util.toast('请填写密码', '', 'error');
  78. return;
  79. }
  80. if(password.length < 6) {
  81. util.toast('密码不能少于六位数', '', 'error');
  82. return ;
  83. }
  84. if(password != repassword) {
  85. util.toast('两次密码输入不一致', '', 'error');
  86. return ;
  87. }
  88. var username = $('#sendcode input[name="username"]').val();
  89. params = {username, password, repassword};
  90. $.post("{php echo url('auth/forget/reset')}", {'username' : username, 'password' : password, 'repassword' : repassword}, function(dat){
  91. dat = $.parseJSON(dat);
  92. if(dat.type != 'success') {
  93. util.toast(dat.message, '', 'error');
  94. } else {
  95. util.toast('设置密码成功');
  96. location.href = "{url 'auth/login' array('forward' => $_GPC['forward'])}#wechat_redirect";
  97. return;
  98. }
  99. });
  100. });
  101. });
  102. </script>
  103. <div class="mui-content">
  104. <input type="hidden" value="{$register_mode}" id="register_mode">
  105. <div id="sendcode">
  106. <div class="mui-content-padded mui-text-muted">请输入{if $register_mode == 'mobile'}手机号{elseif $register_mode == 'email'}邮箱{else}手机号/邮箱{/if},以收取验证码</div>
  107. <div class="mui-input-group mui-mt15">
  108. <div class="mui-input-row mui-help">
  109. <input name="username" type="text" class="js-mobile-val" placeholder="{if $register_mode == 'mobile'}手机号{elseif $register_mode == 'email'}邮箱{else}手机号/邮箱{/if}"/>
  110. </div>
  111. </div>
  112. <div class="mui-content-padded">
  113. <button class="mui-btn mui-btn-success mui-btn-block js-check-mobile" uniacid="{$_W['uniacid']}">下一步</button>
  114. </div>
  115. </div>
  116. <div id="codeverify" style="display:none;">
  117. <div class="mui-content-padded mui-text-muted">您的请输入{if $register_mode == 'mobile'}手机号{elseif $register_mode == 'email'}邮箱{else}手机号/邮箱{/if}<span class="mui-text-success"></span>会收到一条含有6位数字验证码的短息</div>
  118. <div class="mui-input-group mui-mt15">
  119. <div class="mui-input-row mui-help">
  120. <input type="text" placeholder="请输入验证码" name="code"/>
  121. </div>
  122. </div>
  123. <div class="mui-content-padded mui-text-center">
  124. <button class="mui-btn mui-btn-success mui-btn-block check-verify">下一步</button>
  125. <div class="mui-mt15 mui-text-center">
  126. <span class="mui-text-muted js-timer">
  127. </span>
  128. </div>
  129. </div>
  130. </div>
  131. <div id="reset" style="display:none;">
  132. <div class="mui-content-padded mui-text-muted">请为你的账号<span class="mui-ml5 mui-mr5 js-reset"></span>设置密码,以保证下次正常登录</div>
  133. <div class="mui-input-group">
  134. <div class="mui-input-row">
  135. <input name="password" type="password" placeholder="请设置密码"/>
  136. </div>
  137. <div class="mui-input-row">
  138. <input name="repassword" type="password" placeholder="确认新密码"/>
  139. </div>
  140. </div>
  141. <div class="mui-content-padded mui-text-muted">密码为6~16位数字或字母</div>
  142. <div class="mui-content-padded">
  143. <button class="mui-btn mui-btn-success mui-btn-block resetpassword">确认</button>
  144. </div>
  145. </div>
  146. </div>