/* ½º¸¶Æ®±â±â Ç÷§Æû ¿ä±Ý°è»ê JSON [ Çʼö ÀÔ·Â Parameters ] smid ; °Ô½Ã±Û¹øÈ£ [ ¼±Åà ÀÔ·Â Parameters Json ] { "classname":{} ; DOM Class¸í º¯°æ "inputtype":{} ; ELEMENT ŸÀÔº¯°æ "select"/"radio" } [ Çʼö DOM Class ] .sp_corp ; Åë½Å»ç .sp_product ; ¸ðµ¨¸í .sp_join_type ; °¡ÀÔÀ¯Çü .sp_color ; »ö»ó .sp_installment ; ÇҺαⰣ .sp_usim ; À¯½Éºñ .sp_join ; °¡ÀÔºñ .sp_service ; ºÎ°¡¼­ºñ½º .sp_gift ; »çÀºÇ° .sp_fee ; ¿ä±ÝÁ¦ .sp_dc_type ; ÇÒÀÎÀ¯Çü [ Ãâ·Â½ÇÇà ] °´Ã¼¸í.result = function() {½ÇÇà °á°ú À̺¥Æ® Ä¿½ºÅ͸¶ÀÌ¡}; °´Ã¼¸í.RES ; ¿ä±Ý°è»ê °á°úµ¥ÀÌÅÍ */ var Smart_platform_ajax = function (smid) { var params = arguments; var SP = this; SP.AUTOSTART = true; SP.BOX = $(document); SP.RES = {}; // ¿ä±Ý°è»ê °á°úµ¥ÀÌÅÍ SP.DATA = {"smid":null,"sdid":null}; SP.DATA.smid = smid; SP.INPUTTYPE = { "sp_corp" : "select", "sp_join_type" : "radio" } SP.ELE = { "sp_corp" : ".sp_corp", "sp_product" : ".sp_product", "sp_join_type" : ".sp_join_type", "sp_color" : ".sp_color", "sp_installment" : ".sp_installment", "sp_usim" : ".sp_usim", "sp_join" : ".sp_join", "sp_service" : ".sp_service", "sp_gift" : ".sp_gift", "sp_fee" : ".sp_fee", "sp_dc_type" : ".sp_dc_type", "sp_f_gift" : ".sp_f_gift", "sp_s_gift" : ".sp_s_gift" }; if(params.length > 1) { // Ãß°¡ ÆÄ¶ó¹ÌÅÍ Ã¼Å© if(params[1].classname) SP.ELE = params[1].classname; // DOM ±âº» Ŭ·¡½º¸í º¯°æ if(params[1].inputtype) SP.INPUTTYPE = params[1].inputtype; // DOM ±âº» ¿¤¸®¸ÕÆ® º¯°æ } // ¿ä±Ý°è»êÀü ½ÇÇà SP.beforeChange = function() { /* ¿ä±Ý º¯°æÀü ½ÇÇàÇÒ À̺¥Æ®¸¦ ÀÛ¼ºÇØÁÖ¼¼¿ä. °´Ã¼¸í.beforeChange=function(){ console.log(°´Ã¼¸í.RES); } */ }; // ¿ä±Ý°è»ê°á°ú ½ÇÇà SP.result = function() { /* ¿Ï·áÀ̺¥Æ®¸¦ ÀÛ¼ºÇØÁÖ¼¼¿ä. °´Ã¼¸í.result=function(){ console.log(°´Ã¼¸í.RES); } */ }; // ¸®¼Â SP.reset = function() { $(SP.ELE.sp_join_type).html(""); $(SP.ELE.sp_color).html(""); $(SP.ELE.sp_installment).html(""); $(SP.ELE.sp_usim).html(""); $(SP.ELE.sp_join).html(""); $(SP.ELE.sp_service).html(""); $(SP.ELE.sp_gift).html(""); $(SP.ELE.sp_fee).html(""); } // Åë½Å»ç È£Ãâ SP.call_corp = function() { SP.beforeChange(); // ¿ä±Ý°è»êÀü ½ÇÇà $.ajax({ type : "POST", url : "/System/proc/mobile_platform/inc/sell_mobile_json.inc.php", dataType: "json", data : {"process":"call_corp","smid":SP.DATA.smid}, success:function(corp) { var corp_html = ''; for(var i=0; i'+corptit+'   '; else if(SP.INPUTTYPE.sp_corp == "select") corp_html += ''; } if(SP.INPUTTYPE.sp_corp == "select") corp_html = '
'; SP.BOX.find(SP.ELE.sp_corp).html(corp_html); SP.call_model(corp[0]); // µðÆúÆ® ¼±Åà // Åë½Å»ç ¼±Åà À̺¥Æ® if(SP.INPUTTYPE.sp_corp == "radio") { SP.BOX.find(SP.ELE.sp_corp+" [type=radio]").click(function() { SP.reset(); if($(this).val()) SP.call_model($(this).val()); }); } else if(SP.INPUTTYPE.sp_corp == "select") { SP.BOX.find(SP.ELE.sp_corp+" select").change(function() { SP.reset(); if($(this).val()) SP.call_model($(this).val()); }); } // ÀÚµ¿¼±Åà if(SP.AUTOSTART) { if(SP.INPUTTYPE.sp_corp == "radio") { $(SP.ELE.sp_corp+" [type=radio]:first").prop("checked", true); SP.call_model($(SP.ELE.sp_corp+" [type=radio]:first").val()); } else { $(SP.ELE.sp_corp+" select option:first").attr("selected", true); SP.call_model($(SP.ELE.sp_corp+" select").val()); } } } }); } // ¸ðµ¨¸í È£Ãâ SP.call_model = function(corp) { SP.beforeChange(); // ¿ä±Ý°è»êÀü ½ÇÇà $.ajax({ type : "POST", url : "/System/proc/mobile_platform/inc/sell_mobile_json.inc.php", dataType: "json", data : {"process":"call_model","smid":SP.DATA.smid, "corp":corp}, success:function(data) { var model_len = data.length, model_options = ''; if(SP.AUTOSTART) model_options = ''; if( model_len > 1 ) { for(var i=0; i'+data[i].product_name+''; SP.BOX.find(SP.ELE.sp_product).html('
'); } else { SP.BOX.find(SP.ELE.sp_product).html(''+data[0].product_name); } // ¸ðµ¨¸í ¼±Åà À̺¥Æ® SP.BOX.find(SP.ELE.sp_product+" select").change(function() { if($(this).val()) SP.call_device($(this).val()); else SP.reset(""); }); // ÀÚµ¿¼±Åà if(SP.AUTOSTART) { if( model_len > 1 ) { $(SP.ELE.sp_product+" select option:first").attr("selected", true); SP.call_device($(SP.ELE.sp_product+" select").val()); } else { SP.call_device($(SP.ELE.sp_product+" input[type=hidden]").val()); } } } }); }; // ¼±ÅÃµÈ µð¹ÙÀ̽º È£Ãâ SP.call_device = function(sdid) { SP.beforeChange(); // ¿ä±Ý°è»êÀü ½ÇÇà SP.DATA.sdid = sdid; $.ajax({ type : "POST", url : "/System/proc/mobile_platform/inc/sell_mobile_json.inc.php", dataType: "json", data : {"process":"call_device","sdid":SP.DATA.sdid}, success:function(data) { // °¡ÀÔÀ¯Çü var join_type = data.join_type, join_type_html = ''; for(var i=0;i'+join_type[i]+'  '; else if(SP.INPUTTYPE.sp_join_type == "select") join_type_html += ''; } if(SP.INPUTTYPE.sp_join_type == "select") join_type_html = '
'; $(SP.ELE.sp_join_type).html(join_type_html); // »ö»ó var op_color = data.op_color, op_color_html = ''; for(var i=0;i'+op_color[i]+''; if(op_color_html) $(SP.ELE.sp_color).html('
'); else $(SP.ELE.sp_color).html('-'); // ÇҺΠ$(SP.ELE.sp_installment).html(' '+data.installment+'°³¿ù'); // À¯½Éºñ $(SP.ELE.sp_usim).html(data.op_usim); // °¡ÀÔºñ $(SP.ELE.sp_join).html(data.op_join); // ºÎ°¡¼­ºñ½º var op_service_html = data.op_service.join(", "); if(!op_service_html) op_service_html = "¾øÀ½"; $(SP.ELE.sp_service).html(op_service_html); // °¡ÀÔÀ¯Çü ¼±Åà À̺¥Æ® if(SP.INPUTTYPE.sp_join_type == "radio") { SP.BOX.find(SP.ELE.sp_join_type+" [type=radio]").click(function() { SP.call_fee($(this).val()); }); } else if(SP.INPUTTYPE.sp_join_type == "select") { SP.BOX.find(SP.ELE.sp_join_type+" select").change(function() { SP.call_fee($(this).val()); }); } // ÀÚµ¿¼±Åà if(SP.AUTOSTART) { if(SP.INPUTTYPE.sp_join_type == "radio") { $(SP.ELE.sp_join_type+" [type=radio]:first").prop("checked", true); SP.call_fee($(SP.ELE.sp_join_type+" [type=radio]:first").val()); } else { $(SP.ELE.sp_join_type+" select option:first").attr("selected", true); SP.call_fee($(SP.ELE.sp_join_type+" select").val()); } } } }); }; // ¿ä±ÝÁ¦ È£Ãâ SP.call_fee = function(join_type) { SP.beforeChange(); // ¿ä±Ý°è»êÀü ½ÇÇà $.ajax({ type : "POST", url : "/System/proc/mobile_platform/inc/sell_mobile_json.inc.php", dataType: "json", data : {"process":"call_fee","sdid":SP.DATA.sdid,"join_type":join_type}, success:function(response_data) { var fee_data = response_data.fee_list; var f_gift_list = response_data.f_gift_list; // °íÁ¤ »çÀºÇ° var s_gift_list = response_data.s_gift_list; // ¼±Åà »çÀºÇ° // ¿ä±ÝÁ¦ if(!fee_data) return; var fee_len = fee_data.length; var fee_options = ''; if(SP.AUTOSTART) fee_options = ''; if(fee_len > 1) { for(var i=0; i'+fee_data[i].fee_name+''; SP.BOX.find(SP.ELE.sp_fee).html('
'); } else { SP.BOX.find(SP.ELE.sp_fee).html(''+fee_data[0].fee_name); } // ¿ä±ÝÁ¦ ¼±Åà À̺¥Æ® SP.BOX.find(SP.ELE.sp_fee+" select").change(function() { SP.call_price($(this).val()); }); // ÀÚµ¿¼±Åà if(SP.AUTOSTART) { if(fee_len > 1) { $(SP.ELE.sp_fee+" select option:first").attr("selected", true); SP.call_price($(SP.ELE.sp_fee+" select").val()); } else { SP.call_price($(SP.ELE.sp_fee+" input[type=hidden]").val()); } } // °íÁ¤»çÀºÇ° var op_gift_html = ''; $(SP.ELE.sp_f_gift).html('-'); if(f_gift_list) { for(var i=0;i'; } $(SP.ELE.sp_f_gift).html('
    '+op_gift_html+'
'); } // ¼±ÅûçÀºÇ° $(SP.ELE.sp_s_gift).html('-'); if(s_gift_list) { op_gift_html = ''; for(var i=0;i'; } $(SP.ELE.sp_s_gift).html('
    '+op_gift_html+'
'); } } }); }; // ¿ä±Ý°è»ê SP.call_price = function(sfid) { SP.beforeChange(); // ¿ä±Ý°è»êÀü ½ÇÇà var dc_type_data = $(SP.ELE.sp_dc_type+" input[type=radio]:checked").val(); // Áö¿ø±ÝÇÒÀÎÇüÅ $.ajax({ type : "POST", url : "/System/proc/mobile_platform/inc/sell_mobile_json.inc.php", dataType: "json", data : {"process":"call_price","sfid":sfid,"dc_type":dc_type_data}, success:function(data) { // Áö¿ø±ÝÇÒÀÎÇüÅ var dc_type = data.dc_type; var dc_type_html = ''; for(var i=0; i'+dc_type[i]+'  '; } $(SP.ELE.sp_dc_type).html(dc_type_html); // ÇÒÀÎÀ¯Çü ¼±Åà À̺¥Æ® SP.BOX.find(SP.ELE.sp_dc_type+" [type=radio]").click(function() { SP.call_price($(this).data("sfid")); }); SP.RES = data; SP.result(); // ¿Ï·áÀ̺¥Æ® } }); }; // ½ÇÇà if(SP.AUTOSTART) SP.call_corp(); };