hokky пре 4 месеци
родитељ
комит
93d1fc3746
2 измењених фајлова са 96 додато и 128 уклоњено
  1. 14 56
      pro/resources/views/index.blade.php
  2. 82 72
      pro/resources/views/page/sise.blade.php

+ 14 - 56
pro/resources/views/index.blade.php

@@ -44,14 +44,9 @@
 </div>
 <!--// 회원권 매매 신청 끝 -->
 
-
-@php $today = date('Y-m-d'); @endphp
 <!-- 시세 시작 -->
 <div class="m_quote">
 	<div class="container">
-        <div class="tabs today">
-            <input type="date" id="search_date" value="{{$today}}" autocomplete="off">
-        </div>
 		<ul class="tabs nav nav-tabs">
 			<li class="active"><a data-toggle="tab" data-sise="golf" href="#" onclick="changeSiseList(this)">골프 시세</a></li>
 			<li><a data-toggle="tab" href="#" data-sise="condo" onclick="changeSiseList(this)">콘도 시세</a></li>
@@ -138,54 +133,40 @@
 <!--// 블로그 끝 -->
 
 <script>
-var currentSiseType = 'golf';
-var filteredSiseList = [];
+currentSiseType = 'golf';
 $(document).ready(function() {
-    var date = dateFormat(document.getElementById('search_date').value);
-    console.log('date: ', date);
-    filteredSiseList = searchDate(date, currentSiseType);
-    renderMainSiseList(filteredSiseList);
-
-    // console.log('초기값 : ', filteredSiseList);
     // console.log('mainYoutubeList : ',mainYoutubeList);
     // 필터링된 리스트를 렌더링하는 함수 호출
-    // changeSiseListByDefault(currentSiseType);
+    changeSiseListByDefault(currentSiseType);
 	$('.main-header').addClass('main_header');
 	$('.main-header .logo img').attr("src", "/themes/kbgolf/pro/resources/images/logo_wh.png");
 });
 
-document.getElementById('search_date').addEventListener('change', function() {
-    var date = dateFormat(document.getElementById('search_date').value);
-    console.log('date: ', date);
-    //currentSiseType = $(e).attr('data-sise');
-    filteredSiseList = searchDate(date, currentSiseType);
-    // console.log('filteredSiseList : ', filteredSiseList);
-    renderMainSiseList(filteredSiseList);
-});
-
 // siseType별로 tbody 생성
 function changeSiseList(e) {
+    // 다른 li태그 active class 제거
     $('.tabs li').removeClass('active');
+    // 클릭한 태그의 li active class 추가
     $(e).parent().addClass('active');
 
     currentSiseType = $(e).attr('data-sise');
-    filteredSiseList_with_sise = filteredSiseList.filter(function(mainsise) {
+    var filteredSiseList = mainSiseList.filter(function(mainsise) {
         return mainsise['Pc5'].includes(currentSiseType);
     });
 
-    renderMainSiseList(filteredSiseList_with_sise);
+    renderMainSiseList(filteredSiseList);
     // sise 더보기 버튼 list를 change할 때마다 활성화
     $('.m_quote .btn_wrap .m_more').show();
 }
 // defalut 가져오기
-// function changeSiseListByDefault(currentSiseType) {
-//     filteredSiseList_with_sise = filteredSiseList.filter(function(mainsise) {
-//         return mainsise['Pc5'].includes(currentSiseType);
-//     });
-//     renderMainSiseList(filteredSiseList_with_sise);
-//     // sise 더보기 버튼 list를 change할 때마다 활성화
-//     $('.m_quote .btn_wrap .m_more').show();
-// }
+function changeSiseListByDefault(currentSiseType) {
+    var filteredSiseList = mainSiseList.filter(function(mainsise) {
+        return mainsise['Pc5'].includes(currentSiseType);
+    });
+    renderMainSiseList(filteredSiseList);
+    // sise 더보기 버튼 list를 change할 때마다 활성화
+    $('.m_quote .btn_wrap .m_more').show();
+}
 
 // tbody 생성
 function renderMainSiseList(siseList){
@@ -387,20 +368,6 @@ function contactForMembership(){
     window.location.href = url;
 }
 
-function searchDate(date, currentSiseType){
-    if(currentSiseType){
-        return mainSiseList.filter(function(siseFormDate) {
-            var dateMatch = date ? (siseFormDate['Pc6'] && siseFormDate['Pc6'] === date) : true;
-            var typeMatch = siseFormDate['Pc5'].toLowerCase().includes(currentSiseType);
-            return dateMatch && typeMatch;
-        });
-    }
-    return mainSiseList.filter(function(siseFormDate) {
-        var dateMatch = date ? (siseFormDate['Pc6'] && siseFormDate['Pc6'] === date) : true;
-        return dateMatch;
-    });
-}
-
 var swiper = new Swiper(".main_visual .swiper", {
 	loop: true,
 	autoplay: {
@@ -429,15 +396,6 @@ function truncateText(text, maxLength, suffix = '...') {
     return text.substr(0, maxLength) + suffix;
 }
 
-function dateFormat(date){
-    var formattedDate = '';
-    if (date) {
-        var parts = date.split('-');
-        formattedDate = parts.join('');
-    }
-    return formattedDate;
-}
-
 const mainSiseList = {!! json_encode($mainSiseList['Page']) !!};
 const mainYoutubeList = {!! json_encode($mainYoutubeList['Page']) !!};
 const mainBlogList = {!! json_encode($mainBlogList['Page']) !!};

+ 82 - 72
pro/resources/views/page/sise.blade.php

@@ -1,11 +1,7 @@
 @extends('views.layouts.master')
 @section('content')
 
-@php
-    //var_dump($siseList['Page']);
-    //var_dump($siseItems)
-    $today = date('Y-m-d');
-@endphp
+@php $today = date('Y-m-d'); @endphp
 
 <div class="sub golf">
 	<div class="container">
@@ -22,7 +18,7 @@
 		<div class="container">
 			<label>회원권 검색</label>
 			<input type="text" id="membership-name" placeholder="회원권명">
-            <input type="date" id="date" value="{{$today}}">
+            <!-- <input type="date" id="date" value="{{$today}}"> -->
 			<button type="button" class="btn" onclick="searchMemberShip()">검색</button>
 		</div>
 	</div>
@@ -45,6 +41,11 @@
                     <li class="{{ request('area', 'all') === '700' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '700']) }}">강북권</a></li>
                 @endif
 			</ul>
+
+            <div class="tabs today">
+                <input type="date" id="search_date" value="{{$today}}" autocomplete="off">
+            </div>
+
 			<div class="tab-content">
 				<div class="tab-pane fade in active show">
 					<div class="tb_res tb_vertical">
@@ -108,100 +109,109 @@
 
 @push('js')
 <script>
+    var filteredSiseList = [];
     $(document).ready(function() {
-        console.log('siseList : ', siseList);
+        var date = dateFormat(document.getElementById('search_date').value);
+        filteredSiseList = searchDate(date);
+        renderSiseList(filteredSiseList);
+
         if ($('div').hasClass('chatbot') == true) {
             $('.main-footer').addClass('chatbot');
         }
     });
 
+    document.getElementById('search_date').addEventListener('change', function() {
+        var date = dateFormat(document.getElementById('search_date').value);
+        filteredSiseList = searchDate(date);
+        renderSiseList(filteredSiseList);
+    });
+
     // 회원권 검색
     function searchMemberShip() {
         var membershipName = document.getElementById('membership-name').value.toLowerCase();
-        var date = document.getElementById('date').value;
+        var date = dateFormat(document.getElementById('search_date').value);
         // console.log('date : ', date);
-        // if (!membershipName) {
-        //     alert('회원권명을 입력해주세요.');
-        //     return;
-        // }
 
-        var formattedDate = '';
-        if (date) {
-            var parts = date.split('-');
-            formattedDate = parts.join('');
-        }
-
-        console.log('siseList : ', siseList);
-        if(siseList == null){
-            alert('회원권이 존재하지 않습니다');
+        if (!membershipName) {
+            alert('회원권명을 입력해주세요.');
+            return;
         }
 
         var filteredSiseList = siseList.filter(function(sise) {
-            var postTitleMatch = sise['PostTitle'].toLowerCase().includes(membershipName);
-            // var dateMatch = sise['Pc6'] && sise['Pc6'] === formattedDate;
-            var dateMatch = date ? (sise['Pc6'] && sise['Pc6'] === formattedDate) : true;
-            console.log('dateMatch : ', dateMatch);
-
-            if(membershipName == ''){
-                return dateMatch
-            }else{
-                return postTitleMatch && dateMatch;
-            }
+        var postTitleMatch = sise['PostTitle'].toLowerCase().includes(membershipName);
+        var dateMatch = date ? (sise['Pc6'] && sise['Pc6'] === date) : true;
+        return postTitleMatch && dateMatch;
         });
         // console.log('filteredSiseList : ', filteredSiseList);
         renderSiseList(filteredSiseList);
     }
     // 동적으로 tbody 생ㄱ성
     function renderSiseList(siseList) {
-    var tbody = $('#sise-list');
-    tbody.empty(); // Clear existing rows
-    console.log('siseList.length : ', siseList.length);
+        var tbody = $('#sise-list');
+        tbody.empty(); // Clear existing rows
+        // console.log('siseList.length : ', siseList.length);
 
-    if (siseList.length === 0) {
-        tbody.html('<tr><td colspan="5">회원권이 존재하지 않습니다.</td></tr>');
-        return;
-    }
+        if (siseList.length === 0) {
+            tbody.html('<tr><td colspan="5">회원권이 존재하지 않습니다.</td></tr>');
+            return;
+        }
 
-    siseList.forEach(function(sise) {
-        var fluctuationClass = '';
-        var fluctuationIcon = '';
+        siseList.forEach(function(sise) {
+            var fluctuationClass = '';
+            var fluctuationIcon = '';
 
-        if (sise['fluctuation'] > 0) {
-            fluctuationClass = 'up';
-            fluctuationIcon = 'fa-sort-up';
-        } else if (sise['fluctuation'] < 0) {
-            fluctuationClass = 'down';
-            fluctuationIcon = 'fa-sort-down';
-        }
+            if (sise['fluctuation'] > 0) {
+                fluctuationClass = 'up';
+                fluctuationIcon = 'fa-sort-up';
+            } else if (sise['fluctuation'] < 0) {
+                fluctuationClass = 'down';
+                fluctuationIcon = 'fa-sort-down';
+            }
 
-        var fluctuationText = sise['fluctuation'] !== 0 ? `
-            <i class="fa-solid ${fluctuationIcon}"></i>
-            ${number_format(Math.abs(sise['fluctuation']))}
-        ` : `${number_format(sise['fluctuation'])}`;
-
-        var tr = $('<tr>');
-        tr.html(`
-            <td scope="row" data-label="${sise['PostTitle']}">${sise['PostTitle']}</td>
-            <td data-label="${sise['Pc3']}">${number_format(sise['Pc3'])}</td>
-            <td data-label="${sise['Pc4']}">${number_format(sise['Pc4'])}</td>
-            <td data-label="등락" class="${fluctuationClass}">
-                ${fluctuationText}
-            </td>
-            <td data-label="상담신청">
-                <button type="button" class="btn consult-btn"
-                        data-post-title="${sise['PostTitle']}"
-                        data-pc5="${sise['Pc5']}"
-                        onclick="window.location.href = '/contactus-custom/${sise['Pc5']}/${encodeURIComponent(sise['PostTitle'])}'">상담신청
-                </button>
-            </td>
-        `);
-        tbody.append(tr);
-    });
-}
+            var fluctuationText = sise['fluctuation'] !== 0 ? `
+                <i class="fa-solid ${fluctuationIcon}"></i>
+                ${number_format(Math.abs(sise['fluctuation']))}
+            ` : `${number_format(sise['fluctuation'])}`;
+
+            var tr = $('<tr>');
+            tr.html(`
+                <td scope="row" data-label="${sise['PostTitle']}">${sise['PostTitle']}</td>
+                <td data-label="${sise['Pc3']}">${number_format(sise['Pc3'])}</td>
+                <td data-label="${sise['Pc4']}">${number_format(sise['Pc4'])}</td>
+                <td data-label="등락" class="${fluctuationClass}">
+                    ${fluctuationText}
+                </td>
+                <td data-label="상담신청">
+                    <button type="button" class="btn consult-btn"
+                            data-post-title="${sise['PostTitle']}"
+                            data-pc5="${sise['Pc5']}"
+                            onclick="window.location.href = '/contactus-custom/${sise['Pc5']}/${encodeURIComponent(sise['PostTitle'])}'">상담신청
+                    </button>
+                </td>
+            `);
+            tbody.append(tr);
+        });
+    }
+
+    function searchDate(date){
+        return siseList.filter(function(siseFormDate) {
+            var dateMatch = date ? (siseFormDate['Pc6'] && siseFormDate['Pc6'] === date) : true;
+            return dateMatch;
+        });
+    }
 
     function number_format(number) {
         return new Intl.NumberFormat().format(number);
     }
+
+    function dateFormat(date){
+        var formattedDate = '';
+        if (date) {
+            var parts = date.split('-');
+            formattedDate = parts.join('');
+        }
+        return formattedDate;
+    }
 const siseList = {!! json_encode($siseList['Page']) !!}; // JavaScript에서 PHP 배열을 변환하여 변수에 할당
 </script>
 @endpush