Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

users_centre_field_mobile_m.htm 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <div class="row">
  2. <div class="col-xs-3">{$vo.title}</div>
  3. <div class="col-xs-9">
  4. {eyou:if condition="1 == $vo.is_required"}
  5. <span class="redx">*</span>
  6. {eyou:else/}
  7. <span class="redx">&nbsp;</span>
  8. {/eyou:if}
  9. {$vo.dfvalue|default=''}
  10. {eyou:eq name='is_mobile' value='1'}
  11. <!-- 手机端 -->
  12. {eyou:eq name='$users.is_mobile' value='1'}
  13. <span class="err"><a href="JavaScript:void(0);" onclick="BindUpdateMobile('更改手机');">(更改手机)</a></span>
  14. {eyou:else/}
  15. <span class="err"><a href="JavaScript:void(0);" onclick="BindUpdateMobile('绑定手机');">(绑定手机)</a></span>
  16. {/eyou:eq}
  17. <div id="users_bind_mobile_html" style="display: none;">
  18. <div class="changepass">
  19. <eyoucms_form_2020 name='theForm_mobile_form' id="theForm_mobile_form" method="post">
  20. <div class="modal-body">
  21. <div class="form-group">
  22. <div class="input-group">
  23. <input type="text" id="bind_mobile_old" name="mobile" {eq name='$users.is_mobile' value='0'} value="{$users.mobile}" {/eq} required class="form-control" placeholder="新的手机号码">
  24. </div>
  25. </div>
  26. <div class="form-group">
  27. <div class="input-group" style="position: relative;">
  28. <input type="text" class="form-control" id="bind_mobile_code" name="mobile_code" placeholder="手机验证码">
  29. <input type="button" id="bind_mobile_button" onclick="GetMobileCodeMobile();" class="btn btn-primary" value="获取验证码" />
  30. </div>
  31. </div>
  32. </div>
  33. <div class="modal-footer">
  34. <button type="button" class="btn btn-primary" style="width:88%;" onclick="SubmitUpdateMobile();">确定</button>
  35. </div>
  36. </eyoucms_form_2020>
  37. </div>
  38. </div>
  39. <script type="text/javascript">
  40. // 绑定、更换手机号码
  41. function BindUpdateMobile(title) {
  42. var content = $('#users_bind_mobile_html').html();
  43. content = content.replace(/eyoucms_form_2020/g, 'form');
  44. content = content.replace(/theForm_mobile_form/g, 'bind_mobile_form_2020');
  45. content = content.replace(/bind_mobile_old/, 'bind_mobile_new_2020');
  46. content = content.replace(/bind_mobile_code/, 'bind_mobile_code_2020');
  47. content = content.replace(/bind_mobile_button/, 'bind_mobile_button_2020');
  48. layer.open({
  49. type: 1,
  50. title: title,
  51. style:'position:fixed; bottom:0; left:0; width: 100%; padding:10px 0; border:none;max-width: 100%;',
  52. anim:'up',
  53. content: content,
  54. });
  55. }
  56. // 获取手机验证码
  57. function GetMobileCodeMobile() {
  58. // 正在处理提示动画
  59. var loading = loa_ding();
  60. // 标题
  61. var title = $('h3').html();
  62. // 手机号码
  63. var mobile = $("#bind_mobile_new_2020").val();
  64. // 手机号是否为空
  65. if (!mobile) {
  66. layer.close(loading);
  67. $("#bind_mobile_new_2020").focus();
  68. msg_open('请输入新的手机号码!');
  69. return false;
  70. }
  71. // 手机格式不正确
  72. var mobile_format = /^1[0-9]{10}$/i;
  73. if (!mobile_format.test(mobile)) {
  74. layer.close(loading);
  75. $("#bind_mobile_new_2020").focus();
  76. msg_open('请输入正确的新的手机号码!');
  77. return false;
  78. }
  79. // 发送验证码
  80. $("#bind_mobile_button_2020").val('发送中…');
  81. $.ajax({
  82. url: '{$RootDir}/index.php?m=api&c=Ajax&a=SendMobileCode&_ajax=1',
  83. data: {mobile: mobile, is_mobile: true, source: 1},
  84. type:'post',
  85. dataType:'json',
  86. success:function(res) {
  87. layer.close(loading);
  88. if (res.code == 1) {
  89. MobileCountDown();
  90. msg_open(res.msg);
  91. } else {
  92. $("#bind_mobile_button_2020").val('获取验证码').removeAttr("disabled");
  93. msg_open(res.msg);
  94. }
  95. },
  96. error : function() {
  97. $("#bind_mobile_button_2020").val('获取验证码').removeAttr("disabled");
  98. layer.close('发送失败,请尝试重新发送!');
  99. msg_open(res.msg);
  100. }
  101. });
  102. }
  103. // 倒计时
  104. function MobileCountDown() {
  105. var setTime;
  106. var time = 120;
  107. setTime = setInterval(function(){
  108. if(0 >= time){
  109. clearInterval(setTime);
  110. return;
  111. }
  112. time--;
  113. $("#bind_mobile_button_2020").val(time+'秒');
  114. $("#bind_mobile_button_2020").attr('disabled', 'disabled');
  115. if(time == 0){
  116. $("#bind_mobile_button_2020").val('获取验证码');
  117. $("#bind_mobile_button_2020").removeAttr("disabled");
  118. }
  119. }, 1000);
  120. }
  121. // 提交手机及验证码进行绑定
  122. function SubmitUpdateMobile() {
  123. var loading = loa_ding();// 正在处理提示动画
  124. var mobile = $("#bind_mobile_new_2020").val();
  125. var reg = /^1[0-9]{10}$/i;
  126. // 邮箱格式不正确
  127. if(!reg.test(mobile)) {
  128. layer.close(loading);
  129. $("#bind_mobile_new_2020").focus();
  130. msg_open('请正确输入手机号码');
  131. return false;
  132. }
  133. var mobile_code = $("#bind_mobile_code_2020").val();
  134. if(!mobile_code) {
  135. layer.close(loading);
  136. $("#bind_mobile_code_2020").focus();
  137. msg_open('请输入手机验证码');
  138. return false;
  139. }
  140. $.ajax({
  141. url: '{$RootDir}/index.php?m=user&c=Users&a=bind_mobile&_ajax=1',
  142. data: $('#bind_mobile_form_2020').serialize(),
  143. type:'post',
  144. dataType:'json',
  145. success:function(res){
  146. if (res.code == 1) {
  147. layer.closeAll();
  148. msg_open(res.msg);
  149. location.reload();
  150. } else {
  151. layer.close(loading);
  152. msg_open(res.msg);
  153. }
  154. },
  155. error : function() {
  156. layer.close(loading);
  157. footer_open('未知错误,请刷新重试');
  158. }
  159. });
  160. };
  161. </script>
  162. {eyou:else/}
  163. <!-- PC端 -->
  164. {eyou:eq name='$users.is_mobile' value='1'}
  165. <span class="err"><a href="JavaScript:void(0);" onclick="get_{$vo.fieldArr}{$vo.name|default=''}_mobile_code('更改手机');">(更改手机)</a></span>
  166. {eyou:else/}
  167. <span class="err"><a href="JavaScript:void(0);" onclick="get_{$vo.fieldArr}{$vo.name|default=''}_mobile_code('绑定手机');">(绑定手机)</a></span>
  168. {/eyou:eq}
  169. <script type="text/javascript">
  170. function get_{$vo.fieldArr}{$vo.name|default=''}_mobile_code(title) {
  171. var url = '{$RootDir}/index.php?m=user&c=Users&a=bind_mobile';
  172. if (url.indexOf('?') > -1) {
  173. url += '&';
  174. } else {
  175. url += '?';
  176. }
  177. url += 'title=' + title;
  178. //iframe窗
  179. layer.open({
  180. type: 2,
  181. title: title,
  182. shadeClose: false,
  183. maxmin: false, //开启最大化最小化按钮
  184. area: ['350px', '300px'],
  185. content: url
  186. });
  187. }
  188. </script>
  189. {/eyou:eq}
  190. <p class="notic">{$vo.remark|default=''}</p>
  191. </div>
  192. </div>