You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

266 rivejä
7.1 KiB

  1. var systemPath = "http://cs1.zhizhuchuxing.com";
  2. //初始化 第一步
  3. $(function(){
  4. var find_height = $(window).height()-34;
  5. $(".find_box").height(find_height);
  6. findPwdStep.findStepFirst();
  7. });
  8. var findPwdStep = {
  9. step:0,
  10. wait:60,
  11. userId:"",
  12. userPhone:"",
  13. backLogin:function(){
  14. window.location.href="http://cs.zhizhuchuxing.com";
  15. },
  16. findStepFirst:function(){
  17. stepBar.init("navStep",0);
  18. $(".pwd_box_p1").show();
  19. $(".pwd_box_p2").hide();
  20. $(".pwd_box_p3").hide();
  21. $(".pwd_box_p4").hide();
  22. $("#step_first").on("click",function(){
  23. var user = $('#user').val();
  24. if(user == ''){
  25. $("#submit_warning1").text("请输入帐号");
  26. return;
  27. }
  28. $.ajax({
  29. url: systemPath+"/api/login/get-account-info",
  30. data: {account_name:user},
  31. type: 'post',
  32. dataType: "json",
  33. success: function (data) {
  34. console.log(data);
  35. if (data.code == 0) {
  36. //success
  37. stepBar.init("navStep",1);
  38. findPwdStep.findStepSecond(data.data);
  39. } else {
  40. $("#submit_warning1").text(data.message);
  41. }
  42. },
  43. error: function (msg) {
  44. $("#submit_warning1").text('系统错误,请联系管理员');
  45. }
  46. });
  47. });
  48. },
  49. findStepSecond:function(data){
  50. $(".pwd_box_p1").hide();
  51. $(".pwd_box_p2").show();
  52. $(".pwd_box_p3").hide();
  53. $(".pwd_box_p4").hide();
  54. var phoneNoText = data.user_mobile;
  55. var user_id = data.user_id;
  56. this.userId = data.user_id;
  57. this.userPhone = data.user_mobile;
  58. if(phoneNoText != ""){
  59. phoneNoText = phoneNoText.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
  60. }else{
  61. phoneNoText = "未绑定手机";
  62. }
  63. $("#bind_phone_no").text(phoneNoText);
  64. //有无手机的top切换
  65. $("#have_tel").on("click",function(){
  66. $(this).addClass("cut_sel");
  67. $(this).removeClass("cut_nosel");
  68. $("#submit_warning2").text('');
  69. $("#nothave_tel").addClass("cut_nosel");
  70. $("#nothave_tel").removeClass("cut_sel");
  71. $("#bind_phone_no").show();
  72. $("#no_tel").hide();
  73. $("#control_code").show();
  74. });
  75. $("#nothave_tel").on("click",function(){
  76. $(this).addClass("cut_sel");
  77. $(this).removeClass("cut_nosel");
  78. $("#submit_warning2").text('');
  79. $("#have_tel").addClass("cut_nosel");
  80. $("#have_tel").removeClass("cut_sel");
  81. $("#bind_phone_no").hide();
  82. $("#no_tel").show();
  83. $("#control_code").hide();
  84. });
  85. //获取验证码
  86. $("#get_code").on("click",function(){
  87. $("#get_code").addClass("code_time");
  88. $("#get_code").removeClass("find_code");
  89. var thisId = $("#get_code")
  90. findPwdStep.time(thisId);
  91. $("#get_code").off("click");
  92. //获取验证码接口
  93. findPwdStep.getCode();
  94. });
  95. //输入验证码
  96. $("#code_input").on("input",function(){
  97. if($(this).val() != ""){
  98. $("#step_second").addClass("sub_bg_color");
  99. $("#step_second").removeClass("nosub_bg_color");
  100. }else{
  101. $("#step_second").addClass("nosub_bg_color");
  102. $("#step_second").removeClass("sub_bg_color");
  103. }
  104. });
  105. //下一步
  106. $("#step_second").on("click",function(){
  107. //判断输入框是否被隐藏;
  108. if($("#control_code").is(":visible")){
  109. var inputCode = $("#code_input").val();
  110. if(inputCode == ""){
  111. $("#submit_warning2").text("请输入验证码");
  112. return;
  113. }
  114. $.ajax({
  115. url: systemPath+"/api/login/check-auth-code",
  116. data: {user_id:user_id,input_code:inputCode},
  117. type: 'post',
  118. dataType: "json",
  119. success: function (data) {
  120. console.log(data);
  121. if (data.code == 0) {
  122. //success
  123. stepBar.init("navStep",2);
  124. findPwdStep.findStepThird();
  125. } else {
  126. $("#submit_warning2").text(data.message);
  127. }
  128. },
  129. error: function (data) {
  130. $("#submit_warning2").text('系统错误,请联系管理员');
  131. }
  132. });
  133. }else{
  134. $("#submit_warning2").text('');
  135. }
  136. });
  137. },
  138. findStepThird:function(){
  139. $(".pwd_box_p1").hide();
  140. $(".pwd_box_p2").hide();
  141. $(".pwd_box_p3").show();
  142. $(".pwd_box_p4").hide();
  143. var user_id = this.userId;
  144. $("#step_third").on("click",function(){
  145. var new_pwd1 = $("#new_pwd").val();
  146. var new_pwd2 = $("#confirm_new_pwd").val();
  147. if(new_pwd1 == ""){
  148. $("#submit_warning3").text('请填写新密码');
  149. return;
  150. }
  151. if(new_pwd2 == ""){
  152. $("#submit_warning3").text('请确认新密码');
  153. return;
  154. }
  155. if(new_pwd1 != new_pwd2){
  156. $("#submit_warning3").text('!密码不一致');
  157. return;
  158. }
  159. $.ajax({
  160. url: systemPath+"/api/login/change-user-password",
  161. data: {user_id:user_id,input_pwd:new_pwd1},
  162. type: 'post',
  163. dataType: "json",
  164. success: function (data) {
  165. console.log(data);
  166. if (data.code == 0) {
  167. //success
  168. findPwdStep.findfourth();
  169. } else {
  170. $("#submit_warning3").text(data.message);
  171. }
  172. },
  173. error: function (data) {
  174. $("#submit_warning3").text('系统错误,请联系管理员');
  175. }
  176. });
  177. });
  178. },
  179. findfourth:function(){
  180. $("#navStep").remove();
  181. $(".pwd_box_p1").hide();
  182. $(".pwd_box_p2").hide();
  183. $(".pwd_box_p3").hide();
  184. $(".pwd_box_p4").show();
  185. },
  186. time:function(id){
  187. if(this.wait == 0){
  188. id.addClass("find_code");
  189. id.removeClass("code_time");
  190. id.text("重新获取");
  191. this.wait = 60;
  192. id.on("click",function(){
  193. id.addClass("code_time");
  194. id.removeClass("find_code");
  195. findPwdStep.time(id);
  196. id.off("click");
  197. //获取验证码接口
  198. findPwdStep.getCode();
  199. });
  200. }else{
  201. id.text("剩余(" + this.wait + ")");
  202. this.wait--;
  203. setTimeout(function() {
  204. findPwdStep.time(id);
  205. },
  206. 1000)
  207. }
  208. },
  209. //获取验证码接口
  210. getCode:function(){
  211. $.ajax({
  212. url: systemPath+"/api/login/send-reset-message",
  213. data: {
  214. user_id:this.userId,
  215. user_mobile:this.userPhone
  216. },
  217. type: 'post',
  218. dataType: "json",
  219. success: function (data) {
  220. console.log(data);
  221. if (data.code == 0) {
  222. //success
  223. } else {
  224. $("#submit_warning2").text(data.message);
  225. }
  226. },
  227. error: function (msg) {
  228. $("#submit_warning2").text('系统错误,请联系管理员');
  229. }
  230. });
  231. },
  232. seePwd:function(index){
  233. if($(index).hasClass("pwd_eye_on")){
  234. $(index).removeClass("pwd_eye_on");
  235. $(index).addClass("pwd_eye_off");
  236. $(index).prev("input").attr("type","text");
  237. }else{
  238. $(index).removeClass("pwd_eye_off");
  239. $(index).addClass("pwd_eye_on");
  240. $(index).prev("input").attr("type","password");
  241. }
  242. }
  243. }
  244. //当浏览器大小变化时
  245. $(window).resize(function () {
  246. var find_height = $(window).height()-34;
  247. $(".find_box").height(find_height);
  248. });