星火官网,前端页面(前台)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trial.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. $(function () {
  2. $(".header_root").load("./comm/header.html");
  3. $(".footer_root").load("./comm/footer.html");
  4. $(".err_account").hide();
  5. $(".err_phone").hide();
  6. $(".err_mailbox").hide();
  7. //姓名
  8. $("#account").blur(() => {
  9. let name = $("#account").val();
  10. if (!name) {
  11. $(".err_account").show();
  12. }
  13. });
  14. $("#account").focus(() => {
  15. $(".err_account").hide();
  16. });
  17. //联系电话
  18. $("#phone").blur(() => {
  19. let phone = $("#phone").val();
  20. if (!phone) {
  21. $(".err_phone").show();
  22. }
  23. });
  24. $("#phone").focus(() => {
  25. $(".err_phone").hide();
  26. });
  27. //邮箱
  28. $("#mailbox").blur(() => {
  29. let mailbox = $("#mailbox").val();
  30. var filter =
  31. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  32. let blnTest = filter.test(mailbox);
  33. if (!blnTest) {
  34. $(".err_mailbox").show();
  35. }
  36. });
  37. $("#mailbox").focus(() => {
  38. $(".err_mailbox").hide();
  39. });
  40. $("#mailbox").bind("input propertychange change", function (event) {
  41. let mailbox = $("#mailbox").val();
  42. var filter =
  43. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  44. let blnTest = filter.test(mailbox);
  45. if (!blnTest) {
  46. $(".err_mailbox").show();
  47. } else {
  48. $(".err_mailbox").hide();
  49. }
  50. });
  51. //提交
  52. var Loading = false;
  53. $(".btn").click(() => {
  54. if (Loading) {
  55. return;
  56. }
  57. let name = $("#account").val();
  58. if (!name) {
  59. $(".err_account").show();
  60. return;
  61. }
  62. let phone = $("#phone").val();
  63. if (!phone) {
  64. $(".err_phone").show();
  65. return;
  66. }
  67. var data = {
  68. account: $("#account").val(),
  69. phone: $("#phone").val(),
  70. mailbox: $("#mailbox").val(),
  71. commcomm: $("#comm").val()
  72. };
  73. Loading = true;
  74. //7.1.2 申请试用--添加
  75. $.ajax({
  76. type: "POST",
  77. url: $.baseUrl + "fc/add",
  78. dataType: "json",
  79. async: false,
  80. data: JSON.stringify(data),
  81. contentType: "application/json; charset=utf-8",
  82. success: function (data) {
  83. Loading = false;
  84. if (data.code === 0) {
  85. alert("申请成功");
  86. } else {
  87. alert(data.msg);
  88. }
  89. }
  90. });
  91. });
  92. $(".header_root").load("./comm/header.html");
  93. $(".footer_root").load("./comm/footer.html");
  94. $(".err_account").hide();
  95. $(".err_phone").hide();
  96. $(".err_mailbox").hide();
  97. //姓名
  98. $("#account").blur(() => {
  99. let name = $("#account").val();
  100. if (!name) {
  101. $(".err_account").show();
  102. }
  103. });
  104. $("#account").focus(() => {
  105. $(".err_account").hide();
  106. });
  107. //联系电话
  108. $("#phone").blur(() => {
  109. let phone = $("#phone").val();
  110. if (!phone) {
  111. $(".err_phone").show();
  112. }
  113. });
  114. $("#phone").focus(() => {
  115. $(".err_phone").hide();
  116. });
  117. //邮箱
  118. $("#mailbox").blur(() => {
  119. let mailbox = $("#mailbox").val();
  120. var filter =
  121. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  122. let blnTest = filter.test(mailbox);
  123. if (!blnTest) {
  124. $(".err_mailbox").show();
  125. }
  126. });
  127. $("#mailbox").focus(() => {
  128. $(".err_mailbox").hide();
  129. });
  130. $("#mailbox").bind("input propertychange change", function (event) {
  131. let mailbox = $("#mailbox").val();
  132. var filter =
  133. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  134. let blnTest = filter.test(mailbox);
  135. if (!blnTest) {
  136. $(".err_mailbox").show();
  137. } else {
  138. $(".err_mailbox").hide();
  139. }
  140. });
  141. //提交
  142. var Loading = false;
  143. $(".btn").click(() => {
  144. if (Loading) {
  145. return;
  146. }
  147. let name = $("#account").val();
  148. if (!name) {
  149. $(".err_account").show();
  150. return;
  151. }
  152. let phone = $("#phone").val();
  153. if (!phone) {
  154. $(".err_phone").show();
  155. return;
  156. }
  157. var data = {
  158. account: $("#account").val(),
  159. phone: $("#phone").val(),
  160. mailbox: $("#mailbox").val(),
  161. commcomm: $("#comm").val()
  162. };
  163. Loading = true;
  164. //7.1.2 申请试用--添加
  165. $.ajax({
  166. type: "POST",
  167. url: $.baseUrl + "fc/add",
  168. dataType: "json",
  169. async: false,
  170. data: JSON.stringify(data),
  171. contentType: "application/json; charset=utf-8",
  172. success: function (data) {
  173. Loading = false;
  174. if (data.code === 0) {
  175. alert("申请成功");
  176. } else {
  177. alert(data.msg);
  178. }
  179. }
  180. });
  181. });
  182. });