代码调试
This commit is contained in:
parent
d6b503931c
commit
5dd78c1166
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,12 @@
|
|||
:style="{ transform: `translate(${offsetX}px, ${offsetY}px)` }"
|
||||
>
|
||||
<!-- 图片,宽高 100% 跟随 SVG -->
|
||||
<image width="100%" height="100%" :href="demoImg" preserveAspectRatio="none" />
|
||||
<image
|
||||
width="100%"
|
||||
height="100%"
|
||||
:href="mapInfo.mapBase64"
|
||||
preserveAspectRatio="none"
|
||||
/>
|
||||
|
||||
<!-- 标记的点位 -->
|
||||
<circle
|
||||
|
|
|
|||
Loading…
Reference in New Issue