register.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. $(function () {
  2. //查看技淘网协议
  3. var hht = $(window).height();
  4. $('.login_').height(hht);
  5. //登陆
  6. var hht = $(window).height();
  7. $('.login').hide();
  8. //点击账号后面那个×,清空账号
  9. $(".log_del").click(function () {
  10. $("#username").focus().val("").css('color','#666');
  11. });
  12. $("#register").click(function () {
  13. $(".registered").css('display','block')
  14. });
  15. $("#registeredClose").click(function () {
  16. $(".registered").css('display','none')
  17. });
  18. //手机号码
  19. let oldPhoto='';
  20. var phopoVal=[];
  21. $('#photo').attr('disabled', true);
  22. function photo1() {
  23. var pho_pattern = /^1[2|3|4|5|6|7|8|9][0-9]{9}$/;
  24. $("#usePhoto").keyup(function () {
  25. oldPhoto = $(this).val();
  26. if (pho_pattern.test(oldPhoto)) {
  27. tipFun.call(this,false,'')
  28. $('#photo').attr('disabled', false);
  29. $("#photo").css("color", "#F18101");
  30. } else {
  31. tipFun.call(this,true,'请填写正确的手机号码')
  32. $('#photo').attr('disabled', true);
  33. $("#photo").css("color", "#ccc");
  34. }
  35. });
  36. $("#usePhoto").blur(function(){
  37. if (pho_pattern.test(oldPhoto)) {
  38. tipFun.call(this,false,'')
  39. } else {
  40. tipFun.call(this,true,'请填写正确的手机号码')
  41. }
  42. })
  43. }
  44. photo1();
  45. //手机验证码
  46. function photo_num() {
  47. $('#photo_num').blur(function () {
  48. var phoa = $(this).val().trim();
  49. if (phoa == '') {
  50. tipFun.call(this,true,'验证码不能为空')
  51. }else{
  52. tipFun.call(this,false,'')
  53. }
  54. })
  55. }
  56. photo_num();
  57. /*失去焦点处理 */
  58. blurFun();
  59. /* 提示框函数处理 */
  60. function tipFun(state,txt){
  61. let _this=this;
  62. if(state){
  63. $(_this).siblings('.Tips').text(txt);
  64. $(_this).siblings('.Tips').addClass('active')
  65. }else{
  66. $(_this).siblings('.Tips').text('');
  67. $(_this).siblings('.Tips').removeClass('active')
  68. }
  69. }
  70. function blurFun(){
  71. $('#username').blur(function(){
  72. if(!$(this).val().trim()){
  73. tipFun.call(this,true,'请填写用户名')
  74. }else {
  75. tipFun.call(this,false,'')
  76. }
  77. })
  78. $('#userpassword').blur(function () {
  79. var pass_pattern = /^[a-zA-Z\d_]{6,12}$/;
  80. var pass1 = $(this).val().trim();
  81. var tt = $('#userpassword2').val().trim();
  82. if (!pass1|| !(pass_pattern.test(pass1))) {
  83. tipFun.call(this,true,'请输入6-12位数的密码')
  84. }else if(pass1===tt){
  85. tipFun.call($('#userpassword2'),false,'');
  86. }else{
  87. tipFun.call(this,false,'')
  88. tipFun.call($('#userpassword2'),true,'两次密码不一致');
  89. }
  90. });
  91. $('#customerName').blur(function(){
  92. if(!$(this).val().trim()){
  93. tipFun.call(this,true,'请填写客户名称')
  94. }else{
  95. tipFun.call(this,false,'')
  96. }
  97. });
  98. $('#userpassword2').blur(function () {
  99. var orepeat = $(this).val();
  100. var passw = $('#userpassword').val();
  101. if (passw !== orepeat || passw == '') {
  102. tipFun.call(this,true,'两次密码不一致')
  103. }else{
  104. tipFun.call(this,false,'')
  105. }
  106. });
  107. }
  108. function initVal(){
  109. $('#protocol').prop("checked", false)
  110. $(this).prop('checked', false)
  111. $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
  112. $('.sub').attr('disabled', true)
  113. $('.sub').css({
  114. background: '#CCCCCC',
  115. border: 'none'
  116. })
  117. }
  118. //表单提交
  119. if(window.location.search.indexOf('code')>-1){
  120. let code = (window.location.search).split('=');
  121. $('#beInviteCode').val(code[1]);
  122. }
  123. $("#form_register").submit(function (e) {
  124. e.preventDefault();
  125. var user = $("#username").val(),
  126. usePhoto = $('#usePhoto').val(),
  127. password1 = $("#userpassword").val(),
  128. password2 = $("#userpassword2").val();
  129. if(!usePhoto){
  130. tipFun.call($('#usePhoto'),true,'手机号码不能为空.')
  131. return ;
  132. }
  133. if(!password1){
  134. tipFun.call($('#userpassword'),true,'密码不能为空.')
  135. return ;
  136. }
  137. if(password1!==password2){
  138. tipFun.call($('#userpassword2'),true,'两次密码不一致');
  139. return;
  140. };
  141. if(!user){
  142. tipFun.call($('#username'),true,'昵称不能为空');
  143. return;
  144. };
  145. alert("恭喜您!注册成功");
  146. $("#username").val('')
  147. $("#usePhoto").val('')
  148. $("#userpassword").val('')
  149. $("#userpassword2").val('')
  150. $(".registered").css('display','none')
  151. })
  152. agreement();
  153. function agreement(){
  154. $('.head_login_').click(function(){
  155. $('.login_').show();
  156. })
  157. $('.login_close_').click(function(){
  158. $('.login_').hide();
  159. })
  160. }
  161. var tt = 30;
  162. $('#photo').click(function () {
  163. phopoVal=[];
  164. var ophoto = $('#usePhoto').val().trim();
  165. if (ophoto) {
  166. phopoVal.push(ophoto);
  167. $.ajax({
  168. type: "GET",
  169. url: globalConfig.context + "/open/getMCode",
  170. data: {
  171. "mobile": ophoto,
  172. "sign": false,
  173. },
  174. success: function (data) {
  175. if (data.error && data.error.length) {
  176. msg(data.error[0].message);
  177. } else {
  178. //验证码倒计时
  179. $('#photo').attr('disabled', true);
  180. var timer = setInterval(function () {
  181. tt -= 1;
  182. $('#photo').val("发送" + '(' + tt + 's' + ')');
  183. $('#photo').css({
  184. color: '#cccccc'
  185. })
  186. if (tt == 0) {
  187. clearInterval(timer);
  188. $('#photo').attr('disabled', false);
  189. tt = 30;
  190. $('#photo').css({
  191. color: '#f18101'
  192. })
  193. $('#photo').val('重新发送');
  194. }
  195. }.bind(this), 1000);
  196. msg('发送成功');
  197. }
  198. return true;
  199. }
  200. });
  201. } else {
  202. msg('请填写手机号码!');
  203. }
  204. });
  205. //提示框渐隐函数
  206. function msg(mess) {
  207. if($('.smg').hasClass('active')){
  208. return ;
  209. }
  210. $('.smg').addClass('active')
  211. $('#msg').val(mess);
  212. setTimeout(function () {
  213. $('.smg').removeClass('active')
  214. $('#msg').val('');
  215. }, 2000)
  216. }
  217. //注册 底部图片处理
  218. footerImg()
  219. function footerImg(){
  220. $('.cont_left img').css('display','none');
  221. $('.cont_center img').css('display','none');
  222. $('.cont_left div').css('display','block');
  223. $('.cont_center div').css('display','block');
  224. }
  225. });