-
Notifications
You must be signed in to change notification settings - Fork 0
/
lilv.html
252 lines (232 loc) · 10.9 KB
/
lilv.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>等额本息还款法计算器</title>
<script language="javascript">
function estateBorrow(original,active,timeSpan){
var monthBack=original*active*0.001*Math.pow((1+parseFloat(active*0.001)),parseFloat(timeSpan))/(Math.pow((1+parseFloat(active*0.001)),parseFloat(timeSpan))-1);
var totalBack=monthBack*timeSpan;
var totalInterest=totalBack-original;
var monthInterest=totalInterest/timeSpan;
totalInterest=(Math.round(totalInterest*100))/100;//存款利息:取两位小数
monthInterest=(Math.round(monthInterest*10000))/10000;//存款利息:取两位小数
monthBack=(Math.round(monthBack*10000))/10000;//存款利息:取两位小数
totalBack=(Math.round(totalBack*100))/100;//本息合计:取两位小数
var objArray=new Array();
objArray[0]=monthBack;
objArray[1]=totalBack;
objArray[2]=monthInterest;
objArray[3]=totalInterest;
return objArray;
}
function estateBorrow1(original,active,timeSpan){
active = active*0.001;
var monthOriginal = original / timeSpan;
var timeSpan1=parseInt(timeSpan);
var interestTotal=0;
var backMonth = "";
for(i=1;i<timeSpan1+1;i++){
interestM=(original-original*(i-1)/timeSpan1)*active;
backMonth += i + "月:" + (monthOriginal + interestM).toFixed(2) + "元\n";
interestTotal=parseFloat(interestTotal)+parseFloat(interestM);
}
var monthBack=original*active*Math.pow((1+parseFloat(active)),parseFloat(timeSpan))/(Math.pow((1+parseFloat(active)),parseFloat(timeSpan))-1);
interestTotal=(Math.round(interestTotal*100))/100;//贷款利息:取两位小数
var moneyTotal=parseFloat(original)+parseFloat(interestTotal);
var objArray=new Array();
objArray[0]=interestTotal;
objArray[1]=moneyTotal;
objArray[2] = backMonth;
return objArray;
}
function checkData(objArray){
var textnow;
var rst="true";
for(i=0;i<objArray.length;i++){
textnow=eval(objArray[i])
if(textnow.value==""){
rst="false";
alert("请输入完整!");
textnow.focus() ;
textnow.select();
break;
}
}
return rst
}
function isInteger(objArray){
var textnow;
var rst="true";
for(i=0;i<objArray.length;i++){
textnow=eval(objArray[i]);
if(isNaN(textnow.value)){
rst="false";
alert("请输入数字!");
textnow.focus();
textnow.select();
break;
}
}
return rst
}
//计算函数,返回计算结果并显示在相应的结果项上。
function sendrate2(){
//设定一个数组,把要检验的字段对应的输入框的字符串表示赋给数组
var objArray=new Array();
objArray[0]=document.estateborrow.original;
objArray[1]=document.estateborrow.active;
objArray[2]=document.estateborrow.yearSpan;
var rst=checkData(objArray);//调用函数检验是否有空字符
if(rst=="false")
{return;}
rst=isInteger(objArray);//调用函数检验是否为整数
if(rst=="false")
{return;}
//从表单中取值
var original=document.estateborrow.original.value; //贷款总额
var active=document.estateborrow.active.value; //贷款利息
var yearSpan=document.estateborrow.yearSpan.value; //年份
//alert(yearSpan);
var timeSpan=parseFloat(yearSpan)*12;
active=active*10/12;
//计算贷款利息、本息合计
var result=new Array();
if(document.estateborrow.inputSelect.value=="等额本息还款"){
result=estateBorrow(original,active,timeSpan);//贷款利息、利息税额、实得利息、本息合计封在返回的数组中
//将贷款利息本息合计显示
document.estateborrow.monthBack.value=result[0]; //显示贷款利息
document.estateborrow.totalBack.value=result[1]; //显示本息合计
//document.estateborrow.monthInterest.value=result[2]; //显示贷款利息
document.estateborrow.totalInterest.value=result[3]; //显示本息合计
document.getElementById("tr_debj").style.display='none';
document.getElementById("tr_debx").style.display='';
}
else{
var result=estateBorrow1(original,active,timeSpan);
document.estateborrow.totalInterest.value=result[0]; //显示贷款利息
document.estateborrow.totalBack.value=result[1]; //显示本息合计
document.estateborrow.monthBackDEBJ.value=result[2];//显示每月还款额
document.getElementById("tr_debx").style.display='none';
document.getElementById("tr_debj").style.display='';
//document.estateborrow.monthInterest.value="";
}
}
</script>
<style type="text/css">
td{ height:25px; padding-left:5px;}
input {color:#000; }
#readolny input{ background:#F7F7F7;border:1px solid #7F9DB9;height:16px;}
.style1
{
font-size: medium;
}
</style>
</head>
<body id="contractPage">
<div class="container" id="container">
<div id="wrapper">
<div id="content">
<form name="estateborrow" action="counter-aa">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" >
<tr><td valign="top">
<table border="0" cellpadding="1" cellspacing="1" width="100%" bgcolor="#CCCCCC">
<tr bgcolor="#F7F7F7"><td colspan="2" ><strong>计算公式</strong></td></tr>
<tr bgcolor="#FFFFFF"><td width="50%" align="right">贷款种类:</td><td><select name="borrowtype" class="font12">
<option value="个人住房贷款">个人住房贷款</option>
<option value="个人旅游贷款">个人旅游贷款</option>
<option value="个人综合消费贷款">个人综合消费贷款</option>
<option value="个人短期信用贷款">个人短期信用贷款</option>
<option value="个人小额抵押贷款">个人小额抵押贷款</option>
<option value="个人汽车贷款">个人汽车贷款</option>
<option value="助学贷款">助学贷款</option>
<option value="个人留学贷款">个人留学贷款</option>
<option value="大额耐用消费品贷款">大额耐用消费品贷款</option>
</select></td></tr>
<tr bgcolor="#FFFFFF"><td align="right">贷款总额:</td><td><input name="original" id="original" size="9" maxlength="16" class="ts_counter" type="text"> 元</td></tr>
<tr bgcolor="#FFFFFF"><td align="right">按揭年数:</td><td> <input name="yearSpan" size="6" maxlength="8" class="ts_counter" type="text"> 年</td></tr>
<tr bgcolor="#FFFFFF"><td align="right">还款方式:</td><td> <select name="inputSelect" class="font12">
<option value="等额本息还款">等额本息还款</option>
<option value="等额本金还款">等额本金还款</option>
</select></td></tr>
<tr bgcolor="#FFFFFF"><td align="right">贷款利率(年利率):</td><td> <input name="active" size="8" maxlength="10" class="ts_counter" type="text"> %</td></tr>
<tr bgcolor="#FFFFFF"><td colspan="2" align="center"><input onclick="javascript:sendrate2()"; type="button" value="开始计算" name="button1" ><input onclick="javascript:document.estateborrow.reset()"; type="reset" value="重新计算" name="button2" ></td></tr>
</table>
</td>
<td valign="top">
<table border="0" cellpadding="1" cellspacing="1" width="100%" bgcolor="#CCCCCC" id="readolny">
<tr bgcolor="#F7F7F7"><td colspan="2"><b>计算结果</b></td></tr>
<tr id="tr_debx" bgcolor="#FFFFFF"><td align="center" height="28" width="50%"><div align="right">
月均还款:</div></td><td width="50%"> <input readonly="readonly" name="monthBack" size="8" maxlength="16" class="ts_counter" type="text">
元 </td></tr>
<tr id="tr_debj" style="display:none" bgcolor="#FFFFFF"><td align="center" height="28" width="50%"><div align="right">
月还金额:</div></td><td width="50%"> <textarea name="monthBackDEBJ" class="ts_counter" rows=5 cols=20> </textarea></td></tr>
<tr bgcolor="#FFFFFF"><td align="center" height="28" width="50%"> <div align="right">
支付利息:</div></td><td width="50%"> <input readonly="readonly" name="totalInterest" size="8" maxlength="16" class="ts_counter" type="text">
元 </td> </tr>
<tr bgcolor="#FFFFFF"><td align="center" height="28" width="50%"><div align="right">
还款总额:</div></td><td width="50%"> <input readonly="readonly" name="totalBack" size="8" maxlength="16" class="ts_counter" type="text">
元 </td></tr>
</table>
</td></tr>
<tr id="tztable">
<td>
<table>
<tr><td colspan='2'><strong>touzi</strong></td></tr>
<tr><td>init value:</td><td><input v-model="tzvalue" type="text"></td>
<tr><td>rate:</td><td><input v-model='tzrate' type="text">%</td>
<tr><td>years:</td><td><input v-model='tzyears' type="text"></td>
<tr><td><input v-on:click="calTz" type="button" value="calculate"></td> <td>{{ tzresult }} </td></tr>
</table>
</td>
<td>
<table>
<tr><td colspan='2'><strong>ding cun</strong></td></tr>
<tr><td>value:</td><td><input v-model="dcvalue" type="text"></td>
<tr><td>rate:</td><td><input v-model='dcrate' type="text">%</td>
<tr><td>years:</td><td><input v-model='dcyears' type="text"></td>
<tr><td><input v-on:click="calDc" type="button" value="calculate"></td> <td>{{ dcresult }} </td></tr>
</table>
</td>
</table>
</div>
</div>
</div>
<script>
var app = new Vue({
el: '#tztable',
data: {
tzvalue: 0,
tzrate: 0,
tzyears:0,
tzresult:0,
dcvalue:0,
dcrate:0,
dcyears:0,
dcresult:0
},
methods:
{
calTz:function()
{
this.tzresult = this.tzvalue;
for(let y=0;y<this.tzyears;y++)
{
this.tzresult *= (1 + this.tzrate/100);
}
},
calDc:function()
{
this.dcresult = 0;
for(let y=0;y<Number(this.dcyears);y++)
{
this.dcresult= (this.dcresult+Number(this.dcvalue))*(1+Number(this.dcrate)/100);
}
}
}
})
</script>
</body>
</html>