var sel_province = ""; var sel_sub=[]; $(document).ready(function () { console.log(config); var xm = document.getelementbyid("xm") xm.innerhtml = ""; for(var key in config){ xm.innerhtml += ""; } xm_change(); }); function get_range(gsj){ var arr=[0,0,0,0,0,0]; if(gsj<100) arr[0] = gsj; else if(gsj>=100&&gsj<500){ arr[0] = 100; arr[1] = gsj-100; } else if(gsj>=500&&gsj<1000){ arr[0] = 100; arr[1] = 400; arr[2] = gsj-500; } else if(gsj>=1000&&gsj<2000){ arr[0] = 100; arr[1] = 400; arr[2] = 500; arr[3] = gsj-1000; } else if(gsj>=2000&&gsj<5000) { arr[0] = 100; arr[1] = 400; arr[2] = 500; arr[3] = 1000; arr[4] = gsj-2000; } else if(gsj>5000){ arr[0] = 100; arr[1] = 400; arr[2] = 500; arr[3] = 1000; arr[4] = 3000; arr[5] = gsj-5000; } return arr; } function xm_change(){ var key = $("#xm").val(); var sub_dom = document.getelementbyid("sub") sel_sub=[]; sub_dom.innerhtml = ""; if(key==="p1"){ $("#is_show_zj").show(); $("#is_show_sub").hide(); } else{ $("#is_show_zj").hide(); $("#is_show_sub").show(); var sub = config[key].sub; for(var key_sub in sub){ sub_dom.innerhtml += '
  • '+sub[key_sub].title+'
  • '; } } //var sl = (config[key].s_rate*100.0); //$("#s_rate").val(sl.tofixed(2)); } function sub_click(sel_sub,key){ // console.log(sel_sub.id); // console.log(sel_sub.checked); var sub = config[key].sub; sub[sel_sub.id].checked=sel_sub.checked; console.log(sub); } function c(gsj,arr_range,arr_rate,sh_rate,s_rate,arr_zj,zj,zk){ var arr_price = [0,0,0,0,0,0]; arr_price[0] = arr_range[0]*arr_rate[0]; arr_price[1] = arr_range[1]*arr_rate[1]; arr_price[2] = arr_range[2]*arr_rate[2]; arr_price[3] = arr_range[3]*arr_rate[3]; arr_price[4] = arr_range[4]*arr_rate[4]; arr_price[5] = arr_range[5]*arr_rate[5]; var arr_price_zj = [0,0,0,0,0,0]; arr_price_zj[0] = arr_zj[0]*sh_rate[0]; arr_price_zj[1] = arr_zj[1]*sh_rate[1]; arr_price_zj[2] = arr_zj[2]*sh_rate[2]; arr_price_zj[3] = arr_zj[3]*sh_rate[3]; arr_price_zj[4] = arr_zj[4]*sh_rate[4]; arr_price_zj[5] = arr_zj[5]*sh_rate[5]; var sum = 0; for(var i=0;i"; var t ="0-100万:"+ arr_range[0]+"万元×"+arr_rate[0]+"="+ arr_price[0] +"万元
    "; txt += t; t ="100-500万:"+ arr_range[1]+"万元×"+arr_rate[1]+"="+ arr_price[1] +"万元
    "; txt += t; t ="500-1000万:"+ arr_range[2]+"万元×"+arr_rate[2]+"="+ arr_price[2] +"万元
    "; txt += t; t ="1000-2000万:"+ arr_range[3]+"万元×"+arr_rate[3]+"="+ arr_price[3] +"万元
    "; txt += t; t ="2000-5000万:"+ arr_range[4]+"万元×"+arr_rate[4]+"="+ arr_price[4] +"万元
    "; txt += t; t ="大于5000万:"+ arr_range[5]+"万元×"+arr_rate[5]+"="+ arr_price[5] +"万元
    "; txt += t; t="总计:"+sum+"万元
    " txt += t; if(arr_zj.length>0){ for(var i=0;i" txt += t; t ="0-100万:"+ arr_zj[0]+"万元×"+sh_rate[0]+"="+ arr_price_zj[0] +"万元
    "; txt += t; t ="100-500万:"+ arr_zj[1]+"万元×"+sh_rate[1]+"="+ arr_price_zj[1] +"万元
    "; txt += t; t ="500-1000万:"+ arr_zj[2]+"万元×"+sh_rate[2]+"="+ arr_price_zj[2] +"万元
    "; txt += t; t ="1000-2000万:"+ arr_zj[3]+"万元×"+sh_rate[3]+"="+ arr_price_zj[3] +"万元
    "; txt += t; t ="2000-5000万:"+ arr_zj[4]+"万元×"+sh_rate[4]+"="+ arr_price_zj[4] +"万元
    "; txt += t; t ="大于5000万:"+ arr_zj[5]+"万元×"+sh_rate[5]+"="+ arr_price_zj[5] +"万元
    "; txt += t; } t="合计:"+sum+"万元
    "; txt+=t; t="折后价:"+sum+"万元×"+zk+"%="+sum*zk/100+"万元
    "; txt+=t; sum=sum*zk/100; // var sj = sum*s_rate; // t="税金:"+sum+"万元×"+s_rate+"="+sj+"万元
    "; // $("#s_rate").val(formatnumberrgx(math.floor(sj*10000)/10000)); // txt+=t; // sum+=sj; t="折后价:"+sum+"万元
    "; txt+=t; $("#sum").html(formatnumberrgx(math.floor(sum*10000))+"元"); return txt; } function formatnumberrgx(num) { var parts = num.tostring().split("."); parts[0] = parts[0].replace(/\b(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); } function compute(){ var key = $("#xm").val(); var gsj = $("#gsj").val(); var zj = $("#zj").val(); var zk = $("#zk").val(); console.log(key); if(key==="p1"){ var arr = []; arr = get_range(gsj); var arr_zj = []; if(config[key].sh_rate.length>0)arr_zj = get_range(zj); var txt = c(gsj,arr,config[key].arr_rate,config[key].sh_rate,config[key].s_rate,arr_zj,zj,zk); $("#res").html(txt); } else{ var sub = config[key].sub; var total_price = 0; var txt = ""; var t=""; var arr_range = arr = get_range(gsj); for(var key_sub in sub){ if(sub[key_sub].checked){ var sub_price = c2(arr_range,sub[key_sub].arr_rate); t=sub[key_sub].title+":"+sub_price+"万元
    "; txt+=t; total_price+=sub_price; } } console.log(total_price); t="合计:"+total_price+"万元
    "; txt+=t; t="折后价:"+total_price+"万元×"+zk+"%="+total_price*zk/100+"万元
    "; txt+=t; $("#res").html(txt); total_price = total_price*zk/100; $("#sum").html(formatnumberrgx(math.floor(total_price*10000))+"元"); } } function c2(arr_range,arr_rate){ console.log(arr_rate); var arr_price = [0,0,0,0,0,0]; arr_price[0] = arr_range[0]*arr_rate[0]; arr_price[1] = arr_range[1]*arr_rate[1]; arr_price[2] = arr_range[2]*arr_rate[2]; arr_price[3] = arr_range[3]*arr_rate[3]; arr_price[4] = arr_range[4]*arr_rate[4]; arr_price[5] = arr_range[5]*arr_rate[5]; var sub_price = 0; for(var i=0;i