Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

users_reg_field.htm 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. {eyou:volist name="$users_para" id="vo"}
  2. {eyou:switch name="vo.dtype"}
  3. {eyou:case value="hidden"}
  4. <!-- 隐藏域 start -->
  5. <div class="form-group" style="display: none;">
  6. <div class="row">
  7. <div class="ey-form-file-title col-md-3"></div>
  8. <div class="col-md-9">
  9. <input type="hidden" class="input-txt" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}">
  10. </div>
  11. </div>
  12. </div>
  13. <!-- 隐藏域 start -->
  14. {/eyou:case}
  15. {eyou:case value="mobile"}
  16. <!-- 手机文本框 start -->
  17. <div class="wx-form-group">
  18. <input type="text" class="wx-form-control" required id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" maxlength="11" value="{$vo.dfvalue|default=''}" placeholder="{$vo.title}">
  19. </div>
  20. {eyou:if condition="isset($usersConfig['users_verification']) && 3 == $usersConfig['users_verification']"}
  21. <div class="wx-form-group">
  22. <div class="field">
  23. <input type="hidden" name="__mobile_1_token__" value="{$Request.token.__mobile_1_token__}" />
  24. <input type="text" class="wx-form-control" id="{$vo.fieldArr}_{$vo.name|default=''}_code" name="{$vo.fieldArr}[{$vo.name|default=''}_code]" placeholder="手机验证码" autocomplete="off">
  25. <input type="button" id="{$vo.fieldArr}_{$vo.name|default=''}_button" onclick="get_{$vo.fieldArr}{$vo.name|default=''}_code();" class="sento" value="获取验证码"/>
  26. </div>
  27. </div>
  28. <script type="text/javascript">
  29. function get_{$vo.fieldArr}{$vo.name|default=''}_code() {
  30. var mobile = $("#{$vo.fieldArr}_{$vo.name|default=''}").val();
  31. // 手机号是否为空
  32. if (!mobile) {
  33. $("#{$vo.fieldArr}_{$vo.name|default=''}").focus();
  34. layer.msg('请输入{$vo.title}!', {time: 1500});
  35. return false;
  36. }
  37. // 手机格式不正确
  38. var reg = /^1[0-9]{10}$/i;
  39. if (!reg.test(mobile)) {
  40. $("#{$vo.fieldArr}_{$vo.name|default=''}").focus();
  41. layer.msg('请输入正确的{$vo.title}!', {time: 1500});
  42. return false;
  43. }
  44. // 设置为不可点击
  45. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('获取中…').attr('disabled', 'disabled');
  46. var __mobile_1_token__ = $('input[name=__mobile_1_token__]').val();
  47. $.ajax({
  48. url: "{eyou:url link='api/Ajax/SendMobileCode' /}",
  49. data: {type:'reg', mobile:mobile, is_mobile:true, title:'账号注册', source:0, __mobile_1_token__:__mobile_1_token__},
  50. type:'post',
  51. dataType:'json',
  52. success:function(res){
  53. if (res.code == 1) {
  54. {$vo.fieldArr}{$vo.name|default=''}_countdown();
  55. layer.msg(res.msg, {time: 1500});
  56. } else {
  57. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('获取验证码').removeAttr("disabled");
  58. layer.alert(res.msg, {icon: 2, title: false, closeBtn: 0});
  59. }
  60. },
  61. error : function() {
  62. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('获取验证码').removeAttr("disabled");
  63. layer.alert('发送失败,请尝试重新发送!', {icon: 5, title: false, closeBtn: 0});
  64. }
  65. });
  66. }
  67. function {$vo.fieldArr}{$vo.name|default=''}_countdown(){
  68. // 倒计时
  69. var setTime;
  70. var time = 120;
  71. setTime = setInterval(function() {
  72. if(0 >= time) {
  73. clearInterval(setTime);
  74. return false;
  75. }
  76. time--;
  77. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val(time + '秒').attr('disabled', 'disabled');
  78. if(time == 0) $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('获取验证码').removeAttr("disabled");
  79. }, 1000);
  80. }
  81. </script>
  82. {/eyou:if}
  83. <!-- 手机文本框 end -->
  84. {/eyou:case}
  85. {eyou:case value="email"}
  86. <!-- 邮箱文本框 start -->
  87. <div class="wx-form-group">
  88. <input type="text" class="wx-form-control" required id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}" placeholder="{$vo.title}" >
  89. </div>
  90. {eyou:if condition="isset($usersConfig['users_verification']) && 2 == $usersConfig['users_verification']"}
  91. <div class="wx-form-group">
  92. <div class="field">
  93. <input type="text" class="wx-form-control" id="{$vo.fieldArr}_{$vo.name|default=''}_code" name="{$vo.fieldArr}[{$vo.name|default=''}_code]" value="" placeholder="邮箱验证码">
  94. <input type="button" id="{$vo.fieldArr}_{$vo.name|default=''}_button" onclick="get_{$vo.fieldArr}{$vo.name|default=''}_code();" class="sento" value="点击发送" />
  95. </div>
  96. </div>
  97. <script type="text/javascript">
  98. function get_{$vo.fieldArr}{$vo.name|default=''}_code(){
  99. var email = $("#{$vo.fieldArr}_{$vo.name|default=''}").val();
  100. var reg = /^[a-z0-9]([a-z0-9\\.]*[-_]{0,4}?[a-z0-9-_\\.]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+([\.][\w_-]+){1,5}$/i;
  101. // 邮箱格式不正确
  102. if(!reg.test(email)){
  103. layer.msg('请正确输入邮箱地址!', {time: 1500});
  104. return false;
  105. }
  106. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('发送中…');
  107. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").attr('disabled', 'disabled');
  108. $.ajax({
  109. // async:false,
  110. url: "{eyou:url link='user/Smtpmail/send_email' /}",
  111. data: {type:'reg',email:email,title:'账号注册',scene:2},
  112. type:'post',
  113. dataType:'json',
  114. success:function(res){
  115. if(res.code == 1){
  116. {$vo.fieldArr}{$vo.name|default=''}_countdown();
  117. layer.msg(res.msg, {time: 1500});
  118. }else{
  119. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('点击发送');
  120. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").removeAttr("disabled");
  121. showErrorAlert(res.msg);
  122. }
  123. },
  124. error : function(e) {
  125. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('点击发送');
  126. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").removeAttr("disabled");
  127. showErrorAlert(e.responseText);
  128. }
  129. });
  130. }
  131. function {$vo.fieldArr}{$vo.name|default=''}_countdown(){
  132. // 倒计时
  133. var setTime;
  134. var time = {php}echo config('global.email_send_time');{/php};
  135. setTime = setInterval(function(){
  136. if(0 >= time){
  137. clearInterval(setTime);
  138. return;
  139. }
  140. time--;
  141. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val(time+'秒');
  142. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").attr('disabled', 'disabled');
  143. if(time == 0){
  144. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").val('点击发送');
  145. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").removeAttr("disabled");
  146. }
  147. },1000);
  148. }
  149. </script>
  150. {/eyou:if}
  151. <!-- 邮箱文本框 end -->
  152. {/eyou:case}
  153. {/eyou:switch}
  154. {/eyou:volist}