增加友好提示
This commit is contained in:
parent
13cd1c300b
commit
30fe13dac2
@ -136,9 +136,19 @@ export default {
|
||||
showCancel: false // 不显示取消按钮(可选)
|
||||
});
|
||||
// console.log('res', res);
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
uni.showToast({ title: "绑定成功" });
|
||||
uni.showToast({
|
||||
title: "绑定成功",
|
||||
icon: "success", // 可选,增加成功图标
|
||||
duration: 1500 // 1.5秒后自动关闭
|
||||
});
|
||||
|
||||
// 1.5秒后跳转到设备页面
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/device/index"
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("设备绑定失败:", error);
|
||||
|
@ -24,11 +24,6 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 临时调试 -->
|
||||
|
||||
<!-- <video class="img_video_warp" :src="socketData.videoUrl" v-if="socketData.videoUrl"></video>
|
||||
<image class="img_video_warp" v-else :src="socketData.imageUrl"></image> -->
|
||||
<!-- 视频、图片区域(含加载动画) -->
|
||||
<view class="media_container">
|
||||
<!-- 加载动画(转圈效果) -->
|
||||
@ -66,21 +61,21 @@
|
||||
<view class="item_content_warp">
|
||||
<view class="item_content_left">{{ field.label }}</view>
|
||||
<view class="item_content_middel">
|
||||
|
||||
<!-- 状态处理 -->
|
||||
<!-- 状态处理 完成-->
|
||||
<template v-if="field.isStatus">
|
||||
<view class="label_warp" v-if="deviceDetail.status == 0">
|
||||
<view class="label_icon"></view>
|
||||
<view class="label_text">空闲</view>
|
||||
</view>
|
||||
<view class="label_warp" v-if="deviceDetail.status == 2">
|
||||
<view class="label_icon" style="background: #00abff"></view>
|
||||
<view class="label_text" style="color: #00abff">准备中</view>
|
||||
</view>
|
||||
<view class="label_warp" v-if="deviceDetail.status == 1">
|
||||
<view class="label_icon" style="background: #00d195"></view>
|
||||
<view class="label_text" style="color: #00d195">打印中</view>
|
||||
</view>
|
||||
<view class="label_warp" v-if="deviceDetail.status == 2">
|
||||
<view class="label_icon" style="background: #00abff"></view>
|
||||
<view class="label_text" style="color: #00abff">准备中</view>
|
||||
</view>
|
||||
|
||||
<view class="label_warp" v-if="deviceDetail.status == 3">
|
||||
<view class="label_icon" style="background: #fdcb3b"></view>
|
||||
<view class="label_text" style="color: #fdcb3b">铲件中</view>
|
||||
@ -94,10 +89,9 @@
|
||||
<!-- 子状态处理 -->
|
||||
<template v-else-if="field.isErrorStatus">
|
||||
<view class="label_warp2">
|
||||
<view class="label_icon" :style="{ background: getStatusColor(deviceDetail.printStatus) }">
|
||||
</view>
|
||||
<view class="label_text label_text2" :style="{ color: getStatusColor(deviceDetail.printStatus) }">
|
||||
{{ getStatusText2(deviceDetail.printStatus) }}
|
||||
<view class="label_icon" :style="{ background: getStatusColor(printInfo.status) }"></view>
|
||||
<view class="label_text label_text2" :style="{ color: getStatusColor(printInfo.status) }">
|
||||
{{ getStatusText2(printInfo.status) }}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -144,7 +138,8 @@
|
||||
|
||||
<view class="device_status_warp" v-if="deviceType == 2">
|
||||
<view class="empty_state_warp">
|
||||
<image class="empty_state_icon" src="https://online.totustec.com/upload/deviceManage/empty_log_icon.png"></image>
|
||||
<image class="empty_state_icon"
|
||||
src="https://online.totustec.com/upload/deviceManage/empty_log_icon.png"></image>
|
||||
<view class="empty_state_title">暂无日志数据</view>
|
||||
<!-- <view class="empty_state_desc">设备运行日志将在这里显示</view> -->
|
||||
</view>
|
||||
@ -155,7 +150,7 @@
|
||||
<view class="deviceN_input_warp">
|
||||
<view class="device_name_txt"> 打印文件名称:</view>
|
||||
<view class="deviceN_input_area">
|
||||
<input class="deviceN_input" type="text" v-model="deviceName" @input="onDeviceNameInput" />
|
||||
<input class="deviceN_input" type="text" v-model="deviceName" @input="onDeviceNameInput"/>
|
||||
<view class="clear_deviceN_warp">
|
||||
<image class="clear_deviceN_icon" @click="deviceName = ''" v-if="deviceName"
|
||||
src="https://online.totustec.com/upload/deviceManage/clear_deviceN_icon.png">
|
||||
@ -165,44 +160,52 @@
|
||||
</view>
|
||||
<view class="deviceN_input_tip">文件位置:桌面File文件夹内</view>
|
||||
<view class="device_operation_warp">
|
||||
<view class="device_operation_btn" @click="operationData('PRINT')" :style="{
|
||||
backgroundColor:
|
||||
deviceDetail.status == 0
|
||||
? '#ffffff'
|
||||
: '#cccccc',
|
||||
}">
|
||||
<image class="operation_btn_icon" src="https://online.totustec.com/upload/deviceManage/print_status1.png">
|
||||
</image>
|
||||
<view class="operation_btn_txt">开始打印</view>
|
||||
<!--只有主状态等于0时候开始打印才能点击,其他都不能点击-->
|
||||
<view class="device_operation_btn"
|
||||
@click="operationData('PRINT')"
|
||||
:style="{backgroundColor:deviceDetail.status === 0? '#ffffff':'#cccccc'}
|
||||
">
|
||||
<image class="operation_btn_icon"
|
||||
src="https://online.totustec.com/upload/deviceManage/print_status1.png"></image>
|
||||
<view class="operation_btn_txt"
|
||||
:style="{
|
||||
color:deviceDetail.status === 0 ?'#333333':'#ece8e8' ,}"
|
||||
>开始打印</view>
|
||||
</view>
|
||||
|
||||
<view class="device_operation_btn" @click="operationData('CONTINUE')" :style="{
|
||||
backgroundColor:
|
||||
deviceDetail.status != 0 &&
|
||||
deviceDetail.status != 1 &&
|
||||
deviceDetail.printStatus != 6 &&
|
||||
deviceDetail.status != -1
|
||||
? '#ffffff'
|
||||
: '#cccccc',
|
||||
}">
|
||||
<!--继续打印-->
|
||||
<view class="device_operation_btn"
|
||||
@click="operationData('CONTINUE')"
|
||||
:style="{backgroundColor:deviceDetail.status === 0 || printInfo.status !== 6? '#cccccc': '#ffffff'}"
|
||||
>
|
||||
<image class="operation_btn_icon" src="https://online.totustec.com/upload/deviceManage/print_status1.png">
|
||||
</image>
|
||||
<view class="operation_btn_txt">继续打印</view>
|
||||
<view class="operation_btn_txt"
|
||||
:style="{color:deviceDetail.status === 0 || printInfo.status !== 6? '#ece8e8': '#333333'}"
|
||||
>继续打印</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!--暂停打印 退出打印-->
|
||||
<view class="device_operation_warp">
|
||||
<view class="device_operation_btn" @click="operationData('PAUSE')" :style="{
|
||||
backgroundColor:
|
||||
deviceDetail.status == 1 || deviceDetail.status == 2
|
||||
deviceDetail.status === 1 ||
|
||||
deviceDetail.status === 2 ||
|
||||
printInfo.status === 6
|
||||
? '#ffffff'
|
||||
: '#cccccc',
|
||||
}">
|
||||
<!-- <image class="operation_btn_icon" src="https://online.totustec.com/upload/deviceManage/print_status1.png">
|
||||
</image> -->
|
||||
<image class="operation_btn_icon" src="https://online.totustec.com/upload/deviceManage/print_status1.png">
|
||||
</image>
|
||||
<view class="operation_btn_txt">暂停打印</view>
|
||||
<view class="operation_btn_txt"
|
||||
:style="{
|
||||
color:
|
||||
deviceDetail.status === 1 ||
|
||||
deviceDetail.status === 2 ||
|
||||
printInfo.status === 6
|
||||
?'#333333':'#ece8e8' ,
|
||||
}"
|
||||
>暂停打印</view>
|
||||
</view>
|
||||
|
||||
<view class="device_operation_btn" @click="operationData('EXIT')" :style="{
|
||||
@ -211,10 +214,17 @@
|
||||
}">
|
||||
<image class="operation_btn_icon" src="https://online.totustec.com/upload/deviceManage/print_status1.png">
|
||||
</image>
|
||||
<view class="operation_btn_txt">退出打印</view>
|
||||
<view class="operation_btn_txt"
|
||||
:style="{
|
||||
color:
|
||||
deviceDetail.status != -1
|
||||
?'#ece8e8': '#333333',
|
||||
}"
|
||||
>退出打印</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 报警继续 报警退出-->
|
||||
<view class="device_operation_warp">
|
||||
<view class="device_operation_btn" @click="sendWsCommand('ALARM_CONTINUE')">
|
||||
<image class="operation_btn_icon" src="https://online.totustec.com/upload/deviceManage/print_status2.png">
|
||||
@ -238,7 +248,7 @@ import {
|
||||
} from "@/config.js";
|
||||
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
isMediaLoading: false,
|
||||
deviceName: "",
|
||||
@ -403,7 +413,7 @@ export default {
|
||||
socketData: {},
|
||||
};
|
||||
},
|
||||
onLoad (options) {
|
||||
onLoad(options) {
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
const {
|
||||
statusBarHeight, // 状态栏高度(单位:px)
|
||||
@ -421,12 +431,15 @@ export default {
|
||||
|
||||
this.connectWebSocket(); // 初始化 WebSocket 连接
|
||||
},
|
||||
onUnload () {
|
||||
onUnload() {
|
||||
this.closeWebSocket(); // 页面卸载时关闭连接
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
||||
|
||||
// ---------------------- WebSocket 核心方法 ----------------------
|
||||
connectWebSocket () {
|
||||
connectWebSocket() {
|
||||
const wsUrl = BASE_STOKECT_URL;
|
||||
|
||||
// 初始化 WebSocket 连接(使用 uni-app 接口)
|
||||
@ -444,7 +457,7 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
listenSocketMessage () {
|
||||
listenSocketMessage() {
|
||||
// 监听 WebSocket 消息
|
||||
uni.onSocketMessage((event) => {
|
||||
console.log("event", event);
|
||||
@ -455,7 +468,7 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
closeWebSocket () {
|
||||
closeWebSocket() {
|
||||
// 关闭连接并清理资源
|
||||
if (this.socketTask) {
|
||||
uni.closeSocket();
|
||||
@ -465,7 +478,7 @@ export default {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
},
|
||||
|
||||
tryReconnect () {
|
||||
tryReconnect() {
|
||||
// 自动重连机制
|
||||
clearTimeout(this.reconnectTimer);
|
||||
this.reconnectTimer = setTimeout(() => {
|
||||
@ -474,7 +487,7 @@ export default {
|
||||
}, this.reconnectInterval);
|
||||
},
|
||||
|
||||
updateDeviceStatus (message) {
|
||||
updateDeviceStatus(message) {
|
||||
console.log("实时消息", message);
|
||||
// CLOSE、STATUS 你那就刷新接口就行
|
||||
if (message.msgType == "CLOSE" || message.msgType == "STATUS") {
|
||||
@ -510,7 +523,7 @@ export default {
|
||||
* 发送 WebSocket 指令
|
||||
* @param {string} command - 指令值(如 PAUSE、CONTINUE 等)
|
||||
*/
|
||||
sendWsCommand (command) {
|
||||
sendWsCommand(command) {
|
||||
if (!this.isSocketConnected) {
|
||||
console.warn("WebSocket 未连接,无法发送指令");
|
||||
return;
|
||||
@ -543,7 +556,7 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
operationData (type) {
|
||||
operationData(type) {
|
||||
if (type == "PRINT") {
|
||||
// 检查设备名称是否为空
|
||||
if (!this.deviceName || this.deviceName.trim() === '') {
|
||||
@ -554,7 +567,6 @@ export default {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查设备状态
|
||||
if (this.deviceDetail.status == 0 && this.deviceDetail.status != -1) {
|
||||
// 显示确认提示框
|
||||
@ -572,19 +584,30 @@ export default {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (type == "CONTINUE") {
|
||||
if (
|
||||
this.deviceDetail.status != 0 &&
|
||||
this.deviceDetail.status != 1 &&
|
||||
this.deviceDetail.printStatus != 6 &&
|
||||
this.deviceDetail.status != -1
|
||||
) {
|
||||
if (type === "CONTINUE") {
|
||||
// 检查设备状态
|
||||
if (this.deviceDetail.status === 0) {
|
||||
uni.showToast({
|
||||
title: "当前设备空闲,禁止继续打印",
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
console.log("设备未就绪,禁止继续打印");
|
||||
return;
|
||||
}
|
||||
if (this.printInfo.status !== 6) {
|
||||
uni.showToast({
|
||||
title: "当前设备未暂定,禁止继续打印",
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendWsCommand(type);
|
||||
}
|
||||
}
|
||||
if (type == 'PAUSE') {
|
||||
if ((this.deviceDetail.status == 1 || this.deviceDetail.status == 2) && this.deviceDetail.status != -
|
||||
1) {
|
||||
if ((this.deviceDetail.status == 1 || this.deviceDetail.status == 2 || this.printInfo.status == 3) && this.deviceDetail.status != -1) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要暂停打印吗?',
|
||||
@ -614,7 +637,7 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
getVideoImg (type) {
|
||||
getVideoImg(type) {
|
||||
this.isMediaLoading = true;
|
||||
if (type == "img") {
|
||||
this.getType = "img";
|
||||
@ -625,39 +648,41 @@ export default {
|
||||
}
|
||||
},
|
||||
// 获取状态文字
|
||||
getStatusText (status) {
|
||||
getStatusText(status) {
|
||||
if (status == -1) {
|
||||
return "断开";
|
||||
}
|
||||
return this.statusMap[status]?.text || "";
|
||||
},
|
||||
getStatusText2 (status) {
|
||||
if (status == -1) {
|
||||
getStatusText2(status) {
|
||||
//如果状态为-1就算断开
|
||||
if (status === -1) {
|
||||
return "断开";
|
||||
}
|
||||
return this.childStatusMap[status]?.text || "";
|
||||
},
|
||||
// 获取状态颜色
|
||||
getStatusColor (status) {
|
||||
getStatusColor(status) {
|
||||
if (status == -1) {
|
||||
return "#999999";
|
||||
}
|
||||
return this.childStatusMap[status]?.color; // 默认灰色
|
||||
},
|
||||
getCurrentTime () {
|
||||
getCurrentTime() {
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
const hours = String(date.getHours()).padStart(2, "0");
|
||||
const minutes = String(date.getMinutes()).padStart(2, "0");
|
||||
|
||||
return `${year}年${month}月${day}日${hours}时${minutes}分`;
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份补零
|
||||
const day = String(date.getDate()).padStart(2, "0"); // 日期补零
|
||||
const hours = String(date.getHours()).padStart(2, "0"); // 小时补零
|
||||
const minutes = String(date.getMinutes()).padStart(2, "0"); // 分钟补零
|
||||
const seconds = String(date.getSeconds()).padStart(2, "0"); // 新增:秒补零
|
||||
// 格式:YYYY.MM.DD HH:MM:SS
|
||||
return `${year}.${month}.${day} ${hours}:${minutes}:${seconds}`;
|
||||
},
|
||||
goBack () {
|
||||
goBack() {
|
||||
uni.navigateBack();
|
||||
},
|
||||
async getDeviceDetail () {
|
||||
async getDeviceDetail() {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: BASE_API_URL + '/api/front/device/get',
|
||||
@ -702,7 +727,7 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
onDeviceNameInput (e) {
|
||||
onDeviceNameInput(e) {
|
||||
this.deviceName = e.detail.value;
|
||||
// console.log('输入内容:', e.detail.value);
|
||||
},
|
||||
@ -810,6 +835,8 @@ export default {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border: 2rpx solid #cccccc;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
.device_operation_warp {
|
||||
|
Loading…
Reference in New Issue
Block a user