goto.js 11 KB

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