register.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. $(document).ready(function () {
  2. LanguageSwitching();
  3. var timer = null;
  4. timer = setInterval(function () {
  5. $(".zhedang").hide();
  6. }, 400)
  7. document.addEventListener('gesturestart', function (e) {
  8. e.preventDefault();
  9. });
  10. document.addEventListener('dblclick', function (e) {
  11. e.preventDefault();
  12. });
  13. document.addEventListener('touchstart', function (event) {
  14. if (event.touches.length > 1) {
  15. event.preventDefault();
  16. }
  17. });
  18. $(".SLdetaileHeaderImg").on("click", function () {
  19. window.history.back();
  20. })
  21. var lastTouchEnd = 0;
  22. document.addEventListener('touchend', function (event) {
  23. var now = (new Date()).getTime();
  24. if (now - lastTouchEnd <= 300) {
  25. event.preventDefault();
  26. }
  27. lastTouchEnd = now;
  28. }, false);
  29. var timer = null;
  30. function publicBox(publicText) {
  31. $(".AlertBox").show();
  32. $(".AlertBoxChilds").html(publicText);
  33. timer = setInterval(function () {
  34. $(".AlertBox").hide();
  35. }, 2000)
  36. }
  37. function publicBoxBack(publicText) {
  38. $(".AlertBox").show();
  39. $(".AlertBoxChilds").html(publicText);
  40. timer = setInterval(function () {
  41. $(".AlertBox").hide();
  42. // window.history.back();
  43. $(location).attr("href", 'blogin.html');
  44. }, 2000)
  45. }
  46. $(".registerShuomingBackBtn").on("click", function () {
  47. $(location).attr("href", 'blogin.html');
  48. })
  49. $(".LoginBtn").on("click", function () {
  50. clearInterval(timer)
  51. var languageParameter = localStorage.getItem('language') || 'CN';
  52. if(languageParameter === 'CN') {
  53. if ($("#account").val() == "") {
  54. publicBox("請填寫帳戶");
  55. } else if ($("#password").val() == "") {
  56. publicBox("請填寫密碼");
  57. } else if ($("#repeatpassword").val() == "") {
  58. publicBox("請重複密碼");
  59. } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) {
  60. publicBox("賬號格式錯誤");
  61. } else if ($("#password").val() != $("#repeatpassword").val()) {
  62. publicBox("兩次密碼不一致");
  63. } else if (!/^\d{6}$/.test($("#repeatpassword").val())) {
  64. publicBox("密碼格式錯誤");
  65. } else if (!/^\d{6}$/.test($("#password").val())) {
  66. publicBox("密碼格式錯誤");
  67. } else {
  68. $.ajax({
  69. type: "post",
  70. url: "https://www.bibidd.com/bibidd/usertest/slUserRegister",
  71. dataType: "json",
  72. data: {
  73. account: $("#account").val(),
  74. password: $("#password").val()
  75. },
  76. success: function (res) {
  77. if (res.code == "200") {
  78. publicBoxBack("已成功註冊")
  79. } else if (res.code == "201") {
  80. publicBox("註冊失敗。 請重試");
  81. } else if (res.code == "202") {
  82. publicBox("參數不正確");
  83. } else if (res.code == "203") {
  84. publicBox("該帳戶已註冊");
  85. }
  86. }
  87. })
  88. }
  89. }else{
  90. if ($("#account").val() == "") {
  91. publicBox("Please fill in the account number");
  92. } else if ($("#password").val() == "") {
  93. publicBox("Please fill in the password");
  94. } else if ($("#repeatpassword").val() == "") {
  95. publicBox("Please repeat the password");
  96. } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) {
  97. publicBox("Account format error");
  98. } else if ($("#password").val() != $("#repeatpassword").val()) {
  99. publicBox("The two passwords do not match");
  100. } else if (!/^\d{6}$/.test($("#repeatpassword").val())) {
  101. publicBox("Wrong password format");
  102. } else if (!/^\d{6}$/.test($("#password").val())) {
  103. publicBox("Wrong password format");
  104. } else {
  105. $.ajax({
  106. type: "post",
  107. url: "https://www.bibidd.com/bibidd/usertest/slUserRegister",
  108. dataType: "json",
  109. data: {
  110. account: $("#account").val(),
  111. password: $("#password").val()
  112. },
  113. success: function (res) {
  114. if (res.code == "200") {
  115. publicBoxBack("Registered successfully")
  116. } else {
  117. publicBox("Account format error or password format error");
  118. }
  119. return
  120. if (res.code == "200") {
  121. publicBoxBack("Registered successfully")
  122. } else if (res.code == "201") {
  123. publicBox("Registration failed. Please try again");
  124. } else if (res.code == "202") {
  125. publicBox("Incorrect parameters");
  126. } else if (res.code == "203") {
  127. publicBox("The account has already been registered");
  128. }
  129. }
  130. })
  131. }
  132. }
  133. })
  134. function LanguageSwitching() {
  135. var languageParameter = localStorage.getItem('language') || 'CN';
  136. if ( languageParameter == 'CN') {
  137. // 切换中文语言
  138. $('.LoginTitle').text(' 註冊 ');
  139. $('#account').attr('placeholder','長度 8-12位數字+字母');
  140. $('#password').attr('placeholder','密碼(6位密碼)');
  141. $('#repeatpassword').attr('placeholder','重複密碼(6位密碼)');
  142. $('.registerShuoming').text('請牢記賬號密碼,丟失將無法找回');
  143. $('.LoginBtn').text('創建帳戶');
  144. $('.registerShuomingBackText').text('已有帳戶?');
  145. $('.registerShuomingBackBtn').text('登錄');
  146. }else if (!languageParameter || languageParameter == 'EN'){
  147. // 切换英文语言
  148. $('.LoginTitle').text(' Sign Up ');
  149. $('#account').attr('Length 8-12 digits + letters');
  150. $('#password').attr('Password (6 digit password)');
  151. $('#repeatpassword').attr('Repeat password (6 digit password)');
  152. $('.registerShuoming').text('Please keep in mind the account password, you can not find it if you lose');
  153. $('.LoginBtn').text('Creat Account');
  154. $('.registerShuomingBackText').text('Already have an account? ');
  155. $('.registerShuomingBackBtn').text('Sign In');
  156. }
  157. }
  158. })