|
|
@@ -1,7 +1,7 @@
|
|
|
-import axios from '@/api/config'
|
|
|
-import Vue from 'vue'
|
|
|
+import axios from 'axios'
|
|
|
+import store from 'vuex'
|
|
|
class RealDataService {
|
|
|
- constructor () {
|
|
|
+ constructor() {
|
|
|
this.timer = 0
|
|
|
this.axios = axios
|
|
|
this.RealData()
|
|
|
@@ -10,18 +10,17 @@ class RealDataService {
|
|
|
/**
|
|
|
* 实时数据
|
|
|
*/
|
|
|
- async RealData () {
|
|
|
+ async RealData() {
|
|
|
const db = await this.axios.get('/api/v1/getRealData')
|
|
|
if (db.status === 200 && db.data.success) {
|
|
|
- Vue.prototype.$store.commit('setRealDB', db.data.data)
|
|
|
- console.log(77, Vue.prototype.$store.getters.getRealDB.F006054)
|
|
|
+ store.commit('setRealDB', db.data.data)
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 定时器
|
|
|
* @param time 请求时间
|
|
|
*/
|
|
|
- async startTimerGet (time = 5000) {
|
|
|
+ async startTimerGet(time = 5000) {
|
|
|
this.timer = setInterval(async () => {
|
|
|
await this.RealData()
|
|
|
}, time)
|
|
|
@@ -30,7 +29,7 @@ class RealDataService {
|
|
|
/**
|
|
|
* 清除定时器
|
|
|
*/
|
|
|
- stopTimerGet () {
|
|
|
+ stopTimerGet() {
|
|
|
clearInterval(this.timer)
|
|
|
}
|
|
|
}
|