portal html css js resource

invite-friends.js 5.0KB

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