goto.js 11 KB

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