goto.js 5.0 KB

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