|
@@ -26,7 +26,7 @@
|
|
</view>
|
|
</view>
|
|
<view class="status-card">
|
|
<view class="status-card">
|
|
<view class="label">已装数</view>
|
|
<view class="label">已装数</view>
|
|
- <view class="value highlight">{{ currentData.hasNumber || '0' }}</view>
|
|
|
|
|
|
+ <view class="value highlight">{{ currentData.hasNum || '0' }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -93,6 +93,7 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
ws:null,
|
|
ws:null,
|
|
|
|
+ wsUrl:'',
|
|
currentData:{},
|
|
currentData:{},
|
|
orders:[],
|
|
orders:[],
|
|
currentLane:{
|
|
currentLane:{
|
|
@@ -114,7 +115,7 @@
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
uni.hideTabBar()
|
|
uni.hideTabBar()
|
|
this.getLaneList()
|
|
this.getLaneList()
|
|
- this.connectSocket()
|
|
|
|
|
|
+ // this.connectSocket()
|
|
},
|
|
},
|
|
beforeUnmount() {
|
|
beforeUnmount() {
|
|
this.ws.close(); // 组件销毁前关闭连接
|
|
this.ws.close(); // 组件销毁前关闭连接
|
|
@@ -122,8 +123,13 @@
|
|
methods: {
|
|
methods: {
|
|
//连接车道ws
|
|
//连接车道ws
|
|
connectSocket(){
|
|
connectSocket(){
|
|
|
|
+ console.log(this.wsUrl);
|
|
|
|
+ if(!this.wsUrl) return
|
|
|
|
+ if(this.ws){
|
|
|
|
+ this.ws.close(); // 组件销毁前关闭连接
|
|
|
|
+ }
|
|
// 创建 WebSocket 连接(替换为你的服务端地址)
|
|
// 创建 WebSocket 连接(替换为你的服务端地址)
|
|
- this.ws = new WebSocket('ws://192.168.124.27:5559');
|
|
|
|
|
|
+ this.ws = new WebSocket(this.wsUrl);
|
|
|
|
|
|
// 监听连接成功
|
|
// 监听连接成功
|
|
this.ws.onopen = () => {
|
|
this.ws.onopen = () => {
|
|
@@ -132,7 +138,8 @@
|
|
|
|
|
|
// 监听消息接收
|
|
// 监听消息接收
|
|
this.ws.onmessage = (event) => {
|
|
this.ws.onmessage = (event) => {
|
|
- console.log('1111111111111111111',JSON.parse(event.data));
|
|
|
|
|
|
+ console.log('1111111111111111',event);
|
|
|
|
+
|
|
this.currentData = JSON.parse(event.data)
|
|
this.currentData = JSON.parse(event.data)
|
|
};
|
|
};
|
|
|
|
|
|
@@ -147,15 +154,7 @@
|
|
setTimeout(() => this.connectSocket(), 3000); // 3秒后重连
|
|
setTimeout(() => this.connectSocket(), 3000); // 3秒后重连
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- sendMessage() {
|
|
|
|
- if (this.ws.readyState === WebSocket.OPEN) {
|
|
|
|
- console.log('1111111111111111111',this.currentLane.id);
|
|
|
|
- this.ws.send(this.currentLane.id);
|
|
|
|
- }else{
|
|
|
|
- setTimeout(()=>this.sendMessage(),2000)
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+
|
|
//去新增订单
|
|
//去新增订单
|
|
toAdd(){
|
|
toAdd(){
|
|
uni.navigateTo({ url: '/pages/other/addOrder' })
|
|
uni.navigateTo({ url: '/pages/other/addOrder' })
|
|
@@ -178,7 +177,8 @@
|
|
if(this.laneOption.length){
|
|
if(this.laneOption.length){
|
|
this.currentLane.name = this.laneOption[0].text
|
|
this.currentLane.name = this.laneOption[0].text
|
|
this.currentLane.id = this.laneOption[0].value
|
|
this.currentLane.id = this.laneOption[0].value
|
|
- this.sendMessage()
|
|
|
|
|
|
+ this.wsUrl = this.laneOption[0].monitorAddress
|
|
|
|
+ this.connectSocket()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -197,9 +197,13 @@
|
|
},
|
|
},
|
|
//车道确定
|
|
//车道确定
|
|
onConfirm(value) {
|
|
onConfirm(value) {
|
|
- if (value.value) {
|
|
|
|
|
|
+ console.log(value);
|
|
|
|
+
|
|
|
|
+ if (value.value && value.value !== this.currentLane.id) {
|
|
this.currentLane.name = value.text
|
|
this.currentLane.name = value.text
|
|
this.currentLane.id = value.value
|
|
this.currentLane.id = value.value
|
|
|
|
+ this.wsUrl = value.monitorAddress
|
|
|
|
+ this.connectSocket()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|