资源价格计算器
总价:
元/月
元/年
订金:
元
订金支付后将存在您的账户余额中,待正式下单购买时可作为余额直接抵扣.
产品交付时间为订金交付后1-5个工作日内.
';
resource_section += '
';
resource_section += '
'
for(var j in route[k]){
if(filter_isp_id != 0 && route[k][j]['brand_class'].indexOf('brand_band') == -1) continue; //isp filter = wide-bandwidth query
var perchase_type = route[k][j]['for_booking'] ? 'booking' : 'perchase';
var booking_mark = route[k][j]['for_booking'] ? ' [预订]' : '';
resource_section += ' - ';
resource_section += ' ';
resource_section += route[k][j]['show_item'] + booking_mark;
resource_section += ' ';
resource_section += '
';
}
resource_section += '
';
resource_section += '
';
resource_section += '
';
}
$('#form-resource').append($(resource_section));
$('.dc_options:first').click();
}
//内存选项重填
function reload_memory(){
var cpu = data.cpu;
if(typeof(cpu_memory_range[cpu]) == 'undefined') return;
//$("#inputMemory a").each(function(){
$(".memory-block").each(function(){
var index_of_range = $.inArray(Number($(this).attr('pointvalue')), cpu_memory_range[cpu]);
if(index_of_range == -1 ){
$(this).addClass('disabled');
}else{
$(this).removeClass('disabled');
}
});
$(".memory-block").removeClass("selected");
$(".memory-block").not($(".disabled")).first().addClass('selected');
setting_change('reload memory');
}
//获取推荐配置
function get_prod(routeid){
var append_html = '';
if(typeof(prod[routeid]) != 'undefined' && prod[routeid] != null){
for(var i in prod[routeid]){//i=prodid
var idinfo = 'prod-' + routeid + '-' + i;
var info = prod[routeid][i]['cpu'] + "-" + prod[routeid][i]['memory'] + '-' + prod[routeid][i]['disk_size'] + '-';
info += prod[routeid][i]['charge_by'] == 'B' ? prod[routeid][i]['charge_by'] + '-' + prod[routeid][i]['bandwidth'] : prod[routeid][i]['charge_by'] + '-' + prod[routeid][i]['flux'];
append_html += "
" + prod[routeid][i]['name'] + " ";
}
}else
append_html = '';
$("#prod-tabs").html("
");
}
function get_data(){
if($(".dc_chosen").length == 0) return;
var source_ind1 = $(".dc_chosen").attr('ind1');
var source_ind2 = $(".dc_chosen").attr('ind2');
data.perchase_type = $(".dc_chosen").attr('perchase-type');
data.routeid = data.idcid = data.book_idc_id = 0;
//params for booking
data.booking_amount = 0;
if(data.perchase_type == 'booking') {
data.book_idc_id = $(".dc_chosen").attr('book-rsc-id');
}
//params for perchase
if(typeof(source_ind1) != 'undefined' && typeof(source_ind2) != 'undefined') {
data.routeid = route[source_ind1][source_ind2]['routeid'];
data.idcid = route[source_ind1][source_ind2]['idcid'];
data.charge_by = route[source_ind1][source_ind2]['charge_flag'];
data.vlan_id = 0;
data.clu_id = 0;
}
//common params
data.cpu = Number($(".cpu-block.selected").attr("data-value"));
data.memory = Number($(".memory-block.selected").attr("data-value"));
data.disk_size = Number($("#inputDisk").val());
data.bandwidth = data.share_bw > 0 ? 0 : Number($("#inputBW").val());
data.flux = Number($("#inputFlux").val());
data.num = 1;
data.paysort = 1;
data.ip_num = 1;
}
//配置变化时动作
function setting_change(eventname){
if(change_pending == true) return;
data.prodid = 0;
$("a.prod-pills").parent().removeClass("active");
get_data();
var cmpstr = data.cpu + '-' + data.memory + '-' + data.disk_size + '-';
cmpstr += data.charge_by == 'B' ? data.charge_by + '-' + data.bandwidth : data.charge_by + '-' + data.flux;
var match_prod = false;
$("a.prod-pills").each(function(){
if($(this).attr("set") == cmpstr){//匹配到推荐配置
$(this).parent().addClass("active");
data.prodid = $(this).attr("prodid");
if(data.perchase_type=='booking' && data.prodid > 0 && typeof(prod[data.routeid][data.prodid]) != 'undefined') {
data.booking_amount = prod[data.routeid][data.prodid]['booking_price'];
}
return false;
}
});
//if(match_prod) return;
refresh_price();
}
//价格计算
function refresh_price(){
//refresh config detail
$("#result-dc").html($(".dc_chosen").text() + '
[详情]');
$("#result-cpu-memory").html(data.cpu + ' 核, ' + $(".memory-block.selected").attr("pointvalue") + ' G');
$("#result-storage").html(data.disk_size + ' GB');
$("#result-bandwidth").html(data.charge_by == 'B' ? data.bandwidth + ' Mbps' : data.flux + ' GB');
var totalprice = price_calculate();
if(totalprice == false) return false;
if(data.perchase_type == 'booking') {
total_booking_amount = data.booking_amount;
if(!total_booking_amount) { //
total_booking_amount = Math.max(1, Math.round(totalprice / 3 / 100) ) * 100;
}
$('#totalBookPrice').html(total_booking_amount);
$('#booking-amount-div').show();
}else {
$('#booking-amount-div').hide();
}
$("#totalPrice").html(totalprice);
var year_amount = totalprice * 10;
if(typeof(hbw[data.routeid]) != 'undefined' && hbw[data.routeid] == 1){
year_amount = totalprice * 12;
}
$("#totalPrice_y").html(year_amount);
change_pending == false;
}
//计费
function price_calculate(){
var amount_month = 0;
if(data.prodid > 0){
for(var rid in prod){
if(null == prod[rid]) continue;
if(typeof(prod[rid][data.prodid]) != 'undefined')
amount_month = prod[rid][data.prodid]['month_price'];
}
}
if(amount_month == 0){
var p_cpu = _charge_in_step(price_acc['cpu'], data.cpu);
var p_memory = Math.round(_charge_in_step(price_acc['memory'], data.memory / 1024), 2);
var p_disk = _charge_in_step(price_acc['disk'], data.disk_size);
var p_bw = p_flux = p_ip = 0;
if(data.charge_by == 'B' && data.bandwidth > 0 && typeof(price_net[data.routeid]) != 'undefined')
p_bw = _charge_in_step(price_net[data.routeid]['bw'], data.bandwidth);
if(data.charge_by == 'F' && data.flux > 0 && typeof(price_net[data.routeid]) != 'undefined')
p_flux = _charge_in_step(price_net[data.routeid]['flux'], data.flux);
if(data.routeid > 0 && typeof(price_net[data.routeid]) != 'undefined' && data.ip_num > 0)
p_ip = _charge_in_step(price_net[data.routeid]['ip'], data.ip_num);
amount_month = Math.floor((p_cpu + p_memory + p_disk + p_bw + p_flux + p_ip) / 100);
}
var amount = data.paysort == 1 ? amount_month : amount_month * 10;
data.amount = amount = amount * data.num;
//$("#debug").html('cpu:' + p_cpu + '; memory:' + p_memory + '; disk:' + p_disk + '; bw:' + p_bw + '; flux:' + p_flux + '; ip: ' + p_ip + ';amount:' + amount);
return amount;
}
function _charge_in_step(step_array, quantity){
if(step_array == null || typeof(step_array) == 'undefined') return 0;
var rt = 0;
for(var i in step_array){
if(quantity - step_array[i]['from'] >= 0 && (quantity - step_array[i]['to'] <= 0 || step_array[i]['to'] == -1)) {
rt += (quantity - Math.max(0, (step_array[i]['from'] - 1))) * step_array[i]['price'];
quantity = step_array[i]['from'] - 1;
}
}
return rt;
}
function submitData(){
get_data();
var t = Base64.encode(JSON.stringify(data));
window.parent.location = "https://www.yunvm.com/buy_diy/?d=" + t + "";
}
//对话框调整
function modal_adjust(modalID){
var h = $('#' + modalID).outerHeight();
$('#' + modalID).css("top", "50%");
$('#' + modalID).css("margin-top", -h / 2 + 'px');
}
/*IE FF边框*/
$("a, button, input").each(function() {
$(this).attr("hideFocus", "true")
.css("outline", "none");
});
/*IE7滑动条设置值后出现的样式问题*/
$(".ui-slider-handle").trigger("hover");
//取消回车
$(window).keydown(function(event){
if(event.keyCode == 13) return false;
});