goto.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. $(".banner-slider").slick({
  2. speed: 1000,
  3. swipe: true,
  4. arrows: false,
  5. autoplay: true,
  6. });
  7. $(".content1-right").slick({
  8. dotsClass: 'slick-dots',
  9. dots: true,
  10. speed: 1000,
  11. arrows: false,
  12. });
  13. // // gototop 下滑效果
  14. $(".arrow").hide();
  15. $(window).scroll(function () {
  16. var y = window.scrollY;
  17. if (y > 10) {
  18. $(".arrow").show();
  19. } else {
  20. $(".arrow").hide();
  21. }
  22. });
  23. // content輪播圖片偵測效果
  24. $(".text-1").addClass("contant-toggle");
  25. $(".content1-right").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  26. console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  27. if (nextSlide == 1) {
  28. $(".text-1").removeClass("contant-toggle");
  29. $(".text-2").addClass("contant-toggle");
  30. $(".text-3").removeClass("contant-toggle");
  31. } else if (nextSlide == 2) {
  32. $(".text-2").removeClass("contant-toggle");
  33. $(".text-1").removeClass("contant-toggle");
  34. $(".text-3").addClass("contant-toggle");
  35. } else if (nextSlide == 0) {
  36. $(".text-2").removeClass("contant-toggle");
  37. $(".text-1").addClass("contant-toggle");
  38. $(".text-3").removeClass("contant-toggle");
  39. }
  40. });
  41. $.fn.serializeObject = function () {
  42. var o = {};
  43. var a = this.serializeArray();
  44. o["id"] = 0;
  45. o["time_stamp"] = "";
  46. $.each(a, function () {
  47. if (o[this.name]) {
  48. if (!o[this.name].push) {
  49. o[this.name] = [o[this.name]];
  50. }
  51. o[this.name].push(this.value || '');
  52. } else {
  53. o[this.name] = this.value || '';
  54. }
  55. });
  56. return o;
  57. };
  58. $(".contact-form1").submit(function (e) {
  59. /* var formRef = $('#form1').serializeArray();
  60. var jsonString = JSON.stringify(formRef);*/
  61. var jsonInfo = $('.contact-form1').serializeObject();
  62. var jsonString = JSON.stringify(jsonInfo);
  63. console.log(jsonString);
  64. $.ajax({
  65. type: 'POST',
  66. url: 'https://go.hhh.com.tw:8001/deco_request_detail',
  67. data: jsonString,
  68. dataType: 'json',
  69. success: function (data) {
  70. console.log('送出成功: ' + data);
  71. if (data == 0) {
  72. alert("送出成功");
  73. } else if (data == 1) {
  74. alert("此email已填過表單");
  75. } else if (data == 2) {
  76. alert("此phone已填過表單");
  77. } else if (data == 3) {
  78. alert("此email、phone已填過表單");
  79. }
  80. location.reload();
  81. },
  82. beforeSend: function () {
  83. console.log('beforeSend');
  84. },
  85. complete: function () {
  86. console.log('complete');
  87. },
  88. error: function (jqXHR, textStatus, errorThrown) {
  89. console.log(JSON.stringify(jqXHR));
  90. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  91. console.log('送出失敗: ' + jqXHR.responseText);
  92. alert("送出失敗");
  93. }
  94. });
  95. return false;
  96. });
  97. $("*").each(function (index, element) {
  98. // 此元素被點選後執行
  99. $(this).click(function (e) {
  100. // 取得被點選元素的屬性:data-gt-target
  101. var target = $(this).attr("data-gt-target");
  102. var duration = $(this).attr("data-gt-duration");
  103. var offset = $(this).attr("data-gt-offset");
  104. // JS 語法:判斷式
  105. // if (條件) {程式區塊}
  106. // 當條件成立,會執行程式區塊
  107. // 如果 目標有資料 才會執行 { } 內的程式
  108. // 避免出現 undefine (未定義 - 不存在的資料)
  109. if (target) {
  110. //console.log("目標:" + target);
  111. //console.log("時間:" + duration);
  112. //console.log("位移:" + offset);
  113. // 上方位置 = 目標區塊.位移().上方位置
  114. var top = $(target).offset().top;
  115. //console.log("要前往元素的上方位置:" + top);
  116. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  117. // parseInt() 將文字轉為數字
  118. $("html").stop().animate({
  119. scrollTop: top - offset
  120. }, parseInt(duration));
  121. }
  122. });
  123. });
  124. // 避免動畫與使用者滾輪衝突
  125. // html 在滾動滾輪時 停止 html 所有效果
  126. $("html").on("mousewheel", function () {
  127. $("html").stop();
  128. });
  129. $(document).ready(function () {
  130. $("#date").datepicker();
  131. });
  132. window.fbAsyncInit = function () {
  133. FB.init({
  134. appId: '1388696554848391', // 填入 FB APP ID
  135. cookie: true,
  136. xfbml: true,
  137. version: 'v11.0'
  138. });
  139. FB.getLoginStatus(function (response) {
  140. statusChangeCallback(response);
  141. });
  142. };
  143. // 處理各種登入身份
  144. function statusChangeCallback(response) {
  145. console.log(response);
  146. var target = document.getElementById("FB_STATUS_2"),
  147. html = "";
  148. // 登入 FB 且已加入會員
  149. if (response.status === 'connected') {
  150. html = "已登入 FB,並加入 WFU BLOG DEMO 應用程式<br/>";
  151. FB.api('/me?fields=id,name,email', function (response) {
  152. console.log('FB API回傳資料: ' + JSON.stringify(response));
  153. if (response.id) {
  154. // 設定欄位預設值
  155. document.getElementById("email").value = response.email;
  156. document.getElementById("name").value = response.name;
  157. // 隱藏FB登入按鈕
  158. document.getElementById("fb_login").style.display = 'none';
  159. }
  160. });
  161. }
  162. // 登入 FB, 未偵測到加入會員
  163. else if (response.status === "not_authorized") {
  164. target.innerHTML = "已登入 FB,但未加入 WFU BLOG DEMO 應用程式";
  165. }
  166. // 未登入 FB
  167. // else {
  168. // target.innerHTML = "未登入 FB";
  169. // }
  170. }
  171. // 點擊登入
  172. $("#fb_login").click(function () {
  173. // 進行登入程序
  174. FB.login(function (response) {
  175. statusChangeCallback(response);
  176. }, {
  177. scope: 'public_profile,email'
  178. },
  179. );
  180. });
  181. // 點擊登出
  182. // $("#FB_logout").click(function() {
  183. // FB.logout(function(response) {
  184. // statusChangeCallback(response);
  185. // });
  186. // });
  187. // 載入 FB SDK
  188. (function (d, s, id) {
  189. var js, fjs = d.getElementsByTagName(s)[0];
  190. if (d.getElementById(id)) return;
  191. js = d.createElement(s);
  192. js.id = id;
  193. js.src = "https://connect.facebook.net/zh_TW/sdk.js";
  194. fjs.parentNode.insertBefore(js, fjs);
  195. }(document, 'script', 'facebook-jssdk'));