goto.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. autoplay: true,
  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. // email 格式檢查
  59. // $(document).ready(function () {
  60. // //E-MAIL格式檢查
  61. // $("body").on("change", "#email", function () {
  62. // $Emailchecking = IsEmail($("#email").val());
  63. // if ($Emailchecking == false) {
  64. // alert("請填寫正確的E-MAIL格式");
  65. // // $("#email").blur(); //離開焦點
  66. // }
  67. // })
  68. // function IsEmail(email) {
  69. // var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  70. // if (!regex.test(email)) {
  71. // return false;
  72. // } else {
  73. // // return true;
  74. // }
  75. // }
  76. // });
  77. // // phone 格式檢查
  78. // $(document).ready(function () {
  79. // // phone格式檢查
  80. // $("body").on("change", "#phone", function () {
  81. // $Phonechecking = IsPhone($("#phone").val());
  82. // if ($Phonechecking == false) {
  83. // alert("請填寫正確的手機格式");
  84. // // $("#email").blur(); //離開焦點
  85. // }
  86. // })
  87. // function IsPhone(phone) {
  88. // var regex = /^[09]{2}[0-9]{8}$/;
  89. // if (!regex.test(phone)) {
  90. // return false;
  91. // } else {
  92. // // return true;
  93. // }
  94. // }
  95. // });
  96. $(".contact-form1").submit(function (e) {
  97. /* var formRef = $('#form1').serializeArray();
  98. var jsonString = JSON.stringify(formRef);*/
  99. var jsonInfo = $('.contact-form1').serializeObject();
  100. var jsonString = JSON.stringify(jsonInfo);
  101. console.log(jsonString);
  102. $.ajax({
  103. type: 'POST',
  104. url: 'https://go.hhh.com.tw:8001/deco_request_detail',
  105. data: jsonString,
  106. dataType: 'json',
  107. success: function (data) {
  108. console.log('送出成功: ' + data);
  109. if (data == 0) {
  110. alert("送出成功");
  111. } else if (data == 1) {
  112. alert("此email已填過表單");
  113. } else if (data == 2) {
  114. alert("此phone已填過表單");
  115. } else if (data == 3) {
  116. alert("此email、phone已填過表單");
  117. }
  118. location.reload();
  119. },
  120. beforeSend: function () {
  121. console.log('beforeSend');
  122. },
  123. complete: function () {
  124. console.log('complete');
  125. },
  126. error: function (jqXHR, textStatus, errorThrown) {
  127. console.log(JSON.stringify(jqXHR));
  128. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  129. console.log('送出失敗: ' + jqXHR.responseText);
  130. alert("送出失敗");
  131. }
  132. });
  133. return false;
  134. });
  135. $("*").each(function (index, element) {
  136. // 此元素被點選後執行
  137. $(this).click(function (e) {
  138. // 取得被點選元素的屬性:data-gt-target
  139. var target = $(this).attr("data-gt-target");
  140. var duration = $(this).attr("data-gt-duration");
  141. var offset = $(this).attr("data-gt-offset");
  142. // JS 語法:判斷式
  143. // if (條件) {程式區塊}
  144. // 當條件成立,會執行程式區塊
  145. // 如果 目標有資料 才會執行 { } 內的程式
  146. // 避免出現 undefine (未定義 - 不存在的資料)
  147. if (target) {
  148. //console.log("目標:" + target);
  149. //console.log("時間:" + duration);
  150. //console.log("位移:" + offset);
  151. // 上方位置 = 目標區塊.位移().上方位置
  152. var top = $(target).offset().top;
  153. //console.log("要前往元素的上方位置:" + top);
  154. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  155. // parseInt() 將文字轉為數字
  156. $("html").stop().animate({
  157. scrollTop: top - offset
  158. }, parseInt(duration));
  159. }
  160. });
  161. });
  162. // 避免動畫與使用者滾輪衝突
  163. // html 在滾動滾輪時 停止 html 所有效果
  164. $("html").on("mousewheel", function () {
  165. $("html").stop();
  166. });
  167. $(document).ready(function () {
  168. $("#date").datepicker();
  169. });
  170. window.fbAsyncInit = function () {
  171. FB.init({
  172. appId: '1388696554848391', // 填入 FB APP ID
  173. cookie: true,
  174. xfbml: true,
  175. version: 'v11.0'
  176. });
  177. FB.getLoginStatus(function (response) {
  178. statusChangeCallback(response);
  179. });
  180. };
  181. // 處理各種登入身份
  182. function statusChangeCallback(response) {
  183. console.log(response);
  184. var target = document.getElementById("FB_STATUS_2"),
  185. html = "";
  186. // 登入 FB 且已加入會員
  187. if (response.status === 'connected') {
  188. html = "已登入 FB,並加入 WFU BLOG DEMO 應用程式<br/>";
  189. FB.api('/me?fields=id,name,email', function (response) {
  190. console.log('FB API回傳資料: ' + JSON.stringify(response));
  191. if (response.id) {
  192. // 設定欄位預設值
  193. document.getElementById("email").value = response.email;
  194. document.getElementById("name").value = response.name;
  195. // 隱藏FB登入按鈕
  196. document.getElementById("fb_login").style.display = 'none';
  197. }
  198. });
  199. }
  200. // 登入 FB, 未偵測到加入會員
  201. else if (response.status === "not_authorized") {
  202. target.innerHTML = "已登入 FB,但未加入 WFU BLOG DEMO 應用程式";
  203. }
  204. // 未登入 FB
  205. // else {
  206. // target.innerHTML = "未登入 FB";
  207. // }
  208. }
  209. // 點擊登入
  210. $("#fb_login").click(function () {
  211. // 進行登入程序
  212. FB.login(function (response) {
  213. statusChangeCallback(response);
  214. }, {
  215. scope: 'public_profile,email'
  216. },
  217. );
  218. });
  219. // 點擊登出
  220. // $("#FB_logout").click(function() {
  221. // FB.logout(function(response) {
  222. // statusChangeCallback(response);
  223. // });
  224. // });
  225. // 載入 FB SDK
  226. (function (d, s, id) {
  227. var js, fjs = d.getElementsByTagName(s)[0];
  228. if (d.getElementById(id)) return;
  229. js = d.createElement(s);
  230. js.id = id;
  231. js.src = "https://connect.facebook.net/zh_TW/sdk.js";
  232. fjs.parentNode.insertBefore(js, fjs);
  233. }(document, 'script', 'facebook-jssdk'));