This commit is contained in:
luoshiwen 2023-03-31 08:49:33 +08:00
parent 10993487f6
commit d9c0542a6d
5 changed files with 80 additions and 71 deletions

View File

@ -1,11 +1,11 @@
import axios from 'axios'
if (process.env.NODE_ENV === 'development') {
axios.defaults.baseURL = '/api'
} else if (process.env.NODE_ENV === 'test') {
axios.defaults.baseURL = 'https://309k63x452.oicp.vip'
}
// if (process.env.NODE_ENV === 'development') {
// axios.defaults.baseURL = '/api'
// } else if (process.env.NODE_ENV === 'test') {
// axios.defaults.baseURL = 'https://309k63x452.oicp.vip'
// }
// 设置请求头参数 common 为设置所有的接口 post为设置post请求的接口
// axios.defaults.headers.common['Authorization'] = `Bearer ${localStorage.getItem('access_token')}`;
axios.defaults.headers.common['Authorization'] = `Bearer ${localStorage.getItem('access_token')}`;
// 首页数据
axios.interceptors.request.use(function (config) {
const tokenStr = localStorage.getItem('tokenStr')
@ -27,22 +27,19 @@ axios.interceptors.request.use(function (config) {
export const doLogin = (data) =>{
return axios.post('/login/doLogin',data)
}
// export const getHomePageInfo = (params) => {
// return axios.post('/gk/homePage/getHomePageInfo?cityId='+params)
// };
// 首页数据
export const getHomePageInfo = (params) => {
return axios.post('/gk/homePage/getHomePageInfo?cityId='+params)
return axios.get('api/gk/homePage/getHomePageInfo', {
params
})
};
// 环境信息
export const getEnvironmentInfo = (params) => {
return axios.post('/gk/info/getEnvironmentInfo?siteId='+params
)
return axios.get('api/gk/info/getEnvironmentInfo', { params
})
};
// 获取城市列表
export const getCityList = (params)=>{
return axios.post('/gk/homePage/getCityList')
}
// 点击城市查询详情列表
export const getCityDetail = (params)=>{
return axios.post('/gk/homePage/getCityDetail?cityId='+params)
}
export const getSiteInfo = (params) => {
return axios.get('api/gk/info/getSiteInfo', {
params
@ -71,3 +68,13 @@ export const updateDeviceRecord = (params) => {
params
})
};
// 获取城市列表
// export const getCityList = (params)=>{
// return axios.post('/gk/homePage/getCityList')
// }
// 点击城市查询详情列表
// export const getCityDetail = (params)=>{
// return axios.post('/gk/homePage/getCityDetail?cityId='+params)
// }

View File

@ -1812,7 +1812,7 @@ export default {
// //
window.setInterval(() => {
if (this.unityChange == 0) {
getEnvironmentInfo( "2" ).then((res) => {
getEnvironmentInfo( {siteId:"2"} ).then((res) => {
// this.eniorArr
console.log(res,'实时记录');
for (const key in res.data.data) {
@ -1888,7 +1888,7 @@ export default {
}
});
} else {
getEnvironmentInfo("96445C7C4AD6F0C5" ).then((res) => {
getEnvironmentInfo({siteId:"96445C7C4AD6F0C5"} ).then((res) => {
// this.eniorArr
for (const key in res.data.data) {
if (key == "doorState") {

View File

@ -169,7 +169,7 @@ import dialogComponent from "@/components/dialog";
import Chart from "./chart.vue";
// import io from 'socket.io-client'
import BasicBox5 from "@/components/BasicBox5";
import { getHomePageInfo, getCityList, getCityDetail } from "@/api/api";
import { getHomePageInfo} from "@/api/api";//getCityList, getCityDetail
import mqtt from "mqtt";
// let socketRefs = '';
@ -432,12 +432,12 @@ export default {
computed: {
},
mounted() {
getCityList().then(res => {
console.log(res, '城市数据');
})
getCityDetail(1).then(res => {
console.log(res, '城市详情数据');
})
// getCityList().then(res => {
// console.log(res, '');
// })
// getCityDetail(1).then(res => {
// console.log(res, '');
// })
// this.getDataByMqtt(
// "ws://175.24.235.243:8083/mqtt",
// "tra_topic"
@ -457,38 +457,11 @@ export default {
window.setTimeout(() => {
that.nanjingIconShow = true;
}, 2600);
if (this.shijiIconShow) {
// window.setInterval(() => {
// if (this.shijiIconShow) {
window.setInterval(() => {
//
getHomePageInfo('').then((res) => {
console.log(res, '省级数据');
that.leftNum = []
that.totalCustomer = res.data.result.totalCustomer;
that.totalTransformationSite = res.data.result.totalTransformationSite;
let realTimeLoad = res.data.result.realTimeLoad.toString();
let realData = realTimeLoad.substring(0, realTimeLoad.indexOf(".") + 3);
for (var key in res.data.result) {
for (let i = 0; i < that.leftInfodata.length; i++) {
if (key == that.leftInfodata[i].name) {
that.leftInfodata[i].num = res.data.result[key];
that.leftNum.push(that.leftInfodata[i].num)
}
}
for (let i = 0; i < that.rightInfodata.length; i++) {
if (key == that.rightInfodata[i].name) {
that.rightInfodata[i].num = res.data.result[key];
that.rightInfodata[1].num = realData;
}
}
}
});
// }, 3000);
} else {
// window.setInterval(() => {
//
getHomePageInfo('1').then((res) => {
console.log(res, '市级数据');
getHomePageInfo().then((res) => {
// console.log(res, '');
that.leftNum = []
that.totalCustomer = res.data.data.totalCustomer;
that.totalTransformationSite = res.data.data.totalTransformationSite;
@ -510,8 +483,35 @@ export default {
}
});
// }, 3000);
}
}, 3000);
// } else {
// window.setInterval(() => {
//
// getHomePageInfo('1').then((res) => {
// console.log(res, '');
// that.leftNum = []
// that.totalCustomer = res.data.data.totalCustomer;
// that.totalTransformationSite = res.data.data.totalTransformationSite;
// let realTimeLoad = res.data.data.realTimeLoad.toString();
// let realData = realTimeLoad.substring(0, realTimeLoad.indexOf(".") + 3);
// for (var key in res.data.data) {
// for (let i = 0; i < that.leftInfodata.length; i++) {
// if (key == that.leftInfodata[i].name) {
// that.leftInfodata[i].num = res.data.data[key];
// that.leftNum.push(that.leftInfodata[i].num)
// }
// }
// for (let i = 0; i < that.rightInfodata.length; i++) {
// if (key == that.rightInfodata[i].name) {
// that.rightInfodata[i].num = res.data.data[key];
// that.rightInfodata[1].num = realData;
// }
// }
// }
// });
// // }, 3000);
// }

View File

@ -72,17 +72,17 @@ export default {
password:passwordA
}
// console.log(this.loginForm, '');
doLogin(userMsg).then(res => {
// doLogin(userMsg).then(res => {
if (res.data.code == 200) {
// token
localStorage.setItem('tokenStr', res.data.result.token)
//
localStorage.setItem('account', res.data.result.account)
localStorage.setItem('roleId', res.data.result.roleId)
// if (res.data.code == 200) {
// // token
// localStorage.setItem('tokenStr', res.data.result.token)
// //
// localStorage.setItem('account', res.data.result.account)
// localStorage.setItem('roleId', res.data.result.roleId)
}
})
// }
// })
this.$message.success("登录成功");
this.$router.push("/index");
} else {

View File

@ -16,7 +16,9 @@ module.exports = {
// port: 8989, // 开发服务器运行端口号
proxy: {
'/api': { //代理的名字
target: 'https://309k63x452.oicp.vip',
// target: 'https://309k63x452.oicp.vip',
target: 'http://221.226.19.85:10123/',
ws: true,
changeOrigin: true,
pathRewrite:{