From 7d1d7639ce54590befad48f79e3847b9a5f361b0 Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: Mon, 15 Aug 2022 19:44:02 +0800
Subject: [PATCH] Merge branch 'master' of https://sinanoaq.cn:8888/r/gtqt
---
src/views/intellectInspect/intelligentLine/index.vue | 100 +++++++++++++++++++++++++++++--------------------
1 files changed, 59 insertions(+), 41 deletions(-)
diff --git a/src/views/intellectInspect/intelligentLine/index.vue b/src/views/intellectInspect/intelligentLine/index.vue
index f9e56f3..542b1d6 100644
--- a/src/views/intellectInspect/intelligentLine/index.vue
+++ b/src/views/intellectInspect/intelligentLine/index.vue
@@ -10,11 +10,12 @@
<div>全屏</div>
</div>
<div class="backBtn" @click="goBack()">
- <img src="../../../assets/loginPage/back-icon.png" />
+ <img src="../../../assets/loginPage/back-icon.png"/>
<div>退出</div>
</div>
</div>
<div class="blocks">
+ <div>
<div class="star-pic">
<div class="star-bg"><img src="../../../assets/loginPage/star-bg.png" /></div>
<div class="star"><img src="../../../assets/loginPage/device-pic.png" /></div>
@@ -76,6 +77,7 @@
</div>
</div>
<div class="tip" v-else>抱歉,暂时查询不到巡检路线...</div>
+ </div>
</div>
</div>
</template>
@@ -113,7 +115,7 @@
const state = reactive<stateType>({
present: '',
isScreenfull: false,
- path: 'http://192.168.0.29:8008/ws/test/',
+ path: '',
socketData: '',
socket: null,
data: [],
@@ -126,46 +128,57 @@
}, 1000);
let curId = route.query.id
state.id = curId.toString()
- console.log(state.id)
getLine(state.id)
- init(state.id);
+ getUrl(state.id)
});
const dataList = computed(() => {
return userInfos.value.dataList;
});
- // socket获取数据
- const init = (id:string) => {
- if (typeof window.WebSocket === 'undefined') {
- alert('您的浏览器不支持socket');
- } else {
- // 实例化socket
- let uid = userInfos.value.uid.toString()
- var url = state.path + uid + '*' + id;
- console.log(url,'url')
- url = url.replace('https', 'ws').replace('http', 'ws');
- console.log(url, '获取地址');
- state.socket = new window.WebSocket(url);
- // 监听socket连接
- state.socket.onopen = () => {
- console.log('socket连接成功');
- };
- // 监听socket错误信息
- state.socket.onerror = () => {
- console.log('socket连接错误');
- };
- // 监听socket消息
- state.socket.onmessage = (msg) => {
- if (msg.data === '连接成功') return;
- userInfos.value.dataList = JSON.parse(msg.data);
- };
- }
- };
+ // 获取url
- const send = () => {
- state.socket.send(params);
- };
+ const getUrl =async (id:string)=>{
+ const res = await lineApi().getUrl();
+ if (res.data.code === '200') {
+ state.path = 'http://' + res.data.data.ip + ':' + res.data.data.port + '/ws/test/'
+ if (typeof window.WebSocket === 'undefined') {
+ alert('您的浏览器不支持socket');
+ } else {
+ // 实例化socket
+ // debugger
+ let uid = userInfos.value.uid.toString()
+ var url = state.path + uid + '*' + id;
+ console.log(url,'url',uid,'uid')
+ url = url.replace('https', 'ws').replace('http', 'ws');
+ console.log(url, '获取地址');
+ state.socket = new window.WebSocket(url);
+ // 监听socket连接
+ state.socket.onopen = () => {
+ console.log('socket连接成功');
+ };
+ // 监听socket错误信息
+ state.socket.onerror = () => {
+ console.log('socket连接错误');
+ };
+ // 监听socket消息
+ state.socket.onmessage = (msg) => {
+ if (msg.data === '连接成功') return;
+ console.log(msg.data,'data')
+ userInfos.value.dataList = JSON.parse(msg.data);
+ };
+ }
+ } else {
+ ElMessage({
+ type: 'warning',
+ message: res.data.msg
+ });
+ }
+ }
+
+ // const send = () => {
+ // state.socket.send(params);
+ // };
// 接口获取数据
const getLine = async (id:string) => {
@@ -472,14 +485,19 @@
.blocks {
width: 100%;
height: calc(100% - 90px);
- padding: 20px 40px 30px;
+ padding: 10px 40px 35px;
box-sizing: border-box;
- display: flex;
- justify-content: center;
- align-items: flex-start;
- overflow: hidden;
- overflow-x: auto;
- overflow-y: auto;
+
+ &>div{
+ width: 100%;
+ height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: flex-start;
+ overflow: hidden;
+ overflow-x: auto;
+ overflow-y: auto;
+ }
.line-map {
display: flex;
--
Gitblit v1.9.2