//////상품 기본 정보 var _goodUid = $("input[name='guid']").val(); var _goodTitle = $("input[name='title']").val(); var _goodPrice = $("input[name='price']").val(); var _goodStock = $("input[name='stock']").val(); //상품 옵션 정보 var _nChkOpt_useFlag = $("input[name='nChkOpt_useFlag']").val(); var _nChkOPt_count = parseInt($("input[name='nChkOPt_count']").val()); var _nChkOpt_type = $("input[name='nChkOpt_type']").val(); var _nChkStock_type = $("input[name='nChkStock_type']").val(); var _nChkMultiOpt_useFlag = $("input[name='nChkMultiOpt_useFlag']").val(); var _nChkMultiOpt_EA = $("input[name='nChkMultiOpt_EA']").val(); var _nChkMultiOpt_Price = $("input[name='nChkMultiOpt_Price']").val(); var _nChkTextOpt_useFlag = $("input[name='nChkTextOpt_useFlag']").val(); var _nChkAddGoods_useFlag = $("input[name='nChkAddGoods_useFlag']").val(); //''20180712 joonyus 최대구매수량 설정 var _MaxEa=parseInt($("input[name='MaxEa']").val()); var _IsMaxBuy=$("input[name='IsMaxBuy']").val(); //레이어 기본값 var currOptIdx = 0; ///''20171226 joonyus 단위구매추가 var _minEa= parseInt($("input[name='minEa']").val()); var _buyUnit=parseInt($("input[name='buyUnit']").val()); var _IsUnit=$("input[name='IsUnit']").val(); var _EaType=$("input[name='EaType']").val(); //A: 전체계산 B: 개별계산 var _IsPlusOne=$("input[name='IsPlusOne']").val(); var _IsPlusOne_Select_check=false; //20191029 joonyus 리워드 구매자 할인설정 추가 var _I_Reward_UserID=$("input[name='I_Reward_UserID']").val(); //추가상품 옵션 선택시 function fnSetAddOpt(e){ var _optType = "addopt"; var _optUid = $(e).attr("data-optuid"); var _optName = $(e).attr("data-optname"); var _optReq = $(e).attr("data-optreq"); var goodUid = $(e).find("option:selected").val(); var itemName = "└ " + $(e).find("option:selected").attr("data-itemname"); var itemPrice = $(e).find("option:selected").attr("data-itemprice"); var itemStock = parseInt($(e).find("option:selected").attr("data-itemstock")); // // 추가 20180828 joonyus if (goodUid != "0") { //fnSetAddOptionLayer(_optType, goodUid, itemName, itemPrice, "", 0, _optUid, _optName); fnSetAddOptionLayer(_optType, goodUid, itemName, itemPrice, "", 0, _optUid, _optName,itemStock); // 변경 20180828 joonyus fnSetTotalGoodsPrice(); //총 상품금액 구하기 $(e).val('0'); } } //옵션 없는 상품, 수량만 조정 //기본옵션 A 선택시 : 분리형 function fnSetOptTypeA(e, strDELIMITER){ var optType = "opt"; var optCount = 0; var optStock = 0; //옵션 조합의 재고수량 var optPrice = 0; //옵션 조합의 가격 var itemUids = ""; var itemValues = ""; var arrOptUid = new Array(); //옵션 uid 배열 var arrOptName = new Array(); //옵션 이름 배열 var arrItemUid = new Array(); //아이템 uid 배열 var arrItemName = new Array(); //아이템 이름 배열 $("select[name='itemUid'] option:selected").each(function(index){ optCount += 1; var itemUid = $(this).val(); var itemValue = $(this).text(); if (itemUid == "" || itemUid == "0" ) { alert(""+ fnLANG("/m/jscript/fnOption.js",1) +""); $(this).eq(index - 1).focus(); return false; } var optUid = $(this).parent().attr("data-optuid"); var optName = $(this).parent().attr("data-optname"); //선택된 옵션의 배열 저장 arrOptUid[index] = optUid; arrOptName[index] = optName; arrItemUid[index] = itemUid; arrItemName[index] = itemValue; if ( _nChkOPt_count == optCount ) { itemUids += itemUid; itemValues += itemValue; } else { itemUids += itemUid + strDELIMITER; itemValues += itemValue + strDELIMITER; } }); if ( _nChkOPt_count == optCount ){ var rt = true; //재고, 가격 추출 ajax(S) $.ajax({ url : "/common/ajax/exec_getItemInfo.asp", data : "guid=" + _goodUid + "&itemUids=" + itemUids + "&optType="+ _nChkOpt_type, async : false, //전역 처리 error : function(html){ //alert('오류입니다.'); }, success : function(html){ if (html == "fail") { alert(""+ fnLANG("/m/jscript/fnOption.js",2) +""); rt = false; return false; } else { optStock = parseInt(html.split("|")[0]); optPrice = parseInt(html.split("|")[1]); if ( _nChkStock_type == "F" && optStock <= 0) { alert(""+ fnLANG("/m/jscript/fnOption.js",3) +""); rt = false; return false; } } } }); //재고, 가격 추출 ajax(E) //레이어생성(S) var tHtml = ""; for (i=0;i < _nChkOPt_count ;i++ ){ tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "+ arrOptName[i] +" : "+ arrItemName[i]; tHtml += "
"; } tHtml += " ( + ₱ "+ optPrice +" )"; //레이어생성(E) //190514|wjy 옵션이 중복해서 들어가는 오류 수정 var itemCount = $('.selected_option').length; var valOpt = new Array(); var valOpt2 = new Array(); for (j = 1; j <= itemCount ; j++ ) { var itemCount2 = $('.selected_option').eq(j-1).find(".opt_info_cls").length; for (f=0;f < itemCount2 ;f++ ){ chkoptUid = $('.selected_option').eq(j-1).find("input[name=optUid]").eq(f-1).val(); chkoptItemUid = $('.selected_option').eq(j-1).find("input[name=optItemUid]").eq(f-1).val(); valOpt[f] = chkoptUid+"||"+chkoptItemUid } for (i=0;i < _nChkOPt_count ;i++ ){ valOpt2[i] = arrOptUid[i]+"||"+arrItemUid[i] } if (String(valOpt.sort()) == String(valOpt2.sort())) { alert(""+ fnLANG("/m/jscript/fnOption.js",4) +""); rt = false; } } //재고 파악 후 레이어 그리기(S) if (rt){ fnSetAddOptionLayer(optType, _goodUid, _goodTitle, _goodPrice, tHtml, optPrice, "", "", optStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //재고 파악 후 레이어 그리기(E) } //초기화 $("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); select_initAdd($(this));//초기화 추가 처리, jings3, 2019-02-18 }); //초기화 $("textarea[name='textOpt_Value']").each(function(index){ $(this).val(""); }); } // 20180604 kyh 분리형 마지막 이전 옵션 선택 시 function fnSetOptStock(e, strDELIMITER){ var optCount = 0; var itemUids = ""; var arrItemUid = new Array(); //아이템 uid 배열 ///20180711 joonyus 순차옵션선택 체크에 필요함 var selectCnt = $("select[name='itemUid']").length; selectCnt = selectCnt-1; $("select[name='itemUid'] option:selected").each(function(index){ var itemUid = $(this).val(); if (selectCnt > index){ ///20180711 joonyus 순차옵션선택 체크에 필요함 if (itemUid <= 0 ){ alert(""+ fnLANG("/m/jscript/fnOption.js",5) +""); //초기화 $("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); select_initAdd($(this));//초기화 추가 처리, jings3, 2019-02-18 }); //초기화 $("textarea[name='textOpt_Value']").each(function(index){ $(this).val(""); }); return false; }else{//1차만 선택하고선 다음차를 선택안했다면, jings3, 2019-02-18 if ( $("select[name='itemUid']").eq(index + 1).val() == "0" ){ select_initAdd($("select[name='itemUid']").eq(index + 1));//초기화 추가 처리, jings3, 2019-02-18 } } } if (itemUid > 0 ){ optCount += 1; //선택된 옵션의 배열 저장 arrItemUid[index] = itemUid; if ( _nChkOPt_count == optCount ) { itemUids += itemUid; } else { itemUids += itemUid + strDELIMITER; } } }); $.ajax({ url : "/common/ajax/exec_getItemStock.asp", data : "guid=" + _goodUid + "&itemUids=" + itemUids + "&optType="+ _nChkOpt_type, async : false, //동기처리 error : function(data){ //alert('오류입니다.'); }, success : function(data){ if (data != "") { $("select[name='itemUid'] option").css('display', 'block'); $("select[name='itemUid'] option").each(function(index){ var thisValue = $(this).val(); var dataSplit = data.split(","); for ( var i in dataSplit ) { // 가져온 데이타로 돌리면서. if (thisValue == dataSplit[i]){ $(this).css('display', 'none'); } } }); } } }); ////// 20180711 joonyus 분리형 재고수량 노출추가 S result_txt=""; $.ajax({ url : "/common/ajax/exec_getOptItemStock.asp", data : "guid=" + _goodUid + "&itemUids=" + itemUids + "&optType="+ _nChkOpt_type, async : false, //동기처리 error : function(data){ //alert('오류입니다.'); }, success : function(data){ if (data != "") { //20190201 joonyus 옵션 비노출인게 노출되서 아래부분 주석처리 //$("select[name='itemUid'] option").css('display', 'block'); $("select[name='itemUid'] option").each(function(index){ var thisValue = $(this).val(); var dataSplit = data.split(","); for ( var i in dataSplit ) { // 가져온 데이타로 돌리면서. var Iteminfo=dataSplit[i]; var ItemSplit = Iteminfo.split("^^"); var setItemUid=ItemSplit[0]; var setItemStock=ItemSplit[1]; var setItemState=ItemSplit[2]; var setItemValue=ItemSplit[3]; var setItemOptPrice=ItemSplit[4]; ///20180827 joonyus 옵션가추가 //$("select[name='itemUid'] option").eq(index).attr("disabled",false); //$("select[name='itemUid'] option").eq(index).prop("disabled",false); //attr을 prop로 변경, jings3, 2019-02-18 if (thisValue == setItemUid){ //$("select[name='itemUid'] option").eq(index).attr("disabled",true);//왜 disabled시킬까?!, jings3, 2019-02-18 $("select[name='itemUid'] option").eq(index).html(setItemValue); ori_txt=setItemValue; result_txt=ori_txt+""+ fnLANG("/m/jscript/fnOption.js",6) +""+formatComma(setItemStock,3)+")"; if (_nChkStock_type=="F"){ if(setItemStock==0 || setItemState=="F"){ result_txt=ori_txt+""+ fnLANG("/m/jscript/fnOption.js",7) +""; //$("select[name='itemUid'] option").eq(index).attr("disabled",true); $("select[name='itemUid'] option").eq(index).prop("disabled",true); } }else{ if (setItemState=="F") ///품절상태일경우 ->20200116 joonyus 추가 { result_txt=ori_txt+""+ fnLANG("/m/jscript/fnOption.js",8) +""; $("select[name='itemUid'] option").eq(index).prop('disabled',true); }else{ result_txt=ori_txt; } } if (setItemOptPrice>0) ///20180827 joonyus 옵션가추가 { result_txt=result_txt+""+ fnLANG("/m/jscript/fnOption.js",9) +"+"+formatComma(setItemOptPrice,3)+")"; } $("select[name='itemUid'] option").eq(index).html(result_txt); } } }); } } }); ////// 20180711 joonyus 분리형 재고수량 노출추가 E } //기본옵션 type B 선택시 : 일체형 function fnSetOptTypeB(e, strDELIMITER){ var optType = "opt"; var itemUids = ""; var itemValues = ""; var stockUid = ""; var tHtml = ""; var itemStock = 0; var itemPrice = 0; var arrOptUid = new Array(); //옵션 uid 배열 var arrOptName = new Array(); //옵션 이름 배열 var arrItemUid = new Array(); //아이템 uid 배열 var arrItemName = new Array(); //아이템 이름 배열 var optUids = $(e).attr("data-optuid"); var optNames = $(e).attr("data-optname"); stockUid = $("select[name='itemUid'] option:selected").val(); itemUids = $("select[name='itemUid'] option:selected").attr("data-itemuids"); itemValues = $("select[name='itemUid'] option:selected").attr("data-itemvalues"); if (stockUid > 0) { //재고, 가격 추출 ajax(S) $.ajax({ url : "/common/ajax/exec_getItemInfo.asp", data : "guid=" + _goodUid + "&stockUid=" + stockUid + "&optType="+ _nChkOpt_type, async : false, //전역 처리 error : function(html){ //alert('오류입니다.'); }, success : function(html){ if (html == "fail") { alert(""+ fnLANG("/m/jscript/fnOption.js",10) +""); return false; } else { itemStock = parseInt(html.split("|")[0]); itemPrice = parseInt(html.split("|")[1]); if (itemStock == 0) { alert(""+ fnLANG("/m/jscript/fnOption.js",11) +""); return false; } } } }); //재고, 가격 추출 ajax(E) // console.log('itemStock='+itemStock) //레이어생성(S) var tHtml = ""; for (i=0;i < _nChkOPt_count ;i++ ) { arrOptUid[i] = optUids.split("|:|")[i]; arrOptName[i] = optNames.split("|:|")[i]; arrItemUid[i] = itemUids.split("|:|")[i]; arrItemName[i] = itemValues.split("|:|")[i]; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "+ arrOptName[i] +" : "+ arrItemName[i]; tHtml += "
"; } tHtml += " ( + "+ itemPrice +" )"; //레이어생성(E) //190514|wjy 옵션이 중복해서 들어가는 오류 수정 var itemCount = $('.selected_option').length; var valOpt = new Array(); var valOpt2 = new Array(); for (j = 1; j <= itemCount ; j++ ) { var itemCount2 = $('.selected_option').eq(j-1).find(".opt_info_cls").length; for (f=0;f < itemCount2 ;f++ ){ chkoptUid = $('.selected_option').eq(j-1).find("input[name=optUid]").eq(f-1).val(); chkoptItemUid = $('.selected_option').eq(j-1).find("input[name=optItemUid]").eq(f-1).val(); valOpt[f] = chkoptUid+"||"+chkoptItemUid } for (i=0;i < _nChkOPt_count ;i++ ){ valOpt2[i] = arrOptUid[i]+"||"+arrItemUid[i] } if (String(valOpt.sort()) == String(valOpt2.sort())) { alert(""+ fnLANG("/m/jscript/fnOption.js",12) +""); itemStock = 0; } } //재고 파악 후 레이어 그리기(S) if (itemStock > 0 ) { fnSetAddOptionLayer(optType, _goodUid, _goodTitle, _goodPrice, tHtml, itemPrice, 0, "", itemStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //재고 파악 후 레이어 그리기(E) } //end stockUid //초기화 $("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); select_initAdd($(this));//초기화 추가 처리, jings3, 2019-02-18 }); //초기화 $("textarea[name='textOpt_Value']").each(function(index){ $(this).val(""); }); } ///1+1 function fnSetOptTypeC(e, strDELIMITER){ var optType = ""; var optCount = 0; var optStock = 0; //옵션 조합의 재고수량 var optPrice = 0; //옵션 조합의 가격 var itemUids = ""; var itemValues = ""; var arrOptUid = new Array(); //옵션 uid 배열 var arrOptName = new Array(); //옵션 이름 배열 var arrItemUid = new Array(); //아이템 uid 배열 var arrItemName = new Array(); //아이템 이름 배열 $("select[name='itemUid'] option:selected").each(function(index){ var optUid = $(this).parent().attr("data-optuid"); var optName = $(this).parent().attr("data-optname"); var item_optName = $(this).attr("data-itemvalues"); var itemUid = $(this).attr("data-itemuids"); if (itemUid <= 0 && index==0) { alert(""+ fnLANG("/m/jscript/fnOption.js",13) +""); return false; } if (itemUid > 0 ) { optCount += 1; //선택된 옵션의 배열 저장 arrOptUid[index] = optUid; arrOptName[index] = optName; arrItemUid[index] = itemUid; arrItemName[index] = item_optName; } }); if ( optCount == 2 ) { var rt = true; for (i=0;i < optCount ;i++ ) { //재고, 가격 추출 ajax(S) $.ajax({ url : "/common/ajax/exec_getItemInfo.asp", data : "guid=" + _goodUid + "&itemUids=" + arrItemUid[i] + "&optType=A", async : false, //전역 처리 error : function(html){ //alert('오류입니다.'); }, success : function(html){ if (html == "fail") { alert(""+ fnLANG("/m/jscript/fnOption.js",14) +""); rt = false; return false; } else { optStock = parseInt(html.split("|")[0]); optPrice = parseInt(html.split("|")[1]); if ( _nChkStock_type == "F" && optStock <= 0) { alert(""+ fnLANG("/m/jscript/fnOption.js",15) +""); rt = false; return false; } } } }); } //재고, 가격 추출 ajax(E) //레이어생성(S) var tHtml = ""; for (i=0;i < optCount ;i++ ) { tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "+ arrOptName[i] +" : "+ arrItemName[i]; tHtml += "
"; } tHtml += " ( + ₱ "+ optPrice +" )"; //레이어생성(E) if (rt) { _IsPlusOne_Select_check=true; fnSetAddOptionLayer(optType, _goodUid, _goodTitle, _goodPrice, tHtml, optPrice, "", "", optStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } $("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); }); $("textarea[name='textOpt_Value']").each(function(index){ $(this).val(""); }); } } //텍스트영역 입력시 function fnSetTextOptValue(e){ var p = $("#trResultView div.prd_opt_box").last().find("#textOpt"); //입력할 레이어 var index = $("textarea[name='textOpt_Value']").index(e); //입력 영역 var value = $(e).val(); var optUid = $(e).attr("data-uid"); // var optTitle = $(e).attr("data-name"); var optPrice = parseInt($(e).attr("data-price")); if ( value == "" ) { optPrice = 0; optUid = ""; } //해당 필드 수정 $(p).find( "#textOptUid_"+ index ).val(optUid); $(p).find( "#textOptPrice_"+ index ).val(optPrice); $(p).find( "#textOptValue_"+ index ).val(value); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //기본 레이어 생성/추가 function fnSetAddOptionLayer(optType, goodUid, goodsTitle, goodPrice, optHtml, optPrice, optUid, optName, itemStock){ // optMethod = opt, addopt, none currOptIdx += 1; if (!optType) //없으면 { optType = ""; } if (!optName) //없으면 { optName = ""; } if (!optUid) //없으면 { optUid = 0; } if (!goodPrice) //없으면 { goodPrice = 0; } else { goodPrice = parseInt(goodPrice); } if (!optHtml) //없으면 { optHtml = ""; } if (!optPrice) //없으면 { optPrice = 0; } else { optPrice = parseInt(optPrice); } if (!itemStock) //없으면 { itemStock = 0; } else { itemStock = parseInt(itemStock); } if (_nChkStock_type == "T") //무제한이면 { itemStock = 10000; } var tCount = parseInt($("input[name='OptLayerCount']").val()); $("input[name='OptLayerCount']").val( tCount + 1 ); var tHtml = ""; tHtml += "
"; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "+ fnLANG("/m/jscript/fnOption.js",16) +""+ goodsTitle +""; if (optType == "addopt") { tHtml += "
"+ fnLANG("/m/jscript/fnOption.js",17) +""+ optName +""; } //추가옵션인경우 노출 안한다. if ( optType != 'addopt'){ //기본 옵션 보여주기 tHtml += "
"; tHtml += optHtml; tHtml += "
"; //텍스트옵션 var tTextOptCount = $("textarea[name='textOpt_Value']").size(); // console.log('tTextOptCount='+tTextOptCount) if ( tTextOptCount != 0){ tHtml += "
"; for (i=0;i"+ optTitle + optReqTitle +"
"; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += "
"; } tHtml += "
"; //텍스트옵션 } } //end optType var bEa=1; var readonly=""; if (_IsUnit=="T"){ if ( optType != 'addopt') bEa=_minEa; readonly="readonly"; } tHtml += "
"; tHtml += "
"; tHtml += " remove"; tHtml += " "; tHtml += " add"; tHtml += "
"; tHtml += "
"; tHtml += " "+ formatComma(goodPrice + optPrice) +""; if (optType == "addopt" || optType == "opt" || _IsPlusOne=="T"){ tHtml += " "; } tHtml += "
"; tHtml += "
"; tHtml += "
"; ///''20180712 joonyus 최대구매설정추가S $("input:text[name='tEa']", "#optList").each(function(index) { ea=parseInt($("input:text[name='tEa']", "#optList").eq(index).val()); total_ea+=ea; }); if (_IsMaxBuy=="T"){ var total_ea=0; $( "input:text[name='tEa']" ).each(function(index) { ea=parseInt($( "input:text[name='tEa']" ).eq(index).val()); total_ea+=ea; }); total_ea+=bEa; if (total_ea > _MaxEa){ alert(''+ fnLANG("/m/jscript/fnOption.js",20) +''+_MaxEa+''+ fnLANG("/m/jscript/fnOption.js",21) +''); return false; } } ///''20180712 joonyus 최대구매설정추가E $("#trResultView").append(tHtml); optScrollResize(); } //레이어 삭제 function fnDelLayer(e){ $(e).closest("div.prd_opt_box").remove(); //총 주문 상품 갯수 줄이기 var tCount = parseInt($("input[name='OptLayerCount']").val()); $("input[name='OptLayerCount']").val( tCount - 1 ); fnSetTotalGoodsPrice(); //총 상품금액 구하기 optScrollResize(); } //수량 변경 function controlNumNoOPT(e, oper){ var tEa = $(e).closest("div.mtp").find("input[name='tEa']").val(); var tStock = $(e).closest("div.prd_opt_box").find("input[name='tStock']").val(); num = (tEa.stripspace() == "") ? 0 : parseInt(tEa); num = (isNaN(num)) ? 0 : parseInt(num); if (oper == '+') { if ( num >= tStock ){ alert(""+ fnLANG("/m/jscript/fnOption.js",22) +""); return false; } if (_IsMaxBuy == "T"){///''20180712 joonyus 최대구매설정추가 var total_ea=0; $( "input:text[name='tEa']" ).each(function(index) { ea = parseInt($( "input:text[name='tEa']" ).eq(index).val()); total_ea += ea; }); if (_IsUnit=="T"){///''20200117 joonyus 단위구매추가 plusnum=_buyUnit; }else{ plusnum=1; } total_ea = total_ea + plusnum; if (total_ea > _MaxEa){ alert(''+ fnLANG("/m/jscript/fnOption.js",23) +''+_MaxEa+''+ fnLANG("/m/jscript/fnOption.js",24) +''); --num; return false; } } if (_IsUnit == "T"){///''20171226 joonyus 단위구매추가 num = (Number(num) + _buyUnit); }else{ ++num; } }else if(oper == '-'){ if (_IsUnit == "T"){///''20171226 joonyus 단위구매추가 num = (Number(num) - _buyUnit); }else{ --num; } if (num == 0 || num < 0){ var $parent = $(e).closest(".prd_opt_box"); var optType = $parent.find('[name=tOptType]').val(); if ( optType=='addopt' ){ num = 1; } else { num = _minEa; alert(''+ fnLANG("/m/jscript/fnOption.js",25) +''+_minEa+''+ fnLANG("/m/jscript/fnOption.js",26) +''); } return false; } }else{//+,-버튼을 누르지 않고 그냥 입력했을경우, jings3, 2018-12-17 //////////////////////////////////////////////////////////////////////////////////////////B if ( num >= tStock ){ alert(""+ fnLANG("/m/jscript/fnOption.js",27) +""); $(e).closest("div.mtp").find("input[name='tEa']").val(tStock); $(e).trigger("focus"); //위 세팅갯수로 다시 계산되게 처리, jings3, 2018-12-17 return; } if (num == 0 || num < 0){ alert(''+ fnLANG("/m/jscript/fnOption.js",28) +''); num = 1; $(e).closest("div.mtp").find("input[name='tEa']").val(1); $(e).trigger("focus"); //위 세팅갯수로 다시 계산되게 처리, jings3, 2018-12-17 return; } if (_IsMaxBuy == "T"){///''20180712 joonyus 최대구매설정추가 var total_ea = 0; $( "input:text[name='tEa']" ).each(function(index) { ea = parseInt($( "input:text[name='tEa']" ).eq(index).val()); total_ea += ea; }); total_ea = total_ea + 1; if (total_ea > _MaxEa){ alert(''+ fnLANG("/m/jscript/fnOption.js",29) +''+_MaxEa+''+ fnLANG("/m/jscript/fnOption.js",30) +''); $(e).closest("div.mtp").find("input[name='tEa']").val(_MaxEa); $(e).trigger("focus"); //위 세팅갯수로 다시 계산되게 처리, jings3, 2018-12-17 return; } } if (_IsUnit == "T"){///''20171226 joonyus 단위구매추가 //계산식 변경, jings3, 2018-12-17 num = ( ( Math.round(num / _buyUnit) * _buyUnit ) <= 0 ) ? _buyUnit : Math.round(num / _buyUnit) * _buyUnit; } //////////////////////////////////////////////////////////////////////////////////////////E } $(e).closest("div.mtp").find("input[name='tEa']").val(num); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //총 상품금액 구하기 function fnSetTotalGoodsPrice(){ var totGoodsPrice = 0; var total_ea=0; $( "input:text[name='tEa']" ).each(function(index) { ea=parseInt($( "input:text[name='tEa']" ).eq(index).val()); total_ea+=ea; }); $("#trResultView div.prd_opt_box").each(function(){ var OptType = $(this).find("input[name='tOptType']").val(); //옵션타입 var price = parseInt($(this).find("input[name='tGoodPrice']").val()); var sectionPrice = parseInt($(this).find("input[name='tGoodSectionPrice']").val()); // 구간별 할인 var optPrice = parseInt($(this).find("input[name='tGoodOptPrice']").val()); var ea = parseInt($(this).find("input[name='tEa']").val()); var chkea; //복수구매 할인(S), 복수구매가 구간별할인으로 변경 으로 주석, jings3 2017-10-19 //if ( OptType !="addopt" && _nChkMultiOpt_useFlag == "T" && ea >= parseInt(_nChkMultiOpt_EA) ) { //price = price + parseInt(_nChkMultiOpt_Price); //} //복수구매 할인(E) //텍스트옵션 가격(S) var subTextOptPrice = 0; var p = $(this).find("#textOpt").find("input[name='optTextPrice']"); $(p).each(function(){ var textPrice = parseInt($(this).val()); subTextOptPrice += textPrice; }); //텍스트옵션 가격(E) chkea=ea if (_EaType=="A") { chkea=total_ea; } //복수구매( 구간별 할인) 체크(S) if ( OptType != "addopt" ){ // 추가 상품 제외 조건 추가 20180828 joonyus var sectionGuid = $('#guid').val(); // 상품번호 var sectionEa = ea; // 수량 var thisLocation = $(this); $.ajax({ url : "/common/ajax/exec_getSectionPrice.asp", data : "guid=" + sectionGuid + "&ea=" + chkea+"&I_Reward_UserID="+_I_Reward_UserID, async : false, //전역 처리 success : function(sectionPrice){ if (sectionPrice != 0){ thisLocation.find("input[name='tGoodSectionPrice']").val(sectionPrice); price = parseInt(sectionPrice); //구간별 할인가로 계산되게 처리, jings3, 2017-08-28 }else{ thisLocation.find("input[name='tGoodSectionPrice']").val(thisLocation.find("input[name='tGoodPrice']").val()); } } }); } //복수구매( 구간별 할인) 체크(E) //200109|wjy 상세페이지에서 쿠폰 적용 시 쿠폰할인 금액이 보이게.. var couponUid = $("#couponUid").val(); if (couponUid == "" || couponUid ==0) { }else{ //price = $("#coupon_use_id_"+couponUid).data("price"); // 2020-02-27 joonyus 할인금액 노출 변경. 쿠폰이 바로 적용되게 하는 기능 폐쇄. 주문페이지에서 쿠폰변경이 불가하기때문. } totGoodsPrice += (price + optPrice + subTextOptPrice) * ea; $(this).find("#subTotalPrice").text( setCurrency((price + optPrice + subTextOptPrice) * ea) ); }); /////20190226 joonyus $("#TotalGoodsPrice").text(setCurrency(totGoodsPrice)); -> 아래조건으로 변경 setCurrency 호출에러.. (옵션상품일경우 구매하기->닫기->장바구니 경로시 호출에러) if (totGoodsPrice>0){ $("#TotalGoodsPrice").text(setCurrency(totGoodsPrice)); }else{ $("#TotalGoodsPrice").text("₱ "+ 0); } } /*goodsType추가, jings3, 2017-06-27*/ /* isSimplepay추가(간편결제여부{T, F}), jings3, 2018-04-24 */ function checkGoods(method, goodsType, isSimplepay){ //추가된 파라메터 isSimplepay 에 대한 설정 , jings3, 2018-04-24 //(S) try{ if ( isSimplepay === undefined || isSimplepay === null ){ isSimplepay = "F"; } }catch(e){ isSimplepay = "F"; } //추가된 파라메터 isSimplepay 에 대한 설정 , jings3, 2018-04-24 //(E) var f = document.Frm; if(_IsPlusOne=="T" ){ if(_IsPlusOne_Select_check==false){ alert(""+ fnLANG("/m/jscript/fnOption.js",31) +""); rt=false; return false; } }else{ //기본 옵션 선택 여부 파악(S) if ( _nChkOpt_useFlag == "T" ) { var _optReqTCount = 0; //옵션 영역 갯수(필수) var __optReqTCount = 0; //주문 영역 갯수(필수) $("select[name='itemUid']").each(function(){ _optReqTCount += 1; $("#trResultView div.prd_opt_box").find("input[name='tOptType']").each(function(){ var __this = this; var __optType = $(__this).val(); //val == addopt if ( __optType == "opt" ) { __optReqTCount += 1; } }); }); if ( _optReqTCount > __optReqTCount) { alert(""+ fnLANG("/m/jscript/fnOption.js",32) +""); return false; } } //기본 옵션 선택 여부 파악(E) } //텍스트 옵션 입력 여부 파악(S) if ( _nChkTextOpt_useFlag == "T" ) { var _textOptReqTCount = 0; //옵션 영역 갯수(필수) var __textOptReqTCount = 0; //주문 영역 갯수(필수) var arrTextOptReq = new Array(); //옵션 필수 배열 $("textarea[name='textOpt_Value']").each(function(index){ var _optReq = $(this).attr("data-req"); arrTextOptReq[index] = _optReq; if (_optReq == "T") { _textOptReqTCount += 1; } }); $("#trResultView div.prd_opt_box").find("#textOpt").each(function(){ var _this = this; $(_this).find("textarea[name='optTextValue']").each(function(index){ var __this = this; var _optValue = $(__this).val(); if ( arrTextOptReq[index] == "T" && _optValue != "") { __textOptReqTCount += 1; } }); }); if ( _textOptReqTCount > __textOptReqTCount ) { alert(""+ fnLANG("/m/jscript/fnOption.js",33) +""); return false; } } //텍스트 옵션 입력 여부 파악(E) //추가상품 옵션 선택 여부 파악(S) if ( _nChkAddGoods_useFlag == "T" ) { var _addOptReqTCount = 0; //옵션 영역 갯수(필수) var __addOptReqTCount = 0; //주문 영역 갯수(필수) var _orioptUid = ""; //옵션 uid 비교 변수 $("select[name='addGoodsUid']").each(function(){ var _this = this; var _addOptReq = $(_this).attr("data-optreq"); var _addOptUid = $(_this).attr("data-optuid"); _orioptUid = _addOptUid; //비교 opt uid if ( _addOptReq == "T" ) { _addOptReqTCount += 1; $("#trResultView div.prd_opt_box").find("input[name='tOptType']").each(function(){ var __this = this; var __addOptType = $(__this).val(); //val == addopt var __addOptUid = $(__this).parent().find("input[name='tAddOptUid']").val(); if ( __addOptType == "addopt" && _addOptUid == __addOptUid && _orioptUid == __addOptUid && __addOptUid != "0") { __addOptReqTCount += 1; } }); } }); if ( _addOptReqTCount > __addOptReqTCount ) { alert(""+ fnLANG("/m/jscript/fnOption.js",34) +""); return false; } } //추가상품 옵션 선택 여부 파악(E) if (method=="CART") { $("input[name='mode']").val(method); //mode 설정 var params = $("#Frm").find(":input").serializeArray(); $.ajax({ type : "POST", async : false , data : params, url : "/m/goods/ajax/ajaxCartOk.asp", success : function(data) { //190131|wjy 상태값과 스크립트(애드저스트)가 같이 넘어옴 if (data.indexOf("%^&*") != -1) { var data_tmp = data.split('%^&*'); var data = data_tmp[0]; var script_tmp = data_tmp[1]; if (script_tmp.length>1){ $('body').append(script_tmp) } } if(data != "OK"){ //FAIL+|+경고문구 var statusCode = data.split("|")[0] var statusTxt = data.split("|")[1] if (statusCode =="FAIL") { alert(statusTxt); return false; } // $("#result_cart").empty(); // $("#result_cart").html(data); } else { //alert('장바구니에 저장되었습니다.'); functionReset(); setTimeout('opt_box_close()'); setTimeout('conf_cart_fadein()',200); setTimeout('conf_cart_fadeout()',300); setTimeout('getCartCnt()',600); //location.href="/m/product/cart.asp"; //장바구니 수량 //$("#pop_div").show(); } } }); } if (method=="DIRECT") { $("input[name='mode']").val(method); //mode 설정 var params = $("#Frm").find(":input").serializeArray(); $.ajax({ type : "POST", async : false , data : params, url : "/m/goods/ajax/ajaxCartOk.asp", success : function(data) { if(data != "OK"){ //FAIL+|+경고문구 var statusCode = data.split("|")[0] var statusTxt = data.split("|")[1] if (statusCode =="FAIL") { alert(statusTxt); return false; } if (statusCode =="OKFAIL") { alert(statusTxt); return false; } // $("#result_cart").empty(); // $("#result_cart").html(data); } else { //location.href="/m/order/order.asp?chkType="+method + "&transGoodsType=" + goodsType; //$.mobile.changePage("/m/order/order.asp?chkType="+method + "&transGoodsType=" + goodsType, {changeHash: true, reloadPage:true}); gotoUrl("/m/order/order.asp?chkType="+method + "&transGoodsType=" + goodsType + "&isSimplepay=" + isSimplepay ); //Direct일때, 간편결제여부 파라메터 추가 처리,jings3, 2018-04-24 } } }); } if (method=="NPAYDIRECT") { var rt2 = false; $("input[name='mode']").val(method); //mode 설정 var params = $("#Frm").find(":input").serializeArray(); $.ajax({ type : "POST", async : false , data : params, url : "/m/goods/ajax/ajaxCartOk.asp", success : function(data) { // console.log('data='+data) if(data != "OK"){ //FAIL+|+경고문구 var statusCode = data.split("|")[0] var statusTxt = data.split("|")[1] if (statusCode =="FAIL") { alert(statusTxt); rt2 = false; } } else { rt2 = true ; } } }); return rt2; } //상품 주문 내역 info //showValues(); } function showValues() { var fields = $("#trResultView").find(":input").serializeArray(); $("#results").empty(); $.each(fields, function(i, field){ $("#results").append(field.name + "=" + field.value + ", "); }); } //옵션x 이면 레이어를 노출한다. if ( _nChkOpt_useFlag == "F" ) { fnSetAddOptionLayer("none", _goodUid, _goodTitle, _goodPrice, "", 0, 0, "", _goodStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } function opt_box_close(){ $('.fixed_option_box').removeClass('close'); } function conf_cart_fadein(){ $('.con_cart').fadeIn(500); } function conf_cart_fadeout2(){ $('.conf_cart').fadeOut(500); } function conf_cart_fadeout(){ $('.conf_cart').animate({left:'-=40%',bottom:'-=45%'},500); setTimeout('conf_cart_fadeout2()',500); } function functionReset(){ $('.conf_cart').css('left','50%') $('.conf_cart').css('bottom','50%') $('.conf_cart').css('display', 'block') } function getCartCnt(){ $.ajax({ type:"post", url:"/common/ajax/exec_getCartCnt.asp", success:function(data, state, xhr){ $(".cartCnt").html(data); } }); } function cart_pop_close(){ document.getElementById("pop_div").style.display="none"; } function move_cart(){ location.href = "/m/product/cart.asp"; } //초기화 추가처리, jings3, 2019-02-18 function select_initAdd(me){ var $this = me; $this.find("option").each(function(i, e){ $(this).prop("disabled", false); $(this).css("display", "block"); }); }