// // var element = $("#element"); var cPG = rGet(curl, 'pg'); if (cPG == '') cPG = '1'; if (cPG == '";') cPG = ''; $("#pg_" + cPG).addClass("on"); var cTitle = $("#pg_" + cPG).text(); document.title = cTitle + ' - ' + document.title; element.find('#vpsTi').html(cTitle); var pList = element.find("#pList"); var cloudData; var plist = ''; $.getJSON("process.aspx?c=jsapi&action=product&groupid=" + cPG + "&" + new Date(), function (rdata) { if (rdata == null) return false; cloudData = rdata; plist = '
  • 配置:
  • '; $(rdata).each(function (i) { plist += '
  • ' + rdata[i].pname + '
  • '; }); pList.find("li").remove(); pList.append(plist); customCloud(0); }, "json"); function changeOS(os) { element.find(".osMenu a").removeClass("oson"); element.find(".osMenu ." + os).addClass("oson"); element.find(".osConfi div").css("display", "none"); element.find(".osConfi #" + os + "_os").css("display", ""); element.find(".osConfi #" + os + "_os input:first").attr("checked", "checked"); } var cData; function customCloud(num) { cData = cloudData[num]; showCloudInfo(cData); billingMothod = parseInt(cData.pprice.pmothod); pList.find("li").removeClass("on"); pList.find("#p_" + num).addClass("on"); var osMenu = element.find("div[class='osMenu']").children(); var isolist = new Array(); isolist[isolist.length] = '1,Windows 2008|2,Windows 2012|3,Windows 2016|4,Windows 2019'.split('|'); isolist[isolist.length] = '5,CentOS 7|6,CentOS 8|7,Debian 9|8,Debian 10|9,Ubuntu 18|10,Ubuntu 20'.split('|'); for (var i = 0; i < osMenu.length; i++) { $(osMenu[i]).click(function () { element.find("div[class='osMenu']").children().removeClass('on'); $(this).addClass('on'); element.find("div[class='osConfi']").children().remove(); var os = isolist[$(element.find("div[class='osMenu']").children()).index(this)]; for (var j = 0; j < os.length; j++) { if (os[j].length > 0) { var iso = os[j].split(','); element.find("div[class='osConfi']").append('

    ' + iso[1] + '

    '); } } element.find("div[class='osConfi']").children().click(function () { element.find("div[class='osConfi']").children().removeClass('on'); $(this).addClass('on'); }); element.find("div[class='osConfi']").children().first().click(); }); } element.find("div[class='osMenu']").children().first().click(); var ipMin = cData.pconfig.ipc == undefined ? 1 : parseInt(cData.pconfig.ipc); var ipMax = cData.pupgrade.ip_max == undefined ? 1 : parseInt(cData.pupgrade.ip_max); if (ipMax < ipMin) ipMax = ipMin; var snapshotMin = cData.pconfig.snapshot == undefined ? 0 : parseInt(cData.pconfig.snapshot); var snapshotMax = cData.pupgrade.snapshot_max == undefined ? 0 : parseInt(cData.pupgrade.snapshot_max); if (snapshotMax < snapshotMin) snapshotMax = snapshotMin; var fullBackupMin = cData.pconfig.full_backup == undefined ? 0 : parseInt(cData.pconfig.full_backup); var fullBackupMax = cData.pupgrade.full_backup_max == undefined ? 0 : parseInt(cData.pupgrade.full_backup_max); if (fullBackupMax < fullBackupMin) fullBackupMax = fullBackupMin; var timeCycle = cData.psconfig.time_cycle == undefined ? '0' : cData.psconfig.time_cycle; $('#snapshot').children().remove(); for (i = snapshotMin; i <= snapshotMax; i++) $('#snapshot').append(''); $('#full_backup').children().remove(); for (i = fullBackupMin; i <= fullBackupMax; i++) $('#full_backup').append(''); var mincpu = parseFloat(cData.pconfig.cpu); var maxcpu = parseFloat(cData.pupgrade.cpu_max); var cpu_step = parseFloat(cData.pupgrade.cpu_step); var cpu_price = parseFloat(cData.pupgrade.cpu_price); var minram = parseFloat(typeof (cData.pconfig.ram) == 'undefined' ? cData.pconfig.ram_max : cData.pconfig.ram); var maxram = parseFloat(cData.pupgrade.ram_max); var ram_step = parseFloat(cData.pupgrade.ram_step); var ram_price = parseFloat(cData.pupgrade.ram_price); var mindisk = parseFloat(cData.pconfig.disk); var maxdisk = parseFloat(cData.pupgrade.disk_max); var disk_step = parseFloat(cData.pupgrade.disk_step); var disk_price = parseFloat(cData.pupgrade.disk_price); var minbw = parseFloat(cData.pconfig.bw); var maxbw = parseFloat(cData.pupgrade.bw_max); var bw_step = parseFloat(cData.pupgrade.bw_step); var bw_price = parseFloat(cData.pupgrade.bw_price); if (cData.pconfig.bw == '0') { minbw = 0; maxbw = 0; } var minport = parseFloat(cData.pconfig.port); var maxport = parseFloat(cData.pupgrade.port_max); if (cData.pconfig.port == '0' || cData.pconfig.port == cData.pupgrade.port_max) { minport = 0; maxport = 0; } var port_step = parseFloat(cData.pupgrade.port_step); var port_price = parseFloat(cData.pupgrade.port_price); element.find("#cpuText span:eq(1)").text(maxcpu + "核"); element.find("#ramText span:eq(1)").text(maxram + "MB"); element.find("#diskText span:eq(1)").text(maxdisk + "GB"); element.find("#portText span:eq(1)").text((maxport == 0 ? "不限端口" : maxport + "Mb")); element.find("#bwText span:eq(1)").text((maxbw == 0 ? "不限流量" : maxbw + "GB")); cloudSlider(mincpu, maxcpu, cpu_step, cpu_price, minram, maxram, ram_step, ram_price, mindisk, maxdisk, disk_step, disk_price, minbw, maxbw, bw_step, bw_price, minport, maxport, port_step, port_price); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); element.find("select").change(function () { updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }); } var vdisk = element.find("#vdisk"); var vport = element.find("#vport"); var vbw = element.find("#vbw"); var sl_disk = element.find("#sl_disk"); var sl_port = element.find("#sl_port"); var sl_bw = element.find("#sl_bw"); function cloudSlider(mincpu, maxcpu, cpu_step, cpu_price, minram, maxram, ram_step, ram_price, mindisk, maxdisk, disk_step, disk_price, minbw, maxbw, bw_step, bw_price, minport, maxport, port_step, port_price) { element.find("#vcpu").children().remove(); var ccpu = '1,2,4,6,8,12,16'; if (ccpu != '' && ccpu != '";') { var strs = new Array(); var strs = ccpu.split(','); if (strs.length > 0) { for (var i = 0; i < strs.length; i++) { if (strs[i] != '' && strs[i] >= mincpu && strs[i] <= maxcpu) { element.find("#vcpu").append('' + strs[i] + '核') } } } else { for (var i = mincpu; i <= maxcpu; i++) { element.find("#vcpu").append('' + i + '核') } } } else { for (var i = mincpu; i <= maxcpu; i++) { element.find("#vcpu").append('' + i + '核') } } element.find("#vcpu").children().click(function () { element.find("#vcpu").children().removeClass('on'); $(this).addClass('on'); element.find(".cmArea span[name='cpu']").html($(this).html()); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }); element.find("#vcpu").children().eq(0).click(); element.find("#vram").children().remove(); var cnram = '512,1024,2048,4096,8192,12288,16384,32768,65536' var strcnram = new Array(); var strcnram = cnram.split(','); if (maxram <= minram) { if (minram % 1024 == 0) { element.find("#vram").append('' + (minram / 1024) + 'GB'); } else { element.find("#vram").append('' + minram + 'MB'); } } else if (cnram != '' && cnram != '";' && strcnram.length > 0) { for (var j = 0; j < strcnram.length; j++) { if (strcnram[j] != '' && strcnram[j] >= minram && strcnram[j] <= maxram) { if ((strcnram[j] % 1024) == 0) { element.find("#vram").append('' + (strcnram[j] / 1024) + 'GB') } else { element.find("#vram").append('' + strcnram[j] + 'MB') } } } } else { for (var i = 1; i <= (maxram / minram); i++) { if (((i * minram) % 1024) == 0) { element.find("#vram").append('' + ((i * minram) / 1024) + 'GB') } else { if (i > 2) { if ((i % 2) == 0) { element.find("#vram").append('' + (i * minram) + 'MB') } } else { element.find("#vram").append('' + (i * minram) + 'MB') } } } } element.find("#vram").children().click(function () { element.find("#vram").children().removeClass('on'); $(this).addClass('on'); element.find(".cmArea span[name='ram']").html($(this).html()); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }); element.find("#vram").children().eq(0).click(); element.find("#vdisk").children().remove(); var cvdisk = '10,20,30,40,60,80,180,280,480,500,1000' var cvdisklist = new Array(); var cvdisklist = cvdisk.split(','); if (maxdisk <= mindisk) { element.find("#vdisk").append('' + mindisk + 'GB'); } else if (cvdisk != '' && cvdisk != '";' && cvdisklist.length > 0) { for (var v = 0; v < cvdisklist.length; v++) { if (cvdisklist[v] != '' && cvdisklist[v] >= mindisk && cvdisklist[v] <= maxdisk) { element.find("#vdisk").append('' + cvdisklist[v] + 'GB') } } } else { for (var i = mindisk; i <= maxdisk; i++) { if (((i - mindisk) % 10) == 0) { element.find("#vdisk").append('' + i + 'GB') } } } element.find("#vdisk").children().click(function () { element.find("#vdisk").children().removeClass('on'); $(this).addClass('on'); element.find(".cmArea span[name='disk']").html($(this).html()); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }); element.find("#vdisk").children().eq(0).click(); element.find("#vip").children().remove(); var cloudvip = '1,2,3,5,10' var cloudiplist = new Array(); var cloudiplist = cloudvip.split(','); if (cloudvip != '' && cloudvip != '";' && cloudiplist.length > 0) { for (var v = 0; v < cloudiplist.length; v++) { if (cloudiplist[v] != '' && parseInt(cloudiplist[v]) >= parseInt(cData.pconfig.ipc) && parseInt(cloudiplist[v]) <= parseInt(cData.pupgrade.ip_max)) { element.find("#vip").append('' + cloudiplist[v] + '个'); } } } else { for (var i = cData.pconfig.ipc; i <= cData.pupgrade.ip_max; i++) { element.find("#vip").append('' + i + '个'); } } element.find("#vip").children().click(function () { element.find("#vip").children().removeClass('on'); $(this).addClass('on'); element.find(".cmArea span[name='ipc']").html($(this).html() + ' IP地址'); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }); element.find("#vip").children().eq(0).click(); var minPortVal = 0; if (maxport == 0) { minPortVal = -1; vport.css("display", "none"); } else vport.css("display", ""); sl_port.slider({ range: "min", value: minport, min: minPortVal, max: maxport, step: port_step, slide: function (event, ui) { vport.val(ui.value); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }, stop: function (event, ui) { if (parseInt(ui.value) <= minport) { sl_port.slider("value", minport); vport.val(minport); sl_port.attr("title", minport + "Mb"); if (maxport == 0) element.find(".cmArea span[name='port']").html('不限端口'); else element.find(".cmArea span[name='port']").html(minport + ' MB'); } else { if (maxport == 0) sl_port.attr("title", "不限端口"); else sl_port.attr("title", ui.value + "Mb"); element.find(".cmArea span[name='port']").html(maxport == 0 ? "不限端口" : ui.value + ' MB'); } updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); sl_port.find('span').attr('style', sl_port.find('a').last().attr('style')).html(maxport == 0 ? "不限端口" : sl_port.attr("title")); } }); vport.val(minport); sl_port.slider("value", minport); if (maxport == 0) sl_port.attr("title", "不限端口"); else sl_port.attr("title", minport + "Mb"); sl_port.find('span').attr('style', sl_port.find('a').last().attr('style')).html(maxport == 0 ? "不限端口" : sl_port.attr("title")); $('#portText>p[class="valueMax"]').html(maxport + 'Mb'); //$('#portText>p[class="valueMin"]').html(maxport / 2 + 'Mb') $('#portText>p[class="valueMin"]').html('') //vdisk start var minDiskVal = 0; if (maxdisk == 0) { minDiskVal = -1; vdisk.css("display", "none"); } else vdisk.css("display", ""); sl_disk.slider({ range: "min", value: mindisk, min: minDiskVal, max: maxdisk, step: disk_step, slide: function (event, ui) { vdisk.val(ui.value); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }, stop: function (event, ui) { if (parseInt(ui.value) <= mindisk) { sl_disk.slider("value", mindisk); vdisk.val(mindisk); sl_disk.attr("title", mindisk + "GB"); if (maxdisk == 0) element.find(".cmArea span[name='disk']").html('不限磁盘'); else element.find(".cmArea span[name='disk']").html(mindisk + ' GB'); } else { if (maxdisk == 0) sl_disk.attr("title", "不限磁盘"); else sl_disk.attr("title", ui.value + "GB"); element.find(".cmArea span[name='disk']").html(maxdisk == 0 ? "不限磁盘" : ui.value + ' GB'); } updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); sl_disk.find('span').attr('style', sl_disk.find('a').last().attr('style')).html(maxdisk == 0 ? "不限磁盘" : sl_disk.attr("title")); } }); vdisk.val(mindisk); sl_disk.slider("value", mindisk); if (maxdisk == 0) sl_disk.attr("title", "不限磁盘"); else sl_disk.attr("title", mindisk + "GB"); sl_disk.find('span').attr('style', sl_disk.find('a').last().attr('style')).html(maxdisk == 0 ? "不限磁盘" : sl_disk.attr("title")); $('#diskText>p[class="valueMax"]').html(maxdisk + 'GB'); //$('#diskText>p[class="valueMin"]').html(maxdisk / 2 + 'GB') $('#diskText>p[class="valueMin"]').html('') //vdisk end var minVal = 0; if (maxbw == 0) { minVal = -1; } else vbw.css("display", ""); sl_bw.slider({ range: "min", value: minbw, min: minVal, max: maxbw, step: bw_step, slide: function (event, ui) { vbw.val(ui.value); updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); }, stop: function (event, ui) { if (parseInt(ui.value) < minbw) { sl_bw.slider("value", minbw); vbw.val(minbw); sl_bw.attr("title", minbw + "GB"); if (maxbw == 0) element.find(".cmArea span[name='bw']").html('不限流量'); else element.find(".cmArea span[name='bw']").html(minbw + ' GB'); } else { if (maxbw == 0) sl_bw.attr("title", "不限流量"); else sl_bw.attr("title", ui.value + "GB"); element.find(".cmArea span[name='bw']").html(maxbw == 0 ? "不限流量" : ui.value + ' GB'); } updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step); sl_bw.find('span').attr('style', sl_bw.find('a').last().attr('style')).html(maxbw == 0 ? "不限流量" : sl_bw.attr("title")); } }); vbw.val(minbw); sl_bw.slider("value", minbw); if (maxbw == 0) sl_bw.attr("title", "不限流量"); else sl_bw.attr("title", minbw + "GB"); $('#bwText>p[class="valueMax"]').html(maxbw + 'GB'); $('#bwText>p[class="valueMin"]').html(maxbw / 2 + 'GB') sl_bw.find('span').attr('style', sl_bw.find('a').last().attr('style')).html(maxbw == 0 ? "不限流量" : sl_bw.attr("title")); } function updatePrice(mincpu, cpu_price, cpu_step, minram, ram_price, ram_step, mindisk, disk_price, disk_step, minbw, bw_price, bw_step, minport, port_price, port_step) { var vramVal; if ($('#vram>span[class="on"]').html() != undefined && $('#vram>span[class="on"]').html().indexOf('MB') > 0) { vramVal = parseInt($('#vram>span[class="on"]').html().replace(/MB/g, '')) } else { vramVal = (parseInt($('#vram>span[class="on"]').html().replace(/GB/g, '')) * 1024) }; var addPrice = (parseFloat($('#vcpu>span[class="on"]').html().replace(/核/g, '')) - mincpu) * cpu_price / cpu_step; addPrice += (parseFloat(vramVal) - minram) / ram_step * ram_price; addPrice += (parseFloat(vdisk.val()) - mindisk) * disk_price / disk_step; if (minbw > 0) addPrice += (parseFloat(vbw.val()) - minbw) * bw_price / bw_step; if (minport > 0) addPrice += (parseFloat(vport.val()) - minport) * port_price / port_step; var ipMin = cData.pconfig.ipc == undefined ? 1 : parseInt(cData.pconfig.ipc); var snapshotMin = cData.pconfig.snapshot == undefined ? 0 : parseInt(cData.pconfig.snapshot); var fullBackupMin = cData.pconfig.full_backup == undefined ? 0 : parseInt(cData.pconfig.full_backup); var addIPC = $('#vip>span[class="on"]').html().replace(/个/g, '') == undefined ? ipMin : parseInt($('#vip>span[class="on"]').html().replace(/个/g, '')); var addSnapshot = element.find("#snapshot").val() == undefined ? snapshotMin : parseInt(element.find("#snapshot").val()); var addFullBackup = element.find("#full_backup").val() == undefined ? fullBackupMin : parseInt(element.find("#full_backup").val()); addIPC = addIPC - ipMin; addSnapshot = addSnapshot - snapshotMin; addFullBackup = addFullBackup - fullBackupMin; if (addIPC > 0) addPrice += addIPC * parseFloat(cData.pupgrade.ip); if (addSnapshot > 0) addPrice += addSnapshot * parseFloat(cData.pupgrade.snapshot_price); if (addFullBackup > 0) addPrice += addFullBackup * parseFloat(cData.pupgrade.full_backup_price); var timeCycle = cData.psconfig.time_cycle == undefined ? '0' : cData.psconfig.time_cycle; var priceList = '费用:'; var pps = cData.pprice.cprice.split(','); var pcs = cData.pprice.cycle.split(','); var p; for (p = 0; p < pps.length; p++) { if (pps[p] != '0') { priceList += ''; } } element.find(".price").html(priceList); $(".cmArea li:last span>span").html((parseFloat(pps[0]) + (addPrice * parseInt(pcs[0]))).toFixed(2)); element.find(".price input:radio:first").attr("checked", "checked"); element.find(".price label").click(function () { element.find(".cmArea li:last").html('价格:' + $(this).text() + '') }) } function showCloudInfo(info) { var thePrice = getPrice(info.pprice, info.psconfig, -1); if (thePrice.indexOf('') > -1) thePrice += '起'; else thePrice = htmlDecode(thePrice); var timeCycle = info.psconfig.time_cycle == undefined ? '0' : info.psconfig.time_cycle; thePrice = thePrice.replace("月", getTimeCycleSuffix(info.pprice.cycle.split(',')[0], timeCycle, 0)); element.find(".cmArea li").remove(); var str = '
  • CPU:' + info.pconfig['cpu'] + '核
  • ' + '
  • 内存: ' + parseFloat(typeof (info.pconfig['ram']) == 'undefined' ? info.pconfig['ram_max'] : info.pconfig['ram']) + 'MB
  • ' + '
  • 硬盘: ' + info.pconfig['disk'] + 'GB
  • ' + '
  • 带宽:' + (info.pconfig['port'] == '0' || cData.pconfig.port == cData.pupgrade.port_max ? '不限端口' : '' + info.pconfig['port'] + ' MB') + '
  • ' + '
  • 流量: ' + (info.pconfig['bw'] == '0' ? '不限流量' : '' + info.pconfig['bw'] + ' GB ') + '
  • ' + '
  • IP: ' + info.pconfig['ipc'] + '个IP地址
  • ' + '
  • 价格: ' + thePrice + '
  • '; element.find(".cmArea").append(str); element.find(".vpsbuy").html(''); } function cloudOrder(action) { if (action == 0) { if (userID == '') userLogin(0, 'cmd:cloudOrder(1);'); else cloudOrder(1); } else if (action == 1) { var cPrice = element.find(".price input:radio:checked").parent(); var billingCycle = cPrice.find("input:radio:checked").val(); var amount = parseFloat(cPrice.find("span").text()); var ipMin = cData.pconfig.ipc == undefined ? 1 : parseInt(cData.pconfig.ipc); var snapshotMin = cData.pconfig.snapshot == undefined ? 0 : parseInt(cData.pconfig.snapshot); var fullBackupMin = cData.pconfig.full_backup == undefined ? 0 : parseInt(cData.pconfig.full_backup); var ipcount = $('#vip>span[class="on"]').html().replace(/个/g, '') == undefined ? ipMin : parseInt($('#vip>span[class="on"]').html().replace(/个/g, '')); var snapshot = element.find("#snapshot").val() == undefined ? snapshotMin : parseInt(element.find("#snapshot").val()); var full_backup = element.find("#full_backup").val() == undefined ? fullBackupMin : parseInt(element.find("#full_backup").val()); var vramVal; if ($('#vram>span[class="on"]').html().indexOf('MB') > 0) { vramVal = parseInt($('#vram>span[class="on"]').html().replace(/MB/g, '')) } else { var vramMax = (typeof (cData.pconfig.ram) == 'undefined' ? cData.pconfig.ram_max : cData.pconfig.ram); vramVal = ((parseInt($('#vram>span[class="on"]').html().replace(/GB/g, '')) * 1024) / vramMax) * vramMax }; var timeCycle = cData.psconfig.time_cycle == undefined ? '0' : cData.psconfig.time_cycle; var billingCycle = parseInt(cPrice.find("input:radio:checked").val()); var finalPrice = cPrice.find("span").text(); var str = '
    您选择的云服务器配置:
    ' + 'CPU核数:' + parseFloat($('#vcpu>span[class="on"]').html().replace(/核/g, '')) + ' 核
    ' + '内存大小:' + $('#vram>span[class="on"]').html() + '
    ' + '存储容量:' + ((vdisk.val() == '0') ? '不限流量' : vdisk.val() + ' GB') + '
    ' + '带宽速率:' + ((vport.val() == '0') ? '不限流量' : vport.val() + ' Mb') + '
    ' + '流量大小:' + (vbw.val() == '0' ? '不限流量' : vbw.val() + ' GB') + '
    ' + 'IP地址:' + ipcount + ' 个
    ' + (snapshot > 0 ? '快照备份:' + snapshot + ' 个
    ' : '') + (full_backup > 0 ? '完整备份:' + full_backup + ' 个
    ' : '') + '付款周期:' + getTimeCycleSuffix(billingCycle, timeCycle, 0) + '
    ' + '最终价格:' + finalPrice + ' RMB  

    ' + '
    ' + '' + '' + '' + '' + '' + '' + '' + '' + '
    '+ '

    优惠码:

    ' + '

    '; swin.html(str); swin.dialog({ title: "购买确认", autoOpen: false, resizable: false, width: 388, modal: true, buttons: { "确定购买": function () { checkout(cData.pid, billingCycle); }, "关 闭": function () { $(this).dialog("close"); }, "在线充值": function () { payOnline(0, amount); } } }).dialog("open"); } } function getCouponError(rmsg, code) { var rdata = rmsg[1]; switch (rmsg[1]) { case "Invalid coupon code": rdata = '您输入的优惠码无效!'; break; case "The coupon code is only use for monthly payment": rdata = '优惠码只能用于套餐的月付形式!'; break; case "Exceeds the limit": rdata = '您输入的优惠码已超过使用次数限制!'; break; case "Exceeds the per user limit": rdata = '当前优惠码每人只能使用' + rmsg[2] + '次!'; break; case "The coupon code is expired": rdata = '您输入的优惠码已过期!'; break; case "Current product is not allowed to use the coupon code": rdata = '当前产品套餐不允许使用优惠码!'; break; case "Your user group is not allowed to use the coupon code": rdata = '您的用户级别不允许使用优惠码!'; break; case "The coupon code is only use for " + rmsg[2] + " months payment": rdata = '优惠码仅能用于[' + rmsg[2] + ']个周期(月/天/小时)'; break; case "The coupon code is only use for amount more than": rdata = '优惠码仅能在总金额大于' + rmsg[2] + '的时候使用!'; break; case "The coupon code can not be used to order new services": rdata = '优惠码不能用于购买新产品服务!'; break; case "The coupon code can not be used to renew services": rdata = '优惠码不能用于续费产品服务!'; break; case "The coupon code can not be used to upgrade services": rdata = '优惠码不能用于升级产品服务!'; break; default: rdata = rmsg[1]; break; } rdata = rdata.replace('优惠码', '优惠码[' + code + ']'); return rdata; } function applyCode(couponType) { clearCouponCode(0); var code = $("#couponcode").val(); if (code == '') { $("#ccdes").html('请输入正确的优惠码!'); return false; } var cPrice = element.find(".price input:radio:checked").parent(); var finalPrice = parseFloat(cPrice.find("span").text()); var billingCycle = parseInt(cPrice.find("input:radio:checked").val()); var normalPrice = finalPrice; $("#couponcode").val('Loading...'); $.get('idcsystem.aspx?c=ajax&dt=couponcode&p1=' + code + '&p2=' + couponType + '_' + cData.pid + '_' + billingMothod + '_' + billingCycle + '_' + userLevel + '_' + normalPrice.toFixed(2) + '&' + new Date(), function (rdata) { var rmsg = rdata.split('|'); if (rmsg[0] == '0') { var fPrice = normalPrice; var couponConfig = $.parseJSON(rmsg[1]); var discount = parseFloat(couponConfig["discount"]); if (discount > 1) fPrice = fPrice - discount; else if (discount > 0 && discount < 1) fPrice = fPrice * discount; if (discount == 0) { $("#couponcode").val(''); rdata = '当前产品不使用优惠码!'; } else if (fPrice <= 0) { $("#couponcode").val(''); rdata = '当前价格过低不能使用此优惠码!'; } else { $("#swin .finalPrice").html(fPrice.toFixed(2)); $("#swin .normalPrice").html('原始价格:' + normalPrice.toFixed(2) + ' RMB'); $("#couponcode").val(code); rdata = couponConfig["cdes"]; } } else { if (rmsg[0] == "-1") { rdata = getCouponError(rmsg, code); } $("#couponcode").val(''); } $("#ccdes").html(rdata); }); } function clearCouponCode(action) { cPrice = element.find(".price input:radio:checked").parent(); finalPrice = parseFloat(cPrice.find("span").text()); $("#swin .finalPrice").text(finalPrice.toFixed(2)); $("#swin .normalPrice").html(''); $("#ccdes").html(''); if (action == 1) $("#couponcode").val(''); }