export default {// 首頁時間轉化formatDate(val) {var nowDate = new Date()var oldDate = new Date(val)const Y = oldDate.getFullYear()const M = oldDate.getMonth() + 1const D = oldDate.getDate()var diff = nowDate.getTime() - oldDate.getTime()var minutes = Math.floor(diff / (1000 * 60))var hours = Math.floor(diff / (1000 * 60 * 60))var days = Math.floor(diff / (1000 * 60 * 60 * 24))// return hours + ':' + minutesif (minutes < 1) {return '剛剛'} else if (minutes < 60) {return minutes + '分鐘前'} else if (hours < 24) {return hours + '小時前'} else {if (days < 7) {return days + '天前'} else {return Y + '/' + M + '/' + D}}},// 聊天時,發送時間處理formatTime(value) {var nowDate = new Date()var oldDate = new Date(value)const Y = oldDate.getFullYear()const M = oldDate.getMonth() + 1const D = oldDate.getDate()const h = oldDate.getHours() > 9 ? oldDate.getHours() : '0' + oldDate.getHours()const m = oldDate.getMinutes() > 9 ? oldDate.getMinutes() : '0' + oldDate.getMinutes()const s = oldDate.getSeconds() > 9 ? oldDate.getSeconds() : '0' + oldDate.getSeconds()var diff = nowDate.getTime() - oldDate.getTime()var minutes = Math.floor(diff / (1000 * 60))var hours = Math.floor(diff / (1000 * 60 * 60))var days = Math.floor(diff / (1000 * 60 * 60 * 24))// return hours + ':' + minutesif (minutes < 1) {// return '剛剛'} else if (minutes < 60) {return minutes + '分鐘前'} else if (hours < 24) {return hours + '小時前'} else {if (days < 3) {return days + '天前 ' + h + ':' + m + ':' + s} else {return Y + '年' + M + '月' + D + '日 ' + ' ' + h + ':' + m + ':' + s}}}}