goto.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. $(".banner-slider").slick({
  2. speed: 1000,
  3. swipe: true,
  4. arrows: false,
  5. });
  6. $(".content1-right").slick({
  7. dotsClass: 'slick-dots',
  8. dots: true,
  9. speed: 1000,
  10. arrows: false,
  11. });
  12. // banner輪播效果
  13. // $(".banner-slider").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  14. // console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  15. // if (nextSlide == 1) {
  16. // $("#animation2").addClass("animation-h1");
  17. // $("#btn-animation2").addClass("animation-btn");
  18. // $("#animation1").removeClass("animation-h1");
  19. // $("#btn-animation1").removeClass("animation-btn");
  20. // $("#animation3").removeClass("animation-h1");
  21. // $("#btn-animation3").removeClass("animation-btn");
  22. // }
  23. // else if (nextSlide == 2) {
  24. // $("#animation3").addClass("animation-h1");
  25. // $("#btn-animation3").addClass("animation-btn");
  26. // $("#animation1").removeClass("animation-h1");
  27. // $("#btn-animation1").removeClass("animation-btn");
  28. // $("#animation2").removeClass("animation-h1");
  29. // $("#btn-animation2").removeClass("animation-btn");
  30. // }else if (nextSlide == 0) {
  31. // $("#animation1").addClass("animation-h1");
  32. // $("#btn-animation1").addClass("animation-btn");
  33. // $("#animation2").removeClass("animation-h1");
  34. // $("#btn-animation2").removeClass("animation-btn");
  35. // $("#animation3").removeClass("animation-h1");
  36. // $("#btn-animation3").removeClass("animation-btn");
  37. // }
  38. // });
  39. // content輪播圖片偵測效果
  40. $(".text-1").addClass("contant-toggle");
  41. $(".content1-right").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  42. console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  43. if (nextSlide == 1) {
  44. $(".text-1").removeClass("contant-toggle");
  45. $(".text-2").addClass("contant-toggle");
  46. $(".text-3").removeClass("contant-toggle");
  47. } else if (nextSlide == 2) {
  48. $(".text-2").removeClass("contant-toggle");
  49. $(".text-1").removeClass("contant-toggle");
  50. $(".text-3").addClass("contant-toggle");
  51. } else if (nextSlide == 0) {
  52. $(".text-2").removeClass("contant-toggle");
  53. $(".text-1").addClass("contant-toggle");
  54. $(".text-3").removeClass("contant-toggle");
  55. }
  56. });
  57. $.fn.serializeObject = function () {
  58. var o = {};
  59. var a = this.serializeArray();
  60. o["id"] = 0;
  61. o["time_stamp"] = "";
  62. $.each(a, function () {
  63. if (o[this.name]) {
  64. if (!o[this.name].push) {
  65. o[this.name] = [o[this.name]];
  66. }
  67. o[this.name].push(this.value || '');
  68. } else {
  69. o[this.name] = this.value || '';
  70. }
  71. });
  72. return o;
  73. };
  74. $(".contact-form1").submit(function (e) {
  75. /* var formRef = $('#form1').serializeArray();
  76. var jsonString = JSON.stringify(formRef);*/
  77. var jsonInfo = $('.contact-form1').serializeObject();
  78. var jsonString = JSON.stringify(jsonInfo);
  79. // email 格式檢查
  80. $(document).ready(function () {
  81. //E-MAIL格式檢查
  82. $("body").on("change", "#email", function () {
  83. $Emailchecking = IsEmail($("#email").val());
  84. if ($Emailchecking == false) {
  85. alert("請填寫正確的E-MAIL格式");
  86. // $("#email").blur(); //離開焦點
  87. }
  88. })
  89. function IsEmail(email) {
  90. var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  91. if (!regex.test(email)) {
  92. return false;
  93. } else {
  94. return true;
  95. }
  96. }
  97. });
  98. $(document).ready(function () {
  99. //E-MAIL格式檢查
  100. $("body").on("change", "#phone", function () {
  101. $Phonechecking = IsPhone($("#phone").val());
  102. if ($Phonechecking == false) {
  103. alert("請填寫正確的手機格式");
  104. // $("#email").blur(); //離開焦點
  105. }
  106. })
  107. function IsPhone(phone) {
  108. var regex = /^[0-9]+$/;
  109. if (!regex.test(phone)) {
  110. return false;
  111. } else {
  112. return true;
  113. }
  114. }
  115. });
  116. $.ajax({
  117. type: 'POST',
  118. url: 'https://go.hhh.com.tw:8001/deco_request_detail',
  119. data: jsonString,
  120. dataType: 'json',
  121. success: function (data) {
  122. console.log('送出成功: ' + data);
  123. if (data == 0) {
  124. alert("送出成功");
  125. } else if (data == 1) {
  126. alert("此email已填過表單");
  127. } else if (data == 2) {
  128. alert("此phone已填過表單");
  129. } else if (data == 3) {
  130. alert("此email、phone已填過表單");
  131. }
  132. },
  133. beforeSend: function () {
  134. console.log('beforeSend');
  135. },
  136. complete: function () {
  137. console.log('complete');
  138. },
  139. error: function (jqXHR, textStatus, errorThrown) {
  140. console.log(JSON.stringify(jqXHR));
  141. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  142. console.log('送出失敗: ' + jqXHR.responseText);
  143. }
  144. });
  145. return false;
  146. });
  147. $("*").each(function (index, element) {
  148. // 此元素被點選後執行
  149. $(this).click(function (e) {
  150. // 取得被點選元素的屬性:data-gt-target
  151. var target = $(this).attr("data-gt-target");
  152. var duration = $(this).attr("data-gt-duration");
  153. var offset = $(this).attr("data-gt-offset");
  154. // JS 語法:判斷式
  155. // if (條件) {程式區塊}
  156. // 當條件成立,會執行程式區塊
  157. // 如果 目標有資料 才會執行 { } 內的程式
  158. // 避免出現 undefine (未定義 - 不存在的資料)
  159. if (target) {
  160. //console.log("目標:" + target);
  161. //console.log("時間:" + duration);
  162. //console.log("位移:" + offset);
  163. // 上方位置 = 目標區塊.位移().上方位置
  164. var top = $(target).offset().top;
  165. //console.log("要前往元素的上方位置:" + top);
  166. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  167. // parseInt() 將文字轉為數字
  168. $("html").stop().animate({
  169. scrollTop: top - offset
  170. }, parseInt(duration));
  171. }
  172. });
  173. });
  174. // 避免動畫與使用者滾輪衝突
  175. // html 在滾動滾輪時 停止 html 所有效果
  176. $("html").on("mousewheel", function () {
  177. $("html").stop();
  178. });