portal html css js resource

invite-friends.js 4.9KB

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