goto.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. $("*").each(function (index, element) {
  2. // 此元素被點選後執行
  3. $(this).click(function (e) {
  4. // 取得被點選元素的屬性:data-gt-target
  5. var target = $(this).attr("data-gt-target");
  6. var duration = $(this).attr("data-gt-duration");
  7. var offset = $(this).attr("data-gt-offset");
  8. // JS 語法:判斷式
  9. // if (條件) {程式區塊}
  10. // 當條件成立,會執行程式區塊
  11. // 如果 目標有資料 才會執行 { } 內的程式
  12. // 避免出現 undefine (未定義 - 不存在的資料)
  13. if (target) {
  14. //console.log("目標:" + target);
  15. //console.log("時間:" + duration);
  16. //console.log("位移:" + offset);
  17. // 上方位置 = 目標區塊.位移().上方位置
  18. var top = $(target).offset().top;
  19. //console.log("要前往元素的上方位置:" + top);
  20. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  21. // parseInt() 將文字轉為數字
  22. $("html").stop().animate({
  23. scrollTop: top - offset
  24. }, parseInt(duration));
  25. }
  26. });
  27. });
  28. // 避免動畫與使用者滾輪衝突
  29. // html 在滾動滾輪時 停止 html 所有效果
  30. $("html").on("mousewheel", function () {
  31. $("html").stop();
  32. });
  33. // gotop下滑效果
  34. $(".arrow").hide();
  35. $(window).scroll(function () {
  36. var y = window.scrollY;
  37. if (y > 500) {
  38. $(".arrow").show();
  39. } else {
  40. $(".arrow").hide();
  41. }
  42. });
  43. console.log(28);
  44. // $('.nav-item2').click(function(){
  45. // $(this).toggleClass('after-nav')
  46. // })
  47. // function funcTest2() {
  48. // $.ajax({
  49. // method: "GET",
  50. // url: "designer4.json",
  51. // dataType: "json",
  52. // })
  53. // .done(function (msg) {
  54. // var desBanner = '';
  55. // var MobBanner = '';
  56. // var bodyBannerDes = '';
  57. // console.log(msg);
  58. // var res = msg.length;
  59. // console.log(res);
  60. // const limit = res;
  61. // var arrIndex = Math.floor(Math.random() * msg.length);
  62. // console.log(arrIndex);
  63. // console.log(msg[arrIndex].Designerimg);
  64. // desBanner += ' \
  65. // <div class="banner-des row vertical align-items-end px-0 mx-0">\
  66. // <div class="banner-0 col-0 order-1 col-lg-5 order-1 pe-0">\
  67. // <img class="img-fluid" src="./img/banner/bannertitle.png" alt="">\
  68. // </div>\
  69. // <div class="banner-1 col-5 order-3 col-lg-5 order-2 text-white text-end py-3">\
  70. // <a style="text-decoration: none;color:#fff;" href="./about/index.html?id='+ msg[arrIndex].id + '"><div class="banner1-1" style="font-weight: 900;">' + msg[arrIndex].WorkName + '</div>\
  71. // <p><span class="fs-5">'+ msg[arrIndex].DesignerName + '</span>設計師</p>\
  72. // </a>\
  73. // <button type="button" class="btn border border-white"><a target="_blank" href="tel: '+ msg[arrIndex].TollFreeCall + '"><img class="" src="img/002-phone-call.svg" alt=""></a>\</button>\
  74. // <button type="button" class="btn border border-white" data-bs-toggle="modal" data-bs-target="#exampleModal"><img class="" src="img/001-blogging.svg" alt=""></button>\
  75. // </div>\
  76. // <div class="banner-2 col-7 order-2 col-lg-2 order-3 px-0 mx-0">\
  77. // <a class="desbutton" data-info="'+ msg[arrIndex].id + '" href="./about/index.html?id='+ msg[arrIndex].id + '"><img class="img-fluid" src="' + msg[arrIndex].Designerimg + '" alt=""></a>\
  78. // </div>\
  79. // </div>';
  80. // MobBanner += ' \
  81. // <div class="banner-m row vertical align-items-end px-0 mx-0">\
  82. // <div class="bannerm-0 col-12 my-5 px-0">\
  83. // <img class="img-fluid" src="./img/banner/banner-mobile.png" alt="">\
  84. // </div>\
  85. // <div class="bannerm-2 col-7 order-2 col-lg-2 order-3 px-0 mx-0">\
  86. // <a href="./about/index.html?id='+ msg[arrIndex].id + '"><img class="img-fluid" src="' + msg[arrIndex].Designerimg + '" alt=""></a>\
  87. // </div>\
  88. // <div class="bannerm-1 col-5 order-3 col-lg-5 order-2 text-white text-start pb-3">\
  89. // <a style="text-decoration: none;color:#fff;" href="./about/index.html?id='+ msg[arrIndex].id + '">\
  90. // <div class="banner1-1 pt-3 pb-4" style="font-weight: 900;">'+ msg[arrIndex].WorkName + '</div>\
  91. // <p class=""><span class="fs-5">'+ msg[arrIndex].DesignerName + '</span>設計師</p>\
  92. // </a>\
  93. // <button type="button" class="btn border border-white"><a target="_blank" href="tel: '+ msg[arrIndex].TollFreeCall + '"><img class="" src="img/002-phone-call.svg" alt=""></a>\</button>\
  94. // <button type="button" class="btn border border-white" data-bs-toggle="modal" data-bs-target="#exampleModal"><img class="" src="img/001-blogging.svg" alt=""></button>\
  95. // </div>\
  96. // </div > ';
  97. // bodyBannerDes += ' \
  98. // <img class="banner-img img-fluid" id="img_id" src="'+ msg[arrIndex].workimg[0].img + '" alt="">\
  99. // ';
  100. // $('.banner-des').html(desBanner);
  101. // $('.banner-m').html(MobBanner);
  102. // $('#bannerdes-img').html(bodyBannerDes);
  103. // // var test = msg[0].newstext1;
  104. // // $('#jsontest').append(test);
  105. // });
  106. // }
  107. // window.onload = funcTest2();
  108. // window.setInterval("funcTest2()", 1000 * 8);
  109. // $(document).ready(function () {
  110. // $.ajax({
  111. // method: "GET",
  112. // url: "designer4.json",
  113. // dataType: "json",
  114. // })
  115. // .done(function (msg) {
  116. // var DesignerContent = '';
  117. // console.log(msg)
  118. // for (var i = 0; i < msg.length; i++) {
  119. // // new_des1.push(msg[msg.length].id);
  120. // DesignerContent += ' \
  121. // <div id="'+ msg[i].id + '" class="secimg col-4 col-lg-2 mx-0 px-0 border-0"><a href="./about/index.html?id=' + msg[i].id + '"><img class="img-fluid"\
  122. // src="'+ msg[i].Designerimg + '"\
  123. // alt="">\
  124. // <div class="sec02-p-m p-1 mt-1 text-center">\
  125. // <p class="my-0">'+ msg[i].WorkName + '</p>\
  126. // <p>'+ msg[i].DesignerName + '</p>\
  127. // </div>\
  128. // </a>\
  129. // </div>';
  130. // }
  131. // $('.sec01-designer').html(DesignerContent);
  132. // // var test = msg[0].newstext1;
  133. // // $('#jsontest').append(test);
  134. // });
  135. // });
  136. function funcTest5() {
  137. $.ajax({
  138. method: "GET",
  139. url: "designer4.json",
  140. dataType: "json",
  141. async:false,
  142. })
  143. .done(function (msg) {
  144. console.log(msg);
  145. function shuffleArray(inputArray) {
  146. inputArray.sort(() => Math.random() - 0.5);
  147. }
  148. shuffleArray(msg);
  149. console.log(msg.length);
  150. // temp初始化
  151. for (var i = 0; i < msg.length; i++) {
  152. temp[i]=msg[i].id
  153. }
  154. templength=temp.length;
  155. });
  156. }
  157. var templength =0;
  158. var des1 = [];
  159. var des2 = [];
  160. var temp = [];
  161. var numb1=[];
  162. funcTest5();
  163. funcTest4();
  164. function funcTest4() {
  165. for (var j = 0; j < templength; j++) {
  166. des1[j]=temp[j]
  167. }
  168. console.log(des1)
  169. for (var j = 0; j < des1.length-1; j++) {
  170. des2[j]=des1[j]
  171. }
  172. numb1[0]=des1[des1.length-1];
  173. for(var j=0; j<des1.length-1;j++){
  174. numb1[j+1]=des2[j];
  175. }
  176. for (var j = 0; j < numb1.length; j++) {
  177. temp[j]=numb1[j];
  178. }
  179. console.log(temp);
  180. var desBanner = '';
  181. var MobBanner = '';
  182. var bodyBannerDes = '';
  183. var DesignerContent = '';
  184. for (var i = 0; i < temp.length; i++) {
  185. var deslist=0;
  186. var deslist2=0;
  187. deslist=get_data(temp[i]);
  188. deslist2=get_data(temp[0]);
  189. DesignerContent += ' \
  190. <div id="'+ deslist.id + '" class="secimg col-4 col-lg-2 mx-0 px-0 border-0"><a href="./about/index.html?id=' + deslist.id + '"><img class="img-fluid"\
  191. src="'+ deslist.Designerimg + '"\
  192. alt="">\
  193. <div class="sec02-p-m p-1 mt-1 text-center">\
  194. <p class="my-0">'+deslist.WorkName + '</p>\
  195. <p>'+ deslist.DesignerName + '</p>\
  196. </div>\
  197. </a>\
  198. </div>';
  199. }
  200. desBanner += ' \
  201. <div class="banner-des row vertical align-items-end px-0 mx-0">\
  202. <div class="banner-0 col-0 order-1 col-lg-5 order-1 pe-0">\
  203. <img class="img-fluid" src="./img/banner/bannertitle.png" alt="">\
  204. </div>\
  205. <div class="banner-1 col-5 order-3 col-lg-5 order-2 text-white text-end py-3">\
  206. <a style="text-decoration: none;color:#fff;" href="./about/index.html?id='+ deslist2.id + '"><div class="banner1-1" style="font-weight: 900;">' +deslist2.WorkName + '</div>\
  207. <p><span class="fs-5">'+ deslist2.DesignerName + '</span>設計師</p>\
  208. </a>\
  209. <button type="button" class="btn border border-white"><a target="_blank" href="tel: '+ deslist2.TollFreeCall + '"><img class="" src="img/002-phone-call.svg" alt=""></a>\</button>\
  210. <button type="button" class="btn border border-white" data-bs-toggle="modal" data-bs-target="#exampleModal"><img class="" src="img/001-blogging.svg" alt=""></button>\
  211. </div>\
  212. <div class="banner-2 col-7 order-2 col-lg-2 order-3 px-0 mx-0">\
  213. <a class="desbutton" data-info="'+ deslist2.id + '" href="./about/index.html?id='+ deslist2.id + '"><img class="img-fluid" src="' + deslist2.Designerimg + '" alt=""></a>\
  214. </div>\
  215. </div>';
  216. MobBanner += ' \
  217. <div class="banner-m row vertical align-items-end px-0 mx-0">\
  218. <div class="bannerm-0 col-12 my-5 px-0">\
  219. <img class="img-fluid" src="./img/banner/banner-mobile.png" alt="">\
  220. </div>\
  221. <div class="bannerm-2 col-7 order-2 col-lg-2 order-3 px-0 mx-0">\
  222. <a href="./about/index.html?id='+ deslist2.id + '"><img class="img-fluid" src="' + deslist2.Designerimg + '" alt=""></a>\
  223. </div>\
  224. <div class="bannerm-1 col-5 order-3 col-lg-5 order-2 text-white text-start pb-3">\
  225. <a style="text-decoration: none;color:#fff;" href="./about/index.html?id='+ deslist2.id + '">\
  226. <div class="banner1-1 pt-3 pb-4" style="font-weight: 900;">'+ deslist2.WorkName + '</div>\
  227. <p class=""><span class="fs-5">'+ deslist2.DesignerName + '</span>設計師</p>\
  228. </a>\
  229. <button type="button" class="btn border border-white"><a target="_blank" href="tel: '+ deslist2.TollFreeCall + '"><img class="" src="img/002-phone-call.svg" alt=""></a>\</button>\
  230. <button type="button" class="btn border border-white" data-bs-toggle="modal" data-bs-target="#exampleModal"><img class="" src="img/001-blogging.svg" alt=""></button>\
  231. </div>\
  232. </div > ';
  233. bodyBannerDes += ' \
  234. <img class="banner-img img-fluid" id="img_id" src="'+ deslist2.workimg[0].img + '" alt="">\
  235. ';
  236. $('.banner-des').html(desBanner);
  237. $('.banner-m').html(MobBanner);
  238. $('#bannerdes-img').html(bodyBannerDes);
  239. $('.sec01-designer').html(DesignerContent);
  240. console.log(deslist2);
  241. }
  242. function get_data(id) {
  243. var A=[];
  244. $.ajax({
  245. method: "GET",
  246. url: "../designer4.json",
  247. dataType: "json",
  248. async:false,
  249. })
  250. .done(function (msg) {
  251. for (var i = 0; i < msg.length; i++) {
  252. if (msg[i].id == id) {
  253. A =msg[i]
  254. }
  255. }
  256. });
  257. return A
  258. }
  259. setInterval("funcTest4()", 1000*10);
  260. // if (msg[i].id == id) {
  261. // console.log()
  262. // }
  263. // setInterval("funcTest5()", 5000);
  264. // 點選該設計師,導至其對應id的參數網址
  265. // $('#278').click(function () {
  266. // console.log(1);
  267. // window.location.href = `./about/index.html?id=278`;
  268. // });
  269. // $('#507').click(function () {
  270. // console.log(2);
  271. // window.location.href = `./about/index.html?id=507`;
  272. // });
  273. // $('#423').click(function () {
  274. // console.log(3);
  275. // window.location.href = `./about/index.html?id=423`;
  276. // });
  277. // $('#594').click(function () {
  278. // console.log(4);
  279. // window.location.href = `./about/index.html?id=594`;
  280. // });
  281. // $('#364').click(function () {
  282. // console.log(5);
  283. // window.location.href = `./about/index.html?id=364`;
  284. // });
  285. // $('#500').click(function () {
  286. // console.log(6);
  287. // window.location.href = `./about/index.html?id=500`;
  288. // });
  289. // $('#651').click(function () {
  290. // console.log(7);
  291. // window.location.href = `./about/index.html?id=651`;
  292. // });
  293. // $('#347').click(function () {
  294. // console.log(8);
  295. // window.location.href = `./about/index.html?id=347`;
  296. // });
  297. // $('#363').click(function () {
  298. // console.log(9);
  299. // window.location.href = `./about/index.html?id=363`;
  300. // });
  301. // $('#555').click(function () {
  302. // console.log(10);
  303. // window.location.href = `./about/index.html?id=555`;
  304. // });
  305. // $('#79').click(function () {
  306. // console.log(11);
  307. // window.location.href = `./about/index.html?id=79`;
  308. // });
  309. // $('#158').click(function () {
  310. // console.log(12);
  311. // window.location.href = `./about/index.html?id=158`;
  312. // });
  313. // $('#301').click(function () {
  314. // console.log(13);
  315. // window.location.href = `./about/index.html?id=301`;
  316. // });
  317. // $('#402').click(function () {
  318. // console.log(14);
  319. // window.location.href = `./about/index.html?id=402`;
  320. // });
  321. // $('#131').click(function () {
  322. // console.log(15);
  323. // window.location.href = `./about/index.html?id=131`;
  324. // });
  325. // $('#28').click(function () {
  326. // console.log(16);
  327. // window.location.href = `./about/index.html?id=28`;
  328. // });
  329. // $('#65').click(function () {
  330. // console.log(17);
  331. // window.location.href = `./about/index.html?id=65`;
  332. // });
  333. // $('#672').click(function () {
  334. // console.log(9);
  335. // window.location.href = `./about/index.html?id=672`;
  336. // });
  337. // $('#438').click(function () {
  338. // console.log(9);
  339. // window.location.href = `./about/index.html?id=438`;
  340. // });
  341. // $('#291').click(function () {
  342. // console.log(9);
  343. // window.location.href = `./about/index.html?id=291`;
  344. // });
  345. // $('#465').click(function () {
  346. // console.log(9);
  347. // window.location.href = `./about/index.html?id=465`;
  348. // });
  349. // $('#436').click(function () {
  350. // console.log(9);
  351. // window.location.href = `./about/index.html?id=436`;
  352. // });
  353. // $('#279').click(function () {
  354. // console.log(9);
  355. // window.location.href = `./about/index.html?id=279`;
  356. // });
  357. // $('#418').click(function () {
  358. // console.log(9);
  359. // window.location.href = `./about/index.html?id=418`;
  360. // });
  361. // $('#385').click(function () {
  362. // console.log(9);
  363. // window.location.href = `./about/index.html?id=385`;
  364. // });
  365. // $('#688').click(function () {
  366. // console.log(9);
  367. // window.location.href = `./about/index.html?id=688`;
  368. // });
  369. // $('#474').click(function () {
  370. // console.log(9);
  371. // window.location.href = `./about/index.html?id=474`;
  372. // });
  373. // $('#505').click(function () {
  374. // console.log(9);
  375. // window.location.href = `./about/index.html?id=505`;
  376. // });
  377. // $('#712').click(function () {
  378. // console.log(9);
  379. // window.location.href = `./about/index.html?id=712`;
  380. // });
  381. // $('#680').click(function () {
  382. // console.log(9);
  383. // window.location.href = `./about/index.html?id=680`;
  384. // });
  385. // $('#705').click(function () {
  386. // console.log(9);
  387. // window.location.href = `./about/index.html?id=705`;
  388. // });
  389. // $('#23').click(function () {
  390. // console.log(9);
  391. // window.location.href = `./about/index.html?id=23`;
  392. // });
  393. // $('#33').click(function () {
  394. // console.log(9);
  395. // window.location.href = `./about/index.html?id=33`;
  396. // });
  397. // $('#491').click(function () {
  398. // console.log(9);
  399. // window.location.href = `./about/index.html?id=491`;
  400. // });
  401. // function funcTest() {
  402. // $("div.sec01-designer div").sort(function () {
  403. // return Math.random() * 10 > 5 ? 1 : -1;
  404. // }).each(function () {
  405. // var $t = $(this),
  406. // color = $t.attr("");
  407. // $t.css({ backgroundColor: color }).appendTo($t.parent());
  408. // });
  409. // }
  410. // window.setInterval("funcTest()", 1000 * 10);
  411. // window.onload = funcTest();
  412. $.fn.serializeObject = function () {
  413. var o = {};
  414. var a = this.serializeArray();
  415. o["id"] = 0;
  416. o["time_stamp"] = "";
  417. $.each(a, function () {
  418. if (o[this.name]) {
  419. if (!o[this.name].push) {
  420. o[this.name] = [o[this.name]];
  421. }
  422. o[this.name].push(this.value || '');
  423. } else {
  424. o[this.name] = this.value || '';
  425. }
  426. });
  427. return o;
  428. };
  429. $(".contact-form1").submit(function (e) {
  430. /* var formRef = $('#form1').serializeArray();
  431. var jsonString = JSON.stringify(formRef);*/
  432. var jsonInfo = $('.contact-form1').serializeObject();
  433. var jsonString = JSON.stringify(jsonInfo);
  434. console.log(jsonString);
  435. $.ajax({
  436. type: 'POST',
  437. url: 'https://go.hhh.com.tw:8002/deco_request_detail',
  438. data: jsonString,
  439. dataType: 'json',
  440. success: function (data) {
  441. console.log('送出成功: ' + data);
  442. if (data == 0) {
  443. alert("送出成功");
  444. } else if (data == 1) {
  445. alert("此email已填過表單");
  446. } else if (data == 2) {
  447. alert("此phone已填過表單");
  448. } else if (data == 3) {
  449. alert("此email、phone已填過表單");
  450. }
  451. location.href ="./index_complete_line.html";
  452. },
  453. beforeSend: function () {
  454. console.log('beforeSend');
  455. },
  456. complete: function () {
  457. console.log('complete');
  458. },
  459. error: function (jqXHR, textStatus, errorThrown) {
  460. console.log(JSON.stringify(jqXHR));
  461. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  462. console.log('送出失敗: ' + jqXHR.responseText);
  463. alert("送出失敗");
  464. }
  465. });
  466. return false;
  467. });