goto.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. function onClik() {
  75. /* var formRef = $('#form1').serializeArray();
  76. var jsonString = JSON.stringify(formRef);*/
  77. var jsonInfo = $('.contact-form1').serializeObject();
  78. var jsonString = JSON.stringify(jsonInfo);
  79. alert(jsonString);
  80. console.log(jsonString);
  81. // $.ajax({
  82. // type: 'POST',
  83. // url: 'http://172.105.205.52:8001/deco_request_detail',
  84. // data: jsonString,
  85. // dataType: 'json',
  86. // success: function (data, textStatus, jqXHR) {
  87. // alert("送出成功");
  88. // },
  89. // complete: function () {
  90. // alert("complete");
  91. // },
  92. // beforeSend: function () {
  93. // alert("beforeSend");
  94. // },
  95. // error: function (jqXHR, textStatus, errorThrown) {
  96. // alert("送出失敗");
  97. // }
  98. // });
  99. // return false;
  100. $.ajax({
  101. url:'http://172.105.205.52:8001/deco_request_detail',
  102. type: 'POST', // http method
  103. data:jsonString, // data to submit
  104. dataType: 'json',
  105. success: function (res) {
  106. console.log(res);
  107. alert("送出成功");
  108. },
  109. error: function (err) {
  110. console.log(err);
  111. alert("送出失敗");
  112. }
  113. });
  114. }
  115. $("*").each(function (index, element) {
  116. // 此元素被點選後執行
  117. $(this).click(function (e) {
  118. // 取得被點選元素的屬性:data-gt-target
  119. var target = $(this).attr("data-gt-target");
  120. var duration = $(this).attr("data-gt-duration");
  121. var offset = $(this).attr("data-gt-offset");
  122. // JS 語法:判斷式
  123. // if (條件) {程式區塊}
  124. // 當條件成立,會執行程式區塊
  125. // 如果 目標有資料 才會執行 { } 內的程式
  126. // 避免出現 undefine (未定義 - 不存在的資料)
  127. if (target) {
  128. //console.log("目標:" + target);
  129. //console.log("時間:" + duration);
  130. //console.log("位移:" + offset);
  131. // 上方位置 = 目標區塊.位移().上方位置
  132. var top = $(target).offset().top;
  133. //console.log("要前往元素的上方位置:" + top);
  134. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  135. // parseInt() 將文字轉為數字
  136. $("html").stop().animate({
  137. scrollTop: top - offset
  138. }, parseInt(duration));
  139. }
  140. });
  141. });
  142. // 避免動畫與使用者滾輪衝突
  143. // html 在滾動滾輪時 停止 html 所有效果
  144. $("html").on("mousewheel", function () {
  145. $("html").stop();
  146. });