$(function() {
$(".goods_thumb_image").on('click', function() {
var $this = $(this),
$wrap = $('.goods_image_box'),
imgcode = $this.data('imgcode') ? $this.data('imgcode') : '',
imgno = $this.data('imgno');
if( $(".circle_color[data-code='"+imgcode+"']").length > 0 ) {
$(".circle_color[data-code='"+imgcode+"']").trigger('click');
} else {
$('.goods_image').removeClass('on');
if ($wrap.find(".goods_image[data-imgno='"+imgno+"']").length > 0) {
$wrap.find(".goods_image[data-imgno='"+imgno+"']").addClass('on');
} else {
$('.goods_image').eq(0).addClass('on');
}
}
}).trigger('click');
//option open
$(document).on("click",".opt_arrow",function(){
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
$optlayer = $wrap.find('.optlayer'),
optname = $this.data('optname');
if(optname == 'giftview') {
return false;
}
if( $optlayer.hasClass('on') === true ) { //닫기
$('.optlayer').removeClass('on');
$this.empty().html(' ');
} else {
$('.optlayer').removeClass('on');
$optlayer.addClass('on');
$this.empty().html(' ');
}
return false;
});
$(".circle_color").on('click init', function(e) {
var $this = (e.type == 'init') ? $('.circle_color').eq(0) : $(this),
$wrap = $('.goods_image_box'),
color = $this.data('color'),
code = $this.data('code');
$('#colorname').val(color);
$('#colorcode').val(code);
$('.circle_color, .goods_image').removeClass('on');
$this.addClass('on');
if ( ($wrap.find(".goods_image[data-imgcode='"+code+"']").length > 0) && code) {
$wrap.find(".goods_image[data-imgcode='"+code+"']").addClass('on');
} else {
$('.goods_image').eq(0).addClass('on');
}
if($this.hasClass('color_black') == true) {
$('.color_name').css('color','#020202').html(color);
} else {
$('.color_name').css('color',code).html(color);
}
$('.circle').css('background',code);
}).trigger('init');
$(".opt_giga").on('click', function() { //저장공간
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
value = $this.data('name'),
price = $this.data('price');
html = value + '('+number_format(price)+'원)';
$('#modelprice').val(price);
$('#modeloption').val($this.val());
$('.giga_name').empty().html(html);
$wrap.find('.opt_btn').trigger('click');
$('input[name="item_ordtype"]:checked').trigger("click");
});
$(".opt_giga").eq(0).trigger("click");
$(document).on("click",".item_telecom",function(){ //통신사 선택
var $this = $(this),
telecom = $this.val();
//초기화
$('.goodsvalue').val('');
$.ajax({
type: "POST",
data: {act:'select_order', itemcode:viewItemCode, telecom:telecom },
url: './ajax.mshop.php',
success: function(data) {
//console.log(data);
var html = '';
if(data.result == 'failer') {
return false;
}
$.each(data.ordertype, function(i, $i) {
html += '
';
html += ' ';
html += ''+$i.ms_order_type+' ';
html += '
';
});
$('#ot').empty().html(html);
if(oid) {
$("input[name='item_ordtype']:input[value='"+oid+"']").trigger("click");
} else {
$('.item_ordtype').eq(0).trigger("click");
}
$('#item_telecom').val(telecom);
//계산
calc();
}
});
});
if(tid) {
$("input[name='item_telecom']:input[value='"+tid+"']").trigger("click");
} else {
$('.item_telecom').eq(0).trigger("click");
}
$(document).on("click",".item_ordtype",function(){ //가입 유형 선택
var $this = $(this),
ordtype = $this.val(),
telecom = $('input[name="item_telecom"]:checked').val(),
price = $('#modelprice').val() ? $('#modelprice').val() : 0;
html = '';
if(ordtype == '신규가입') {
html += telecom + ' 통신사로 새로운 번호로 가입하고 싶어요';
$('#mytelecom').empty().hide();
} else if(ordtype == '번호이동') {
html += '사용하는 번호 그대로 ' + telecom + '통신사로 이동하고 싶어요';
myTelecom();
$('#mytelecom').show();
} else {
html += '사용하는 번호는 ' + telecom + ' 그대로 휴대폰만 바꾸고 싶어요';
$('#mytelecom').empty().hide();
}
$('#ot_txt').empty().html(html);
$.ajax({
type: "POST",
ansys: false,
data: {act:'calc_bill', itemcode:viewItemCode, telecom:telecom, ordertype:ordtype, modelcode:viewModelCode, price:price},
url: './ajax.mshop.php',
success: function(data) {
console.log(data);
if(data.result == 'failer') {
return false;
}
/*기본 요금제 선택 */
var selectbill = data.bill[0];
var bill_html = '';
bill_html += ''+selectbill.billname+' (기본료 '+number_format(selectbill.billprice)+'원) ';
$('input[name="ip_id"]').val(selectbill.ip_id);
$('input[name="bill_code"]').val(selectbill.billcode);
$('input[name="bill_price"]').val(selectbill.billprice);
$('input[name="gongsi_price"]').val(selectbill.gongsi);
$('input[name="user_point"]').val(selectbill.ip_point);
$('input[name="dc_type"]').val(selectbill.saletype);
$('#goodsbill').empty().html(bill_html);
$('#item_ordtype').val(ordtype);
/* 요금제 리스트 */
var html = '';
$('#bill_list').empty().html(html);
//할인방식 출력
set_saletype_list(selectbill.gongsi,selectbill.billprice,selectbill.gpoint,selectbill.spoint);
//결합할인 상품
if(data.disunion.length > 0) {
var html = '';
$.each(data.disunion, function(i,$i) {
html += '';
html += '
';
html += '
';
html += '';
html += ''+$i.disname+' ';
html += '최대 '+number_format($i.disprice)+' 원 할인 ';
html += '
';
html += ''+$i.disinfo+'
';
html += ' ';
html += '
';
});
$('#disunion_list').empty().html(html);
$('#goods_option_disunion').show();
} else {
$('#goods_option_disunion').hide();
}
//추가 사은품 구매 가능한 적립금이 있을때
if(selectbill.ip_point > 0) {
var html = '기기할인 포인트 ' + number_format(selectbill.ip_point) + 'P 로 추가 사은품 선택!';
$('#pointgift').empty().html(html);
} else {
$('#option_point_gift').hide();
}
//계산
calc();
}
});
});
$(document).on("click",".opt_bill_list",function(){ //요금제 선택
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
ipid = $this.data('ipid'),
billcode = $this.data('billcode'),
billprice = parseInt($this.data('billprice')),
billname = $this.data('billname'),
billcall = $this.data('billcall'),
billsms = $this.data('billsms'),
billdata = $this.data('billdata'),
billbenefit = $this.data('billbenefit'),
gongsi = parseInt($this.data('gongsi')),
ip_point = parseInt($this.data('point')),
gpoint = parseInt($this.data('gpoint')),
spoint = parseInt($this.data('spoint'));
$('.opt_bill_list').removeClass('on');
$this.addClass('on');
var bill_html = '';
bill_html += ''+billname+' (기본료: '+number_format(billprice)+'원) ';
$('input[name="ip_id"]').val(ipid);
$('input[name="bill_code"]').val(billcode);
$('input[name="bill_price"]').val(billprice);
$('input[name="gongsi_price"]').val(gongsi);
$('input[name="user_point"]').val(ip_point);
$('#goodsbill').empty().html(bill_html);
set_saletype_list(gongsi,billprice,gpoint,spoint);
$wrap.find('.opt_btn').trigger('click');
//계산
calc();
});
$(document).on("click",".saletype_list",function(e){ //할인 유형 선택
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
saletype = $this.data('saletype'),
gongsi = $('input[name="gongsi_price"]').val() ? $('input[name="gongsi_price"]').val() : 0,
billprice = $('input[name="bill_price"]').val() ? $('input[name="bill_price"]').val() : 0,
ip_id = $('input[name="ip_id"]').val() ? $('input[name="ip_id"]').val() : 0;
saleprice = parseInt($this.data('saleprice'));
//지원금 재계산
if(ip_id == 0) {
alertModal('요금제를 먼저 선택하셔야 합니다.');
return false;
}
$.ajax({
type: "POST",
ansys: false,
data: {act:'calc_saletype', ip_id:ip_id, saletype:saletype, gongsi:gongsi, billprice:billprice },
url: './ajax.mshop.php',
success: function(data) {
if(data.result == 'failer') {
alertModal('요금제를 먼저 선택하셔야 합니다.');
return false;
}
$('input[name="user_point"]').val(data.userpoint);
$('input[name="dc_point"]').val(data.userpoint);
//dom 입력 및 계산
$('.saletype_list').removeClass('on');
$this.addClass('on');
var shtml = '';
if(saletype == '1') {
shtml = '공시지원금 할인 (총 '+number_format(saleprice)+'원 할인) ';
}
if(saletype == '24') {
shtml = '선택약정 24개월 할인 (총 '+number_format(saleprice)+'원 할인) ';
}
if(saletype == '12') {
shtml = '선택약정 12개월 할인 (총 '+number_format(saleprice)+'원 할인) ';
}
$('input[name="dc_type"]').val(saletype);
$('#saletype').empty().html(shtml);
if(e.originalEvent !== undefined) {
$wrap.find('.opt_btn').trigger('click');
}
//계산
calc();
}
});
});
/*
$(document).on("click",".saletype_list",function(e){ //할인 유형 선택
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
saletype = $this.data('saletype'),
saleprice = parseInt($this.data('saleprice'));
$('.saletype_list').removeClass('on');
$this.addClass('on');
var shtml = '';
if(saletype == '1') {
shtml = '공시지원금 할인 (총 '+number_format(saleprice)+'원 할인) ';
}
if(saletype == '24') {
shtml = '선택약정 24개월 할인 (총 '+number_format(saleprice)+'원 할인) ';
}
if(saletype == '12') {
shtml = '선택약정 12개월 할인 (총 '+number_format(saleprice)+'원 할인) ';
}
$('input[name="dc_type"]').val(saletype);
$('#saletype').empty().html(shtml);
if(e.originalEvent !== undefined) {
$wrap.find('.opt_btn').trigger('click');
}
//계산
calc();
});
*/
$(document).on("click",".pay_type",function() { //할부개월 선택
var $this = $(this),
value = $this.val();
$('.pay_type_label').removeClass('on');
$this.next('.pay_type_label').addClass('on');
$('input[name="halbu_month"]').val(value);
//계산
calc();
});
$(document).on("click",".dis_union_chk",function() { //결합할인 선택
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
disname = $this.data('disname'),
disbill = parseInt($this.data('discount'));
$wrap.find('.option_list').removeClass('on');
if($this.prop('checked') == true) {
$('input[name="discount_int"]').val(disbill);
$('.dis_internet').prop('checked',false);
$this.prop('checked',true);
$this.parents('.option_list').addClass('on');
$('.dcint').show();
} else {
$('input[name="discount_int"]').val('');
$('.dip_bill, .dip').empty();
$('.dcint').hide();
}
var html = ''+disname+' 최대 '+number_format(disbill)+' 원 할인 ';
$('#disunion').empty().html(html);
$wrap.find('.opt_btn').trigger('click');
//계산
calc();
});
$(document).on("click",".dis_public_chk",function() { //복지할인 선택
var $this = $(this),
$wrap = $this.closest('.goods_option_wrap'),
disname = $this.val(),
disbill = parseInt($this.data('discount'));
$wrap.find('.option_list').removeClass('on');
if(disbill == 1) {
var html = ''+disname+' 최대 35 % 할인 ';
} else {
var html = ''+disname+' 최대 '+number_format(disbill)+' 원 할인 ';
}
$('#dispublic').empty().html(html);
if($this.prop('checked') == true) {
if(disbill == 1) {
var billprice = $('input[name="bill_price"]').val() ? parseInt($('input[name="bill_price"]').val()) : 0;
disbill = Math.round(billprice * 0.35);
}
$('input[name="discount_pub"]').val(disbill);
$('.dis_public_chk').prop('checked',false);
$this.prop('checked',true);
$this.parents('.option_list').addClass('on');
$('.dcpublic').show();
} else {
$('input[name="discount_pub"]').val('');
$('.dpp_bill, .dip').empty(); // 할인금액
$('.dcpublic').hide();
}
is_calc = true;
$wrap.find('.opt_btn').trigger('click');
//계산
calc();
});
$(".calc_btn_toggle").on('click', function() {
$('.point_box').slideToggle('slow');
$('.price_box').slideToggle('slow');
});
});
/* 중고폰 반납 */
$(function() {
$(document).on("click","#addsale_oldphone",function() { //중고폰 반납 modal open
telecom = $('input[name="item_telecom"]').val() ? $('input[name="item_telecom"]').val() : '';
$.ajax({
type: "POST",
data: {act:'select_oldphone', telecom:telecom},
url: './ajax.mshop.php',
success: function(data) {
var tle = '';
var html = '';
var oldphone = $('input[name="discount_old"]').val();
var arr_old = oldphone.split(",");
if(data.template) {
html += ''; //템플릿을 활용
}
if(data.result == 'failer') {
html += '';
html += '
중고폰 반납 서비스를 진행하지 않습니다.
';
html += '
';
}
if(data.result == 'success') {
html += '';
html += '
';
html += '';
html += '제조사 선택 ';
$.each(data.company, function(i, $i) {
html += ''+$i.ms_item_company+' ';
});
html += ' ';
html += '
';
html += '
';
html += '';
html += '모델 선택 ';
$.each(data.model, function(i, $i) {
html += ''+$i.mm_model_name+' ';
});
html += ' ';
html += '
';
html += '
';
var modelclass = new Array('a','b','c','d');
html += '';
$.each(data.model, function(i, $i) {
var chk_state = '';
var chk_list = '';
$.each(arr_old, function(k, $k) {
var chk_item = $k.split(":");
if($i.mm_id == chk_item[0]) {
chk_list = 'checked';
chk_state = chk_item[1];
}
});
html += '';
html += '';
html += '';
html += '
';
html += ''+$i.ms_item_company+' ';
html += ''+$i.mm_model_name+' ';
html += ''+$i.mm_model_cname+' ';
html += '
';
html += '
';
$.each(modelclass, function(j, $j) {
var op_checked = '';
var op_price = parseInt($i['op_price_'+$j]) || 0;
var state = $j.toUpperCase();
if( state == chk_state) {
op_checked = 'checked';
}
html += '
';
html += ' ';
html += ''+state+'급 '+number_format(op_price)+'원 ';
html += '
';
});
html += '
';
html += '
';
html += '';
html += '
';
html += ' ';
html += ' ';
html += '
';
html += '
';
html += ' ';
});
html += ' ';
}
$('.header-title').empty().append(tle);
$('.myModal-body').empty().append(html);
$('#myModal').show(0,'swing', function() {
$('html').addClass('noscroll');
$('#myModal').addClass('fadedown oldphone');
$('#myModal .myModal-content').addClass('open');
});
}
});
});
$(document).on("change",".old_select",function() { //중고폰 검색 셀렉트
var $this = $(this),
$wrap = $('#op_ul'),
company = $('select[name="old_company"]').children('option:selected').data('company') ? $('select[name="old_company"]').children('option:selected').data('company') : '',
mno = $('select[name="old_model"]').children('option:selected').data('mno') ? $('select[name="old_model"]').children('option:selected').data('mno') : '';
if( $this.attr('id') == 'old_company' ) {
mno = '';
$('#old_model').prop('selectedIndex',0);
}
if(mno) {
$('.op_list').hide();
$wrap.find(".op_list[data-mno='"+mno+"']").show();
if(company) {
$('select[name="old_model"]').find("[data-company!='"+company+"']").hide();
$('select[name="old_model"]').children('option[value=""]').show();
$('select[name="old_model"]').find("[data-company='"+company+"']").show();
} else {
$('select[name="old_model"]').children('option').show();
}
} else if ( company && !mno ) {
$('.op_list').hide();
$wrap.find(".op_list[data-company='"+company+"']").show();
$('select[name="old_model"]').find("[data-company!='"+company+"']").hide();
$('select[name="old_model"]').children('option[value=""]').show();
$('select[name="old_model"]').find("[data-company='"+company+"']").show();
} else {
$('.op_list').show();
$('select[name="old_model"]').children('option').show();
}
});
$(document).on("click",".op_radio",function() {
var $this = $(this),
$wrap = $this.closest('li');
if( $wrap.find('.op_chk').prop('checked') === false ) {
$wrap.find('.op_chk').prop('checked',true);
}
opt_calc();
});
$(document).on("click",".op_chk",function() {
var $this = $(this),
$wrap = $this.closest('li');
if($this.prop('checked') === true) {
if( $wrap.find('.op_radio:checked').length == 0 ) {
alert('반납하실 핸드폰의 상태를 선택해 주세요.');
$wrap.find('.op_radio').eq(0).focus();
return false;
}
$wrap.addClass('on');
} else {
$wrap.find('.op_radio').prop('checked',false);
$wrap.removeClass('on');
}
opt_calc();
});
});
function myTelecom()
{
var usetelecom= $('input[name="item_telecom"]:checked').val() ? $('input[name="item_telecom"]:checked').val() : '';
var html = '';
html += '사용중인 통신사
';
html += '';
html += '
';
$.each(arr_telecom, function(i,$i) {
if (i != usetelecom) {
html += '
';
html += ' ';
html += ''+$i+' ';
html += '
';
}
});
html += '
';
html += '
';
$('#mytelecom').empty().html(html);
}
function set_saletype_list(g,b,gp,bp) {
/* 할인유형 입력 */
var sale_month = Math.floor(parseInt(b) * 0.25);
var salebill24 = Math.floor(sale_month * 24);
var salebill12 = Math.floor(sale_month * 12);
var gpoint = parseInt(g+gp);
var s24point = parseInt(salebill24+bp);
var s12point = parseInt(salebill12+bp);
var on1 = '';
var on2 = '';
if ( gpoint > s24point ) {
on1 = 'on';
var saletype = 1;
var shtml = '공시지원금 할인 (총 '+number_format(gpoint)+'원 할인) ';
} else {
on2 = 'on';
var saletype = 24;
var shtml = '선택약정 24개월 할인 (총 '+number_format(s24point)+'원 할인) ';
}
$('#saletype').empty().html(shtml);
var sale_html = '';
sale_html += '';
sale_html += '';
sale_html += '
공시지원금 할인
';
sale_html += '
';
sale_html += '';
sale_html += '
기기값 할인 '+number_format(g)+'원
';
sale_html += '
'+saleName+' '+number_format(gp)+'원
';
sale_html += '
총 '+number_format(gpoint)+'원 할인
';
sale_html += '
';
sale_html += ' ';
sale_html += '';
sale_html += '';
sale_html += '
선택약정 할인 24개월
';
sale_html += '
';
sale_html += '';
sale_html += '
요금할인 '+number_format(salebill24)+'원
';
sale_html += '
'+saleName+' '+number_format(bp)+'원
';
sale_html += '
총 '+number_format(s24point)+'원 할인
';
sale_html += '
';
sale_html += ' ';
/*
sale_html += '';
sale_html += '';
sale_html += '
선택약정 할인 12개월
';
sale_html += '
';
sale_html += '';
sale_html += '
요금할인 '+number_format(salebill12)+'원
';
sale_html += '
'+saleName+' '+number_format(bp)+'원
';
sale_html += '
총 '+number_format(s12point)+'원 할인
';
sale_html += '
';
sale_html += ' ';
*/
sale_html += ' ';
$('#saletype_list').empty().html(sale_html);
if(saletype == 1) {
$('#type_gongsi').trigger("click");
}
if(saletype == 24) {
$('#type_sale').trigger("click");
}
}
function calc() {
var modelprice = $('input[name="modelprice"]').val() ? parseInt($('input[name="modelprice"]').val()) : 0,
billprice = $('input[name="bill_price"]').val() ? parseInt($('input[name="bill_price"]').val()) : 0,
dctype = $('input[name="dc_type"]').val() ? parseInt($('input[name="dc_type"]').val()) : 1,
halbumonth = $('input[name="halbu_month"]').val() ? parseInt($('input[name="halbu_month"]').val()) : 24,
gongsiprice = $('input[name="gongsi_price"]').val() ? parseInt($('input[name="gongsi_price"]').val()) : 0,
giftpoint = $('input[name="gift_point"]').val() ? parseInt($('input[name="gift_point"]').val()) : 0,
userpoint = $('input[name="user_point"]').val() ? parseInt($('input[name="user_point"]').val()) : 0,
discountcard = $('input[name="discount_card"]').val() ? parseInt($('input[name="discount_card"]').val()) : 0,
discountint = $('input[name="discount_int"]').val() ? parseInt($('input[name="discount_int"]').val()) : 0,
discountpub = $('input[name="discount_pub"]').val() ? parseInt($('input[name="discount_pub"]').val()) : 0;
var npoint = userpoint - giftpoint; //기기할인 포인트
var gpoint = giftpoint; //사은품 구매 포인트
var opoint = 0;
var buypoint = userpoint - giftpoint; //사은품 구매 가능 포인트
//복지할인을 적용하여 계산용 기본료 정의
var publicbill = billprice;
if(discountpub > 0) {
publicbill = Math.round(billprice - discountpub);
} else {
publicbill = billprice;
}
//약정에 따른 공시지원금 및 기본요금 재설정
if(dctype == 1) {
gongsiprice = gongsiprice;
billmonth = publicbill;
disbill = 0; //선택약정할인금액
var halbuprice = modelprice - gongsiprice - npoint; //실구매금액=할부금액
} else {
gongsiprice = 0;
billmonth = Math.round(publicbill * 0.75);
disbill = Math.round(publicbill * 0.25); //선택약정할인금액 복지할인 적용 후 선택약정 적용
var halbuprice = modelprice - npoint; //실구매금액=할부금액
}
if(halbuprice < 0) {
npoint = npoint + halbuprice;
opoint = 0 - halbuprice; //오버포인트
halbuprice = 0;
}
//할부이자 계산
var lendingRate = 0.059;
power = Math.pow(1+lendingRate/12,halbumonth);
repayments = halbuprice*lendingRate/12*power/(power-1);
monthprice = Math.round(repayments); //월할부금(원금+이자)
if(halbumonth == 1) {
var halbutext = '일시불';
monthprice = 0; //일시불이므로 월 할부금 0원 처리
} else {
var halbutext = halbumonth + '개월';
}
if(monthprice == 0) {
halbutext = '일시불';
}
//월 통신요금
var totalprice = monthprice + billmonth;
/* 계산된 금액 돔 입력 */
$('.ipoint').empty().html(number_format(userpoint) + 'P '); //총적립포인트
$('.npoint, .mpoint').empty().html(number_format(npoint) + 'P '); //기기할인 포인트, SHOP 추가할인
$('.gpoint').empty().html(number_format(gpoint) + 'P '); //사은품 구매 포인트
$('.opoint').empty().html(number_format(opoint) + 'P '); //남은 포인트
$('.buypoint').empty().html(number_format(buypoint) + 'P '); //남은 포인트
$('.mp_text').empty().html(number_format(monthprice) + '원 '); //월할부금
$('.hp_text').empty().html(number_format(modelprice) + '원 '); //정상가
$('.gp_text').empty().html(number_format(gongsiprice) + '원 '); //공시지원금
$('.sp_text').empty().html(number_format(npoint) + '원 '); //SHOP 추가할인
$('.up_text').empty().html(number_format(halbuprice) + '원 '); //실구매가
$('.mt_text').empty().html(halbutext); //할부개월
$('.tot_price').empty().html(number_format(billmonth) + '원 '); //월 통신요금
$('.bas_price').empty().html(number_format(billprice) + '원 '); //기본료
$('.pub_price').empty().html(number_format(discountpub) + '원 '); //복지할인
$('.dis_price').empty().html(number_format(disbill) + '원 '); //선택약정 할인
$('.tmp').empty().html(number_format(totalprice) + '원 '); // 월 예상 납부금액(요금+월할부금)
/* 카드 및 결합할인 할인 */
var monthcard = totalprice - discountcard; //제휴카드 월 금액
if(monthcard < 0) { monthcard = 0; }
$('.dcp_bill').empty().html(number_format(discountcard) + '원 '); //제휴카드 할인금액
$('.dcp').empty().html(number_format(monthcard) + '원 '); //제휴카드 월 요금
if(discountcard > 0) {
$('.dccard').show();
} else {
$('.dccard').hide();
}
/* 복지할인까지 신청하면 결합할인이 마이너스 금액이 될 수 있음 */
/* 실제 요금과는 상관없지만 - 일경우 0원 표기 */
var monthint = totalprice - discountcard - discountint //결합할인 월 금액
if(monthint < 0) { monthint = 0; }
$('.dip_bill').empty().html(number_format(discountint) + '원 '); //결합할인 할인금액
$('.dip').empty().html(number_format(monthint) + '원 '); //결합할인 월 요금
//공시지원금 및 선택약정 입출력
if(gongsiprice > 0) {
$('.dlgongsi').show();
$('.dldcbill').hide();
} else {
$('.dlgongsi').hide();
$('.dldcbill').show();
}
if(discountpub > 0) {
$('.dlpubill').show();
} else {
$('.dlpubill').hide();
}
//dc_point, total price 입력
$('input[name="dc_point"]').val(npoint);
$('input[name="total_price"]').val(totalprice);
//월 할부금이 0원이면
if(monthprice == 0) {
$('#pay_type_1').prop('checked',true);
$('.calc_pay').removeClass('on');
$('#pay_type_1').closest('li').addClass('on');
}
}
function opt_calc() {
var oldphone = new Array();
var model_html = '';
$.each( $('.op_chk'), function(i, $i) {
if( $(this).prop('checked') === true ) {
var $wrap = $(this).closest('li');
var modelname = $wrap.data('modelname');
var opid = $wrap.find('.op_radio:checked').data('opid');
var modelid = $wrap.find('.op_radio:checked').data('modelid');
var modelclass = $wrap.find('.op_radio:checked').data('modelclass');
var modelprice = $wrap.find('.op_radio:checked').val();
modelclass = modelclass.toUpperCase();
var oldmodel = opid+':'+modelclass+':'+modelprice;
oldphone.push(oldmodel);
model_html += ''+modelname+' ('+modelclass+'급) '+number_format(modelprice)+'원 ';
}
});
$('#discount_old').val(oldphone);
if(oldphone.length > 0) {
var html = '';
html += '중고폰 반납 신청 내역 ';
html += '';
$('#oldphone').empty().html(html);
$('#oldphone').show();
} else {
$('#oldphone').empty().hide();
}
}