goto.js 5.2 KB

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