goto.js 6.4 KB

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