99 lines
3.1 KiB
JavaScript
99 lines
3.1 KiB
JavaScript
|
|
|
|
// 수정 . 시작하자마자 1번 연산 실행
|
|
// 백엔드에서 일부 데이터가 없으므로 이상한 결과가 나옴
|
|
// 고객요청사항에 따라, 단말,요금 할인금액 임의 입력으로 수정
|
|
// innit_calue();
|
|
|
|
// innit2();
|
|
|
|
function innit2() {
|
|
jQuery('#dcYogum').text("- 000,000");
|
|
jQuery('#dcDanmal').text("- 000,000");
|
|
jQuery('#monthCost').text("000,000");
|
|
jQuery('#relasePrice').text("000,000")
|
|
}
|
|
|
|
function innit_calue() {
|
|
var d_size = jQuery('#size_select option').eq(1).attr('data-size');
|
|
var d_prcie = jQuery('#size_select option').eq(1).attr('data-price');
|
|
var dcyogum = jQuery('#dcYogum').attr('data-dcyogum');
|
|
var dcdanmal = jQuery('#dcDanmal').attr('data-dcdanmal');
|
|
var halbu = jQuery('#halbu').val();
|
|
// var min_cost = jQuery('.min_cost').val();
|
|
// 수동 입력으로 변경. 임의의 최저 요금 등록
|
|
var min_cost = +jQuery('#docu_habsan_yogum').val();
|
|
|
|
discount_compare(d_prcie,dcdanmal,dcyogum,halbu,min_cost);
|
|
}
|
|
|
|
|
|
function numberFormat(num){
|
|
var regexp = /\B(?=(\d{3})+(?!\d))/g;
|
|
return num.toString().replace(regexp, ',');
|
|
}
|
|
|
|
function get_discount_compare_values() {
|
|
if(jQuery('#size_select option:selected').val() != "") {
|
|
|
|
var getValues_target = ['dcYogum','dcDanmal','halbu'];
|
|
var d_size = jQuery('#size_select option:selected').attr('data-size');
|
|
var d_prcie = jQuery('#size_select option:selected').attr('data-price');
|
|
var dcyogum = jQuery('#dcYogum').attr('data-dcyogum');
|
|
var dcdanmal = jQuery('#dcDanmal').attr('data-dcdanmal');
|
|
var halbu = jQuery('#halbu').val();
|
|
|
|
// 한날 납부금 계산시 추가하는 요금의 금액을 제일 저렴한걸로 함, 마지막날 추가
|
|
var min_cost = +jQuery('#docu_habsan_yogum').val();
|
|
|
|
console.log("선택한 용량 "+ d_size);
|
|
//값 전달
|
|
discount_compare(d_prcie,dcdanmal,dcyogum,halbu,min_cost);
|
|
|
|
// console.log("단말기 값(출고가)"+d_prcie);
|
|
// console.log("요금할인 : " + dcyogum);
|
|
// console.log("단말할인 : " + dcdanmal);
|
|
// console.log("선택한 할부 : " + halbu);
|
|
} else {
|
|
innit2();
|
|
}
|
|
}
|
|
|
|
function discount_compare(relase,danmal,yogum,montly,handal_cost) {
|
|
var cost ="";
|
|
// console.log("단말기(출고가)"+relase);
|
|
// console.log("단말할인 : " + danmal);
|
|
// console.log("요금할인 : " + yogum);
|
|
// console.log("선택한 할부 : " + montly);
|
|
// console.log("최저 한달 요금 : " + cost);
|
|
//최저 월납부금
|
|
if(danmal > yogum) { //단말할인
|
|
cost = Math.floor((relase - danmal) / montly);
|
|
cost = Math.floor(Number(cost) + Number(handal_cost));
|
|
|
|
} else {//요금할인
|
|
cost = Math.floor((relase - yogum) / montly);
|
|
cost = Math.floor(Number(cost) + Number(handal_cost));
|
|
}
|
|
|
|
jQuery('#dcYogum').text(numberFormat(yogum));
|
|
jQuery('#dcDanmal').text(numberFormat(danmal));
|
|
update_monthCost(relase,cost);
|
|
}
|
|
|
|
function update_monthCost(relase,cost) {
|
|
jQuery('#relasePrice').text(numberFormat(relase));
|
|
jQuery('#monthCost').text(numberFormat(cost));
|
|
}
|
|
|
|
|
|
|
|
function selectState(state) {
|
|
if(state == false) {
|
|
jQuery('#size_select').prop('disabled',true);
|
|
|
|
} else {
|
|
jQuery('#size_select').prop('disabled',false);
|
|
}
|
|
}
|