diff --git a/src/utils/getRobotInfo.js b/src/utils/getRobotInfo.js index 7fe62dd..a3caf0e 100644 --- a/src/utils/getRobotInfo.js +++ b/src/utils/getRobotInfo.js @@ -5,85 +5,134 @@ const robotData = useRobotDataStore() // 获取机器人token export const getRobotTokenFn = async () => { - if (!robotData.tokenInfo.deviceToken) { - const loginParams = { - address: '112.31.70.193', - port: '9988', - user: 'bns3', - password: 'Bns@admin**', - epid: 'system', - bfix: 1, - } - const res = await initLoginApi(loginParams) - robotData.setTokenInfo({ - deviceToken: res.data.token, - }) - return res.data.token - } else { - return robotData.tokenInfo.deviceToken + // if (!robotData.tokenInfo.deviceToken) { + // const loginParams = { + // address: '112.31.70.193', + // port: '9988', + // user: 'bns3', + // password: 'Bns@admin**', + // epid: 'system', + // bfix: 1, + // } + // const res = await initLoginApi(loginParams) + // robotData.setTokenInfo({ + // deviceToken: res.data.token, + // }) + // return res.data.token + // } else { + // return robotData.tokenInfo.deviceToken + // } + + const loginParams = { + address: '112.31.70.193', + port: '9988', + user: 'bns3', + password: 'Bns@admin**', + epid: 'system', + bfix: 1, } + const res = await initLoginApi(loginParams) + return res.data.token } // 获取设备信息 export const getRobotDeviceListFn = async () => { - if (!robotData.robotInfo.puId) { - const { data: res } = await getDeviceInfoApi() - if (res?.data?.length > 0) { - const deviceInfo = res.data[0] - robotData.setRobotInfo({ - devName: deviceInfo.devName, - puId: deviceInfo.puId, - }) + // if (!robotData.robotInfo.puId) { + // const { data: res } = await getDeviceInfoApi() + // if (res?.data?.length > 0) { + // const deviceInfo = res.data[0] + // robotData.setRobotInfo({ + // devName: deviceInfo.devName, + // puId: deviceInfo.puId, + // }) - return { - devName: deviceInfo.devName, - puId: deviceInfo.puId, - } + // return { + // devName: deviceInfo.devName, + // puId: deviceInfo.puId, + // } + // } + // } else { + // return robotData.robotInfo + // } + + const { data: res } = await getDeviceInfoApi() + if (res?.data?.length > 0) { + const deviceInfo = res.data[0] + return { + devName: deviceInfo.devName, + puId: deviceInfo.puId, } - } else { - return robotData.robotInfo } } // 获取地图信息 export const getRobotMapInfoFn = async (puId) => { - if (!robotData.mapInfo.mapBase64) { - const { data: res } = await handleRobotActionApi({ - puId, - type: 4, - }) - if (res.code === 200) { - const { Data, Height, Width, MapId, Name } = res.data - const mapInfo = { - mapBase64: 'data:image/png;base64,' + Data, - mapWidth: Width, - mapHeight: Height, - mapName: Name, - mapId: MapId, - } - robotData.setMapInfo(mapInfo) - return mapInfo + // if (!robotData.mapInfo.mapBase64) { + // const { data: res } = await handleRobotActionApi({ + // puId, + // type: 4, + // }) + // if (res.code === 200) { + // const { Data, Height, Width, MapId, Name } = res.data + // const mapInfo = { + // mapBase64: 'data:image/png;base64,' + Data, + // mapWidth: Width, + // mapHeight: Height, + // mapName: Name, + // mapId: MapId, + // } + // robotData.setMapInfo(mapInfo) + // return mapInfo + // } + // } else { + // return robotData.mapInfo + // } + + const { data: res } = await handleRobotActionApi({ + puId, + type: 4, + }) + if (res.code === 200) { + const { Data, Height, Width, MapId, Name } = res.data + const mapInfo = { + mapBase64: 'data:image/png;base64,' + Data, + mapWidth: Width, + mapHeight: Height, + mapName: Name, + mapId: MapId, } - } else { - return robotData.mapInfo + + return mapInfo } } // 获取机器人实时定位信息 export const getRobotPointsInfoFn = async (puId) => { - if (!robotData.robotPoints.Robot_x && !robotData.robotPoints.Robot_y) { - const { data: res } = await handleRobotActionApi({ - puId, - type: 2, - }) - if (res.code === 200) { - const pointsInfo = { - Robot_x: res?.data?.Robot_x, - Robot_y: res?.data?.Robot_y, - } - robotData.setRobotPoints(pointsInfo) - return pointsInfo + // if (!robotData.robotPoints.Robot_x && !robotData.robotPoints.Robot_y) { + // const { data: res } = await handleRobotActionApi({ + // puId, + // type: 2, + // }) + // if (res.code === 200) { + // const pointsInfo = { + // Robot_x: res?.data?.Robot_x, + // Robot_y: res?.data?.Robot_y, + // } + // robotData.setRobotPoints(pointsInfo) + // return pointsInfo + // } + // } else { + // return robotData.robotPoints + // } + + const { data: res } = await handleRobotActionApi({ + puId, + type: 2, + }) + if (res.code === 200) { + const pointsInfo = { + Robot_x: res?.data?.Robot_x, + Robot_y: res?.data?.Robot_y, } - } else { - return robotData.robotPoints + return pointsInfo } } diff --git a/src/views/home/components/modal-content/preset-setting.vue b/src/views/home/components/modal-content/preset-setting.vue index fe65478..68b0355 100644 --- a/src/views/home/components/modal-content/preset-setting.vue +++ b/src/views/home/components/modal-content/preset-setting.vue @@ -25,7 +25,12 @@ :style="{ transform: `translate(${offsetX}px, ${offsetY}px)` }" > - +