1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- App({
- onLaunch() {
- Object.assign(Date.prototype, {
- getDateName(realtime) {
- let td = new Date(),
- d = new Date(this.getFullYear(), this.getMonth(), this.getDate()),
- n
- td = new Date(td.getFullYear(), td.getMonth(), td.getDate())
- n = (d - td) / 1000 / 60 / 60 / 24;
- if (n < -2) {
- return -n + '天前'
- }
- if (n < -1) {
- return '前天'
- }
- if (n < 0) {
- return '昨天'
- }
- if (n == 0) {
- return realtime ? this.format(realtime) : '今天'
- }
- if (n < 2) {
- return '明天'
- }
- if (n < 3) {
- return '后天'
- }
- return n + '天后'
- },
- format(fmt) { //author: meizz
- var o = {
- "M+": this.getMonth() + 1, //月份
- "d+": this.getDate(), //日
- "h+": this.getHours(), //小时
- "m+": this.getMinutes(), //分
- "s+": this.getSeconds(), //秒
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
- "S": this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- })
- },
- data: {
- nav: {}
- },
- config: {},
- globalData: {
- userInfo: null,
- appid: 'wx4398d60942bc7710',
- imgUrl: 'http://cdn.info666.com/'
- }
- })
|