SearchLayerMob.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : SearchLayerMob.html
  7. * @desc : 검색 레이어 Page
  8. *============================================================================
  9. * STYLE24
  10. * Copyright(C) 2020 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2021.06.14 bin2107 최초 작성
  15. *******************************************************************************
  16. -->
  17. <body>
  18. <div class="modal-dialog" role="document">
  19. <div class="modal-content">
  20. <div class="modal-header htop">
  21. <h5 class="modal-title sr-only" id="schPopLabel">통합검색</h5>
  22. </div>
  23. <div class="modal-body">
  24. <section class="sch_result">
  25. <!-- 1.통합검색 default -->
  26. <div class="inner">
  27. <form id="searchMainForm" name="searchMainForm">
  28. <input type="hidden" name="brandGroupNo" th:value="${brandGroupNo}"/>
  29. <div class="sch_title">
  30. <input type="text" class="form_control" name="keyword" placeholder="검색어를 입력하세요." autocomplete="off" onkeyup="fnOnkeyupKeyword(this);">
  31. <button type="button" class="btn_x" id="deleteKeyword" style="display:none;">X</button>
  32. <button type="button" class="btn_sch" id="btnSearchKeyword"><img src="/images/mo/ico_btn_search.png" alt=""></button>
  33. </div>
  34. </form>
  35. </div>
  36. <div class="inner default_box" id="defaultArea">
  37. <div class="filter-list">
  38. <div class="f_left">
  39. <h3>최근 검색어</h3>
  40. </div>
  41. <div class="f_right">
  42. </div>
  43. </div>
  44. <div class="search-list" th:classappend="${#lists.isEmpty(recentlyKeywordList)?'nodata':''}"> <!-- 검색데이터 없을시 nodata 클래스 추가. -->
  45. <ul>
  46. <li th:if="${recentlyKeywordList}" th:each="oneData, status : ${recentlyKeywordList}">
  47. <a href="javascript:void(0);" th:onclick="fnSearchKeyword([[${oneData}]])">
  48. <p th:text="${oneData}"></p>
  49. </a>
  50. <button type="button" class="xBtn" th:onclick="fnDeleteCookie(this,[[${oneData}]]);"><span>삭제</span></button>
  51. </li>
  52. </ul>
  53. <p class="nodata_txt" th:if="${#lists.isEmpty(recentlyKeywordList)}">최근 검색어가 없습니다.</p>
  54. </div>
  55. <h3 class="hot-key" th:if="${brandGroupNo==null}">STYLE24에서 검색되고 있어요</h3>
  56. <div class="related_keyword" th:if="${brandGroupNo==null}">
  57. <div class="sub_category">
  58. <div class="cate_wrap" id="popularKeyArea">
  59. <!-- <a href="javascript:;" class="on">전체</a>-->
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <!-- //1.통합검색 default -->
  65. <!-- 3.지금 많이 보고 있어요 상품. -->
  66. <div class="inner default_box" id="popularArea">
  67. <div class="now_view">
  68. <div class="store_product">
  69. <div class="allresult-tit">
  70. <h3>지금 많이 보고 있어요</h3>
  71. <button type="button" class="btn_refresh" onclick="fnRealtimeGoodsList();"><span th:text="${#calendars.format(#calendars.createNow(), 'HH:mm')}">17:30</span> 기준</button>
  72. </div>
  73. <div class="swiper-container sch_product">
  74. <div class="swiper-wrapper" id="itemViewArea">
  75. <th:block th:each="item, status : ${realtimeGoodsList}">
  76. <div class="swiper-slide">
  77. <div class="item_prod">
  78. <button type="button" class="itemLike" th:classappend="${item.wishCnt > 0}? 'likeit' : ''" onclick="cfnMoPutWishList(this);" th:attr="goodsCd=${item.itemId}">관심상품 추가</button>
  79. <a th:href="${item.itemUrl}">
  80. <img th:src="${item.imageUrl}" alt="">
  81. <div class="s-text">
  82. <div class="itemName" th:text="${item.itemName}"></div>
  83. <p class="itemTag" th:text="${item.count < 10 ? '10명 미만' : item.count + '명 보는중'}">508명 보는중</p>
  84. </div>
  85. </a>
  86. </div>
  87. </div>
  88. </th:block>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <!-- //3.지금 많이 보고 있어요 상품. -->
  95. <!-- 4.검색어 타이핑 -->
  96. <div class="inner searching_box" id="keyupArea" style="display:none;" th:if="${brandGroupNo==null}">
  97. <div class="filter-list store-list">
  98. </div>
  99. <div class="relative-list">
  100. </div>
  101. </div>
  102. <div class="inner searching_box" id="keyupCateArea" style="display:none;" th:if="${brandGroupNo==null}">
  103. <div class="sch_category">
  104. </div>
  105. </div>
  106. <!-- //4.검색어 타이핑 -->
  107. <!-- 3.검색결과 없을때 -->
  108. <div class="inner empty_box" id="noDataArea" style="display:none;">
  109. <div class="relative-list nodata"> <!-- 검색결과 없을 시 nodata 클래스 추가 -->
  110. <p class="nodata_txt">&lsquo;<span id="noDataKeyword"></span>&rsquo; 에 맞는 상품을 찾지 못했습니다.<br>검색어를 변경해 보세요.</p>
  111. </div>
  112. <h3 class="hot-key">STYLE24에서 검색되고 있어요</h3>
  113. <div class="related_keyword">
  114. <div class="sub_category">
  115. <div class="cate_wrap" id="noDataRelatedKeyword">
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="inner empty_box" id="recommandArea" style="display:none;">
  121. <div class="recommand_product">
  122. <div class="store_product">
  123. <div class="swiper-container recommand_slide">
  124. <h3>이런 상품은 어떤가요?</h3>
  125. <div class="swiper-wrapper" id="recommendItemArea">
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- //3.검색결과 없을때 -->
  132. </section>
  133. </div>
  134. </div>
  135. </div>
  136. <script src="/ux/plugins/gaga/gaga.paging.js"></script>
  137. <script th:inline="javascript">
  138. /*<![CDATA[*/
  139. var trendKeywordList = [[${trendKeywordList.trendList}]];
  140. var swiperschProduct = new Swiper('.swiper-container.sch_product', {
  141. slidesPerView: 3,
  142. spaceBetween: 7,
  143. autoplay: {
  144. delay: 4000,
  145. },
  146. freeMode: true,
  147. //centeredSlides: true,
  148. });
  149. var swiperschProduct = new Swiper('.swiper-container.recommand_slide', {
  150. slidesPerView: 2.2,
  151. spaceBetween: 8,
  152. autoplay: {
  153. delay: 4000,
  154. },
  155. freeMode: true,
  156. //centeredSlides: true,
  157. });
  158. $(".itemLike").click(function () {
  159. $(this).toggleClass("likeit");
  160. });
  161. var ckKeyword = "st24ck_today_keyword";
  162. var fnSetKeywordCookie = function(keyword) {
  163. var arrKeyword = new Array;
  164. var arrTempKeyword = new Array;
  165. var j = 0;
  166. arrKeyword = gagajf.getCookie(ckKeyword).split(",");
  167. if (arrKeyword.length > 0) {
  168. for (var i = 0; i < arrKeyword.length; i++) {
  169. // 쿠키에 없으면
  170. if (arrKeyword[i] != keyword && arrKeyword[i] != "") {
  171. arrTempKeyword[j++] = arrKeyword[i];
  172. }
  173. }
  174. arrTempKeyword[j++] = keyword;
  175. } else {
  176. gagajf.setCookie(ckKeyword, keyword, 1);
  177. }
  178. gagajf.setCookie(ckKeyword, arrTempKeyword, 1);
  179. }
  180. // 키워드 검색
  181. $('#btnSearchKeyword').on('click', function() {
  182. if (!gagajf.validation($('#searchMainForm'))) {
  183. return false;
  184. }
  185. let keyword = encodeURIComponent($('#searchMainForm input[name=keyword]').val());
  186. // 쿠키 세팅
  187. fnSetKeywordCookie(keyword);
  188. let actionUrl = _PAGE_SEARCH_GOODS + '?keyword=' + keyword + '&brandGroupNo=' + $('#searchMainForm input[name=brandGroupNo]').val();
  189. cfnGoToPage(actionUrl);
  190. });
  191. // 검색어 찾기
  192. var fnGetAutoSearch = function (){
  193. gagajf.ajaxFormSubmit("/display/search/auto/complete", document.searchMainForm, fnAutoCompleteList);
  194. }
  195. // 검색어 찾기 결과
  196. var fnAutoCompleteList = function (result){
  197. if(result.autoKeywords.length==0 && gagajf.isNull(result.brand.brandGroupNo) && result.cateList.length == 0 && gagajf.isNull(result.goodsList)){
  198. $('.sch_result .default_box').hide();
  199. $('.sch_result .searching_box').hide();
  200. $('.sch_result .empty_box').show();
  201. $("#noDataArea").find('#noDataKeyword').text($("#searchMainForm").find('input[name=keyword]').val());
  202. // 검색어 연관 상품 추천
  203. fnRecommendItemList($("#searchMainForm").find('input[name=keyword]').val());
  204. // 인기검색어
  205. fnTrendKeywordList();
  206. }else{
  207. $('.sch_result .default_box').hide();
  208. $('.sch_result .searching_box').show();
  209. $('.sch_result .empty_box').hide();
  210. // 자동완성 키워드
  211. if(result.autoKeywords != null && result.autoKeywords.length > 0){
  212. $("#keyupArea").find(".relative-list").html('');
  213. let tag = '';
  214. tag += '<ul>\n';
  215. $.each(result.autoKeywords, function (idx,item){
  216. tag += '<li>\n';
  217. tag += ' <a href="javascript:void(0);" onclick="fnSearchKeyword(\''+result.autoKeywords[idx]+'\');">\n';
  218. tag += ' <p><span>'+result.autoKeywords[idx]+'</span></p>\n';
  219. tag += ' </a>\n';
  220. tag += '</li>\n';
  221. });
  222. tag += '</ul>\n';
  223. $("#keyupArea").find(".relative-list").append(tag);
  224. }else{
  225. $("#keyupArea").find(".relative-list").html('');
  226. }
  227. // 브랜드
  228. if(result.brand != null && !gagajf.isNull(result.brand.brandGroupNo)){
  229. $("#keyupArea").find(".store-list").html('');
  230. let tag = '';
  231. tag += '<div class="f_left">\n';
  232. tag += ' <h3>'+result.brand.brandGroupNm+' 공식 스토어</h3>\n';
  233. tag += '</div>\n';
  234. tag += '<div class="f_right">\n';
  235. tag += ' <a href="javascript:void(0);" onclick="cfnGoToBrandMain('+result.brand.brandGroupNo+');">바로가기</a>\n';
  236. tag += '</div>\n';
  237. $("#keyupArea").find(".store-list").append(tag);
  238. }else{
  239. $("#keyupArea").find(".store-list").html('');
  240. }
  241. if(result.cateList != null && result.cateList.length > 0){
  242. $("#keyupCateArea").find(".sch_category").html('');
  243. let tag = '';
  244. tag += '<h3>카테고리</h3>\n';
  245. tag += '<ul>\n';
  246. $.each(result.cateList, function (idx, item){
  247. tag +='<li>\n';
  248. tag +=' <a href="javascript:void(0);" onclick="cfnGoToGoodsList(0,\'G032_101\' ';
  249. if(item.cate1No != null){
  250. tag += ', '+item.cate1No;
  251. }
  252. if(item.cate2No != null){
  253. tag += ', '+item.cate2No;
  254. }
  255. if(item.cate3No != null){
  256. tag += ', '+item.cate3No;
  257. }
  258. if(item.cate4No != null){
  259. tag += ', '+item.cate4No;
  260. }
  261. if(item.cate5No != null){
  262. tag += ', '+item.cate5No;
  263. }
  264. tag += ');">\n';
  265. if(item.cate1Nm != null){
  266. tag += ' <span>'+item.cate1Nm+'</span>\n';
  267. }
  268. if(item.cate2Nm != null){
  269. tag += ' <span>'+item.cate2Nm+'</span>\n';
  270. }
  271. if(item.cate3Nm != null){
  272. tag += ' <span>'+item.cate3Nm+'</span>\n';
  273. }
  274. if(item.cate4Nm != null){
  275. tag += ' <span>'+item.cate4Nm+'</span>\n';
  276. }
  277. if(item.cate5Nm != null){
  278. tag += ' <span>'+item.cate5Nm+'</span>\n';
  279. }
  280. tag +=' </a>\n';
  281. tag +='</li>\n';
  282. });
  283. tag += '</ul>\n';
  284. $("#keyupCateArea").find(".sch_category").append(tag);
  285. }else{
  286. $("#keyupCateArea").find(".sch_category").html('');
  287. }
  288. }
  289. }
  290. // 검색어 입력
  291. var fnOnkeyupKeyword = function (obj){
  292. var searchValue = $(obj).val();
  293. if(searchValue.length > 0){
  294. fnGetAutoSearch();
  295. }else{
  296. $('.sch_result .default_box').show();
  297. $('.sch_result .searching_box').hide();
  298. $('.sch_result .empty_box').hide();
  299. }
  300. }
  301. document.getElementById("deleteKeyword").onclick = function (){
  302. $("#searchMainForm").find("input[name=keyword]").val('');
  303. fnOnkeyupKeyword($("#searchMainForm").find("input[name=keyword]"));
  304. }
  305. $(document).ready( function() {
  306. if (trendKeywordList.length > 0) {
  307. $("#popularKeyArea").html('');
  308. trendKeywordList.forEach(function (item, idx) {
  309. var tag = '';
  310. if (idx < 10) {
  311. tag += ' <a href="javascript:void(0);" onclick="fnSearchKeyword(\''+item.keyword+'\');">'+ item.keyword +'</a>';
  312. }
  313. $("#popularKeyArea").append(tag);
  314. });
  315. }else{
  316. $("#popularKeyArea").html('');
  317. }
  318. $("#keyupArea").hide();
  319. $("#keyupCateArea").hide();
  320. $("#deleteKeyword").hide();
  321. $("#noDataArea").hide();
  322. $("#recommandArea").hide();
  323. });
  324. // 선택 단어 검색
  325. var fnSearchKeyword = function (obj){
  326. $("#searchMainForm").find("input[name=keyword]").val(obj);
  327. $('#btnSearchKeyword').trigger('click');
  328. }
  329. // 선택 단어 삭제
  330. var fnDeleteCookie = function (obj, keyword){
  331. $(obj).closest('li').remove();
  332. gagajf.setCookie('st24ck_today_keyword',keyword, -1);
  333. }
  334. // 검색어 입력 후 엔터키
  335. $('#searchMainForm input[name=keyword]').keypress(function (event) {
  336. if (event.which === 13) {
  337. event.preventDefault();
  338. $('#btnSearchKeyword').trigger('click');
  339. }
  340. });
  341. // 인기검색어 조회
  342. var fnTrendKeywordList = function (){
  343. $("#noDataRelatedKeyword").html('');
  344. var html = '';
  345. $.getJSON('/display/search/trend/keyword/list', function (result){
  346. if(result.trendList.length > 0){
  347. $.each(result.trendList, function (idx, item){
  348. html += '<a href="javascript:void(0);" onclick="fnSearchKeyword(\''+item.keyword+'\');"><span>#</span>'+item.keyword+'</a>';
  349. });
  350. }
  351. $("#noDataRelatedKeyword").append(html);
  352. });
  353. }
  354. // 실시간 상품 새로고침
  355. var fnRealtimeGoodsList = function (){
  356. $("#itemViewArea").html('');
  357. var html = '';
  358. $.getJSON('/display/realtime/goods/list', function (result){
  359. // console.log(result);
  360. if(result.length > 0){
  361. $.each(result, function (idx, item){
  362. html += '<div class="swiper-slide">\n';
  363. html += ' <div class="item_prod">\n';
  364. html += ' <button type="button" class="itemLike';
  365. if(item.wishCnt > 0){
  366. html += ' likeit';
  367. }
  368. html += '" onclick="cfnMoPutWishList(this);" goodsCd="'+item.itemId+'">관심상품 추가</button>\n';
  369. html += ' <a href="'+item.itemUrl+'">\n';
  370. html += ' <img src="'+item.imageUrl+'" alt="">\n';
  371. html += ' <div class="s-text">\n';
  372. html += ' <div class="itemName">'+item.itemName+'</div>\n';
  373. if(item.count < 10){
  374. html += ' <p class="itemTag">10명 미만</p>\n';
  375. }else{
  376. html += ' <p class="itemTag">'+item.count.addComma()+'명 보는중</p>\n';
  377. }
  378. html += ' </div>\n';
  379. html += ' </a>\n';
  380. html += ' </div>\n';
  381. html += '</div>\n';
  382. });
  383. }
  384. $("#itemViewArea").append(html);
  385. var swiperschProduct2 = new Swiper('.swiper-container.sch_product', {
  386. slidesPerView: 3,
  387. spaceBetween: 7,
  388. autoplay: {
  389. delay: 4000,
  390. },
  391. freeMode: true,
  392. //centeredSlides: true,
  393. });
  394. });
  395. }
  396. // 검색어 연관 상품 추천
  397. var fnRecommendItemList = function (keyword){
  398. if(gagajf.isNull(keyword)){
  399. keyword = "";
  400. }
  401. var data = {keyword : keyword.trim()};
  402. var html = '';
  403. $.getJSON('/display/recommend/item/list', data, function (result){
  404. $("#recommendItemArea").html('');
  405. if(result.length > 0){
  406. $.each(result, function (idx, item){
  407. html += '<div class="swiper-slide">\n';
  408. html += ' <div class="item_prod">\n';
  409. html += ' <div class="item_state">\n';
  410. html += ' <button type="button" class="itemLike">관심상품 추가</button>\n';
  411. html += ' <a href="'+item.product.itemUrl+'" class="itemLink">\n';
  412. html += ' <div class="itemPic">\n';
  413. html += ' <img class="vLHTC pd_img" src="'+item.product.itemImage+'" alt="">\n';
  414. html += ' </div>\n';
  415. html += ' <p class="itemBrand">'+item.product.brandName+'</p>\n';
  416. html += ' <div class="itemName">'+item.product.itemName+'</div>\n';
  417. html += ' <p class="itemPrice">\n';
  418. if(item.product.salePrice < item.product.originalPrice) {
  419. html += ' <span class="itemPrice_original">'+ item.product.originalPrice.addComma() +'</span>\n';
  420. }
  421. html += item.product.salePrice.addComma() ;
  422. if(item.product.salePrice < item.product.originalPrice) {
  423. html += ' <span class="itemPercent">' + Math.round((item.product.originalPrice - item.product.salePrice) / (item.product.originalPrice * 1.0) * 100) + '%</span>\n';
  424. }
  425. html += ' </p>\n';
  426. html += ' </a>\n';
  427. html += ' </div>\n';
  428. html += ' </div>\n';
  429. html += '</div>\n';
  430. });
  431. }
  432. $("#recommendItemArea").append(html);
  433. var swiperschProduct3 = new Swiper('.swiper-container.recommand_slide', {
  434. slidesPerView: 2.2,
  435. spaceBetween: 8,
  436. autoplay: {
  437. delay: 4000,
  438. },
  439. freeMode: true,
  440. //centeredSlides: true,
  441. });
  442. });
  443. }
  444. /*]]>*/
  445. </script>
  446. </body>
  447. </html>