-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
314 lines (297 loc) · 15 KB
/
index.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>爱自己,爱人生</title>
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.min.js"></script>
<!--<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>-->
<style>
*{margin: 0;padding: 0;}
b{margin: 3px;}
.head{margin: 0 auto;}
.title {
height: 60px;
line-height: 60px;
text-align: center;
}
.title .line {
display: inline-block;
width: 250px;
/*vertical-align: -4px;*/
border-top: 1px solid #ccc ;
}
.title .txt {
color: #686868;
vertical-align: middle;
}
.mark{color: #686868;text-align: center;}
#from{width: 90%; padding-left: 5%;padding-right: 5%;}
.content{
width: 1100px;
/*height: 800px;*/
margin: 0 auto;
padding-top: 30px;/*padding-left: 20%;padding-right: 20%;*/
background-color: #fff; opacity: 0.9;
}
#iframe{
/*min-width: 1000px;*/
width: 100%;
height: 420px;
/*left: 50%;*/
/*right: 50%;*/
overflow: hidden;
}
.marginbottom{margin-bottom: 10px;}
</style>
</head>
<!--
你的名字 {}
你打算活到几岁
你的生日 这些涉及到人生度过% 大概吃了几顿饭 度过多少个周末 享受过夜晚
计算规则:
过去了多少天,即当前天-1
当前星期几(0-6,0代表星期天)
今天过去时间百分比 (this.hour*60+this.minute)/24/60
本周过去时间百分比 (this.week*24*60+this.hour*60+this.minute)/7/24/60
这个月过去时间百分比 (this.day*24*60+this.hour*60+this.minute)/days/24/60/ (days为这个月具体多少天)
今年过去时间 现在时间-今年1月1好0时0分0秒000毫秒的时间
人生进度条 现在时间-生日时间 得出具体的毫秒值
进度条颜色安排: 20绿 bg-success
20-50蓝 bg-info
50-80黄 bg-warning
红 bg-danger
-->
<body >
<div class="container" id="app">
<div class="head">
<div class="爱自己,爱人生">
</div>
<br>
<div>
<!--{{title}} 这里的名句 创建个方法 点击一下换一句 -->
<!--https://www.tianapi.com/apiview/26 会员免费??? 5000个够你玩了 -->
<!--后台也可以专门写一个数据表 存取你喜欢的名言名句 通过随机数确定获取哪一句 我的属于这种 -->
<h2 class="mark">"更好的有很多很多,但刚刚好的只有你一个" </h2>
</div>
</div>
<div class="content" >
<div id="from">
<p>你的<b>人生</b>已经走了 {{age}}年 </p>
<div v-html="theLife()" class="marginbottom"></div>
<p>
您的生日: {{yearForYour}} 年 {{monthForYour}} 月 {{dayForYour}} 日
<span style="padding-left: 20px;">现中国人类平均寿命是76.34岁 这里按80岁算~_~</span>
</p>
<p> 你可能已经吃过了<b>{{youreat}}</b>, 度过了<b>{{yourweek}}</b>个愉快的周末, 以及享受过 <b>{{yourtian}}</b> 个美妙的夜晚</p>
<hr style="border-top:1px dashed #987cb9;" width="100%" color="#987cb9" size=1>
<p>今<b>天</b>已经过去了 大约 {{hour}}小时</p>
<div v-html="jinduT()" class="marginbottom"></div>
<p>本<b>周</b>已经过去了 {{week}}天, 这是第{{curweek}}天</p>
<div v-html="jinduZ()" class="marginbottom"></div>
<p>这个<b>月</b>已经过去了 {{day}}天 , 这是第{{curday}}天</p>
<div v-html="jinduD()" class="marginbottom"></div>
<p>{{year}}<b>年</b>已经过去了 {{month}}个月 度过了{{outday}}天</p> <!--{{year}}-->
<div v-html="jinduY()" class="marginbottom"></div>
</div>
<br>
<br>
</div>
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
site: "更好的有很多很多,但刚刚好的只有你一个", //献给要过生日的某某人 这个词可以换的
age: "24",
year:"",
month:"",
day:"",
curday:"",
time:"",
hour:"",
minute:"",
sec:"",
week:"",
curweek:"",
life:"",
outday:"",
yearForYour:"1997",
monthForYour:"3",
dayForYour:"14",
yourtian:"",
youreat:"",
yourweek:""
},
created: function () {//这里是定时器
this.timer();
setInterval(this.timer, 60000);
},
methods: {// 我的理解是方法区和数据区
timer: function() {
var myDate = new Date();
var myYear = myDate.getFullYear(); // 获取当前年份
var myMonth = myDate.getMonth() +1; // 获取当前月份
var myDay = myDate.getDate(); // 获取当前日(1- 31)
var myHours = myDate.getHours(); // 获取当前小时(0-23)
var myMinu = myDate.getMinutes(); // 获取当前分钟(0-59)
var mySec = myDate.getSeconds(); // 获取当前秒数(0-59)
var myWeek = myDate.getDay(); //获取当前星期几(0-6,0代表星期天)
// if (this.monthForYour==myMonth && this.dayForYour==myDay ){
// //祝你生日快乐 撒花 这个老兄的烟花或者自己写 https://github.com/cunzher/canvas-/blob/master/index.html
// }
this.hour = myHours;
this.year = myYear;
this.month = myMonth-1;
this.day = myDay-1; this.curday=myDay;
this.week = myWeek-1; this.curweek = myWeek;
this.minute = myMinu;
this.age = myYear-this.yearForYour;
},
//life
theLife:function(){
var dt = new Date(this.yearForYour, this.monthForYour, this.dayForYour);
var today = new Date();
var ms = today.getTime() - dt.getTime();//parseInt((today.getTime() - dt.getTime())/86400000);
this.yourtian = parseInt(ms/86400000);
this.youreat = parseInt(ms/86400000)*3;
this.yourweek = parseInt(ms/86400000/7);
var lift = (parseInt(ms/86400000/365)/80 *100).toFixed(1);
var color = this.jinduColor(lift);
return "<div class='progress'> <div class='progress-bar "+ color +" progress-bar-striped progress-bar-animated' style='width:"+ lift +"%'>"+lift+"</div> </div>";
},
//今天
jinduT:function(){
var tian = ((this.hour*60+this.minute)/24/60*100).toFixed(1); // + "%"
var color = this.jinduColor(tian);
return "<div class='progress'> <div class='progress-bar "+ color +" progress-bar-striped progress-bar-animated' style='width:"+ tian +"%'>"+tian+"</div> </div>";
},
//本周
jinduZ:function(){
var curdayWithHour = (this.week*24*60+this.hour*60+this.minute)/7/24/60;
var zhou = (curdayWithHour*100).toFixed(1);
var color = this.jinduColor(zhou);
return "<div class='progress'> <div class='progress-bar "+ color +" progress-bar-striped progress-bar-animated' style='width:"+ zhou +"%'>"+zhou+"</div> </div>";
},
//这个月
jinduD:function(){
var days=new Date(this.year,this.month+1,0).getDate();
var yue = ((this.day*24*60+this.hour*60+this.minute)/days/24/60*100).toFixed(1); //js如何得到这个月具体多少天
var color = this.jinduColor(yue);
return "<div class='progress'> <div class='progress-bar "+ color +" progress-bar-striped progress-bar-animated"+ color +"' style='width:"+ yue +"%'>"+yue+"</div> </div>";
},
//年
jinduY:function(){
var olddate = new Date(this.year, 0);
var nowdate = new Date(this.year,this.month,this.day+1);
var outday = (nowdate - olddate) / (1000 * 60 * 60 * 24) + 1;//
this.outday = outday;//已经过去天数
var isLeap = (0===this.year%4) && (0===this.year%100) || (0===this.year%400);
var days = isLeap ? 366 : 365;//今年的天数
var ye = (((outday-1)*24*60 + this.hour*60+ this.minute)/days/24/60*100).toFixed(1);
var color = this.jinduColor(ye);
return "<div class='progress'> <div class='progress-bar "+ color +" progress-bar-striped progress-bar-animated"+ color +"' style='width:"+ ye +"%'>"+ye+"</div> </div>";
},
jinduColor: function (value) {
// 20绿 bg-success
// 20-50蓝 bg-info
// 50-80黄 bg-warning
// 红 bg-danger
if (value >= 80) {
return 'bg-danger';
}else if(value >= 50 && value<80){
return 'bg-warning';
}else if(value >= 20 && value<50){
return 'bg-info';
}else {
return 'bg-success';
}
}
}
// ,components: {
// 'Demo': clock //将别名demo 变成 组件 Demo
// }
})
</script>
<script>
/**
* Copyright (c) 2016 hustcc
* License: MIT
* Version: v1.0.1
* GitHub: https://github.com/hustcc/ribbon.js
**/
!function(){function e(e,t,n){return Number(e.getAttribute(t))||n}function t(){for(r.clearRect(0,0,h,s),a=[{x:0,y:.7*s+u},{x:0,y:.7*s-u}];a[1].x<h+u;)n(a[0],a[1])}function n(e,t){r.beginPath(),r.moveTo(e.x,e.y),r.lineTo(t.x,t.y);var n=t.x+(2*p()-.25)*u,o=i(t.y);r.lineTo(n,o),r.closePath(),m-=x/-50,r.fillStyle="#"+(127*y(m)+128<<16|127*y(m+x/3)+128<<8|127*y(m+x/3*2)+128).toString(16),r.fill(),a[0]=a[1],a[1]={x:n,y:o}}function i(e){return l=e+(2*p()-1.1)*u,l>s||l<0?i(e):l}var o=document.getElementsByTagName("script"),c=o[o.length-1];config={z:e(c,"zIndex",-1),a:e(c,"alpha",.6),s:e(c,"size",90)};var a,l,d=document.createElement("canvas"),r=d.getContext("2d"),g=window.devicePixelRatio||1,h=window.innerWidth,s=window.innerHeight,u=config.s,f=Math,m=0,x=2*f.PI,y=f.cos,p=f.random;d.width=h*g,d.height=s*g,r.scale(g,g),r.globalAlpha=config.a,d.style.cssText="position:fixed;top:0;left:0;z-index: "+config.z+";width:100%;height:100%;pointer-events:none;opacity:0.5;",document.getElementsByTagName("body")[0].appendChild(d),document.onclick=t,document.ontouchstart=t,t()}();
</script>
<script>
//鼠标点击出现爱心特效
(function(window,document,undefined){
var hearts = [];
window.requestAnimationFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback){
setTimeout(callback,1000/60);
}
})();
init();
function init(){
css(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
attachEvent();
gameloop();
}
function gameloop(){
for(var i=0;i<hearts.length;i++){
if(hearts[i].alpha <=0){
document.body.removeChild(hearts[i].el);
hearts.splice(i,1);
continue;
}
hearts[i].y--;
hearts[i].scale += 0.004;
hearts[i].alpha -= 0.013;
hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color;
}
requestAnimationFrame(gameloop);
}
function attachEvent(){
var old = typeof window.onclick==="function" && window.onclick;
window.onclick = function(event){
old && old();
createHeart(event);
}
}
function createHeart(event){
var d = document.createElement("div");
d.className = "heart";
hearts.push({
el : d,
x : event.clientX - 5,
y : event.clientY - 5,
scale : 1,
alpha : 1,
color : randomColor()
});
document.body.appendChild(d);
}
function css(css){
var style = document.createElement("style");
style.type="text/css";
try{
style.appendChild(document.createTextNode(css));
}catch(ex){
style.styleSheet.cssText = css;
}
document.getElementsByTagName('head')[0].appendChild(style);
}
function randomColor(){
return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
}
})(window,document);
</script>
</body>
</html>