portal html css js resource

invite-friends.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*邀请好友*/
  2. $(function(){
  3. var phoneCode = false;
  4. var ifCode = false;
  5. var ifpassword = false;
  6. var state;
  7. var inviterId = GetQueryString("professorId");
  8. var username = GetQueryString("professorName");
  9. //var inviterId="6E199CFA7B034D69A7029731B6E77D4A";
  10. //var username="特朗普";
  11. $(".inviteTit span").text(username);
  12. /*控制提示框样式*/
  13. function bombox(textt){
  14. $(".bomb-box").fadeIn("slow");
  15. $(".bomb-box").text(textt);
  16. var bombwidth = $(".bomb-box").width();
  17. $(".bomb-box").css({"marginLeft": -(bombwidth+25)/2 + "px"});
  18. setInterval (function(){
  19. $(".bomb-box").fadeOut("slow");
  20. },4000);
  21. }
  22. /*校验提交按钮显示状态*/
  23. $('.form-group').on('keyup', "#userphone,#code,#password", function() {
  24. if($("#userphone").val() == "" || $("#code").val() == "" || $("#password").val() == "") {
  25. $("#regbtn").attr("disabled",true);
  26. } else {
  27. $("#regbtn").attr("disabled",false);
  28. }
  29. });
  30. /*注册按钮*/
  31. $("#regbtn").on('click',function() {
  32. codeVal();
  33. if(ifpassword && ifCode){
  34. completeReg();
  35. }
  36. });
  37. /*点击获取验证码*/
  38. $('#obtain-code').on('click',function() {
  39. phoneVal();
  40. });
  41. /*校验手机号*/
  42. function phoneVal() {
  43. var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
  44. if(hunPhone.test($("#userphone").val())) {
  45. isReg();
  46. } else {
  47. bombox("请输入正确的手机号码");
  48. return;
  49. }
  50. }
  51. /*校验用户名是否注册*/
  52. function isReg() {
  53. $.ajax({
  54. url:"/ajax/isReg?key=" + $("#userphone").val(),
  55. dataType: 'json', //数据格式类型
  56. type: 'GET', //http请求类型
  57. timeout: 10000, //超时设置
  58. success: function(data) {
  59. if(data.data == false) {
  60. bombox("您的手机已被注册");
  61. return;
  62. } else {
  63. phoneCode = true;
  64. if(phoneCode){
  65. sendAuthentication();
  66. }
  67. }
  68. },
  69. error: function() {
  70. bombox("服务器链接超时");
  71. return;
  72. }
  73. });
  74. }
  75. /*手机发送验证码*/
  76. function sendAuthentication() {
  77. $.ajax({
  78. url:"/ajax/regmobilephone",
  79. data: {
  80. mobilePhone: $("#userphone").val()
  81. },
  82. dataType: 'json', //数据格式类型
  83. type: 'GET', //http请求类型
  84. async: false,
  85. timeout: 10000, //超时设置
  86. success: function(data) {
  87. console.log(data);
  88. if(data.success) {
  89. state = data.data;
  90. doClick();
  91. }
  92. },
  93. error: function() {
  94. bombox("服务器链接超时");
  95. return;
  96. }
  97. })
  98. }
  99. /*30s后重新获取验证码*/
  100. function doClick() {
  101. $("#obtain-code").hide();
  102. $("#getcodeoff").show();
  103. $("#getcodeoff").text("30s后重新获取");
  104. var clickTime = new Date().getTime();
  105. var Timer = setInterval(function() {
  106. var nowTime = new Date().getTime();
  107. var second = Math.ceil(30 - (nowTime - clickTime) / 1000);
  108. if(second > 0) {
  109. $("#getcodeoff").text(second + "s后重新获取");
  110. } else {
  111. clearInterval(Timer);
  112. $("#obtain-code").show();
  113. $("#getcodeoff").hide();
  114. $("#obtain-code").text("获取验证码");
  115. }
  116. }, 1000);
  117. }
  118. /*校验验证码*/
  119. function codeVal() {
  120. $.ajax({
  121. url:"/ajax/validCode",
  122. data: {
  123. "state": state,
  124. "vc": $("#code").val()
  125. },
  126. dataType: 'json', //数据格式类型
  127. async: false,
  128. type: 'POST', //http请求类型
  129. timeout: 10000, //超时设置
  130. success: function(data) {
  131. console.log(data.success);
  132. if(data.success) {
  133. if(data.data==false) {
  134. bombox("验证码不正确");
  135. return;
  136. }else{
  137. passwordVal();
  138. ifCode =true;
  139. return;
  140. }
  141. }else{
  142. console.log(data.msg);
  143. if(data.msg=="验证超时"){
  144. bombox("验证码超时");
  145. return;
  146. }else{
  147. bombox("请填写正确的手机号,验证码");
  148. return;
  149. }
  150. }
  151. },
  152. error: function() {
  153. bombox("服务器链接超时");
  154. return;
  155. }
  156. })
  157. }
  158. /*校验注册密码*/
  159. function passwordVal() {
  160. var passwordv = $("#password").val();
  161. if(passwordv.length < 6) {
  162. bombox("请输入由6-24 个字符组成,区分大小写");
  163. return;
  164. }else{
  165. ifpassword = true;
  166. return;
  167. }
  168. }
  169. //注册提交
  170. function completeReg() {
  171. $.ajax({
  172. url:"/ajax/regmobile",
  173. data: {
  174. state: state,
  175. mobilePhone: $("#userphone").val(),
  176. validateCode: $("#code").val(),
  177. password: $("#password").val(),
  178. inviterId:inviterId
  179. },
  180. dataType: 'json', //数据格式类型
  181. type: 'post', //http请求类型
  182. async: false,
  183. success: function(data) {
  184. if(data.success) {
  185. bombox("注册成功");
  186. location.href="invitSucceed.html";
  187. }
  188. },
  189. error: function() {
  190. bombox("服务器链接超时");
  191. }
  192. });
  193. }
  194. });