forgetPass.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <meta name="format-detection"content="telephone=no">
  8. <title></title>
  9. <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
  10. <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
  11. <link rel="stylesheet" type="text/css" href="../../css/toast.css"/>
  12. <link rel="stylesheet" href="../../css/projeck.css">
  13. <style media="screen">
  14. body,html{
  15. background: #ecf0f1;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div class="api_layout">
  21. <!-- <header class="header-login">
  22. <img class="backBtn" src="../../image/btn_back.png" alt="" onclick="backIndex()">
  23. <p class="api_text">修改密码</p>
  24. </header> -->
  25. <div class="api_forget_phone">
  26. <div class="api_phone">
  27. <input type="number" name="" value="" placeholder="请输入手机号" class="api_phone_bind">
  28. </div>
  29. <div class="api_phone">
  30. <input type="number" name="" value="" placeholder="验证码" class="api_vali">
  31. <button type="button" class="api_btn_vali" id="verify-sms" onclick="changeTitleOnSendSms()">发送验证码</button>
  32. </div>
  33. <div class="api_phone">
  34. <input type="password" placeholder="输入新密码" class="api_new_pass">
  35. </div>
  36. <div class="api_phone">
  37. <input type="password" placeholder="重复新密码" onblur="passVerification()" class="api_new_pass01">
  38. </div>
  39. <div class="api_bnt" onclick="sureForget()">确认修改</div>
  40. </div>
  41. <div class="api_layout">
  42. </body>
  43. </html>
  44. <script type="text/javascript" src="../../script/api.js"></script>
  45. <!-- <script src="../../script/aui-toast.js" charset="utf-8"></script> -->
  46. <!-- <script src="../../script/fastclick.min.js"></script> -->
  47. <script src="../../script/config.js" charset="utf-8"></script>
  48. <script type="text/javascript">
  49. var uuid;
  50. apiready = function () {
  51. $api.fixStatusBar($api.dom('header'));
  52. var info = $api.getStorage('data');
  53. uuid = JSON.parse(info).data.user.staff_num;
  54. }
  55. function backIndex() {
  56. api.closeWin();
  57. };
  58. var interval;
  59. function changeTitleOnSendSms() {
  60. var phone = $api.dom('.api_phone_bind').value;
  61. var reg = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/;
  62. if (phone == "") {
  63. api.toast({
  64. msg: '电话号码不能为空',
  65. duration: 2000,
  66. location: 'top'
  67. });
  68. return false;
  69. }else if (!reg.test(phone)) {
  70. api.toast({
  71. msg: '电话号码格式不正确',
  72. duration: 2000,
  73. location: 'top'
  74. });
  75. return false;
  76. }else {
  77. phoneFun();
  78. interval = setInterval("changeTime()", 1000);
  79. var verify_btn = $api.byId("verify-sms");
  80. verify_btn.style.backgroundColor = "#D9D9D9";
  81. verify_btn.setAttribute('disabled','true');
  82. }
  83. }
  84. //
  85. var remaining_time = 30;
  86. function changeTime() {
  87. var verify_btn = $api.byId("verify-sms");
  88. $api.html(verify_btn, remaining_time + "s后重发");
  89. remaining_time -= 1;
  90. if (remaining_time <= 0) {
  91. window.clearInterval(interval);
  92. remaining_time = 30;
  93. verify_btn.style.backgroundColor = "#009fe8";
  94. verify_btn.removeAttribute('disabled','true');
  95. $api.html(verify_btn, "获取验证码");
  96. // canSms = true;
  97. }
  98. }
  99. function phoneFun() {
  100. var mobile = $api.val($api.dom('.api_phone_bind'));
  101. $http.requestData(UrlRouter.vcodeApi,'post',{mobile})
  102. .then(ret=>{
  103. if (ret.code === 0) {
  104. api.toast({
  105. msg: '发送成功',
  106. duration: 2000,
  107. location: 'top'
  108. });
  109. }else if (ret.code === 3001) {
  110. api.toast({
  111. msg: '电话号码错误',
  112. duration: 2000,
  113. location: 'top'
  114. });
  115. }else if (ret.code === 3002) {
  116. api.toast({
  117. msg: '发送失败',
  118. duration: 2000,
  119. location: 'top'
  120. });
  121. }
  122. })
  123. .catch(err=>{
  124. api.toast({
  125. msg: '发送失败',
  126. duration: 2000,
  127. location: 'top'
  128. });
  129. })
  130. };
  131. // 密码做验证
  132. function passVerification() {
  133. var newPass = $api.dom('.api_new_pass').value,
  134. api_new_pass01 = $api.dom('.api_new_pass01').value;
  135. if (newPass != api_new_pass01) {
  136. api.toast({
  137. msg: '两次密码不一致',
  138. duration: 2000,
  139. location: 'top'
  140. });
  141. return false;
  142. }else {
  143. return true;
  144. }
  145. }
  146. function sureForget() {
  147. var mobile = $api.dom('.api_phone_bind').value,
  148. vcode = $api.dom('.api_vali').value,
  149. password = $api.dom('.api_new_pass').value;
  150. if (mobile != '' && vcode != '' && password != '' && passVerification()) {
  151. $http.requestDataLoging(UrlRouter.repasswordApi,'post',{mobile,vcode,password})
  152. .then(ret=>{
  153. if(ret.code === 0){
  154. api.toast({
  155. msg: '修改密码成功',
  156. duration: 2000,
  157. location: 'top'
  158. });
  159. var userInfo = {username:uuid,password:""}
  160. $api.setStorage('userInfo',JSON.stringify(userInfo));
  161. api.openWin({
  162. name: 'login',
  163. reload:true,
  164. slidBackEnabled:false,
  165. url: '../../login.html',
  166. pageParam:{
  167. status:true
  168. }
  169. });
  170. api.closeWin({
  171. name:'index'
  172. });
  173. }else if(ret.code === 4002){
  174. api.toast({
  175. msg: '验证码超时',
  176. duration: 2000,
  177. location: 'top'
  178. });
  179. }
  180. })
  181. .catch(err=>{
  182. api.toast({
  183. msg: '发送失败',
  184. duration: 2000,
  185. location: 'top'
  186. });
  187. })
  188. }else {
  189. api.toast({
  190. msg: '手机号,验证码,密码不能为空',
  191. duration: 2000,
  192. location: 'top'
  193. })
  194. }
  195. }
  196. </script>