bind-mobile.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>绑定手机号</title>
  6. <meta name="format-detection" content="telephone=no"/>
  7. <meta name="viewport"
  8. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
  9. <meta name="apple-mobile-web-app-capable" content="yes"/>
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
  11. <link rel="stylesheet" href="../../../css/cross.css" type="text/css"/>
  12. <link rel="stylesheet" href="../../../css/cross.ui.css" type="text/css"/>
  13. <link rel="stylesheet" type="text/css" href="../../../css/ss-style.css">
  14. <link rel="stylesheet" type="text/css" href="../../../iconfont/iconfont.css" />
  15. <style>
  16. .n-list-info{position: relative;}
  17. .searchbar-clear{position: absolute;width: 28px;height: 28px;right: 0;top:8px;opacity:0;pointer-events:none;background-position:center;background-repeat:no-repeat;background-image:url(../../../images/delete01_pre.png);-webkit-background-size:20px 20px;background-size:20px 20px;-webkit-transition-duration:300ms;transition-duration:300ms;cursor:pointer;}
  18. .div-zczh{width:auto;height:29px;border:0;color:#4DCD70;font-size:14px;line-height:29px;text-align:center;border-radius:10px;color:#17b3ec;float: left;margin-left: 20px;}
  19. .div-zhmmdl{width:auto;height:29px;border:0;color:#4DCD70;font-size:14px;line-height:29px;text-align:center;border-radius:10px;color:#17b3ec;float: right; margin-right: 20px;}
  20. .bgc-fa8888{background-color: #FA8888;}
  21. </style>
  22. </head>
  23. <body>
  24. <div class="main">
  25. <ul class="n-list edit-info registered c-border-tb mt15 c-f15 form-register">
  26. <li>
  27. <div class="n-list-key" style="width: 2.3em;">
  28. <i class="iconfont icon-shouji1"></i>
  29. </div>
  30. <div class="n-list-info">
  31. <input id="txtMobile" type="tel" class="width-100 c-f16 c-5b5b5b" maxlength="11" placeholder="请输入手机号码" onkeyup="this.value=this.value.replace(/[^\d]/g,'')"/>
  32. <a href="#" class="searchbar-clear"></a>
  33. </div>
  34. </li>
  35. <li>
  36. <div class="n-list-key" style="width: 2.3em;">
  37. <i class="iconfont icon-yanzhengma01"></i>
  38. </div>
  39. <div class="n-list-info">
  40. <input id="txtCode" type="text" class="width-100 c-f16 c-5b5b5b" placeholder="请输入验证码"/>
  41. <a href="#" class="searchbar-clear"></a>
  42. </div>
  43. <div id="messageCode1" class="n-list-key pl15 c-17b3ec" onclick="sendCode()">
  44. <span>获取短信验证码</span>
  45. </div>
  46. <div id="messageCode2" class="n-list-key pl15 c-999999" style="display: none;">
  47. <span id="message"></span>
  48. </div>
  49. </li>
  50. </ul>
  51. <div class="mb15 mlr15 mt20">
  52. <a href="javascript:;" style="font-size: 18px;" class="c-btn c-btn-4dcd70 c-btn-full c-btn-radius c-f16" onclick="commit()">确认绑定</a>
  53. </div>
  54. </div>
  55. </body>
  56. <script type="text/javascript" src="../../../js/jquery/2.1.3/jquery.js" ></script>
  57. <script type="text/javascript" src="../../../js/common_http.js" ></script>
  58. <script type="text/javascript" src="../../../js/weixin_common.js?11=11" ></script>
  59. <link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
  60. <script src="../../../widget/artDialog/6.0.5/js/dialog-plus.js"></script>
  61. <script type="text/javascript" src="../../../js/commit_validate.js" ></script>
  62. <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  63. <script type="text/javascript">
  64. var dd = dialog({contentType:'load', skin:'bk-popup', content:'请稍后...'});
  65. var clock = "";
  66. var nums = 60;
  67. $(function (){
  68. bindEvents();
  69. })
  70. function bindEvents(){
  71. $("input").on("focus",function(){
  72. $(".searchbar-clear").css("pointer-events","none").css("opacity",0);
  73. if($(this).val()){
  74. $(this).next().css("pointer-events","auto").css("opacity",1);
  75. }
  76. }).on("input",function(){
  77. $(this).next().css("pointer-events","auto").css("opacity",1);
  78. });
  79. $(".n-list-info").on("click",".searchbar-clear",function(){
  80. $(this).prev().val("");
  81. $(this).css("pointer-events","none").css("opacity",0);
  82. $(this).prev().focus();
  83. return false;
  84. });
  85. }
  86. function sendCode(){
  87. var mobile = document.getElementById("txtMobile").value;
  88. if(!mobile){
  89. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请输入手机号'}).show();
  90. return;
  91. }
  92. if(!isphone(mobile)){
  93. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'手机号格式不正确'}).show();
  94. return;
  95. }
  96. $("#messageCode1").hide();
  97. document.getElementById("message").innerHTML = nums+'秒后可重新获取';
  98. $("#messageCode2").show();
  99. clock = setInterval(doLoop, 1000); //一秒执行一次
  100. var data = {};
  101. data.mobile = mobile;
  102. data.type = 4;
  103. sendPost("common/checkCaptcha", data, "json", "post", sendFailed, sendSuccesss);
  104. }
  105. //失败
  106. function sendFailed(res) {
  107. clearInterval(clock); //清除js定时器
  108. $("#messageCode1").show();
  109. $("#messageCode2").hide();
  110. nums = 60; //重置时间
  111. if (res && res.msg) {
  112. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  113. } else {
  114. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'获取失败'}).show();
  115. }
  116. }
  117. function sendSuccesss(res){
  118. if (res.status == 200) {
  119. }
  120. else{
  121. sendFailed(res);
  122. }
  123. }
  124. function doLoop(){
  125. nums--;
  126. if(nums > 0){
  127. document.getElementById("message").innerHTML = nums+'秒后可重新获取';
  128. }else{
  129. clearInterval(clock); //清除js定时器
  130. $("#messageCode1").show();
  131. $("#messageCode2").hide();
  132. nums = 60; //重置时间
  133. }
  134. }
  135. function commit(){
  136. var mobile = document.getElementById("txtMobile").value;
  137. var captcha = document.getElementById("txtCode").value;
  138. if (!mobile || !captcha) {
  139. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'手机号和验证码不能为空'}).show();
  140. return;
  141. }
  142. if(!isphone(mobile)){
  143. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'手机号格式不正确'}).show();
  144. return;
  145. }
  146. dd.showModal();
  147. //拼请求内容
  148. var data = {};
  149. data.mobile = mobile;
  150. data.captcha = captcha;
  151. data.type = 4;
  152. sendPost("patient/mobileUpdate", data, "json", "post", operateFailed, operateSuccesss);
  153. }
  154. //失败
  155. function operateFailed(res) {
  156. dd.close();
  157. if (res && res.msg) {
  158. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  159. } else {
  160. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'登录失败'}).show();
  161. }
  162. }
  163. //成功调用手机绑定接口
  164. function operateSuccesss(res) {
  165. if (res.status == 200) {
  166. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: "手机号绑定成功!"}).show();
  167. setTimeout(function() {
  168. history.go(-1)
  169. }, 2000)
  170. } else {
  171. operateFailed(res);
  172. }
  173. }
  174. //注册
  175. function regist(){
  176. window.location.href = "regist-info.html?type=" + type + "&openid=" + openid;
  177. }
  178. //帐号密码登录
  179. function zhmmLogin(){
  180. window.location.href = "zhmm-login.html?type=" + type + "&openid=" + openid;
  181. }
  182. </script>
  183. </html>