提交 dac9edbb authored 作者: 王鹏飞's avatar 王鹏飞

增加定时刷新

上级 b3fe6671
...@@ -12,7 +12,8 @@ export default { ...@@ -12,7 +12,8 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
response: { sell_data: [] } response: { sell_data: [] },
timer: null
} }
}, },
computed: { computed: {
...@@ -91,6 +92,9 @@ export default { ...@@ -91,6 +92,9 @@ export default {
} }
}, },
methods: { methods: {
init() {
!this.data && this.getData()
},
getData() { getData() {
this.loading = true this.loading = true
api api
...@@ -101,10 +105,20 @@ export default { ...@@ -101,10 +105,20 @@ export default {
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
} }
}, },
beforeMount() { beforeMount() {
!this.data && this.getData() this.init()
this.setTimer()
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<b>单条留资成本:</b><span>{{ numbers.app_cost }}</span> <b>单条留资成本:</b><span>{{ numbers.app_cost }}</span>
</li> </li>
<li> <li>
<b>&nbsp;&nbsp;&nbsp;本月缴费数:</b><span>{{ numbers.pay_count }}</span> <b>&nbsp;&nbsp;&nbsp;本月缴费数:</b><span>{{ currentData.all_pay_count }}</span>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -41,7 +41,8 @@ export default { ...@@ -41,7 +41,8 @@ export default {
loading: false, loading: false,
response: { sell_data: [] }, response: { sell_data: [] },
list: [], list: [],
dateStr: '' dateStr: '',
timer: null
} }
}, },
computed: { computed: {
...@@ -122,10 +123,20 @@ export default { ...@@ -122,10 +123,20 @@ export default {
}, },
formatValue(value = '') { formatValue(value = '') {
return value.toLocaleString() return value.toLocaleString()
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
} }
}, },
beforeMount() { beforeMount() {
this.init() this.init()
this.setTimer()
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
......
...@@ -16,7 +16,8 @@ export default { ...@@ -16,7 +16,8 @@ export default {
return { return {
loading: false, loading: false,
response: [], response: [],
legendselect: {} legendselect: {},
timer: null
} }
}, },
computed: { computed: {
...@@ -122,6 +123,9 @@ export default { ...@@ -122,6 +123,9 @@ export default {
} }
}, },
methods: { methods: {
init() {
this.getData()
},
getData() { getData() {
this.loading = true this.loading = true
api api
...@@ -135,10 +139,20 @@ export default { ...@@ -135,10 +139,20 @@ export default {
}, },
legendselectchanged({ selected }) { legendselectchanged({ selected }) {
this.legendselect = selected this.legendselect = selected
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
} }
}, },
beforeMount() { beforeMount() {
this.getData() this.init()
this.setTimer()
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
...@@ -10,7 +10,8 @@ export default { ...@@ -10,7 +10,8 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
response: [] response: [],
timer: null
} }
}, },
computed: { computed: {
...@@ -54,6 +55,9 @@ export default { ...@@ -54,6 +55,9 @@ export default {
} }
}, },
methods: { methods: {
init() {
this.getData()
},
getData() { getData() {
this.loading = true this.loading = true
api api
...@@ -64,10 +68,20 @@ export default { ...@@ -64,10 +68,20 @@ export default {
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
} }
}, },
beforeMount() { beforeMount() {
this.getData() this.init()
this.setTimer()
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
...@@ -16,7 +16,8 @@ export default { ...@@ -16,7 +16,8 @@ export default {
return { return {
loading: false, loading: false,
response: [], response: [],
legendselect: {} legendselect: {},
timer: null
} }
}, },
computed: { computed: {
...@@ -127,6 +128,9 @@ export default { ...@@ -127,6 +128,9 @@ export default {
} }
}, },
methods: { methods: {
init() {
this.getData()
},
getData() { getData() {
this.loading = true this.loading = true
api api
...@@ -140,10 +144,20 @@ export default { ...@@ -140,10 +144,20 @@ export default {
}, },
legendselectchanged({ selected }) { legendselectchanged({ selected }) {
this.legendselect = selected this.legendselect = selected
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
} }
}, },
beforeMount() { beforeMount() {
this.getData() this.init()
this.setTimer()
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
......
...@@ -18,7 +18,8 @@ export default { ...@@ -18,7 +18,8 @@ export default {
loading: false, loading: false,
response: [], response: [],
legendselect: {}, legendselect: {},
height: 0 height: 0,
timer: null
} }
}, },
computed: { computed: {
...@@ -81,6 +82,9 @@ export default { ...@@ -81,6 +82,9 @@ export default {
} }
}, },
methods: { methods: {
init() {
this.getData()
},
getData() { getData() {
this.loading = true this.loading = true
api api
...@@ -97,16 +101,24 @@ export default { ...@@ -97,16 +101,24 @@ export default {
}, },
getChartHeight() { getChartHeight() {
this.height = this.$refs.chart.$el.offsetHeight this.height = this.$refs.chart.$el.offsetHeight
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
} }
}, },
beforeMount() { beforeMount() {
this.getData() this.init()
this.setTimer()
}, },
mounted() { mounted() {
this.getChartHeight() this.getChartHeight()
window.addEventListener('resize', this.getChartHeight) window.addEventListener('resize', this.getChartHeight)
}, },
destroyed() { destroyed() {
this.clearTimer()
window.removeEventListener('resize', this.getChartHeight) window.removeEventListener('resize', this.getChartHeight)
} }
} }
......
...@@ -81,18 +81,29 @@ export default { ...@@ -81,18 +81,29 @@ export default {
el: '.swiper-pagination' el: '.swiper-pagination'
} }
}, },
month: {} month: {},
timer: null
} }
}, },
methods: { methods: {
init() {
this.getMonthData()
},
getMonthData() { getMonthData() {
api.getMonthIncome().then(response => { api.getMonthIncome().then(response => {
this.month = response this.month = response
}) })
},
setTimer() {
this.timer = setInterval(this.init, 5 * 60 * 1000)
},
clearTimer() {
this.timer && clearInterval(this.init)
} }
}, },
beforeMount() { beforeMount() {
this.getMonthData() this.init()
this.setTimer()
}, },
mounted() { mounted() {
document.body.addEventListener( document.body.addEventListener(
...@@ -102,6 +113,9 @@ export default { ...@@ -102,6 +113,9 @@ export default {
}, },
{ passive: false } { passive: false }
) )
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论