login.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. let url = window.location.search;
  22. var theRequest = new Object();
  23. if (url.indexOf("?") != -1) {
  24. var str = url.substr(1);
  25. strs = str.split("&");
  26. for (var i = 0; i < strs.length; i++) {
  27. theRequest[strs[i].split("=")[0]] = unescape(decodeURI(strs[i].split("=")[1]));
  28. }
  29. }
  30. var lastTouchEnd = 0;
  31. document.addEventListener('touchend', function (event) {
  32. var now = (new Date()).getTime();
  33. if (now - lastTouchEnd <= 300) {
  34. event.preventDefault();
  35. }
  36. lastTouchEnd = now;
  37. }, false);
  38. $("#Goregister").on("click", function () {
  39. window.location.href = "register.html";
  40. })
  41. var timer = null;
  42. function publicBox(publicText) {
  43. $(".AlertBox").show();
  44. $(".AlertBoxChilds").html(publicText);
  45. timer = setInterval(function () {
  46. $(".AlertBox").hide();
  47. }, 2000)
  48. }
  49. function publicBoxBack(publicText) {
  50. $(".AlertBox").show();
  51. $(".AlertBoxChilds").html(publicText);
  52. timer = setInterval(function () {
  53. $(".AlertBox").hide();
  54. // window.history.back();
  55. $(location).attr("href", 'index.html');
  56. // if (theRequest.type1 == undefined && theRequest.m3u8 == undefined) {
  57. // window.location.href = theRequest.sta;
  58. // } else if (theRequest.m3u8 != undefined) {
  59. // window.location.href = theRequest.sta + "?m3u8=" + theRequest.m3u8;
  60. // } else {
  61. // window.location.href = theRequest.sta + "?type1=" + theRequest.type1;
  62. // }
  63. }, 2000)
  64. }
  65. $(".LoginBtn").on("click", function () {
  66. clearInterval(timer);
  67. var languageParameter = localStorage.getItem('language') || 'CN';
  68. if ( languageParameter == 'CN') {
  69. if ($("#account").val() == "") {
  70. publicBox("請填寫帳號");
  71. } else if ($("#password").val() == "") {
  72. publicBox("請填寫密碼");
  73. } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) {
  74. publicBox("賬號格式錯誤");
  75. } else if (!/^\d{6}$/.test($("#password").val())) {
  76. publicBox("密碼格式錯誤");
  77. } else {
  78. $.ajax({
  79. type: "post",
  80. url: "https://www.bibidd.com/bibidd/usertest/slUserLogin",
  81. dataType: "json",
  82. data: {
  83. account: $("#account").val(),
  84. password: $("#password").val()
  85. },
  86. success: function (res) {
  87. if (res.code == "200") {
  88. localStorage.setItem("uid", res.user_id);
  89. localStorage.setItem("username", $("#account").val());
  90. publicBoxBack("登錄成功")
  91. } else if (res.code == "201") {
  92. publicBox("賬號和密碼不匹配")
  93. } else if (res.code == "202") {
  94. publicBox("參數不正確");
  95. } else if (res.code == "203") {
  96. publicBox("該帳戶未註冊");
  97. }
  98. }
  99. })
  100. }
  101. }else{
  102. if ($("#account").val() == "") {
  103. publicBox("Please fill in the account number");
  104. } else if ($("#password").val() == "") {
  105. publicBox("Please fill in the password")
  106. } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) {
  107. publicBox("Account format error")
  108. } else if (!/^\d{6}$/.test($("#password").val())) {
  109. publicBox("Wrong password format");
  110. } else {
  111. $.ajax({
  112. type: "post",
  113. url: "https://www.bibidd.com/bibidd/usertest/slUserLogin",
  114. dataType: "json",
  115. data: {
  116. account: $("#account").val(),
  117. password: $("#password").val()
  118. },
  119. success: function (res) {
  120. if (res.code == "200") {
  121. localStorage.setItem("uid", res.user_id);
  122. localStorage.setItem("username", $("#account").val());
  123. publicBoxBack("Login successful")
  124. } else if (res.code == "201") {
  125. publicBox("Account and password do not match")
  126. } else if (res.code == "202") {
  127. publicBox("Incorrect parameters");
  128. } else if (res.code == "203") {
  129. publicBox("The account is not registered");
  130. }
  131. }
  132. })
  133. }
  134. }
  135. })
  136. function LanguageSwitching() {
  137. var languageParameter = localStorage.getItem('language') || 'CN';
  138. if ( languageParameter == 'CN') {
  139. // 切换中文语言
  140. $('.LoginTitle').text(' 登錄 ');
  141. $('#account').attr('placeholder','長度 8-12位數字+字母');
  142. $('#password').attr('placeholder','密碼(6位數字密碼)');
  143. $('.registerShuoming').text('請牢記賬號密碼,丟失將無法找回');
  144. $('.LoginBtn').text('登錄');
  145. $('.LoginTextLeft').text('沒有帳號?');
  146. $('.LoginTextRight').text('註冊');
  147. }else if (!languageParameter || languageParameter == 'EN'){
  148. // 切换英文语言
  149. $('.LoginTitle').text(' Sign In ');
  150. $('#account').attr('Length 8-12 digits + letters');
  151. $('#password').attr('Password (6-digit password)');
  152. $('.LoginBtn').text('Sign In');
  153. $('.LoginTextLeft').text('Don’t have account? ');
  154. $('.LoginTextRight').text('Sign Up');
  155. }
  156. }
  157. })