sise.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. @extends('views.layouts.master')
  2. @section('content')
  3. @php
  4. date_default_timezone_set('Asia/Seoul');
  5. $today = date('Y-m-d');
  6. @endphp
  7. <div class="sub golf">
  8. <div class="container">
  9. <div class="navi">
  10. <a href="/"><i class="fa-solid fa-house"></i> 홈</a> > {{ $title_dir }} > {{ $title }}
  11. </div>
  12. <div class="title">
  13. <h2> {{ $title }} </h2>
  14. </div>
  15. </div>
  16. <!-- 회원권 검색 시작 -->
  17. <div class="search_ticket">
  18. <div class="container">
  19. <label>회원권 검색</label>
  20. <input type="text" id="membership-name" placeholder="회원권명">
  21. <button type="button" class="btn" onclick="searchMemberShip()">검색</button>
  22. </div>
  23. </div>
  24. <!--// 회원권 검색 끝 -->
  25. <!-- 시세 시작 -->
  26. <div class="quote">
  27. <div class="container">
  28. <ul class="tabs nav nav-tabs">
  29. <li class="{{ request('area', 'all') === 'all' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, 'all']) }}">전체</a></li>
  30. @if($siseType === 'golf')
  31. <li class="{{ request('area', 'all') === '100' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '100']) }}">수도권/강원/충청권</a></li>
  32. <li class="{{ request('area', 'all') === '200' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '200']) }}">영남/제주권</a></li>
  33. <li class="{{ request('area', 'all') === '300' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '300']) }}">호남권</a></li>
  34. @elseif($siseType === 'condo')
  35. <li class="{{ request('area', 'all') === '400' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '400']) }}">체인형콘도</a></li>
  36. <li class="{{ request('area', 'all') === '500' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '500']) }}">스키장콘도</a></li>
  37. @else
  38. <li class="{{ request('area', 'all') === '600' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '600']) }}">강남권</a></li>
  39. <li class="{{ request('area', 'all') === '700' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '700']) }}">강북권</a></li>
  40. @endif
  41. </ul>
  42. <div class="tabs">
  43. <!-- <input type="date" id="search_date" value="{{$today}}" autocomplete="off" style="cursor: pointer;"> -->
  44. <input type="text" id="search_date">
  45. </div>
  46. <div class="tab-content">
  47. <div class="tab-pane fade in active show">
  48. <div class="tb_res tb_vertical">
  49. <table cellspacing="0" cellpadding="0">
  50. <caption>단위: 만원</caption>
  51. <thead>
  52. <tr>
  53. <th>회원권명</th>
  54. <th>금일시세</th>
  55. <th>전일시세</th>
  56. <th>등락</th>
  57. <th>상담</th>
  58. </tr>
  59. </thead>
  60. <tbody id="sise-list"></tbody>
  61. </table>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <div id="loader" style="display: none;">Loading...</div>
  67. </div>
  68. <!--// 시세 끝 -->
  69. </div>
  70. @push('js')
  71. <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
  72. <script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/ko.js"></script>
  73. <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" />
  74. <script>
  75. var filteredSiseList = [];
  76. var allSiseList = [];
  77. var loadingData = false; // 데이터 로딩 중인지 여부를 나타내는 플래그 변수
  78. var page = 1;
  79. // 스크롤 이벤트 핸들러
  80. function handleScroll() {
  81. let scrollTop = $(document).scrollTop();
  82. let offsetHeight = $(document).height();
  83. let innerHeight = $(window).height();
  84. if (innerHeight + scrollTop >= offsetHeight) {
  85. page++;
  86. loadMoreData(10);
  87. }else{
  88. if ((offsetHeight - (innerHeight + scrollTop)) <= 1) { // 사용자 스크린의 크기가 달라짐에 따라 오차범위 1 이내 일때
  89. page++;
  90. loadMoreData(10);
  91. }else if((offsetHeight - (innerHeight + scrollTop)) == 1.25){
  92. page++;
  93. loadMoreData(10);
  94. }
  95. }
  96. }
  97. function loadMoreData(limit) {
  98. let date = dateFormat($('#search_date').val());
  99. if(siseType != 'golf'){
  100. const monday = dateFormat(formatDate($('#search_date').val()));
  101. // console.log('monday : ', monday);
  102. date = monday;
  103. }
  104. // console.log('siseType : ', siseType);
  105. let data = {
  106. "siseType": siseType,
  107. "areaType": areaType,
  108. "siseDate": date
  109. };
  110. if (limit) {
  111. data.page = page;
  112. data.limit = limit;
  113. }
  114. $.ajax({
  115. url: '/load-scroll-sise',
  116. method: 'GET',
  117. data: data,
  118. success: function(response) {
  119. var newSiseList = response.Page;
  120. if (newSiseList != null) {
  121. if(limit){
  122. filteredSiseList = filteredSiseList.concat(newSiseList);
  123. console.log(newSiseList);
  124. renderSiseList(filteredSiseList);
  125. }else{
  126. allSiseList = newSiseList;
  127. }
  128. } else {
  129. renderSiseList(filteredSiseList);
  130. }
  131. },
  132. error: function(error) {
  133. console.error('Error loading more data:', error);
  134. }
  135. });
  136. }
  137. // 회원권 검색
  138. function searchMemberShip() {
  139. $(window).off('scroll', handleScroll);
  140. var membershipName = $('#membership-name').val().toLowerCase();
  141. var date = dateFormat($('#search_date').val());
  142. if(siseType != 'golf'){
  143. const monday = dateFormat(formatDate($('#search_date').val()));
  144. date = monday;
  145. }
  146. if (!membershipName) {
  147. $(window).on('scroll', handleScroll);
  148. // alert('회원권명을 입력해주세요');
  149. // page = 1;
  150. // loadMoreData(10);
  151. renderSiseList(filteredSiseList);
  152. }else{
  153. var searchMemberShipList = allSiseList.filter(function(sise) {
  154. var postTitleMatch = sise['PostTitle'].toLowerCase().includes(membershipName);
  155. var dateMatch = date ? (sise['Pc6'] && sise['Pc6'] === date) : true;
  156. return postTitleMatch && dateMatch;
  157. });
  158. renderSiseList(searchMemberShipList);
  159. }
  160. }
  161. $(document).ready(function() {
  162. $('#search_date').flatpickr({
  163. dateFormat: 'Y-m-d',
  164. defaultDate: 'today',
  165. locale: 'ko',
  166. disableMobile: true,
  167. // onOpen: function(selectedDates, dateStr, instance) {
  168. // console.log('test');
  169. // },
  170. // onClose: function(selectedDates, dateStr, instance) {
  171. // // 위젯이 닫힐 때 실행할 코드
  172. // },
  173. // onChange: function(selectedDates, dateStr, instance) {
  174. // console.log('change');
  175. // },
  176. });
  177. $('#search_date').attr('type', 'text');
  178. // console.log('pickr : ', flatpickr);
  179. // console.log(siseList);
  180. loadMoreData();
  181. loadMoreData(10);
  182. // 스크롤 이벤트 설정
  183. $(window).on('scroll', handleScroll);
  184. // $(window).on('scroll', handleScrollWithDate);
  185. $('#search_date').on('change', function() {
  186. // if(siseType != 'golf'){
  187. // const monday = formatDate($(this).val());
  188. // // $(this).val(monday);
  189. // }
  190. page = 1;
  191. filteredSiseList = [];
  192. $(window).on('scroll', handleScroll);
  193. loadMoreData();
  194. loadMoreData(10);
  195. });
  196. if ($('div').hasClass('chatbot') == true) {
  197. $('.main-footer').addClass('chatbot');
  198. }
  199. });
  200. // 동적으로 tbody 생성
  201. function renderSiseList(siseList) {
  202. // console.log('renderSiseList : ', siseList);
  203. var tbody = $('#sise-list');
  204. tbody.empty(); // Clear existing rows
  205. if (siseList.length === 0) {
  206. tbody.html('<tr><td colspan="5">회원권이 존재하지 않습니다.</td></tr>');
  207. return;
  208. }
  209. // Pc1:회원권 코드 중복값 체크
  210. var uniquePc1Values = new Set();
  211. var uniqueSiseList = [];
  212. siseList.forEach(function(sise) {
  213. if (!uniquePc1Values.has(sise['Pc1'])) {
  214. uniquePc1Values.add(sise['Pc1']);
  215. uniqueSiseList.push(sise);
  216. }
  217. });
  218. uniqueSiseList.forEach(function(sise) {
  219. var fluctuationClass = '';
  220. var fluctuationIcon = '';
  221. if (sise['fluctuation'] > 0) {
  222. fluctuationClass = 'up';
  223. fluctuationIcon = 'fa-sort-up';
  224. } else if (sise['fluctuation'] < 0) {
  225. fluctuationClass = 'down';
  226. fluctuationIcon = 'fa-sort-down';
  227. }
  228. var fluctuationText = sise['fluctuation'] !== 0 ? `
  229. <i class="fa-solid ${fluctuationIcon}"></i>
  230. ${number_format(Math.abs(sise['fluctuation']))}
  231. ` : `${number_format(sise['fluctuation'])}`;
  232. var tr = $('<tr>');
  233. tr.html(`
  234. <td scope="row" data-label="${sise['PostTitle']}">${sise['PostTitle']}</td>
  235. <td data-label="${sise['Pc3']}">${number_format(sise['Pc3'])}</td>
  236. <td data-label="${sise['Pc4']}">${number_format(sise['Pc4'])}</td>
  237. <td data-label="등락" class="${fluctuationClass}">
  238. ${fluctuationText}
  239. </td>
  240. <td data-label="상담신청">
  241. <button type="button" class="btn consult-btn"
  242. data-post-title="${sise['PostTitle']}"
  243. data-pc5="${sise['Pc5']}"
  244. onclick="window.location.href = '/contactus-custom/${sise['Pc5']}/${encodeURIComponent(sise['PostTitle'])}'">상담신청
  245. </button>
  246. </td>
  247. `);
  248. tbody.append(tr);
  249. });
  250. }
  251. function number_format(number) {
  252. return new Intl.NumberFormat().format(number);
  253. }
  254. function dateFormat(date) {
  255. var formattedDate = '';
  256. if (date) {
  257. var parts = date.split('-');
  258. formattedDate = parts.join('');
  259. }
  260. return formattedDate;
  261. }
  262. function formatDate(date) {
  263. const selectedDate = new Date(date); // Date 객체로 변환
  264. const dayOfWeek = selectedDate.getDay(); // (0: 일요일, 1: 월요일, ..., 6: 토요일)
  265. const monday = new Date(selectedDate); // 해당 주의 월요일
  266. monday.setDate(selectedDate.getDate() - (dayOfWeek === 0 ? 6 : dayOfWeek - 1));
  267. const year = monday.getFullYear();
  268. const month = String(monday.getMonth() + 1).padStart(2, '0');
  269. const day = String(monday.getDate()).padStart(2, '0');
  270. return `${year}-${month}-${day}`;
  271. }
  272. let siseList = {!! json_encode($siseList['Page']) !!};
  273. const siseType = {!! json_encode($siseType) !!};
  274. const areaType = {!! json_encode($area) !!};
  275. </script>
  276. @endpush
  277. @endsection