portal html css js resource

invite-friends.js 5.3KB

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