/**
*
*/
$().ready(function(){
$(".c_cpmbuttons").click(function() {
var account = $("#account").val();
var flag = true;
if (account == "") {
flag = false;
$("#calculErr").html("请输入投资金额");
$("#calculErr").show();
// 计算器校验问题 start
} else if (account > 5000000) {
flag = false;
$("#calculErr").html("投资金额最高为5000000元");
$("#calculErr").show();
}
var apr = $("#apr").val();
if (apr == "") {
flag = false;
$("#calculErr").html("请输入日利率");
$("#calculErr").show();
} else if (apr > 30) {
flag = false;
$("#calculErr").html("日利率最高30%");
$("#calculErr").show();
}
var statusStr = $(".select_showbox").eq(1).html();
if($(".select_box").eq(0).find(".selected").html()=="天标"){
status = 1;
}else if(statusStr=="一次性还"){
status = 2;
}else if(statusStr=="每月付息"){
status = 3;
}else if(statusStr=="等额本息"){
status = 4;
}
var periods = $("#periods").val();
if (periods == "") {
flag = false;
$("#calculErr").html("请输入投资期限");
$("#calculErr").show();
} else if (periods > 0) {
if (!/^[0-9]*[1-9][0-9]*$/.test(periods)) {
flag = false;
$("#calculErr").html("投资期限-请输入正整数");
$("#calculErr").show();
}
if($(".select_box").eq(0).find(".selected").html()=="天标" && periods > 999){
flag = false;
$("#calculErr").html("投资期限-天标最大为999天");
$("#calculErr").show();
}else if($(".select_box").eq(0).find(".selected").html()!="天标" && periods > 999 ){
flag = false;
$("#calculErr").html("投资期限-天标最大为999天");
$("#calculErr").show();
}
} else if (periods <= 0) {
flag = false;
$("#calculErr").html("投资期限-请输入正数");
$("#calculErr").show();
}
// 计算器校验问题 end
if (flag) {
$("#calculErr").html("");
$("#calculErr").hide();
var html='';
html+='
';
html+='';
html+='- 收款日期
';
html+='- 收款金额
';
html+='- 收回本金
';
html+='- 收回利息
';
html+='- 剩余本金
';
html+='
';
html+='';
var html2 = '';
if($(".select_showbox").val() == "1"){//到期还本还息
html+='';
html+='';
html+='- '+GetDateStr(parseInt(periods))+'
';
html+='- '+(parseFloat(periods*apr*account/100)+parseFloat(account))+'
';
html+='- '+(account)+'
';
html+='- '+(periods*apr*account/100)+'
';
html+='- 0
';
html+='
';
html+='';
html2+='';
html2+='';
html2+='- 总结
';
html2+='- '+((parseFloat(periods*apr*account/100)+parseFloat(account)).toFixed(2))+'
';
html2+='- '+(account)+'
';
html2+='- '+((periods*apr*account/100).toFixed(2))+'
';
html2+='';
html2+='
';
html2+='';
html2+='实际总收益:¥'+((periods*apr*account/100).toFixed(2))+'元';
}
else if($(".select_showbox").val() == "2"){//每日返息,到期还本
for(var i = 1;i<= periods;i++){
html+='';
html+='';
html+='- '+GetDateStr(parseInt(i))+'
';
if(i==periods){
html+='- '+(parseFloat(apr*account/100)+parseFloat(account))+'
';
html+='- '+(account)+'
';
}
else{
html+='- '+(apr*account/100)+'
';
html+='- 0
';
}
html+='- '+(apr*account/100)+'
';
if(i!=periods) {
html += '- '+(account)+'
';
}
else{
html += '- 0
'
}
html+='
';
html+='';
}
html2+='';
html2+='';
html2+='- 总结
';
html2+='- '+((parseFloat(periods*apr*account/100)+parseFloat(account)).toFixed(2))+'
';
html2+='- '+(account)+'
';
html2+='- '+((periods*apr*account/100).toFixed(2))+'
';
html2+='';
html2+='
';
html2+='';
html2+='实际总收益:¥'+((periods*apr*account/100).toFixed(2))+'元';
}
else if($(".select_showbox").val() == "3"){//每周返息,到期还本
periods = parseInt(periods/7);
for(var i = 1;i<= periods;i++){
html+='';
html+='';
html+='- '+GetDateStr(parseInt(i*7))+'
';
if(i==periods){
html+='- '+(parseFloat(apr*account/100*7)+parseFloat(account))+'
';
html+='- '+(account)+'
';
}
else{
html+='- '+(apr*account/100*7)+'
';
html+='- 0
';
}
html+='- '+(apr*account/100*7)+'
';
if(i!=periods) {
html += '- '+(account)+'
';
}
else{
html += '- 0
'
}
html+='
';
html+='';
}
html2+='';
html2+='';
html2+='- 总结
';
html2+='- '+((parseFloat(periods*apr*account/100*7)+parseFloat(account)).toFixed(2))+'
';
html2+='- '+(account)+'
';
html2+='- '+((periods*apr*account/100*7).toFixed(2))+'
';
html2+='';
html2+='
';
html2+='';
html2+='实际总收益:¥'+((periods*apr*account/100*7).toFixed(2))+'元';
}
else if($(".select_showbox").val() == "4") {//每月返息,到期还本
periods = parseInt(periods/30);
for(var i = 1;i<= periods;i++){
html+='';
html+='';
html+='- '+GetDateStr(parseInt(i*30))+'
';
if(i==periods){
html+='- '+(parseFloat(apr*account/100*30)+parseFloat(account))+'
';
html+='- '+(account)+'
';
}
else{
html+='- '+(apr*account/100*30)+'
';
html+='- 0
';
}
html+='- '+(apr*account/100*30)+'
';
if(i!=periods) {
html += '- '+(account)+'
';
}
else{
html += '- 0
'
}
html+='
';
html+='';
}
html2+='';
html2+='';
html2+='- 总结
';
html2+='- '+((parseFloat(periods*apr*account/100*30)+parseFloat(account)).toFixed(2))+'
';
html2+='- '+(account)+'
';
html2+='- '+((periods*apr*account/100*30).toFixed(2))+'
';
html2+='';
html2+='
';
html2+='';
html2+='实际总收益:¥'+((periods*apr*account/100*30).toFixed(2))+'元';
}
else if($(".select_showbox").val() == "5") {//每日复利,保本保息
var account2 = account;
var lx = 0;
for(var i = 1;i<= periods;i++){
if(i!=1){
account =(parseFloat(account)+parseFloat(apr*account/100)).toFixed(2);
}
lx += parseFloat(apr*account/100).toFixed(2);//计算利息
html+='';
html+='';
html+='- '+GetDateStr(parseInt(i))+'
';
if(i==periods){
html+='- '+(parseFloat(account)+parseFloat(apr*account/100)).toFixed(2)+'
';
html+='- '+(account)+'
';
}
else{
html+='- '+(apr*account/100).toFixed(2)+'
';
html+='- 0
';
}
html+='- '+(apr*account/100).toFixed(2)+'
';
if(i!=periods) {
html += '- '+(account)+'
';
}
else{
html += '- 0
'
}
html+='
';
html+='';
}
html2+='';
html2+='';
html2+='- 总结
';
html2+='- '+((parseFloat(account)+parseFloat(apr*account/100)).toFixed(2))+'
';
html2+='- '+(account2)+'
';
html2+='- '+((parseFloat(account)+parseFloat(apr*account/100)-parseFloat(account2)).toFixed(2))+'
';
html2+='';
html2+='
';
html2+='';
html2+='实际总收益:¥'+((parseFloat(account)+parseFloat(apr*account/100)).toFixed(2))+'元';
}
else if($(".select_showbox").val() == "6") {//交易日返息,到期还本
var weekDay = ["7", "1", "2", "3", "4", "5", "6"];
var jia = 0;
for(var i = 1;i<= periods;i++){
var dateStr = GetDateStr(parseInt(i));
var myDate = new Date(Date.parse(dateStr.replace(/-/g, "/")));
if(weekDay[myDate.getDay()] == "6"){
jia += 2;
}
if(weekDay[myDate.getDay()] == "7"){
jia += 1;
}
html+='';
html+='';
html+='- '+GetDateStr(parseInt(i+jia))+'
';
if(i==periods){
html+='- '+(parseFloat(apr*account/100)+parseFloat(account))+'
';
html+='- '+(account)+'
';
}
else{
html+='- '+(apr*account/100)+'
';
html+='- 0
';
}
html+='- '+(apr*account/100)+'
';
if(i!=periods) {
html += '- '+(account)+'
';
}
else{
html += '- 0
'
}
html+='
';
html+='';
}
html2+='';
html2+='';
html2+='- 总结
';
html2+='- '+((parseFloat(periods*apr*account/100)+parseFloat(account)).toFixed(2))+'
';
html2+='- '+(account)+'
';
html2+='- '+((periods*apr*account/100).toFixed(2))+'
';
html2+='';
html2+='
';
html2+='';
html2+='实际总收益:¥'+((periods*apr*account/100).toFixed(2))+'元';
}
$('#calculatorList').html(html);
$(".c_bottomcpm").html(html2);
$(".c_calculatorCpmLeft").hide();
$(".c_calculatorCpmRight").show();
}
});
});
$(function() {
$(".c_show_left").click(function() {
$(".c_calculatorCpmLeft").show();
$(".c_calculatorCpmRight").hide();
})
});
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
/*var y = dd.getFullYear();
y = y.toString().substr(2,2); */
var m = dd.getMonth()+1;//获取当前月份的日期
var d = dd.getDate();
m = m < 10?"0" + m : m;
d = d < 10?"0" + d : d;
return m+"-"+d;
}