公司业务用server返回unix格林时间作为当前时间,同时将返回截止时间
<template>
<div></div>
</template>
<script type="text/babel">
/* eslint-disable */
import axios from 'axios'
import {GroupTitle, Swipeout, SwipeoutItem, SwipeoutButton, XButton} from 'vux'
export default {
components: {
},
data() {
return {
interval: null
}
},
mounted() {
axios.get('http://172.16.118.54:3030/unixTest').then(res => {
console.log('axios.get', res)
const a = Moment(Moment.unix(res.data.deadLine))
const b = Moment(Moment.unix(res.data.nowServer))
const diff = a.diff(b)
const duration = Moment.duration(diff)
this.interval = setInterval(() => {
const thisDuration = duration.subtract(1, 's')
console.log(`${thisDuration.get('days')*24+thisDuration.get('hours')}/${thisDuration.get('minutes')}/${thisDuration.get('seconds')}`)
}, 1000)
})
},
computed: {},
destroyed() {
clearInterval(this.interval)
},
methods: {
},
created() {
}
}
</script>
<style lang='scss' scoped>
</style>
网友评论