goto.js 11 KB

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