goto.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // menu彈跳視窗
  2. $("#menu-box2").hide();
  3. $("#menu-box").hide();
  4. $("#menu-btn1").click(function () {
  5. $("#menu-box").slideToggle("slow");
  6. $("#menu-box2").slideToggle("slow");
  7. });
  8. $(".link").click(function () {
  9. $("#menu-box").slideUp("slow", function () {
  10. $("#menu-box2").slideUp("slow");
  11. // Animation complete.
  12. });
  13. });
  14. $(".feedback-slider1").slick({
  15. dots: true,
  16. dotsClass: 'slick-dots',
  17. speed: 1000,
  18. swipe: true,
  19. arrows: false,
  20. });
  21. $(".banner-slider").slick({
  22. dots: true,
  23. dotsClass: 'slick-dots',
  24. speed: 1000,
  25. autoplay: true,
  26. });
  27. $.fn.serializeObject = function () {
  28. var o = {};
  29. var a = this.serializeArray();
  30. o["id"] = 0;
  31. o["time_stamp"] = "";
  32. $.each(a, function () {
  33. if (o[this.name]) {
  34. if (!o[this.name].push) {
  35. o[this.name] = [o[this.name]];
  36. }
  37. o[this.name].push(this.value || '');
  38. } else {
  39. o[this.name] = this.value || '';
  40. }
  41. });
  42. return o;
  43. };
  44. $(".contact-form1").submit(function (e) {
  45. /* var formRef = $('#form1').serializeArray();
  46. var jsonString = JSON.stringify(formRef);*/
  47. var jsonInfo = $('.contact-form1').serializeObject();
  48. var jsonString = JSON.stringify(jsonInfo);
  49. console.log(jsonString);
  50. $.ajax({
  51. type: 'POST',
  52. url: 'https://go.hhh.com.tw:8002/deco_request_detail',
  53. data: jsonString,
  54. dataType: 'json',
  55. async: false,
  56. success: function (data) {
  57. console.log('送出成功: ' + data);
  58. if (data == 0) {
  59. alert("送出成功");
  60. } else if (data == 1) {
  61. alert("此email已填過表單");
  62. } else if (data == 2) {
  63. alert("此phone已填過表單");
  64. } else if (data == 3) {
  65. alert("此email、phone已填過表單");
  66. }
  67. location.href ="./index_complete_line.html";
  68. },
  69. beforeSend: function () {
  70. console.log('beforeSend');
  71. },
  72. complete: function () {
  73. console.log('complete');
  74. },
  75. error: function (jqXHR, textStatus, errorThrown) {
  76. console.log(JSON.stringify(jqXHR));
  77. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  78. console.log('送出失敗: ' + jqXHR.responseText);
  79. }
  80. });
  81. if ($('#credit').prop("checked")) {
  82. $.ajax({
  83. type: 'POST',
  84. url: 'https://api.ptt.cx:9999/hhh/mail/deco/v2',
  85. data: jsonString,
  86. dataType: 'json',
  87. contentType: 'application/json; charset=utf-8',
  88. success: function (res) {
  89. alert('送出成功');
  90. },
  91. error: function (error) {
  92. console.error(error);
  93. alert('送出失敗');
  94. }
  95. });
  96. }
  97. return false;
  98. });
  99. $("*").each(function (index, element) {
  100. // 此元素被點選後執行
  101. $(this).click(function (e) {
  102. // 取得被點選元素的屬性:data-gt-target
  103. var target = $(this).attr("data-gt-target");
  104. var duration = $(this).attr("data-gt-duration");
  105. var offset = $(this).attr("data-gt-offset");
  106. // JS 語法:判斷式
  107. // if (條件) {程式區塊}
  108. // 當條件成立,會執行程式區塊
  109. // 如果 目標有資料 才會執行 { } 內的程式
  110. // 避免出現 undefine (未定義 - 不存在的資料)
  111. if (target) {
  112. //console.log("目標:" + target);
  113. //console.log("時間:" + duration);
  114. //console.log("位移:" + offset);
  115. // 上方位置 = 目標區塊.位移().上方位置
  116. var top = $(target).offset().top;
  117. //console.log("要前往元素的上方位置:" + top);
  118. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  119. // parseInt() 將文字轉為數字
  120. $("html").stop().animate({
  121. scrollTop: top - offset
  122. }, parseInt(duration));
  123. }
  124. });
  125. });
  126. // 避免動畫與使用者滾輪衝突
  127. // html 在滾動滾輪時 停止 html 所有效果
  128. $("html").on("mousewheel", function () {
  129. $("html").stop();
  130. });
  131. $(document).ready(function () {
  132. $("#date").datepicker();
  133. });
  134. // // gototop 下滑效果
  135. $(".arrow").hide();
  136. $(window).scroll(function(){
  137. var y = window.scrollY;
  138. if(y>10){
  139. $(".arrow").show();
  140. }else{
  141. $(".arrow").hide();
  142. }
  143. });
  144. window.fbAsyncInit = function () {
  145. FB.init({
  146. appId: '1388696554848391', // 填入 FB APP ID
  147. cookie: true,
  148. xfbml: true,
  149. version: 'v11.0'
  150. });
  151. FB.getLoginStatus(function (response) {
  152. statusChangeCallback(response);
  153. });
  154. };
  155. // 處理各種登入身份
  156. function statusChangeCallback(response) {
  157. console.log(response);
  158. var target = document.getElementById("FB_STATUS_2"),
  159. html = "";
  160. // 登入 FB 且已加入會員
  161. if (response.status === 'connected') {
  162. html = "已登入 FB,並加入 WFU BLOG DEMO 應用程式<br/>";
  163. FB.api('/me?fields=id,name,email', function (response) {
  164. console.log('FB API回傳資料: ' + JSON.stringify(response));
  165. if (response.id) {
  166. // 設定欄位預設值
  167. document.getElementById("email").value = response.email;
  168. document.getElementById("name").value = response.name;
  169. // 隱藏FB登入按鈕
  170. document.getElementById("fb_login").style.display = 'none';
  171. }
  172. });
  173. }
  174. // 登入 FB, 未偵測到加入會員
  175. // else if (response.status === "not_authorized") {
  176. // target.innerHTML = "已登入 FB,但未加入 WFU BLOG DEMO 應用程式";
  177. // }
  178. // 未登入 FB
  179. // else {
  180. // target.innerHTML = "未登入 FB";
  181. // }
  182. }
  183. // 點擊登入
  184. $("#fb_login").click(function () {
  185. // 進行登入程序
  186. FB.login(function (response) {
  187. statusChangeCallback(response);
  188. }, {
  189. scope: 'public_profile,email'
  190. },
  191. );
  192. });
  193. // 點擊登出
  194. // $("#FB_logout").click(function() {
  195. // FB.logout(function(response) {
  196. // statusChangeCallback(response);
  197. // });
  198. // });
  199. // 載入 FB SDK
  200. (function (d, s, id) {
  201. var js, fjs = d.getElementsByTagName(s)[0];
  202. if (d.getElementById(id)) return;
  203. js = d.createElement(s);
  204. js.id = id;
  205. js.src = "https://connect.facebook.net/zh_TW/sdk.js";
  206. fjs.parentNode.insertBefore(js, fjs);
  207. }(document, 'script', 'facebook-jssdk'));
  208. $(function() {
  209. var dateToday = new Date();
  210. //jQuery datepicker 設定限制日期最小最大 minDate maxDate hideIfNoPrevNext
  211. $(".datepicker").datepicker({
  212. //顯示上個月日期 及下個月日期 ,但是不可選的。
  213. //default:false
  214. showOtherMonths : true,
  215. // 設置當沒有上一個/下一個可選擇的情況下,隱藏掉相應的按鈕。(默認為不可用)
  216. //配合有設定最大最小時使用
  217. //default:false
  218. hideIfNoPrevNext : true,
  219. minDate : dateToday ,
  220. // 設置一個最大的可選日期。可以是Date對象,或者是數字(從今天算起,例如+7),
  221. //或者有效的字符串('y'代表年, 'm'代表月, 'w'代表周, 'd'代表日, 例如:'+1m +7d')。
  222. });
  223. });