goto.js 9.9 KB

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