goto.js 6.4 KB

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