portal html css js resource

inviteAuthor.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. (function($) {
  2. $(document).ready(function() {
  3. var state;
  4. function Init() {
  5. this.id = s64to16(GetQueryString("i"));
  6. if(GetQueryString("d")) {
  7. this.inviteId =s64to16(GetQueryString("d"));
  8. }else{
  9. this.inviteId ="";
  10. }
  11. this.flag = GetQueryString("f");
  12. this.passCode=false;
  13. this.ajax({
  14. url: (this.flag)?"/ajax/ppaper/qo":"/ajax/ppatent/qo",
  15. obj: {
  16. "id":this.id
  17. },
  18. type: "get",
  19. status:true,
  20. oFun: this.title
  21. });
  22. this.bindEvent(this);
  23. }
  24. Init.prototype.ajax = function(objec) {
  25. $.ajax({
  26. url: objec.url,
  27. data: objec.obj,
  28. dataType: 'json', //服务器返回json格式数据
  29. type: objec.type, //HTTP请求类型
  30. timeout: 10000, //超时时间设置为10秒;
  31. async:objec.status,
  32. traditional: true,
  33. success: function(data) {
  34. objec.oFun(data);
  35. },
  36. error: function(e) {
  37. console.log(e);
  38. bombox("服务器链接超时");
  39. return;
  40. }
  41. });
  42. }
  43. Init.prototype.title = function($data) {
  44. console.log($data);
  45. if($data.success) {
  46. $(".formTit").html("《"+$data.data.name+"》")
  47. }
  48. console.log($data);
  49. }
  50. Init.prototype.sendAuthentication = function($data) {
  51. if($data.success) {
  52. state = $data.data;
  53. doClick();
  54. }
  55. }
  56. Init.prototype.code = function(data) {
  57. if(data.success) {
  58. if(data.data==false) {
  59. bombox("验证码错误,请检查后重新输入");
  60. return;
  61. }else{
  62. init.passCode=true;
  63. return;
  64. }
  65. }else{
  66. if(data.msg=="验证超时"){
  67. bombox("验证码已过期,请重新获取");
  68. return;
  69. }else{
  70. bombox("请填写正确的手机号,验证码");
  71. return;
  72. }
  73. }
  74. }
  75. Init.prototype.completeReg = function(data) {
  76. if (data.success) {
  77. if(init.flag) {
  78. location.href="../ekexiu/InviteResult.html?flag=1&code="+data.data
  79. }else{
  80. location.href="../ekexiu/InviteResult.html?code="+data.data
  81. }
  82. }
  83. }
  84. Init.prototype.bindEvent = function(sel) {
  85. /*校验提交按钮显示状态*/
  86. $('.form-group').on('keyup', "#userphone,#code,#username", function() {
  87. if($("#userphone").val() == "" || $("#code").val() == "" || $("#username").val() == "") {
  88. $("#regbtn").attr("disabled", true);
  89. } else {
  90. $("#regbtn").attr("disabled", false);
  91. }
  92. });
  93. /*注册按钮*/
  94. $("#regbtn").on('click', function() {
  95. var oStringLength = $("#username").val().length;
  96. if(oStringLength > 10) {
  97. bombox("请输入您的真实姓名");
  98. return;
  99. }
  100. sel.ajax({
  101. url: "/ajax/validCode",
  102. obj: {
  103. "state": state,
  104. "vc": $("#code").val()
  105. },
  106. status:false,
  107. type: "post",
  108. oFun: sel.code
  109. });
  110. if(sel.passCode) {
  111. sel.ajax({
  112. url: (sel.flag)?"/ajax/regAndAssPaper":"/ajax/regAndAssPatent",
  113. obj: (sel.flag)?{
  114. "state":state,
  115. "vc":$("#code").val(),
  116. "phone":$("#userphone").val(),
  117. "inviterId":sel.inviteId,
  118. "name":$("#username").val(),
  119. "paper":sel.id
  120. }:{
  121. "state":state,
  122. "vc":$("#code").val(),
  123. "phone":$("#userphone").val(),
  124. "inviterId":sel.inviteId,
  125. "name":$("#username").val(),
  126. "patent":sel.id
  127. },
  128. status:true,
  129. type: "post",
  130. oFun: sel.completeReg
  131. });
  132. }
  133. });
  134. /*点击获取验证码*/
  135. $('#obtain-code').on('click', function() {
  136. var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
  137. if(hunPhone.test($("#userphone").val())) {
  138. sel.ajax({
  139. url: "/ajax/phoneValidCode",
  140. obj: {
  141. "phone":$("#userphone").val(),
  142. },
  143. status:true,
  144. type: "get",
  145. oFun: sel.sendAuthentication
  146. });
  147. } else {
  148. bombox("请输入正确的手机号码");
  149. return;
  150. }
  151. });
  152. }
  153. /*控制提示框样式*/
  154. function bombox(textt) {
  155. $(".bomb-box").fadeIn("slow");
  156. $(".bomb-box").text(textt);
  157. var bombwidth = $(".bomb-box").width();
  158. $(".bomb-box").css({
  159. "marginLeft": -(bombwidth + 25) / 2 + "px"
  160. });
  161. setTimeout(function() {
  162. $(".bomb-box").fadeOut("slow");
  163. }, 4000);
  164. }
  165. /*30s后重新获取验证码*/
  166. function doClick() {
  167. $("#obtain-code").attr("disabled",true);
  168. $("#obtain-code").text("60s后重新获取");
  169. var clickTime = new Date().getTime();
  170. var Timer = setInterval(function() {
  171. var nowTime = new Date().getTime();
  172. var second = Math.ceil(60 - (nowTime - clickTime) / 1000);
  173. if(second > 0) {
  174. $("#obtain-code").text(second + "s后重新获取");
  175. } else {
  176. clearInterval(Timer);
  177. $("#obtain-code").attr("disabled",false);
  178. $("#obtain-code").text("获取验证码");
  179. }
  180. }, 1000);
  181. }
  182. var init=new Init();
  183. })
  184. })(jQuery);