星火官网,前端页面(前台)
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 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. $(function () {
  2. // $(".header_root").load("./comm/header.html");
  3. $(".footer_root").load("./comm/footer.html");
  4. // nav传值显示下划线
  5. // $(".header_root").data("nav_info", 4);
  6. $(".err_account").hide();
  7. $(".err_phone").hide();
  8. $(".err_mailbox").hide();
  9. //姓名
  10. $("#account").blur(() => {
  11. let name = $("#account").val();
  12. if (!name) {
  13. $(".err_account").show();
  14. }
  15. });
  16. $("#account").focus(() => {
  17. $(".err_account").hide();
  18. });
  19. //联系电话
  20. $("#phone").blur(() => {
  21. let phone = $("#phone").val();
  22. if (!phone) {
  23. $(".err_phone").show();
  24. }
  25. });
  26. $("#phone").focus(() => {
  27. $(".err_phone").hide();
  28. });
  29. var mailboxf = true;
  30. //邮箱
  31. $("#mailbox").blur(() => {
  32. let mailbox = $("#mailbox").val();
  33. mailboxf = false;
  34. var filter =
  35. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  36. let blnTest = filter.test(mailbox);
  37. if (mailbox && !blnTest) {
  38. $(".err_mailbox").show();
  39. mailboxf = true;
  40. }
  41. });
  42. $("#mailbox").focus(() => {
  43. $(".err_mailbox").hide();
  44. });
  45. $("#mailbox").bind("input propertychange change", function (event) {
  46. let mailbox = $("#mailbox").val();
  47. mailboxf = false;
  48. var filter =
  49. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  50. let blnTest = filter.test(mailbox);
  51. if (mailbox && !blnTest) {
  52. $(".err_mailbox").show();
  53. mailboxf = true;
  54. } else {
  55. $(".err_mailbox").hide();
  56. }
  57. });
  58. //提交
  59. var Loading = false;
  60. $(".btn").click(() => {
  61. if (Loading) {
  62. return;
  63. }
  64. let name = $("#account").val();
  65. if (!name) {
  66. $(".err_account").show();
  67. return;
  68. }
  69. let phone = $("#phone").val();
  70. if (!phone) {
  71. $(".err_phone").show();
  72. return;
  73. }
  74. if (mailboxf) {
  75. //邮箱不合法
  76. return;
  77. }
  78. var data = {
  79. account: $("#account").val(),
  80. phone: $("#phone").val(),
  81. mailbox: $("#mailbox").val(),
  82. comm: $("#comm").val()
  83. };
  84. Loading = true;
  85. //7.1.2 申请试用--添加
  86. $.ajax({
  87. type: "POST",
  88. url: $.baseUrl + "fc/add",
  89. dataType: "json",
  90. async: false,
  91. data: JSON.stringify(data),
  92. contentType: "application/json; charset=utf-8",
  93. success: function (data) {
  94. Loading = false;
  95. if (data.code === 0) {
  96. alert("申请成功");
  97. $("#account").val("");
  98. $("#phone").val("");
  99. $("#mailbox").val("");
  100. $("#comm").val("");
  101. $(".err_account").hide();
  102. $(".err_phone").hide();
  103. $(".err_mailbox").hide();
  104. } else {
  105. alert(data.msg);
  106. }
  107. }
  108. });
  109. });
  110. });