公司業(yè)務(wù)用server返回unix格林時間作為當(dāng)前時間咳蔚,同時將返回截止時間
<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>