goto.js 6.6 KB

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