Commit 560b3818 by zhangxw

访问时间公用方法修改

1 parent eb70c069
......@@ -48,28 +48,28 @@ export function commentTime(dateTimeStamp) {
let time = dateTimeStamp
let nowTime = new Date().getTime()
let timeDifference = nowTime - time
let minTime = 60000
let hourTime = minTime * 60
let dayTime = hourTime * 24
let weektTime = dayTime * 7
let monthTime = dayTime * 30
let yearTime = dayTime * 365
if (parseInt(timeDifference / minTime) <= 5) {
//五分钟内就是刚刚
result = '刚刚'
} else if (parseInt(timeDifference / minTime) > 5) {
result = parseInt(timeDifference / minTime) + '分钟前'
} else if (parseInt(timeDifference / hourTime) >= 1) {
result = parseInt(timeDifference / hourTime) + '小时前'
} else if (parseInt(timeDifference / dayTime) >= 1) {
result = parseInt(timeDifference / dayTime) + '天前'
} else if (parseInt(timeDifference / weektTime) >= 1) {
result = parseInt(timeDifference / weektTime) + '周前'
} else if (parseInt(timeDifference / monthTime) >= 1) {
result = parseInt(timeDifference / monthTime) + '月前'
} else if (parseInt(timeDifference / yearTime) >= 1) {
result = parseInt(timeDifference / yearTime) + '年前'
if (timeDifference / yearTime > 1 && Math.floor(timeDifference / yearTime) >= 1) {
result = Math.floor(timeDifference / yearTime) + '年前'
} else if (Math.floor(timeDifference / monthTime) >= 1) {
result = Math.floor(timeDifference / monthTime) + '月前'
} else if (Math.floor(timeDifference / weektTime) >= 1) {
result = Math.floor(timeDifference / weektTime) + '周前'
} else if (Math.floor(timeDifference / dayTime) >= 1) {
result = Math.floor(timeDifference / dayTime) + '天前'
} else if (Math.floor(timeDifference / hourTime) >= 1) {
result = Math.floor(timeDifference / hourTime) + '小时前'
} else if (Math.floor(timeDifference / minTime) >= 0) {
result = Math.floor(timeDifference / minTime) + '分钟前'
if (Math.floor(timeDifference / minTime) <= 5) {
//五分钟内就是刚刚
result = '刚刚'
}
}
return result
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!