接口优化
This commit is contained in:
parent
d28e26fa71
commit
5d744eef17
69
src/App.vue
69
src/App.vue
|
|
@ -1,33 +1,82 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
|
||||||
<datav2 v-if="dataType==4"/>
|
<component :is="currentComponent" />
|
||||||
<datav v-else/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import datav from './components/baozuo-demo/index.vue'
|
|
||||||
import datav2 from './components/baozuo-demo2/index.vue'
|
|
||||||
// import datav from './components/datav/index.vue'
|
|
||||||
// import datav from './components/zidingyi/index.vue'
|
|
||||||
|
|
||||||
|
import api from './api.js'
|
||||||
|
//import testRes from './components/baozuo-demo/test'
|
||||||
const queryParams = new URLSearchParams(window.location.search);
|
const queryParams = new URLSearchParams(window.location.search);
|
||||||
const dataTypeParam = queryParams.get('q');
|
const dataTypeParam = queryParams.get('q');
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
components: {
|
components: {
|
||||||
datav,datav2
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dataType: ''
|
dataType: '',
|
||||||
|
//确保testRes加载好后再加载组件
|
||||||
|
currentComponent: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
// 异步注册两个组件
|
||||||
|
datav2: () => import('./components/baozuo-demo2/index.vue'),
|
||||||
|
datav: () => import('./components/baozuo-demo/index.vue')
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.dataType = dataTypeParam;
|
this.dataType = dataTypeParam;
|
||||||
|
|
||||||
|
if (this.dataType == '3') {
|
||||||
|
this.init();
|
||||||
|
} else {
|
||||||
|
this.currentComponent = this.dataType == 4 ? 'datav2' : 'datav';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
/**
|
||||||
|
* 获取当前地址
|
||||||
|
* @returns {string} 当前地址
|
||||||
|
*/
|
||||||
|
function getCurrentAddress() {
|
||||||
|
if (typeof window !== 'undefined' && window.location) {
|
||||||
|
return window.location.origin;
|
||||||
|
} else {
|
||||||
|
console.warn('当前环境非浏览器环境,无法使用 window.location 获取地址');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(api.baseURL)
|
||||||
|
if (getCurrentAddress().includes('192.168') || api.baseURL.includes('natool')) {
|
||||||
|
console.log('当前环境为开发环境');
|
||||||
|
api.post2('/api/web/getBiData', ["yx_v_scgdgk", "yx_v_byzcl", "yx_v_wwcscdd", "yx_v_bzcl1w", "yx_v_bzcl6m", "yx_v_pgjd"]).then(res => {
|
||||||
|
|
||||||
|
window.htd_bidata = res;
|
||||||
|
console.log(window.htd_bidata);
|
||||||
|
this.currentComponent = 'datav';
|
||||||
|
|
||||||
|
}).catch(() => {
|
||||||
|
//window.htd_bidata = testRes;
|
||||||
|
console.log(window.htd_bidata);
|
||||||
|
|
||||||
|
this.currentComponent = 'datav';
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//window.htd_bidata = testRes;
|
||||||
|
|
||||||
|
|
||||||
|
this.currentComponent = 'datav';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ const api = {
|
||||||
//永盛
|
//永盛
|
||||||
baseURL2: 'http://123.207.37.67:9001',
|
baseURL2: 'http://123.207.37.67:9001',
|
||||||
|
|
||||||
baseURL: 'http://36.139.158.169:9261',
|
baseURL3: 'http://36.139.158.169:9261',
|
||||||
|
|
||||||
|
baseURL: 'http://vmikhs.demo.natool.cn',
|
||||||
|
|
||||||
get (url) {
|
get (url) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios({
|
axios({
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LabelTag from './LabelTag'
|
import LabelTag from './LabelTag'
|
||||||
import testRes from './test'
|
let testRes = window.htd_bidata;
|
||||||
let timer = null;
|
let timer = null;
|
||||||
export default {
|
export default {
|
||||||
name: 'BottomCharts',
|
name: 'BottomCharts',
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,8 @@
|
||||||
import LabelTag from './LabelTag'
|
import LabelTag from './LabelTag'
|
||||||
import PieChart from './pieChart.vue'
|
import PieChart from './pieChart.vue'
|
||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
import testRes from './test'
|
|
||||||
|
let testRes = window.htd_bidata;
|
||||||
|
|
||||||
console.log(testRes)
|
console.log(testRes)
|
||||||
export default {
|
export default {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ function getRecentWeekDates() {
|
||||||
}
|
}
|
||||||
|
|
||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
import testRes from './test';
|
|
||||||
|
let testRes = window.htd_bidata;
|
||||||
console.log(testRes)
|
console.log(testRes)
|
||||||
export default {
|
export default {
|
||||||
name: 'RoseChart',
|
name: 'RoseChart',
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ function getRecentSixMonths() {
|
||||||
|
|
||||||
return months;
|
return months;
|
||||||
}
|
}
|
||||||
import testRes from './test';
|
|
||||||
|
let testRes = window.htd_bidata;
|
||||||
console.log(testRes)
|
console.log(testRes)
|
||||||
export default {
|
export default {
|
||||||
name: 'RoseChart',
|
name: 'RoseChart',
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
import testRes from './test'
|
let testRes = window.htd_bidata;
|
||||||
console.log(testRes)
|
console.log(testRes)
|
||||||
export default {
|
export default {
|
||||||
name: 'RoseChart',
|
name: 'RoseChart',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import api from '../../api.js'
|
|
||||||
let testRes = {
|
let testRes = {
|
||||||
"code": "200",
|
"code": "200",
|
||||||
"data": {
|
"data": {
|
||||||
|
|
@ -3197,28 +3197,7 @@ let testRes = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 获取当前地址
|
|
||||||
* @returns {string} 当前地址
|
|
||||||
*/
|
|
||||||
function getCurrentAddress() {
|
|
||||||
if (typeof window !== 'undefined' && window.location) {
|
|
||||||
return window.location.origin;
|
|
||||||
} else {
|
|
||||||
console.warn('当前环境非浏览器环境,无法使用 window.location 获取地址');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(getCurrentAddress().includes('192.168')){
|
|
||||||
console.log('当前环境为开发环境');
|
|
||||||
api.post2('/api/web/getBiData').then(res => {
|
|
||||||
if(res.code === 200){
|
|
||||||
testRes = res;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
console.log('当前环境为生产环境');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export default testRes
|
export default testRes
|
||||||
Loading…
Reference in New Issue