cuiqian2004
2025-09-19 d8743368ffda9bc0fb2c6818f695a9a6b1079e57
pages/map/scene.vue
@@ -17,6 +17,9 @@
      </view>
      <view class="content" v-show="opSceneType =='scan'">
         <view class="fabric" :message="ctxDataStr" :change:message="ctx.receiveMsg" id="canvasMap"></view>
         <view class="position" @click="clickVehiclePosition">
            <text class="ico my-location-rounded"></text>
         </view>
      </view>
      <view class="bottom">
         <view class="bottom-content" v-if="opSceneType =='add_name' ">
@@ -64,6 +67,8 @@
      showToast,
      showModal,
      session,
      showError,
      showInfo
   } from "@/comm/utils.js"
   import {
      Button
@@ -94,7 +99,9 @@
            showClearName: false,
            mapId: "",
            ctxDataStr: "[]",
            localSceneList: []
            localSceneList: [],
            positioningAgv: true,
            robotPos: {}
         }
      },
@@ -139,6 +146,10 @@
            })
            return true
         } else if (this.opSceneType == "finish") {
            const eventChannel = this.getOpenerEventChannel();
            eventChannel.emit('create_finish', this.sceneName);
            return false
         } else {
            return false
         }
@@ -186,7 +197,7 @@
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
         receiveRenderData(param) {
@@ -219,6 +230,8 @@
                  })
               }
            } else if (param.method == "cancel_positioning_agv") {
               this.positioningAgv = false
            }
         },
@@ -227,7 +240,7 @@
               const list = session.getValue("scene_db") || []
               return list
            } catch (ex) {
               this.showError(ex)
               showError(ex)
               return []
            }
         },
@@ -250,7 +263,7 @@
                  delta: 1, //返回层数,2则上上页
               })
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            } finally {
               this.loading = false
               uni.hideLoading()
@@ -286,7 +299,7 @@
            } catch (ex) {
               this.showError(ex)
               showError(ex)
               this.opSceneType = 'add_name'
            } finally {
               this.loading = false
@@ -349,7 +362,6 @@
                  title: "结束场景构建"
               })
               this.opSceneType = ""
               await createScene(this.ip, this.sceneName, 0)
               const eventChannel = this.getOpenerEventChannel();
               eventChannel.emit('create_finish', this.sceneName);
               uni.navigateBack({
@@ -376,7 +388,7 @@
               const info = await getMapLaserData(this.ip, this.mapId)
               return info
            } catch (ex) {
               this.showError(ex)
               showError(ex)
               return {}
            }
         },
@@ -388,7 +400,7 @@
                  const listCtrData = []
                  if (data.base_map?.image_base64) {
                     this.robotPos = {}
                     this.mapId = data.base_map.map_id
                     listCtrData.push({
                        method: "background",
@@ -404,49 +416,56 @@
                           filedata: data.base_map.image_base64
                        }
                     })
                  }
                  listCtrData.push({
                     method: "agv_laser",
                     param: data.robot_pose
                  })
                  listCtrData.push({
                     method: "point_cloud",
                     param: data.point_cloud
                  })
                  if (this.positioningAgv) {
                     listCtrData.push({
                        method: "agv_laser",
                        param: data.robot_pose
                     })
                     listCtrData.push({
                        method: "point_cloud",
                        param: data.point_cloud
                     })
                     listCtrData.push({
                        method: "move_canvas",
                        method: "move_pt_visible",
                        param: {
                           x: data.robot_pose.x,
                           y: data.robot_pose.y
                           y: data.robot_pose.y,
                           width:50,
                           height:50,
                        }
                     })
                  } else {
                     listCtrData.push({
                        method: "agv_laser",
                        param: data.robot_pose
                     })
                     listCtrData.push({
                        method: "point_cloud",
                        param: data.point_cloud
                     })
                  }
                  this.ctxDataStr = JSON.stringify(listCtrData)
                  this.robotPos = {
                     x: data.robot_pose.x,
                     y: data.robot_pose.y
                  }
               }
            } catch (ex) {
               this.showError(ex)
            } finally {
               // 无论成功失败,1 秒后再来
               setTimeout(this.refreshMapLaserData, 1000);
            } catch (ex) {
               showError(ex).then((res) => {
                  setTimeout(this.refreshMapLaserData, 1000);
               })
            }
         },
         async clickVehiclePosition() {
            this.positioningAgv = true
         showError(ex) {
            console.log(ex)
            let exStr = JSON.stringify(ex)
            if (exStr == "{}")
               exStr = ex
            let tip = typeof ex.msg == "string" ? ex.msg : exStr
            showModal(tip, "错误", false, "确定")
            if (this.robotPos.x) {
               this.ctxDataStr = JSON.stringify([{
                  method: "move_pt_center",
                  param: {
                     x: this.robotPos.x,
                     y: this.robotPos.y
                  }
               }])
            }
         },
@@ -475,6 +494,16 @@
            background-color: #fff;
         }
         .position {
            position: absolute;
            right: 50rpx;
            bottom: 500rpx;
            .ico {
               font-size: 65rpx;
               color: #1890FF;
            }
         }
      }