hokky пре 4 месеци
родитељ
комит
1d98ba5239
2 измењених фајлова са 60 додато и 17 уклоњено
  1. 56 14
      pro/resources/views/index.blade.php
  2. 4 3
      pro/resources/views/page/sise.blade.php

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

@@ -44,9 +44,14 @@
 </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>
@@ -133,40 +138,54 @@
 <!--// 블로그 끝 -->
 
 <script>
-currentSiseType = 'golf';
+var currentSiseType = 'golf';
+var filteredSiseList = [];
 $(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');
-    var filteredSiseList = mainSiseList.filter(function(mainsise) {
+    filteredSiseList_with_sise = filteredSiseList.filter(function(mainsise) {
         return mainsise['Pc5'].includes(currentSiseType);
     });
 
-    renderMainSiseList(filteredSiseList);
+    renderMainSiseList(filteredSiseList_with_sise);
     // sise 더보기 버튼 list를 change할 때마다 활성화
     $('.m_quote .btn_wrap .m_more').show();
 }
 // defalut 가져오기
-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();
-}
+// 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();
+// }
 
 // tbody 생성
 function renderMainSiseList(siseList){
@@ -368,6 +387,20 @@ 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: {
@@ -396,6 +429,15 @@ 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']) !!};

+ 4 - 3
pro/resources/views/page/sise.blade.php

@@ -131,7 +131,10 @@
             formattedDate = parts.join('');
         }
 
-        // console.log('siseList : ', siseList);
+        console.log('siseList : ', siseList);
+        if(siseList == null){
+            alert('회원권이 존재하지 않습니다');
+        }
 
         var filteredSiseList = siseList.filter(function(sise) {
             var postTitleMatch = sise['PostTitle'].toLowerCase().includes(membershipName);
@@ -145,9 +148,7 @@
                 return postTitleMatch && dateMatch;
             }
         });
-
         // console.log('filteredSiseList : ', filteredSiseList);
-
         renderSiseList(filteredSiseList);
     }
     // 동적으로 tbody 생ㄱ성