phone_bang.jsp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  4. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
  5. <%
  6. String path = request.getContextPath();
  7. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort() + path+"/";
  8. request.setAttribute("contextPath", basePath);
  9. String redirectUrl= request.getParameter("redirectUrl");
  10. request.setAttribute("redirectUrl", redirectUrl);
  11. %>
  12. <!DOCTYPE html>
  13. <html lang="en">
  14. <head>
  15. <base href="<%=basePath%>">
  16. <meta charset="UTF-8">
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  18. <meta name="apple-mobile-web-app-capable" content="yes">
  19. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  20. <meta name="format-detection" content="telephone=no">
  21. <title>手机绑定</title>
  22. <c:set var="path" value="${pageContext.request.contextPath}" />
  23. <script src="${contextPath }app/lib/flexible.js"></script>
  24. <script type="text/javascript" src="${contextPath }res/js/jquery.min.js"></script>
  25. <script type="text/javascript" src="${contextPath }res/js/layer/layer.min.js"></script>
  26. <link rel="stylesheet" href="${contextPath }app/lib/flexible.css">
  27. <link rel="stylesheet" href="${contextPath }app/css/basem.css">
  28. <link rel="stylesheet" href="${contextPath }app/css/logome.css">
  29. <script type="text/javascript">
  30. var timeid, remainTime;
  31. function calcTime() {
  32. remainTime--;
  33. if (remainTime > 0) {
  34. $('#loginForm p[data-action="getcode"]').text("(" + remainTime + "秒)");
  35. } else {
  36. window.clearInterval(timeid);
  37. $('#loginForm p[data-action="getcode"]').text("获取验证码");
  38. $('#loginForm p[data-action="getcode"]').removeAttr("disabled");
  39. }
  40. }
  41. $(function(){
  42. var $loginForm = $('#loginForm');
  43. $('#loginForm p[data-action="getcode"]').click(function() {
  44. var phone=$loginForm.find("input[name='phone']").val();
  45. if(phone=='' || phone=='请输入11位手机号码')
  46. {
  47. layer.msg("请输入正确的手机号!");
  48. return false;
  49. }
  50. if(!checkMobile(phone)){
  51. return;
  52. }
  53. if($('#loginForm p[data-action="getcode"]').attr("disabled")){
  54. return;
  55. }
  56. $('#loginForm p[data-action="getcode"]').attr("disabled","true");
  57. //$('input[name="phone"]').val()
  58. var parm='{"phone":"'+phone+'" ,"type":"3"}'
  59. $.post('${contextPath}rest/mgmUser/getCode.cs',{
  60. "data":parm
  61. }, function(data) {1
  62. if (data.ret == 1) {
  63. remainTime = 60;
  64. timeid = window.setInterval("calcTime()", 1000);
  65. } else {
  66. layer.msg(data.msg);
  67. $('#loginForm p[data-action="getcode"]').removeAttr("disabled");
  68. }
  69. }, "json");
  70. });
  71. $('#button').click(function(){
  72. var phone=$("input[name='phone']").val();
  73. var code=$("input[name='code']").val();
  74. var password=$("input[name='password']").val();
  75. var password2=$("input[name='password2']").val();
  76. if(phone==''){
  77. layer.msg("请输入手机号!");
  78. return ;
  79. }
  80. if(code=="" || code==null){
  81. layer.msg("请输入验证码!");
  82. return ;
  83. }
  84. if(password==""){
  85. layer.msg("请输入新密码!");
  86. return ;
  87. }
  88. if(password2==""){
  89. layer.msg("请再次输入新密码!");
  90. return ;
  91. }else{
  92. if(password!=password2){
  93. layer.msg("两次输入密码不一致!");
  94. return ;
  95. }
  96. }
  97. var parm='{"phone":"'+phone+'" ,"code":"'+code+'","pwd":"'+password+'","userId":"${USER_ID}"}'
  98. //手机绑定
  99. $.post('${contextPath}web/mgmUserCtl/phoneBinding.cs', {
  100. "data" : parm
  101. }, function(data) {
  102. var datas=eval(data.data);
  103. if (data.ret == 1) {
  104. layer.msg('绑定成功!', {
  105. time: 1000
  106. }, function(){
  107. window.location.href = '${contextPath }web/mgmUserCtl/index.cs?userId='+datas.id;
  108. });
  109. } else {
  110. layer.msg(data.msg);
  111. }
  112. }, "json");
  113. });
  114. function checkMobile(sMobile){
  115. //手机号正则
  116. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  117. //电话
  118. var phone = $.trim(sMobile);
  119. if (!phoneReg.test(phone)) {
  120. alert('请输入有效的手机号码!');
  121. return false;
  122. }
  123. return true;
  124. }
  125. });
  126. </script>
  127. </head>
  128. <body>
  129. <div class="titbox">
  130. <a class="titreturn left" href="${contextPath }app/login/login.jsp"><img src="${contextPath }app/img/return1@2x.png" alt=""></a>
  131. <h1>手机绑定</h1>
  132. </div>
  133. <div class="forgetbox top50">
  134. <div class="safe">
  135. <form action="#" name="loginForm" id="loginForm" method="post">
  136. <ul class="logul">
  137. <li>
  138. <div><img class="logicon" src="${contextPath }app/img/iphone@2x.png" alt=""><span>手机</span></div>
  139. <input type="text" name="phone" placeholder="请输入您的手机号">
  140. </li>
  141. <li>
  142. <div><img class="logicon" src="${contextPath }app/img/yanz@2x.png" alt=""><span>验证码</span></div>
  143. <div class="logclean">
  144. <input class="left" type="text" name="code" placeholder="请输入验证码">
  145. <p data-action="getcode" class="right">获取验证码</p>
  146. </div>
  147. </li>
  148. <li>
  149. <div><img class="logicon" src="${contextPath }app/img/pw@2x.png" alt=""><span>密码</span></div>
  150. <input type="password" name="password" placeholder="请重新设置您的登录密码">
  151. </li>
  152. <li>
  153. <div><img class="logicon" src="${contextPath }app/img/pw@2x.png" alt=""><span>确认密码</span></div>
  154. <input type="password" name="password2" placeholder="请重新设置您的登录密码">
  155. </li>
  156. </ul>
  157. <a class="redbtn" href="javascript:void(0);" id="button">完成</a>
  158. </form>
  159. </div>
  160. </div>
  161. </body>
  162. </html>