goto.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. $(".banner-slider").slick({
  2. speed: 800,
  3. arrows: false,
  4. autoplay: true,
  5. });
  6. // // gototop 下滑效果
  7. $(".arrow").hide();
  8. $(window).scroll(function () {
  9. var y = window.scrollY;
  10. if (y > 10) {
  11. $(".arrow").show();
  12. } else {
  13. $(".arrow").hide();
  14. }
  15. });
  16. $(".content1-right").slick({
  17. dotsClass: 'slick-dots',
  18. dots: true,
  19. speed: 1000,
  20. arrows: false,
  21. autoplay: true,
  22. });
  23. // content輪播圖片偵測效果
  24. $(".text-1").addClass("contant-toggle");
  25. $(".content1-right").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  26. console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  27. if (nextSlide == 1) {
  28. $(".text-1").removeClass("contant-toggle");
  29. $(".text-2").addClass("contant-toggle");
  30. $(".text-3").removeClass("contant-toggle");
  31. } else if (nextSlide == 2) {
  32. $(".text-2").removeClass("contant-toggle");
  33. $(".text-1").removeClass("contant-toggle");
  34. $(".text-3").addClass("contant-toggle");
  35. } else if (nextSlide == 0) {
  36. $(".text-2").removeClass("contant-toggle");
  37. $(".text-1").addClass("contant-toggle");
  38. $(".text-3").removeClass("contant-toggle");
  39. }
  40. });
  41. // $( ".text2" ).hover( function() {
  42. // $(".content1-right").slick('slickGoTo',1);
  43. // });
  44. // $( ".text1" ).hover( function() {
  45. // $(".content1-right").slick('slickGoTo',0);
  46. // });
  47. // $( ".text3" ).hover( function() {
  48. // $(".content1-right").slick('slickGoTo',2);
  49. // });
  50. // $( ".text-2" ).hover( function() {
  51. // $(".content1-right").slick('slickGoTo',1);
  52. // });
  53. // $( ".text-1" ).hover( function() {
  54. // $(".content1-right").slick('slickGoTo',0);
  55. // });
  56. // $( ".text-3" ).hover( function() {
  57. // $(".content1-right").slick('slickGoTo',2);
  58. // });
  59. // $( ".text-2" ).click( function() {
  60. // $(".content1-right").slick('slickGoTo',1);
  61. // });
  62. // $( ".text-1" ).click( function() {
  63. // $(".content1-right").slick('slickGoTo',0);
  64. // });
  65. // $( ".text-3" ).click( function() {
  66. // $(".content1-right").slick('slickGoTo',2);
  67. // });
  68. $.fn.serializeObject = function () {
  69. var o = {};
  70. var a = this.serializeArray();
  71. o["id"] = 0;
  72. o["time_stamp"] = "";
  73. $.each(a, function () {
  74. if (o[this.name]) {
  75. if (!o[this.name].push) {
  76. o[this.name] = [o[this.name]];
  77. }
  78. o[this.name].push(this.value || '');
  79. } else {
  80. o[this.name] = this.value || '';
  81. }
  82. });
  83. return o;
  84. };
  85. $(".contact-form1").submit(function (e) {
  86. /* var formRef = $('#form1').serializeArray();
  87. var jsonString = JSON.stringify(formRef);*/
  88. var jsonInfo = $('.contact-form1').serializeObject();
  89. var jsonString = JSON.stringify(jsonInfo);
  90. console.log(jsonString);
  91. $.ajax({
  92. type: 'POST',
  93. url: 'https://go.hhh.com.tw:8002/deco_request_detail',
  94. data: jsonString,
  95. dataType: 'json',
  96. success: function (data) {
  97. console.log('送出成功: ' + data);
  98. if (data == 0) {
  99. alert("送出成功");
  100. } else if (data == 1) {
  101. alert("此email已填過表單");
  102. } else if (data == 2) {
  103. alert("此phone已填過表單");
  104. } else if (data == 3) {
  105. alert("此email、phone已填過表單");
  106. }
  107. location.href = "./index_complete_line.html";
  108. },
  109. beforeSend: function () {
  110. console.log('beforeSend');
  111. },
  112. complete: function () {
  113. console.log('complete');
  114. },
  115. error: function (jqXHR, textStatus, errorThrown) {
  116. console.log(JSON.stringify(jqXHR));
  117. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  118. console.log('送出失敗: ' + jqXHR.responseText);
  119. alert("送出失敗");
  120. }
  121. });
  122. if ($('#credit').prop("checked")) {
  123. $.ajax({
  124. type: 'POST',
  125. url: 'https://api.ptt.cx:9999/hhh/mail/deco/v2',
  126. data: jsonString,
  127. dataType: 'json',
  128. contentType: 'application/json; charset=utf-8',
  129. success: function (res) {
  130. alert('送出成功');
  131. },
  132. error: function (error) {
  133. console.error(error);
  134. alert('送出失敗');
  135. }
  136. });
  137. }
  138. return false;
  139. });
  140. // $(".contact-form1").submit(function (e) {
  141. // if ($('#credit').prop("checked")) {
  142. // $.fn.serializeObject = function () {
  143. // var o = {};
  144. // var a = this.serializeArray();
  145. // // o["id"] = 0;
  146. // // o["time_stamp"] = "";
  147. // $.each(a, function () {
  148. // if (o[this.name]) {
  149. // if (!o[this.name].push) {
  150. // o[this.name] = [o[this.name]];
  151. // }
  152. // o[this.name].push(this.value || '');
  153. // } else {
  154. // o[this.name] = this.value || '';
  155. // }
  156. // });
  157. // return o;
  158. // };
  159. // var jsonInfo = $('.contact-form1').serializeObject();
  160. // var jsonString = JSON.stringify(jsonInfo);
  161. // console.log(jsonString);
  162. // var http = new XMLHttpRequest();
  163. // var url = 'http://api.ptt.cx:9998/hhh/mail/deco/v2';
  164. // var params = '';
  165. // http.open('POST', url, true);
  166. // //Send the proper header information along with the request
  167. // http.setRequestHeader('Content-type', 'application/x-www-form-unlencoded');
  168. // http.onreadystatechange = function () {//Call a function when the state changes.
  169. // if (http.readyState == 4 && http.status == 200) {
  170. // alert(http.responseText);
  171. // }
  172. // }
  173. // http.send(params);
  174. // $.ajax({
  175. // type: 'POST',
  176. // url: 'https://api.ptt.cx:9999/hhh/mail/deco/v2',
  177. // data: jsonString,
  178. // dataType: 'json',
  179. // contentType: 'application/json; charset=utf-8',
  180. // success: function (res) {
  181. // alert('送出成功');
  182. // },
  183. // error: function (error) {
  184. // console.error(error);
  185. // alert('送出失敗');
  186. // }
  187. // });
  188. // }
  189. // return false;
  190. // });
  191. $("*").each(function (index, element) {
  192. // 此元素被點選後執行
  193. $(this).click(function (e) {
  194. // 取得被點選元素的屬性:data-gt-target
  195. var target = $(this).attr("data-gt-target");
  196. var duration = $(this).attr("data-gt-duration");
  197. var offset = $(this).attr("data-gt-offset");
  198. // JS 語法:判斷式
  199. // if (條件) {程式區塊}
  200. // 當條件成立,會執行程式區塊
  201. // 如果 目標有資料 才會執行 { } 內的程式
  202. // 避免出現 undefine (未定義 - 不存在的資料)
  203. if (target) {
  204. //console.log("目標:" + target);
  205. //console.log("時間:" + duration);
  206. //console.log("位移:" + offset);
  207. // 上方位置 = 目標區塊.位移().上方位置
  208. var top = $(target).offset().top;
  209. //console.log("要前往元素的上方位置:" + top);
  210. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  211. // parseInt() 將文字轉為數字
  212. $("html").stop().animate({
  213. scrollTop: top - offset
  214. }, parseInt(duration));
  215. }
  216. });
  217. });
  218. // 避免動畫與使用者滾輪衝突
  219. // html 在滾動滾輪時 停止 html 所有效果
  220. $("html").on("mousewheel", function () {
  221. $("html").stop();
  222. });
  223. $(document).ready(function () {
  224. $("#date").datepicker();
  225. });
  226. window.fbAsyncInit = function () {
  227. FB.init({
  228. appId: '1388696554848391', // 填入 FB APP ID
  229. cookie: true,
  230. xfbml: true,
  231. version: 'v11.0'
  232. });
  233. FB.getLoginStatus(function (response) {
  234. statusChangeCallback(response);
  235. });
  236. };
  237. // 處理各種登入身份
  238. function statusChangeCallback(response) {
  239. console.log(response);
  240. var target = document.getElementById("FB_STATUS_2"),
  241. html = "";
  242. // 登入 FB 且已加入會員
  243. if (response.status === 'connected') {
  244. html = "已登入 FB,並加入 WFU BLOG DEMO 應用程式<br/>";
  245. FB.api('/me?fields=id,name,email', function (response) {
  246. console.log('FB API回傳資料: ' + JSON.stringify(response));
  247. if (response.id) {
  248. // 設定欄位預設值
  249. document.getElementById("email").value = response.email;
  250. document.getElementById("name").value = response.name;
  251. // 隱藏FB登入按鈕
  252. document.getElementById("fb_login").style.display = 'none';
  253. }
  254. });
  255. }
  256. // 登入 FB, 未偵測到加入會員
  257. // else if (response.status === "not_authorized") {
  258. // target.innerHTML = "已登入 FB,但未加入 WFU BLOG DEMO 應用程式";
  259. // }
  260. // 未登入 FB
  261. // else {
  262. // target.innerHTML = "未登入 FB";
  263. // }
  264. }
  265. // 點擊登入
  266. $("#fb_login").click(function () {
  267. // 進行登入程序
  268. FB.login(function (response) {
  269. statusChangeCallback(response);
  270. }, {
  271. scope: 'public_profile,email'
  272. },
  273. );
  274. });
  275. // 點擊登出
  276. // $("#FB_logout").click(function() {
  277. // FB.logout(function(response) {
  278. // statusChangeCallback(response);
  279. // });
  280. // });
  281. // 載入 FB SDK
  282. (function (d, s, id) {
  283. var js, fjs = d.getElementsByTagName(s)[0];
  284. if (d.getElementById(id)) return;
  285. js = d.createElement(s);
  286. js.id = id;
  287. js.src = "https://connect.facebook.net/zh_TW/sdk.js";
  288. fjs.parentNode.insertBefore(js, fjs);
  289. }(document, 'script', 'facebook-jssdk'));
  290. $(function () {
  291. var dateToday = new Date();
  292. //jQuery datepicker 設定限制日期最小最大 minDate maxDate hideIfNoPrevNext
  293. $(".datepicker").datepicker({
  294. //顯示上個月日期 及下個月日期 ,但是不可選的。
  295. //default:false
  296. showOtherMonths: true,
  297. // 設置當沒有上一個/下一個可選擇的情況下,隱藏掉相應的按鈕。(默認為不可用)
  298. //配合有設定最大最小時使用
  299. //default:false
  300. hideIfNoPrevNext: true,
  301. minDate: dateToday,
  302. // 設置一個最大的可選日期。可以是Date對象,或者是數字(從今天算起,例如+7),
  303. //或者有效的字符串('y'代表年, 'm'代表月, 'w'代表周, 'd'代表日, 例如:'+1m +7d')。
  304. });
  305. });