/* * 작성자 : 천승환 * 작성일 : 2014-10-23 * 설명 : 장바구니 */ var g_entpArr = new Array(); var g_goodArr = new Array(); var assistGoodName = new Array(); $(document).ready(function(){ // 타이틀변경 $(document).attr("title",'한국소비자원 참가격'+' 장바구니가격비교'); // 품목군 코드 fn_getItemCode("2", "", "searchConM", $("#hid_searchConM").val()); $("#searchConM").load(); // 품목 코드 fn_getItemCode("3", $("#hid_searchConM").val(), "searchConS", $("#hid_searchConS").val()); // 품목군 코드 변경 $("#searchConM").change(function(){ fn_getItemCode("3", $(this).val(), "searchConS", $("#hid_searchConS").val()); }); //상품 자동완성 $.ajax({ type:"POST", url:"/tprice/portal/saleinfo/saleinfo/getAssistWords2.do", dayaType:"json", success:function(data) { goodName = data.goodNames; $.each(goodName, function(key) { assistGoodName.push(goodName[key].goodName); }); $("#goodName").autocomplete({ source: assistGoodName, minLength:0 }); $("#goodName").dblclick(function(){ $("#goodName").autocomplete("search",""); }); }, failure:function(data) { } }); // 업태코드 설정 fn_getCode("BU", "", "entpTypeCode", $("#hid_entpTypeCode").val(), fn_delEntptype); // 지역코드 설정 fn_getCode("", "020000000", "entpAreaCode", $("#hid_entpAreaCode").val()); // 업체목록 설정 fn_setEntpList("", "", ""); // 업태 변경 $("#entpTypeCode").change(function(){ fn_setEntpList($(this).val(), $("#entpAreaCode option:selected").val(), ""); }); // 지역 변경 $("#entpAreaCode").change(function(){ fn_setEntpList($("#entpTypeCode option:selected").val(), $(this).val(), ""); }); // cookie에 상품정보가 있으면 조회 if($.cookie("cartItem") != undefined){ fn_search(); } // 업체 추가 $("#search_btn").click(function(){ if( !fn_validation() ){ $("#entpId").val(""); return; } // 조회 fn_search(); }); // 상품조회 $("#btn_schGood").click(function(){ var searchConM = $("#searchConM").val(); var searchConS = $("#searchConS").val(); var tmp = fn_XSSFilter($("#goodName").val()); var goodName = encodeURI(encodeURIComponent(tmp)); var pop_status= fn_bpopup("/tprice/portal/dailynecessitypriceinfo/shoppingbasketcomparison/getShoppingBasketSearchGoods.do" + "?searchConM="+searchConM + "&searchConS="+searchConS + "&goodName="+goodName , 850, 650,"상품조회"); if(pop_status != null) { pop_status.focus(); //20170330 } $("#searchConM").focus(); //20170330 }); // 판매업체 삭제 $("#resultTable").on("click", "#btn_delEntp", function(){ var delEntpId = $(this).siblings("input:hidden").val(); if(g_entpArr.length > 1){ for(var i=0; i>>>>>>>>>" + elem); var entpId = $(this).siblings("input:hidden").val(); fn_bpopup("/tprice/portal/map/map.do?entpId="+entpId+"&focusObj="+$(elem).attr('id')+"&serviceType=default", 850, 600); }); }); $(window).load(function(){}); // 업체명 조회 function fn_setEntpList(entpType, entpArea, selVal){ $("#entpId option").each(function(){ $(this).remove(); }); $("#entpId").append(""); fn_getEntpList(entpType, entpArea, "", "entpId", selVal); } // 업태 selectbox '제조업체' 항목 삭제 function fn_delEntptype(){ $("#entpTypeCode option").each(function(){ if($(this).val() == "MF"){ $(this).remove(); } }); } // 장바구니 가격정보 조회전 체크 function fn_validation(){ var newEntpId = $.trim($("#entpId option:selected").val()); var dupEntp = false; if($.cookie("cartItem") == undefined){ alert("장바구니에 상품이 없습니다."); return false; } // 장바구니 판매업체 확인 if(g_entpArr.length == 4){ alert("판매업체는 4개 까지만 선택 할수 있습니다."); return false; } // 이미 추가한 판매업체인지 확인 for(var i=0; i"; strHtml += " 지도보기"; strHtml += " 판매업체 제거"; strHtml += " "; strHtml += " "; } strHtml += " 내지역 최저가
(" + myArea + ")"; strHtml += " "; strHtml += ""; strHtml += ""; // 상품 tr 생성 for(var i=0; i"; } strHtml += ""; strHtml += " "; strHtml += " " + goodImgUrl + "
" + g_goodArr[i].goodName; strHtml += "
상품 제거
"; strHtml += " "; strHtml += " "; // 전국 평균가 if(totAvgPriceList.length > 0){ var existGoodId = false; for(var j=0; j"; // 전국 평균가 저장 amountArr[i].push( {"goodId":goodId, "totAvgGoodPrice":totAvgPriceList[j].totAvgGoodPrice} ); existGoodId = true; } } if(!existGoodId){ strHtml += "가격정보 없음"; // 전국 평균가 저장 amountArr[i].push( {"goodId":goodId, "totAvgGoodPrice":0} ); } } else{ strHtml += "가격정보 없음"; // 전국 평균가 저장 amountArr[i].push( {"goodId":goodId, "totAvgGoodPrice":0} ); } // 업체별 평균가 td 생성 for(var j=0; j" + $.number(tmpList[l].entpAvgGoodPrice) + ""; noPriceInfo = false; // 판매업체 평균가 저장 amountArr[i].push( {"goodId":goodId, "entpId":g_entpArr[j].entpId, "entpAvgGoodPrice":tmpList[l].entpAvgGoodPrice} ); } } } } // 판매업체 평균 가격정보가 없으면 판매업체별 가격정보도 없음으로 셀 병합 if(noPriceInfo){ noItemPrice = true; strHtml += "가격정보 없음"; // 판매업체 평균가 저장 amountArr[i].push( {"goodId":goodId, "entpId":g_entpArr[j].entpId, "entpAvgGoodPrice":0} ); } // 업체별 평균 가격정보가 있으면 true, 없으면 false 저장 noPriceInfoArr[i][j] = noItemPrice; } // 지역 최저가 td 생성 if(areaMinPriceList.length > 0){ var existGoodId = false; for(var j=0; j(" + tmpList[k].entpName + ")
"; areaMinPrice = tmpList[k].areaMinGoodPrice; } strHtml += ""; existGoodId = true; } } if(!existGoodId){ strHtml += "가격정보 없음"; } } else{ strHtml += "가격정보 없음"; } // 지역 최저가 저장 amountArr[i].push( {"goodId":goodId, "areaMinGoodPrice":areaMinPrice} ); strHtml += ""; strHtml += ""; // 판매점 가격 td 생성 for(var j=0; j 0 && j <= g_entpArr.length){ for(var k=0; k (g_entpArr.length+1) && j <= (g_entpArr.length*2)+2){ for(var k=0; k 0 && j <= g_entpArr.length){ for(var k=0; k (g_entpArr.length+1) && j <= (g_entpArr.length*2)+2){ for(var k=0; k"; // 업체별 공통 판매상품 총액 td 생성 for(var i=0; i(" + $.number(g_entpArr[i].comSaleItemAvgAmt) + ")"; } strHtml += " " + $.number(comNationalMinAmt) + ""; // 내지역 최저가(공통 판매상품) strHtml += " "; strHtml += " "; // 공통 판매상품 총액, 총액 항목 구분 tr strHtml += " "; strHtml += " "; strHtml += " "; strHtml += " 총액
(평균가 총액)"; strHtml += " " + $.number(totNationalAvgAmt) + ""; // 총액 td 생성 for(var i=0; i(" + $.number(g_entpArr[i].totSaleItemAvgAmt) + ")"; } strHtml += " " + $.number(totNationalMinAmt) + ""; strHtml += " "; strHtml += ""; $("#resultTable").html(strHtml); } // 상품정보를 cookie에 저장 function fn_setCookie(goodId, goodNm, goodImgSeq){ var cookieVal = new Array(); if($.cookie("cartItem") != undefined){ cookieVal = $.cookie("cartItem").split(","); if(cookieVal.length == 20){ alert("상품은 20개만 선택 가능 합니다."); return; } $.cookie("cartItem", $.cookie("cartItem") + "," + goodId + ":" + goodNm + ":" + goodImgSeq, {path:'/',expires:30}); } else{ $.cookie("cartItem", goodId + ":" + goodNm + ":" + goodImgSeq, {path:'/',expires:30}); } // 조회 호출 // fn_search(); // 웹접근성 지적(의도하지 않은 동작)으로 주석 처리 by 황인환 2021.04.22. } // 상품정보를 cookie에서 삭제 function fn_delCookie(goodId){ var cookieVal = new Array(); var newCookieVal = ""; var cookieValGoodId = ""; var cookieValGoodNm = ""; var cookieValGoodImgSeq = ""; cookieVal = $.cookie("cartItem").split(","); if(cookieVal.length == 1){ $.removeCookie("cartItem", {path:'/'}); // $("#resultTable").html(""); // 웹접근성 지적(의도치 않은 동작)으로 삭제 2021.04.22 // $('#search_btn').focus(); // 웹접근성 2019.04.19., 웹접근성 지적(상품검색 레이어 팝업에서 아이템 모두 삭제 시 포커스 잃음)으로 삭제 2021.04.22. } else{ for(var i=0; i전체"); if(itemLevel == undefined){ itemLevel = ""; } if(highItemCode == undefined){ highItemCode = ""; } if(itemLevel != "" || highItemCode != ""){ $.ajax({ type:"POST", url: "/tprice/portal/dailynecessitypriceinfo/shoppingbasketcomparison/selectItemCode.do", data: "itemLevel=" + itemLevel + "&highItemCode=" + highItemCode, dataType:"json", success:function(data){ var codeData = data.json; $.each(codeData, function(i){ if(codeData[i].CODE == selVal){ $("#" + objId).append(""); } else{ $("#" + objId).append(""); } }); if( typeof callbackFn === "function" ) { callbackFn(); } }, failure:function(data){} }); } } function fn_bFocus(){ $('#resultTable').focus(); }