提交 9a529f82 编写于 作者: hudan's avatar hudan

优化多久之前组件逻辑

上级 b0f5ca4b
......@@ -12,6 +12,7 @@
<script lang="ts">
import { Vue, Component, Prop, Emit, Watch, Model } from 'vue-property-decorator';
import { Subject, Subscription } from 'rxjs';
import moment from 'moment';
@Component({})
export default class AppAfterTime extends Vue {
......@@ -104,9 +105,11 @@ export default class AppAfterTime extends Vue {
* @memberof AppAfterTime
*/
public transTime(){
console.log(this.value)
if(this.value){
let oldTime = new Date(this.value).getTime();
let nowTime = new Date().getTime();
let dateString:any = 'YYYY年MM月DD日' || 'YYYY年MM月DD日 HH小时mm分钟ss秒' || 'YYYY-MM-DD HH:mm:ss' || 'YYYY-MM-DD' || 'YYYY/MM/DD HH:mm:ss' || 'YYYY/MM/DD';
let oldTime = moment(this.value,dateString).valueOf();
let nowTime = moment().valueOf();
let diffTime = nowTime - oldTime;
if(diffTime < 3600000){
this.curvalue = Math.ceil(diffTime/60000)+'';
......@@ -119,7 +122,7 @@ export default class AppAfterTime extends Vue {
this.diffTime = 'days';
}else if(diffTime < 31104000000){
this.curvalue = Math.floor(diffTime/2592000000)+'';
this.diffTime = 'mounth';
this.diffTime = 'mouth';
}else{
this.curvalue = Math.floor(diffTime/31104000000)+'';
this.diffTime = 'years';
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册