index.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. let userAgent;
  2. let isSafari = false;
  3. let browserName;
  4. window.onload = function(){
  5. //window.scrollBy(0, 1);
  6. /* if(screen.width >= 901){
  7. window.location.href = "https://www2.hhh.com.tw/";
  8. } */
  9. userAgent = navigator.userAgent;
  10. detectBrowser(userAgent);
  11. detectDirection ();
  12. let result;
  13. $.ajax({
  14. method: "GET",
  15. url: "./json/realtime.json",
  16. dataType: "json",
  17. }).done(function (msg) {
  18. result = [...msg];
  19. renderSec00(result);
  20. renderSec02(result);
  21. renderSec03(result);
  22. renderSec06(result);
  23. renderSec07(result);
  24. renderSec08(result);
  25. renderSec09(result);
  26. renderSec10(result);
  27. renderSec11(result);
  28. renderVideo(result);
  29. });
  30. }
  31. function detectBrowser(agent){
  32. if(userAgent.match(/chrome|chromium|crios/i)){
  33. browserName = "chrome";
  34. }else if(userAgent.match(/firefox|fxios/i)){
  35. browserName = "firefox";
  36. } else if(userAgent.match(/safari/i)){
  37. browserName = "safari";
  38. }else if(userAgent.match(/opr\//i)){
  39. browserName = "opera";
  40. } else if(userAgent.match(/edg/i)){
  41. browserName = "edge";
  42. }else{
  43. browserName="No browser detection";
  44. }
  45. if(browserName === 'safari'){
  46. isSafari = true;
  47. }
  48. console.log(isSafari);
  49. }
  50. function detectDirection () {
  51. let height = (window.screen.width * 2) / 3;
  52. $('.sec-02 .slide-item').css('height', `${height}px`);
  53. let topHeight = (window.screen.width * 30) / 131;
  54. $('.sec-00 .slide-item').css('height', `${topHeight}px`);
  55. $('.sec-00 .container-fluid').css('height', `${topHeight}px`);
  56. }
  57. $(".sec-01__slider").slick({
  58. dots: true,
  59. autoplay: false,
  60. arrows: false,
  61. });
  62. function renderSec00(data) {
  63. let temp = data[0]['data'];
  64. renderBannerStr('sec-00__slider', temp);
  65. $(".sec-00__slider").slick({
  66. dots: false,
  67. speed: 800,
  68. autoplay: true,
  69. });
  70. }
  71. function renderSec02(data) {
  72. let temp = data[1]['data'];
  73. renderBannerStr('sec-02__slider', temp);
  74. let str = '';
  75. $(".sec-02__slider").slick({
  76. dots: false,
  77. autoplay: true,
  78. arrows: true,
  79. fade: true,
  80. });
  81. }
  82. function renderBannerStr(sec, data) {
  83. let str = '';
  84. console.log(isSafari);
  85. for(let i = 0; i < data.length; i++){
  86. if(data[i]['webp'] && !isSafari) {
  87. str+= `<div class="${sec}-${i+1} slide-item" onclick="window.open('${data[i]['link']}');" style="background-image: url('${data[i]['webp']}');" data-bg="${data[i]['webp']}"></div>`
  88. } else {
  89. str+= `<div class="${sec}-${i+1} slide-item" onclick="window.open('${data[i]['link']}');" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"></div>`
  90. }
  91. }
  92. $(`.${sec}`).html(str);
  93. }
  94. function renderSec03(data) {
  95. let randomIdx = Math.floor(Math.random()*3);
  96. let moreLinks = ['https://hhh.com.tw/cases/lists/', 'https://hhh.com.tw/videos/lists/', 'https://hhh.com.tw/columns/lists/'];
  97. const ran = $('.sec-03__tabdiv .nav-item-link').eq(randomIdx);
  98. const ranDiv = $('#pills-tabContent .tab-pane').eq(randomIdx);
  99. ran.addClass('active');
  100. ranDiv.addClass('active');
  101. ranDiv.addClass('show');
  102. $('.sec-03 .morelink').attr('href', $('.sec-03__tabdiv .nav-item-link.active').data('link'));
  103. let temp = data[2]['data'];
  104. for(let i = 0; i < temp.length; i++){
  105. if(temp[i]["tab"] == '最夯設計'){
  106. let str = '';
  107. let sub = temp[i]["data"];
  108. for(let j = 0; j < sub.length; j++){
  109. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}')";>
  110. <div class="tabpar__card__imgfr" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  111. <p class="mt-2 pe-2">${sub[j]['title']}</p>
  112. </div>`
  113. }
  114. $('#pills-hot .tabpar').html(str);
  115. }
  116. if(temp[i]["tab"] == '影音實錄'){
  117. let str = '';
  118. let sub = temp[i]["data"];
  119. for(let j = 0; j < sub.length; j++){
  120. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}')";>
  121. <div class="tabpar__card__imgfr" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"><img class="tabpar__card__play lazyload" data-src="images/Play-Button.webp"></div>
  122. <p class="mt-2 pe-2">${sub[j]['description']}</p>
  123. </div>`
  124. }
  125. $('#pills-video .tabpar').html(str);
  126. }
  127. if(temp[i]["tab"] == '專欄文章'){
  128. let str = '';
  129. let sub = temp[i]["data"];
  130. for(let j = 0; j < sub.length; j++){
  131. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}')";>
  132. <div class="tabpar__card__imgfr" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  133. <p class="mt-2 pe-2">${sub[j]['title']}</p>
  134. </div>`
  135. }
  136. $('#pills-blog .tabpar').html(str);
  137. }
  138. }
  139. const cardText = document.querySelectorAll('.tabpar__card p');
  140. cardText.forEach((item, i) => {
  141. let len = item.textContent.length;
  142. if(len > 20) {
  143. let str = item.textContent.substring(0, 20) + '...';
  144. item.textContent = str;
  145. }
  146. });
  147. $('.sec-03__tabdiv .nav-item-link').click(function() {
  148. $('.sec-03 .morelink').attr('href',$('.sec-03__tabdiv .nav-item-link.active').data('link'));
  149. });
  150. }
  151. function renderSec06(data) {
  152. let temp = data[3]['data'];
  153. let str = '';
  154. for(let i = 0; i < temp.length; i++){
  155. if(i === 0) {
  156. str+= `<div class="carousel-item active" onclick="window.open('${temp[i]['link']}');"
  157. style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}">
  158. </div>`
  159. } else {
  160. str+= `<div class="carousel-item" onclick="window.open('${temp[i]['link']}');"
  161. style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}">
  162. </div>`
  163. }
  164. }
  165. $('.sec-06 .carousel-inner').html(str);
  166. }
  167. function renderSec07(data) {
  168. let temp = data[4]['data'];
  169. let str = '';
  170. for(let i = 0; i < temp.length; i++){
  171. str+= `
  172. <div class="sec-07__slider-${i+1} sec-07__card col-12 mx-1" onclick="window.open('${temp[i]['link']}');">
  173. <div class="sec-07__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');"></div>
  174. <p class="sec-07__cardtxt">${temp[i]['description']}</p>
  175. </div>`
  176. }
  177. $('.sec-07__slider').html(str);
  178. $(".sec-07__slider").slick({
  179. arrows: false,
  180. slidesToShow: 3,
  181. centerMode: true,
  182. infinite: false,
  183. dots: false,
  184. centerPadding: '12px',
  185. responsive: [
  186. {
  187. breakpoint: 480,
  188. settings: {
  189. arrows: false,
  190. slidesToShow: 1,
  191. centerMode: true,
  192. infinite: false,
  193. dots: true,
  194. centerPadding: '12px',
  195. }
  196. }
  197. ],
  198. });
  199. const cardText = document.querySelectorAll('.sec-07__cardtxt');
  200. cardText.forEach((item, i) => {
  201. let len = item.textContent.length;
  202. if(len > 20) {
  203. let str = item.textContent.substring(0, 25) + '...';
  204. item.textContent = str;
  205. }
  206. })
  207. }
  208. function renderSec08(data) {
  209. let temp = data[5]['data'];
  210. let str = '';
  211. for(let i = 0; i < temp.length; i++){
  212. str+= `<div class="sec-08__slider-${i+1} mx-1 slide-item" style="width: 70vw; background-image: url('${temp[i]['imgUrl']}');" onclick="window.open('${temp[i]['link']}');" data-bg="${temp[i]['imgUrl']}"></div>`
  213. }
  214. $('.sec-08__slider').html(str);
  215. $(".sec-08__slider").slick({
  216. autoplay: true,
  217. autoplaySpeed: 8000,
  218. arrows: false,
  219. slidesToShow: 3,
  220. centerMode: true,
  221. infinite: true,
  222. dots: false,
  223. centerPadding: '6px',
  224. responsive: [
  225. {
  226. breakpoint: 480,
  227. settings: {
  228. autoplay: true,
  229. autoplaySpeed: 8000,
  230. arrows: false,
  231. slidesToShow: 1,
  232. centerMode: true,
  233. infinite: true,
  234. dots: false,
  235. centerPadding: '12px',
  236. }
  237. }
  238. ],
  239. });
  240. }
  241. function renderSec09(data) {
  242. let temp = data[6]['data'];
  243. let str = '';
  244. for(let i = 0; i < temp.length; i++){
  245. if(temp[i].video !== 'false') {
  246. str+= `<div class="sec-09__card" onclick="window.open('${temp[i]['link']}');">
  247. <div class="sec-09__card__imgfr" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-09__card__play lazyload" data-src="images/Play-Button.webp"></div>
  248. <p>${temp[i]['title']}</p>
  249. </div>`
  250. } else {
  251. str+= `<div class="sec-09__card" onclick="window.open('${temp[i]['link']}');">
  252. <div class="sec-09__card__imgfr" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  253. <p>${temp[i]['title']}</p>
  254. </div>`
  255. }
  256. }
  257. $('.sec-09__cardgrp').html(str);
  258. $(".sec-09__cardgrp").slick({
  259. arrows: false,
  260. slidesToShow: 3,
  261. slidesToScroll: 1,
  262. infinite: true,
  263. dots: false,
  264. centerPadding: '10px',
  265. responsive: [
  266. {
  267. breakpoint: 480,
  268. settings: {
  269. arrows: false,
  270. slidesToShow: 2,
  271. slidesToScroll: 1,
  272. infinite: true,
  273. dots: false,
  274. centerPadding: '10px',
  275. }
  276. }
  277. ],
  278. });
  279. }
  280. function renderSec10(data) {
  281. let temp = data[7]['data'];
  282. renderRecStr('sec-10', temp);
  283. }
  284. function renderSec11(data) {
  285. let temp = data[8]['data'];
  286. renderRecStr('sec-11', temp);
  287. }
  288. function renderRecStr(sec, data) {
  289. let str = '';
  290. for(let i = 0; i < data.length; i++){
  291. if(data[i].video !== 'false') {
  292. str+= `<div class="${sec}__card col-12 mx-1" onclick="window.open('${data[i]['link']}');">
  293. <div class="${sec}__slider-${i+1} mb-2 slide-item" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"><img class="${sec}__card__play lazyload" data-src="images/Play-Button.webp"></div>
  294. <p class="${sec}__cardtxt">${data[i]['title']}</p>
  295. </div>`;
  296. } else {
  297. str+= `<div class="${sec}__card col-12 mx-1" onclick="window.open('${data[i]['link']}');">
  298. <div class="${sec}__slider-${i+1} mb-2 slide-item" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"></div>
  299. <p class="${sec}__cardtxt">${data[i]['title']}</p>
  300. </div>`;
  301. }
  302. }
  303. $(`.${sec}__slider`).html(str);
  304. $(`.${sec}__slider`).slick({
  305. arrows: false,
  306. slidesToShow: 3,
  307. centerMode: false,
  308. infinite: false,
  309. dots: false,
  310. centerPadding: '12px',
  311. responsive: [
  312. {
  313. breakpoint: 480,
  314. settings: {
  315. arrows: false,
  316. slidesToShow: 1,
  317. centerMode: true,
  318. infinite: false,
  319. dots: false,
  320. centerPadding: '12px',
  321. }
  322. }
  323. ],
  324. });
  325. }
  326. function renderVideo(data) {
  327. let temp = data[9];
  328. $('.sec-05__video__txt').text(temp['title']);
  329. $('.sec-05__video__imgfr').css('background-image', `url(https://img.youtube.com/vi/${temp['yt']}/hqdefault.jpg)`);
  330. $('#videoModal').on('shown.bs.modal', function () {
  331. $('#videoModal iframe').attr('src', `https://www.youtube.com/embed/${temp['yt']}?controls=0&autoplay=1&amp;enablejsapi=1&amp;origin=https%3A%2F%2Fm.hhh.com.tw&amp;widgetid=1`);
  332. });
  333. $('#videoModal').on('hidden.bs.modal', function () {
  334. $('#videoModal iframe').removeAttr('src');
  335. });
  336. }
  337. window.addEventListener('scroll', fixedOnScroll);
  338. const navbar = document.querySelector('.navbar-main');
  339. function fixedOnScroll() {
  340. if(window.innerHeight < window.innerWidth){
  341. $('.sec-02 .slide-item').css('height', `130vh`);
  342. $('.sec-00 .slide-item').css('height', `200px`);
  343. $('.sec-00 .container-fluid').css('height', `200px`);
  344. } else {
  345. detectDirection ();
  346. }
  347. const sticky = document.querySelector('.sec-00 .container-fluid').offsetHeight;
  348. if(window.pageYOffset >= sticky){
  349. navbar.classList.add('sticky');
  350. } else {
  351. navbar.classList.remove('sticky');
  352. }
  353. }
  354. $('.navbar-toggler').click(function(){
  355. $(".sec-menu").css('display', 'block');
  356. $(".wholeBody").css('overflow-y', 'hidden');
  357. $('.sec-menu-block').addClass('slidein');
  358. $('.sec-menu-block').removeClass('slideout');
  359. });
  360. $('.navbar-back').click(function(){
  361. $(".sec-menu").css('display', 'none');
  362. $(".wholeBody").css('overflow-y', 'scroll');
  363. $('.sec-menu-block').removeClass('slidein');
  364. $('.sec-menu-block').addClass('slideout');
  365. });
  366. $('.subexpand').click(function(){
  367. $(this).parent().next().toggleClass('show');
  368. $(this).parent().toggleClass('show');
  369. });
  370. $('.navbar-search').click(function(){
  371. $(".sec-search").css('display', 'block');
  372. $(".wholeBody").css('overflow-y', 'hidden');
  373. })
  374. $('.navbar-backs').click(function(){
  375. $(".sec-search").css('display', 'none');
  376. $(".wholeBody").css('overflow-y', 'scroll');
  377. });
  378. $('.btn-match').click(function(){
  379. $(".sec-match").css('display', 'block');
  380. $(".wholeBody").css('overflow-y', 'hidden');
  381. })
  382. $('.navbar-backs').click(function(){
  383. $(".sec-match").css('display', 'none');
  384. $(".wholeBody").css('overflow-y', 'scroll');
  385. });
  386. $('.navbar-back-fav').click(function(){
  387. $(".sec-favor").css('display', 'none');
  388. })
  389. $('.btn-gotop').click(function () {
  390. $('html, body').animate({
  391. scrollTop: 0
  392. }, 500)
  393. });
  394. $(window).scroll(function() {
  395. if ( $(this).scrollTop() > 500 ){
  396. $('.fixed-btn').fadeIn(222);
  397. } else {
  398. $('.fixed-btn').stop().fadeOut(222);
  399. }
  400. }).scroll();
  401. const searchBtn = document.querySelector('.searchBtn');
  402. const searchBar = document.querySelector('.searchBar');
  403. const searchHotLink = document.querySelectorAll('.sec-search-hots__link');
  404. searchBtn.addEventListener('click', search);
  405. searchBar.addEventListener('keyup', pressSearch);
  406. function search() {
  407. if(searchBar.value == '') {
  408. window.location.href = 'https://m.hhh.com.tw/search/lists/case/';
  409. } else {
  410. window.location.href = `https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`;
  411. }
  412. }
  413. function pressSearch(e) {
  414. if (e.keyCode === 13) {
  415. e.preventDefault();
  416. search();
  417. }
  418. }
  419. searchHotLink.forEach((item, i) => {
  420. item.addEventListener('click', function() {
  421. window.location.href = `https://m.hhh.com.tw/search/lists/case/${this.textContent}-keyword/`;
  422. })
  423. })
  424. document.addEventListener('lazybeforeunveil', function(e){
  425. var bg = e.target.getAttribute('data-bg');
  426. if(bg){
  427. e.target.style.backgroundImage = 'url(' + bg + ')';
  428. }
  429. });
  430. //jQuery time
  431. var current_fs, next_fs, previous_fs; //fieldsets
  432. var left, opacity, scale; //fieldset properties which we will animate
  433. var animating; //flag to prevent quick multi-click glitches
  434. $(".next").click(function(){
  435. if(animating) return false;
  436. animating = true;
  437. current_fs = $(this).parent().parent();
  438. next_fs = $(this).parent().parent().next();
  439. //activate next step on progressbar using the index of next_fs
  440. $(".form-progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
  441. //show the next fieldset
  442. next_fs.animate({opacity: 1}, {
  443. step: function(now, mx) {
  444. //as the opacity of current_fs reduces to 0 - stored in "now"
  445. //1. scale current_fs down to 80%
  446. scale = 0 + (1 + now) * .5 ;
  447. //2. bring next_fs from the right(50%)
  448. left = (now * 50)+"%";
  449. //3. increase opacity of next_fs to 1 as it moves in
  450. opacity = 0 + now;
  451. next_fs.css({
  452. 'transform': 'scale('+scale+')',
  453. });
  454. next_fs.css({'opacity': opacity});
  455. },
  456. duration: 400,
  457. complete: function(){
  458. next_fs.show();
  459. animating = false;
  460. },
  461. //this comes from the custom easing plugin
  462. easing: 'easeInOutBack'
  463. });
  464. //hide the current fieldset with style
  465. current_fs.animate({opacity: 0}, {
  466. step: function(now, mx) {
  467. //as the opacity of current_fs reduces to 0 - stored in "now"
  468. //1. scale current_fs down to 80%
  469. scale = 1 - (1 - now) * 0.2;
  470. //2. bring next_fs from the right(50%)
  471. left = (now * 50)+"%";
  472. //3. increase opacity of next_fs to 1 as it moves in
  473. opacity = 1 - now;
  474. current_fs.css({
  475. 'transform': 'scale('+scale+')',
  476. });
  477. next_fs.css({'opacity': opacity});
  478. },
  479. duration: 400,
  480. complete: function(){
  481. current_fs.hide();
  482. animating = false;
  483. },
  484. //this comes from the custom easing plugin
  485. easing: 'easeInOutBack'
  486. });
  487. });
  488. $('.container_match2').hide();
  489. $('.last-step').click(function() {
  490. $('.container_match').fadeIn(500);
  491. $('.container_match2').fadeOut(0);
  492. });
  493. $('.match__next').click(function() {
  494. console.log($('#area').val());
  495. console.log($('#type').val());
  496. if ($('#area').val() == '' || $('#area').val() == null) {
  497. $('#area-error').text('請選擇地區');
  498. stop = 1;
  499. } else {
  500. $('#area-error').text('');
  501. stop = 0
  502. }
  503. if ($('#type').val() == ''|| $('#type').val() == null) {
  504. $('#type-error').text('請選擇房屋類型');
  505. stop = 1;
  506. } else {
  507. $('#type-error').text('');
  508. stop = 0
  509. }
  510. if ($('#square').val() == ''|| $('#square').val() == null) {
  511. $('#square-error').text('請選擇房屋坪數');
  512. stop = 1;
  513. } else {
  514. $('#square-error').text('');
  515. stop = 0
  516. }
  517. if ($('#pattern').val() == ''|| $('#pattern').val() == null) {
  518. $('#pattern-error').text('請選擇房屋格局');
  519. stop = 1;
  520. } else {
  521. $('#pattern-error').text('');
  522. stop = 0
  523. }
  524. if ($('#style').val() == ''|| $('#style').val() == null) {
  525. $('#style-error').text('請選擇喜愛的風格');
  526. stop = 1;
  527. } else {
  528. $('#style-error').text('');
  529. stop = 0
  530. }
  531. console.log(stop);
  532. if(stop === 0) {
  533. $('.container_match').fadeOut(0);
  534. $('.container_match2').fadeIn(500);
  535. }
  536. });
  537. $('.match__next2').click(function() {
  538. if ($('#name').val() == ''|| $('#name').val() == null) {
  539. $('#name-error').text('請填寫您的姓名');
  540. name = 1;
  541. } else {
  542. $('#name-error').text('');
  543. name = 0;
  544. }
  545. if ($('#phone').val() == ''|| $('#phone').val() == null || !/^[09]{2}[0-9]{8}$/.test($('#phone').val())) {
  546. $('#phone-error').text('請以手機格式填寫(格式:0987654321)');
  547. phone = 1;
  548. } else {
  549. $('#phone-error').text('');
  550. phone = 0;
  551. }
  552. console.log($('#phone').val());
  553. if ($('#sex').val() == ''|| $('#sex').val() == null) {
  554. $('#sex-error').text('請選擇性別');
  555. sex = 1;
  556. } else {
  557. $('#sex-error').text('');
  558. sex = 0;
  559. }
  560. if(!$('#readPolicy').prop('checked')) {
  561. $('#readPolicy-error').text('必須同意免責聲明與隱私使用政策');
  562. readPolicy = 1;
  563. } else {
  564. $('#readPolicy-error').text('');
  565. readPolicy = 0;
  566. }
  567. var obj = document.getElementsByName("time");
  568. var time = [];
  569. for (k in obj) {
  570. if (obj[k].checked)
  571. time.push(obj[k].value);
  572. }
  573. console.log(time);
  574. if(name== 0 && phone == 0 && sex == 0 && readPolicy == 0) {
  575. $.ajax({
  576. type: "POST",
  577. url: "",
  578. data:
  579. {
  580. data: JSON.stringify(
  581. {
  582. name: $('#name').val(),
  583. sex: $('#sex').val(),
  584. phone: $('#phone').val(),
  585. time: $('#datepicker').val(),
  586. area: $('#area').val(),
  587. type: $('#type').val(),
  588. square: $('#square').val(),
  589. pattern: $('#pattern').val(),
  590. style: $('#style').val(),
  591. time: time.toString(),
  592. })
  593. },
  594. success: function (res) {
  595. if (res.status == "Success") {
  596. // gaEvent('功能 - 軟裝需求單 - 送出', '經紀人');
  597. Swal.fire({
  598. html: '<h5 class="text-primary font-weight-bold">' + res.error + '</h5>',
  599. showConfirmButton: true,
  600. confirmButtonText: '確定',
  601. confirmButtonColor: '#EE7800'
  602. }).then(function (result) {
  603. if (result.value) {
  604. location.reload();
  605. }
  606. })
  607. } else {
  608. Swal.fire({
  609. title: '似乎出了什麼問題 請稍後再試',
  610. showConfirmButton: false,
  611. })
  612. }
  613. },
  614. error: function (error) {
  615. console.error(error)
  616. }
  617. })
  618. $(".sec-match").css('display', 'none');
  619. $(".wholeBody").css('overflow-y', 'scroll');
  620. window.open('./index_match.html');
  621. }
  622. })
  623. $('.check-click').click(function(e) {
  624. if($('#2b').is(':checked')) {
  625. $('#2a').prop('checked', false);
  626. }
  627. if($('#2c').is(':checked')) {
  628. $('#2a').prop('checked', false);
  629. }
  630. if($('#2d').is(':checked')) {
  631. $('#2a').prop('checked', false);
  632. }
  633. if($('#2e').is(':checked')) {
  634. $('#2a').prop('checked', false);
  635. }
  636. console.log(e.target.id);
  637. if(e.target.id === '2a') {
  638. $('#2a').prop('checked', true);
  639. $('#2b').prop('checked', false);
  640. $('#2c').prop('checked', false);
  641. $('#2d').prop('checked', false);
  642. $('#2e').prop('checked', false);
  643. }
  644. })