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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. //邮箱
  30. $("#mailbox").blur(() => {
  31. let mailbox = $("#mailbox").val();
  32. var filter =
  33. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  34. let blnTest = filter.test(mailbox);
  35. console.log(mailbox);
  36. if (mailbox && !blnTest) {
  37. $(".err_mailbox").show();
  38. }
  39. });
  40. $("#mailbox").focus(() => {
  41. $(".err_mailbox").hide();
  42. });
  43. $("#mailbox").bind("input propertychange change", function (event) {
  44. let mailbox = $("#mailbox").val();
  45. var filter =
  46. /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
  47. let blnTest = filter.test(mailbox);
  48. if (mailbox && !blnTest) {
  49. $(".err_mailbox").show();
  50. } else {
  51. $(".err_mailbox").hide();
  52. }
  53. });
  54. //提交
  55. var Loading = false;
  56. $(".btn").click(() => {
  57. if (Loading) {
  58. return;
  59. }
  60. let name = $("#account").val();
  61. if (!name) {
  62. $(".err_account").show();
  63. return;
  64. }
  65. let phone = $("#phone").val();
  66. if (!phone) {
  67. $(".err_phone").show();
  68. return;
  69. }
  70. var data = {
  71. account: $("#account").val(),
  72. phone: $("#phone").val(),
  73. mailbox: $("#mailbox").val(),
  74. commcomm: $("#comm").val()
  75. };
  76. Loading = true;
  77. //7.1.2 申请试用--添加
  78. $.ajax({
  79. type: "POST",
  80. url: $.baseUrl + "fc/add",
  81. dataType: "json",
  82. async: false,
  83. data: JSON.stringify(data),
  84. contentType: "application/json; charset=utf-8",
  85. success: function (data) {
  86. Loading = false;
  87. if (data.code === 0) {
  88. alert("申请成功");
  89. } else {
  90. alert(data.msg);
  91. }
  92. }
  93. });
  94. });
  95. });