650完成,并解决了冲突
This commit is contained in:
@ -47,448 +47,421 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||||
import {
|
import {
|
||||||
generateShortId
|
generateShortId,
|
||||||
} from '@/utils/function.js';
|
getdeviceSTatus
|
||||||
import {
|
} from '@/utils/function.js';
|
||||||
deviceInfo,
|
import {
|
||||||
} from '@/api/common/index.js'
|
deviceInfo,
|
||||||
import {
|
} from '@/api/common/index.js'
|
||||||
deviceSendAlarmMessage
|
import {
|
||||||
} from '@/api/6170/callPolice.js'
|
deviceSendAlarmMessage
|
||||||
import {
|
} from '@/api/6170/callPolice.js'
|
||||||
deviceRealTimeStatus //设备状态
|
import {
|
||||||
} from '@/api/6170/deviceControl.js'
|
deviceRealTimeStatus //设备状态
|
||||||
export default {
|
} from '@/api/6170/deviceControl.js'
|
||||||
components: {
|
export default {
|
||||||
CustomPopup
|
components: {
|
||||||
},
|
CustomPopup
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
deviceList: [],
|
|
||||||
showPopupFlag: false,
|
|
||||||
popupTitle: '',
|
|
||||||
popupMessage: '确认要对所选设备开启强制报警?',
|
|
||||||
popupConfirmText: '确认',
|
|
||||||
popupType: 'force', // 'force' or 'cancel'
|
|
||||||
pendingAlarmAction: '',
|
|
||||||
sendInfo: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
selectedDeviceIds() {
|
|
||||||
return this.deviceList.filter(item => item.checked).map(item => item.id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onclosePopup() {
|
|
||||||
this.showPopupFlag = false
|
|
||||||
},
|
},
|
||||||
toggleSelect(index) {
|
data() {
|
||||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
return {
|
||||||
this.$forceUpdate()
|
deviceList: [],
|
||||||
|
showPopupFlag: false,
|
||||||
|
popupTitle: '',
|
||||||
|
popupMessage: '确认要对所选设备开启强制报警?',
|
||||||
|
popupConfirmText: '确认',
|
||||||
|
popupType: 'force', // 'force' or 'cancel'
|
||||||
|
pendingAlarmAction: '',
|
||||||
|
sendInfo: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
computed: {
|
||||||
* 获取设备状态(带自动轮询)
|
selectedDeviceIds() {
|
||||||
* @param {number} val - 功能模式
|
return this.deviceList.filter(item => item.checked).map(item => item.id);
|
||||||
* @param {string} batchId - 批次ID
|
}
|
||||||
* @param {number} [interval=1000] - 轮询间隔(毫秒)
|
},
|
||||||
*/
|
methods: {
|
||||||
async getdeviceSTatus(val, batchId, interval =500) {
|
onclosePopup() {
|
||||||
const checkStatus = async () => {
|
this.showPopupFlag = false
|
||||||
try {
|
},
|
||||||
const data = {
|
toggleSelect(index) {
|
||||||
functionMode: val,
|
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||||
batchId: batchId,
|
this.$forceUpdate()
|
||||||
typeName: this.sendInfo.typeName,
|
},
|
||||||
deviceImei: this.sendInfo.deviceImei
|
// 全选/取消全选
|
||||||
};
|
selectAll() {
|
||||||
const res = await deviceRealTimeStatus(data);
|
console.log('123');
|
||||||
if (res.code !== 200) {
|
const allSelected = this.deviceList.every(item => item.checked);
|
||||||
throw new Error(res.msg || '请求失败');
|
this.deviceList.forEach(item => {
|
||||||
|
item.checked = !allSelected;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$forceUpdate();
|
||||||
|
},
|
||||||
|
// 获取设备列表
|
||||||
|
getData(deviceType) {
|
||||||
|
this.loading = true;
|
||||||
|
let data = {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
deviceType: deviceType
|
||||||
|
}
|
||||||
|
deviceInfo(data).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
const newDevices = res.rows.map(device => ({
|
||||||
|
...device,
|
||||||
|
showConfirm: false,
|
||||||
|
checked: false
|
||||||
|
}));
|
||||||
|
this.total = res.total;
|
||||||
|
this.deviceList = newDevices
|
||||||
}
|
}
|
||||||
switch (res.data.functionAccess) {
|
}).finally(() => {
|
||||||
case 'OK':
|
this.loading = false;
|
||||||
return res; // 成功完成
|
|
||||||
case 'ACTIVE':
|
|
||||||
await new Promise(r => setTimeout(r, interval));
|
|
||||||
return checkStatus(); // 继续轮询
|
|
||||||
case 'FAILED':
|
|
||||||
throw new Error('设备操作失败');
|
|
||||||
case 'TIMEOUT':
|
|
||||||
throw new Error('设备响应超时');
|
|
||||||
default:
|
|
||||||
throw new Error('未知状态');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return checkStatus();
|
|
||||||
},
|
|
||||||
// 全选/取消全选
|
|
||||||
selectAll() {
|
|
||||||
console.log('123');
|
|
||||||
const allSelected = this.deviceList.every(item => item.checked);
|
|
||||||
this.deviceList.forEach(item => {
|
|
||||||
item.checked = !allSelected;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$forceUpdate();
|
|
||||||
},
|
|
||||||
// 获取设备列表
|
|
||||||
getData(deviceType) {
|
|
||||||
this.loading = true;
|
|
||||||
let data = {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 50,
|
|
||||||
deviceType: deviceType
|
|
||||||
}
|
|
||||||
deviceInfo(data).then((res) => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
const newDevices = res.rows.map(device => ({
|
|
||||||
...device,
|
|
||||||
showConfirm: false,
|
|
||||||
checked: false
|
|
||||||
}));
|
|
||||||
this.total = res.total;
|
|
||||||
this.deviceList = newDevices
|
|
||||||
}
|
|
||||||
}).finally(() => {
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 强制报警
|
|
||||||
forceAlarm() {
|
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
|
||||||
if (selectedDevices.length === 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请选择一个设备',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
});
|
||||||
return;
|
},
|
||||||
}
|
// 强制报警
|
||||||
this.popupType = 'force';
|
forceAlarm() {
|
||||||
this.popupMessage = '确认要对所选设备开启强制报警?';
|
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||||
this.showPopupFlag = true;
|
if (selectedDevices.length === 0) {
|
||||||
this.pendingAlarmAction = 1
|
|
||||||
|
|
||||||
},
|
|
||||||
// 解除报警
|
|
||||||
cancelAlarm() {
|
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked);
|
|
||||||
if (selectedDevices.length === 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请选择一个设备',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.popupType = 'cancel';
|
|
||||||
this.popupMessage = '确认要解除所选设备的报警状态?';
|
|
||||||
this.showPopupFlag = true;
|
|
||||||
this.pendingAlarmAction = 0
|
|
||||||
},
|
|
||||||
// 确认
|
|
||||||
async sendAlarmCommand() {
|
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked);
|
|
||||||
const deviceIds = selectedDevices.map(item => item.id);
|
|
||||||
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
|
||||||
const isAlarming = this.pendingAlarmAction == 1;
|
|
||||||
try {
|
|
||||||
|
|
||||||
uni.showLoading({
|
|
||||||
title: isAlarming ? '设备报警中...' : '解除报警中...',
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
// 2. 准备请求数据
|
|
||||||
const batchId = generateShortId();
|
|
||||||
const data = {
|
|
||||||
deviceIds: deviceIds,
|
|
||||||
typeName: this.sendInfo.typeName,
|
|
||||||
deviceImeiList: deviceImeiList,
|
|
||||||
batchId: batchId,
|
|
||||||
instructValue: this.pendingAlarmAction == 1 ? '1' : '0'
|
|
||||||
};
|
|
||||||
const registerRes = await deviceSendAlarmMessage(data);
|
|
||||||
if (registerRes.code !== 200) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: registerRes.msg,
|
title: '请选择一个设备',
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 4. 获取设备状态
|
|
||||||
const statusRes = await this.getdeviceSTatus(2, batchId);
|
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
|
||||||
uni.showToast({
|
|
||||||
title: statusRes.msg,
|
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
this.showPopupFlag = false
|
return;
|
||||||
uni.$emit('deviceStatusUpdate', {});
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 500)
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
this.popupType = 'force';
|
||||||
uni.showToast({
|
this.popupMessage = '确认要对所选设备开启强制报警?';
|
||||||
title: error.message,
|
this.showPopupFlag = true;
|
||||||
icon: 'none'
|
this.pendingAlarmAction = 1
|
||||||
});
|
|
||||||
} finally {
|
},
|
||||||
uni.hideLoading();
|
// 解除报警
|
||||||
}
|
cancelAlarm() {
|
||||||
|
const selectedDevices = this.deviceList.filter(item => item.checked);
|
||||||
|
if (selectedDevices.length === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请选择一个设备',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.popupType = 'cancel';
|
||||||
|
this.popupMessage = '确认要解除所选设备的报警状态?';
|
||||||
|
this.showPopupFlag = true;
|
||||||
|
this.pendingAlarmAction = 0
|
||||||
|
},
|
||||||
|
// 确认
|
||||||
|
async sendAlarmCommand() {
|
||||||
|
const selectedDevices = this.deviceList.filter(item => item.checked);
|
||||||
|
const deviceIds = selectedDevices.map(item => item.id);
|
||||||
|
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
||||||
|
const isAlarming = this.pendingAlarmAction == 1;
|
||||||
|
try {
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: isAlarming ? '设备报警中...' : '解除报警中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
// 2. 准备请求数据
|
||||||
|
const batchId = generateShortId();
|
||||||
|
const data = {
|
||||||
|
deviceIds: deviceIds,
|
||||||
|
typeName: this.sendInfo.typeName,
|
||||||
|
deviceImeiList: deviceImeiList,
|
||||||
|
batchId: batchId,
|
||||||
|
instructValue: this.pendingAlarmAction == 1 ? '1' : '0'
|
||||||
|
};
|
||||||
|
const registerRes = await deviceSendAlarmMessage(data);
|
||||||
|
if (registerRes.code !== 200) {
|
||||||
|
uni.showToast({
|
||||||
|
title: registerRes.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 4. 获取设备状态
|
||||||
|
let deviceImei = this.sendInfo.deviceImei
|
||||||
|
let typeName = this.sendInfo.typeName
|
||||||
|
const statusRes = await getdeviceSTatus({
|
||||||
|
functionMode: 2,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei,
|
||||||
|
interval: 500
|
||||||
|
},
|
||||||
|
deviceRealTimeStatus
|
||||||
|
);
|
||||||
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
|
uni.showToast({
|
||||||
|
title: statusRes.msg,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
this.showPopupFlag = false
|
||||||
|
uni.$emit('deviceStatusUpdate', {});
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
uni.showToast({
|
||||||
|
title: error.message,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 点击确认状态
|
||||||
|
onPopupConfirm() {
|
||||||
|
this.sendAlarmCommand(this.popupType);
|
||||||
|
// 处理确认逻辑
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// 点击确认状态
|
onLoad(options) {
|
||||||
onPopupConfirm() {
|
const eventChannel = this.getOpenerEventChannel();
|
||||||
this.sendAlarmCommand(this.popupType);
|
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||||
// 处理确认逻辑
|
eventChannel.on('devicePolice', (data) => {
|
||||||
|
this.getData(data.data.id)
|
||||||
|
this.sendInfo = data.data
|
||||||
|
});
|
||||||
|
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||||
|
eventChannel.emit('ack', {})
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
onLoad(options) {
|
|
||||||
const eventChannel = this.getOpenerEventChannel();
|
|
||||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
|
||||||
eventChannel.on('devicePolice', (data) => {
|
|
||||||
this.getData(data.data.id)
|
|
||||||
this.sendInfo = data.data
|
|
||||||
});
|
|
||||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
|
||||||
eventChannel.emit('ack', {})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.container {
|
.container {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background-color: rgb(18, 18, 18);
|
background-color: rgb(18, 18, 18);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.allSelect {
|
.allSelect {
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
float: right;
|
float: right;
|
||||||
padding: 25rpx;
|
padding: 25rpx;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-list {
|
.device-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0rpx 20rpx;
|
padding: 0rpx 20rpx;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-card {
|
.device-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox {
|
.checkbox {
|
||||||
width: 40rpx;
|
width: 40rpx;
|
||||||
height: 40rpx;
|
height: 40rpx;
|
||||||
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
border-radius: 4rpx;
|
border-radius: 4rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox.checked {
|
.checkbox.checked {
|
||||||
background: rgba(224, 52, 52, 1);
|
background: rgba(224, 52, 52, 1);
|
||||||
border-color: rgba(224, 52, 52, 1);
|
border-color: rgba(224, 52, 52, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-content {
|
.device-content {
|
||||||
background-color: rgb(26, 26, 26);
|
background-color: rgb(26, 26, 26);
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
/* display: flex; */
|
/* display: flex; */
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-header {
|
.device-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 15rpx;
|
margin-bottom: 15rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-name {
|
.device-name {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
margin-left: 12rpx;
|
margin-left: 12rpx;
|
||||||
line-height: 50rpx;
|
line-height: 50rpx;
|
||||||
width: 83%;
|
width: 83%;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ID {
|
.ID {
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: rgba(255, 255, 255, 0.6);
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-status {
|
.device-status {
|
||||||
width: 122rpx;
|
width: 122rpx;
|
||||||
height: 52rpx;
|
height: 52rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
border-radius: 0px 8px 0px 8px;
|
border-radius: 0px 8px 0px 8px;
|
||||||
background-color: rgb(42, 42, 42);
|
background-color: rgb(42, 42, 42);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0rpx;
|
top: 0rpx;
|
||||||
right: 0rpx;
|
right: 0rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 52rpx;
|
line-height: 52rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.online {
|
.online {
|
||||||
color: rgb(187, 230, 0);
|
color: rgb(187, 230, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.unline {
|
.unline {
|
||||||
color: rgba(255, 255, 255, 0.4);
|
color: rgba(255, 255, 255, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-info {
|
.device-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
padding-top: 10rpx;
|
padding-top: 10rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.deviceIMG {
|
.deviceIMG {
|
||||||
width: 100rpx;
|
width: 100rpx;
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: rgba(42, 42, 42, 0.6);
|
background-color: rgba(42, 42, 42, 0.6);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.IMG {
|
.IMG {
|
||||||
width: 68rpx;
|
width: 68rpx;
|
||||||
height: 50rpx;
|
height: 50rpx;
|
||||||
margin-left: 17%;
|
margin-left: 17%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.onlines {
|
.onlines {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.onlines::before {
|
.onlines::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 15rpx;
|
width: 15rpx;
|
||||||
height: 15rpx;
|
height: 15rpx;
|
||||||
background: rgb(0, 171, 103);
|
background: rgb(0, 171, 103);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
top: 20rpx;
|
top: 20rpx;
|
||||||
left: -20rpx
|
left: -20rpx
|
||||||
}
|
}
|
||||||
|
|
||||||
.unlines {
|
.unlines {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unlines::before {
|
.unlines::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 15rpx;
|
width: 15rpx;
|
||||||
height: 15rpx;
|
height: 15rpx;
|
||||||
background: rgba(255, 255, 255, 0.4);
|
background: rgba(255, 255, 255, 0.4);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
top: 20rpx;
|
top: 20rpx;
|
||||||
left: -20rpx
|
left: -20rpx
|
||||||
}
|
}
|
||||||
|
|
||||||
.line {
|
.line {
|
||||||
width: 2rpx;
|
width: 2rpx;
|
||||||
height: 24rpx;
|
height: 24rpx;
|
||||||
background: linear-gradient(90deg,
|
background: linear-gradient(90deg,
|
||||||
rgba(0, 0, 0, 0) 0%,
|
rgba(0, 0, 0, 0) 0%,
|
||||||
rgb(255, 255, 255) 50%,
|
rgb(255, 255, 255) 50%,
|
||||||
rgba(255, 255, 255, 0) 100%);
|
rgba(255, 255, 255, 0) 100%);
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ql-editor {
|
.ql-editor {
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: rgba(255, 255, 255, 0.6);
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ql-input {
|
.ql-input {
|
||||||
width: 95.9%;
|
width: 95.9%;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 30rpx;
|
padding: 30rpx;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
background: rgb(26, 26, 26);
|
background: rgb(26, 26, 26);
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
color: rgba(255, 255, 255, 0.8);
|
color: rgba(255, 255, 255, 0.8);
|
||||||
background: rgba(42, 42, 42, 1);
|
background: rgba(42, 42, 42, 1);
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
padding: 10rpx;
|
padding: 10rpx;
|
||||||
height: 150rpx;
|
height: 150rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editInfmation {
|
.editInfmation {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
border-radius: 40rpx 40rpx 0px 0px;
|
border-radius: 40rpx 40rpx 0px 0px;
|
||||||
width: 96%;
|
width: 96%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 50rpx;
|
bottom: 50rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-btn {
|
.login-btn {
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
color: rgb(35, 35, 35);
|
color: rgb(35, 35, 35);
|
||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
width: 40%;
|
width: 40%;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
line-height: 88rpx;
|
line-height: 88rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.qz {
|
.qz {
|
||||||
background: rgba(224, 52, 52, 1);
|
background: rgba(224, 52, 52, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.jc {
|
.jc {
|
||||||
border: 1px solid rgba(255, 255, 255, 0.87);
|
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||||
background: rgba(18, 18, 18, 1);
|
background: rgba(18, 18, 18, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox.disabled {
|
.checkbox.disabled {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
background-color: rgba(255, 255, 255, 0.1) !important;
|
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||||
border-color: rgba(255, 255, 255, 0.2) !important;
|
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
/* 阻止点击事件 */
|
/* 阻止点击事件 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 可选:离线设备的卡片整体置灰 */
|
/* 可选:离线设备的卡片整体置灰 */
|
||||||
.device-card[data-offline="true"] {
|
.device-card[data-offline="true"] {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -271,7 +271,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import MqttClient from '@/utils/mqtt.js';
|
import MqttClient from '@/utils/mqtt.js';
|
||||||
import {
|
import {
|
||||||
generateShortId
|
generateShortId,
|
||||||
|
getdeviceSTatus
|
||||||
} from '@/utils/function.js';
|
} from '@/utils/function.js';
|
||||||
import {
|
import {
|
||||||
deviceDetail,
|
deviceDetail,
|
||||||
@ -334,7 +335,9 @@
|
|||||||
popupType: 'person', //弹框类型
|
popupType: 'person', //弹框类型
|
||||||
isLaserOn: false,
|
isLaserOn: false,
|
||||||
isSending: false,
|
isSending: false,
|
||||||
isProcessing: false
|
isProcessing: false,
|
||||||
|
isLoading: false, // 主加载状态
|
||||||
|
isPolling: false // 轮询状态
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -346,44 +349,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
|
||||||
* 获取设备状态(带自动轮询)
|
|
||||||
* @param {number} val - 功能模式
|
|
||||||
* @param {string} batchId - 批次ID
|
|
||||||
* @param {number} [interval=800] - 轮询间隔(毫秒)
|
|
||||||
*/
|
|
||||||
async getdeviceSTatus(val, batchId, interval = 800) {
|
|
||||||
const checkStatus = async () => {
|
|
||||||
try {
|
|
||||||
const data = {
|
|
||||||
functionMode: val,
|
|
||||||
batchId: batchId,
|
|
||||||
typeName: this.itemInfo.typeName,
|
|
||||||
deviceImei: this.itemInfo.deviceImei
|
|
||||||
};
|
|
||||||
const res = await deviceRealTimeStatus(data);
|
|
||||||
if (res.code !== 200) {
|
|
||||||
throw new Error(res.msg || '请求失败');
|
|
||||||
}
|
|
||||||
switch (res.data.functionAccess) {
|
|
||||||
case 'OK':
|
|
||||||
return res; // 成功完成
|
|
||||||
case 'ACTIVE':
|
|
||||||
await new Promise(r => setTimeout(r, interval));
|
|
||||||
return checkStatus(); // 继续轮询
|
|
||||||
case 'FAILED':
|
|
||||||
throw new Error('设备操作失败');
|
|
||||||
case 'TIMEOUT':
|
|
||||||
throw new Error('设备响应超时');
|
|
||||||
default:
|
|
||||||
throw new Error('未知状态');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return checkStatus();
|
|
||||||
},
|
|
||||||
// 点击弹框外的区域关闭
|
// 点击弹框外的区域关闭
|
||||||
closePopup() {
|
closePopup() {
|
||||||
this.lightModeA = false;
|
this.lightModeA = false;
|
||||||
@ -554,22 +519,6 @@
|
|||||||
toggleForm() {
|
toggleForm() {
|
||||||
this.isFormExpanded = !this.isFormExpanded;
|
this.isFormExpanded = !this.isFormExpanded;
|
||||||
},
|
},
|
||||||
// onItemClick(index) {
|
|
||||||
// const selectedItem = this.items[index];
|
|
||||||
// if (selectedItem.text === '激光') {
|
|
||||||
// this.lightModeC = true;
|
|
||||||
// } else {
|
|
||||||
// // 更新选中状态
|
|
||||||
// this.items = this.items.map((item, i) => ({
|
|
||||||
// ...item,
|
|
||||||
// selected: i === index
|
|
||||||
// }));
|
|
||||||
// this.currentMainMode = selectedItem.text;
|
|
||||||
// this.selectedItemIndex = index;
|
|
||||||
// // 强制更新视图(如果需要)
|
|
||||||
// this.$forceUpdate();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
onItemClick(index) {
|
onItemClick(index) {
|
||||||
const item = this.items[index];
|
const item = this.items[index];
|
||||||
// 激光模式特殊处理
|
// 激光模式特殊处理
|
||||||
@ -585,7 +534,7 @@
|
|||||||
selected: i === index
|
selected: i === index
|
||||||
}));
|
}));
|
||||||
// 显示临时选中的模式名称(视觉反馈)
|
// 显示临时选中的模式名称(视觉反馈)
|
||||||
this.pendingMainMode = item.text;
|
this.pendingMainMode = item.text;
|
||||||
},
|
},
|
||||||
// 灯光模式的确认
|
// 灯光模式的确认
|
||||||
handleSumbit() {
|
handleSumbit() {
|
||||||
@ -749,6 +698,7 @@
|
|||||||
mask: true
|
mask: true
|
||||||
});
|
});
|
||||||
loadingShown = true;
|
loadingShown = true;
|
||||||
|
this.isPolling = true; // 标记开始轮询
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: baseURL + '/app/bjq/device/uploadLogo',
|
url: baseURL + '/app/bjq/device/uploadLogo',
|
||||||
filePath: this.selectedImage,
|
filePath: this.selectedImage,
|
||||||
@ -773,7 +723,19 @@
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
// 获取设备状态
|
// 获取设备状态
|
||||||
const statusRes = await this.getdeviceSTatus(1);
|
// 4. 获取设备状态
|
||||||
|
let deviceImei = this.itemInfo.deviceImei
|
||||||
|
let typeName = this.itemInfo.typeName
|
||||||
|
let batchId = ''
|
||||||
|
const statusRes = await getdeviceSTatus({
|
||||||
|
functionMode: 1,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei,
|
||||||
|
interval: 800
|
||||||
|
},
|
||||||
|
deviceRealTimeStatus
|
||||||
|
);
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
this.selectedImage = '';
|
this.selectedImage = '';
|
||||||
@ -784,6 +746,7 @@
|
|||||||
this.lightModeB = false;
|
this.lightModeB = false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.isPolling = false; // 标记轮询结束
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message,
|
title: error.message,
|
||||||
@ -791,6 +754,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.isPolling = false; // 标记轮询结束
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: responseData.msg,
|
title: responseData.msg,
|
||||||
@ -798,6 +762,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
this.isPolling = false; // 标记轮询结束
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: e.message,
|
title: e.message,
|
||||||
@ -918,6 +883,7 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.isPolling = true; // 标记开始轮询
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '解除告警中...',
|
title: '解除告警中...',
|
||||||
@ -942,7 +908,17 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 4. 获取设备状态
|
// 4. 获取设备状态
|
||||||
const statusRes = await this.getdeviceSTatus(2, batchId);
|
let deviceImei = this.itemInfo.deviceImei
|
||||||
|
let typeName = this.itemInfo.typeName
|
||||||
|
const statusRes = await getdeviceSTatus({
|
||||||
|
functionMode: 2,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei,
|
||||||
|
interval: 500
|
||||||
|
},
|
||||||
|
deviceRealTimeStatus
|
||||||
|
);
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: statusRes.msg,
|
title: statusRes.msg,
|
||||||
@ -964,6 +940,7 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
this.isPolling = false; // 标记开始轮询
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -987,6 +964,7 @@
|
|||||||
}
|
}
|
||||||
this.isSending = true;
|
this.isSending = true;
|
||||||
let loadingShown = false;
|
let loadingShown = false;
|
||||||
|
this.isPolling = true; // 标记开始轮询
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '正在发送...',
|
title: '正在发送...',
|
||||||
@ -1011,8 +989,18 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 轮询获取状态(重要:这里必须await)
|
// 4. 获取设备状态
|
||||||
const statusRes = await this.getdeviceSTatus(2, batchId);
|
let deviceImei = this.itemInfo.deviceImei
|
||||||
|
let typeName = this.itemInfo.typeName
|
||||||
|
const statusRes = await getdeviceSTatus({
|
||||||
|
functionMode: 2,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei,
|
||||||
|
interval: 500
|
||||||
|
},
|
||||||
|
deviceRealTimeStatus
|
||||||
|
);
|
||||||
// 只有当状态为'OK'时才显示成功弹窗
|
// 只有当状态为'OK'时才显示成功弹窗
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
this.popupType = 'person';
|
this.popupType = 'person';
|
||||||
@ -1025,7 +1013,7 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
console.log('失败还是成功了');
|
this.isPolling = false; // 标记轮询结束
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
this.isSending = false;
|
this.isSending = false;
|
||||||
}
|
}
|
||||||
@ -1062,9 +1050,16 @@
|
|||||||
this.isSharedDevice = false;
|
this.isSharedDevice = false;
|
||||||
this.activePermissions = []; // 非分享设备清空权限
|
this.activePermissions = []; // 非分享设备清空权限
|
||||||
}
|
}
|
||||||
if (!isUpdate) {
|
// 只有不是轮询状态时才关闭loading
|
||||||
// 关闭加载中
|
if (!this.isPolling) {
|
||||||
uni.hideLoading()
|
this.pageLoading = false;
|
||||||
|
uni.hideLoading(); // 确保关闭
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 只有不是轮询状态时才关闭loading
|
||||||
|
if (!this.isPolling) {
|
||||||
|
this.pageLoading = false;
|
||||||
|
uni.hideLoading(); // 确保关闭
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1081,25 +1076,15 @@
|
|||||||
try {
|
try {
|
||||||
const res = await deviceDetail(id)
|
const res = await deviceDetail(id)
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.handleDeviceData(res, false, isUpdate)
|
this.handleDeviceData(res, false, isUpdate, true)
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
title: res.msg,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
if (!isUpdate) {
|
|
||||||
uni.hideLoading()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!isUpdate) {
|
// 只有不是轮询状态时才关闭loading
|
||||||
uni.hideLoading()
|
if (!this.isPolling) {
|
||||||
|
this.pageLoading = false;
|
||||||
|
uni.hideLoading(); // 确保关闭
|
||||||
}
|
}
|
||||||
// uni.showToast({
|
|
||||||
// title: error.msg,
|
|
||||||
// icon: 'none'
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 获取分享设备详情
|
// 获取分享设备详情
|
||||||
@ -1107,20 +1092,13 @@
|
|||||||
try {
|
try {
|
||||||
const res = await deviceShareId(id)
|
const res = await deviceShareId(id)
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.handleDeviceData(res, true)
|
this.handleDeviceData(res, false, false, true)
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
title: res.msg,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({
|
if (!this.isPolling) {
|
||||||
title: error.msg,
|
this.pageLoading = false;
|
||||||
icon: 'none'
|
uni.hideLoading(); // 确保关闭
|
||||||
})
|
}
|
||||||
uni.hideLoading()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 操作说明
|
// 操作说明
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- 设备列表 -->
|
<!-- 设备列表 -->
|
||||||
<scroll-view class="device-list" scroll-y>
|
<scroll-view class="device-list" scroll-y>
|
||||||
<view class="device-card" v-for="(item, index) in deviceList" :key="index" @click="item.onlineStatus === 1 ? toggleSelect(index) : null">
|
<view class="device-card" v-for="(item, index) in deviceList" :key="index"
|
||||||
|
@click="item.onlineStatus === 1 ? toggleSelect(index) : null">
|
||||||
<!-- 复选框 -->
|
<!-- 复选框 -->
|
||||||
<view class="checkbox" :class="{ checked: item.checked,disabled: item.onlineStatus !== 1 }">
|
<view class="checkbox" :class="{ checked: item.checked, disabled: item.onlineStatus !== 1 }">
|
||||||
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
|
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
<!-- 设备信息 -->
|
<!-- 设备信息 -->
|
||||||
@ -43,393 +44,368 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||||
import {
|
import {
|
||||||
deviceInfo,
|
deviceInfo,
|
||||||
} from '@/api/common/index.js'
|
} from '@/api/common/index.js'
|
||||||
import {
|
import {
|
||||||
deviceSendMessage,
|
deviceSendMessage,
|
||||||
deviceRealTimeStatus //设备状态
|
deviceRealTimeStatus //设备状态
|
||||||
} from '@/api/6170/deviceControl.js'
|
} from '@/api/6170/deviceControl.js'
|
||||||
import {
|
import {
|
||||||
generateShortId
|
generateShortId,
|
||||||
} from '@/utils/function.js';
|
getdeviceSTatus
|
||||||
export default {
|
} from '@/utils/function.js';
|
||||||
components: {
|
export default {
|
||||||
CustomPopup
|
components: {
|
||||||
|
CustomPopup
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
deviceList: [],
|
||||||
|
messageToSend: '', //发送信息
|
||||||
|
showPopupFlag: false,
|
||||||
|
popupTitle: '',
|
||||||
|
popupMessage: '信息发送成功!',
|
||||||
|
popupConfirmText: '确认',
|
||||||
|
isSending: false,
|
||||||
|
sendInfo: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onPullDownRefresh() {
|
||||||
|
// 执行下拉刷新时的操作,比如重新获取数据
|
||||||
|
this.getData();
|
||||||
},
|
},
|
||||||
data() {
|
toggleSelect(index) {
|
||||||
return {
|
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||||
deviceList: [],
|
this.$forceUpdate()
|
||||||
messageToSend: '', //发送信息
|
},
|
||||||
showPopupFlag: false,
|
// 获取设备列表
|
||||||
popupTitle: '',
|
getData(deviceType) {
|
||||||
popupMessage: '信息发送成功!',
|
this.loading = true;
|
||||||
popupConfirmText: '确认',
|
let data = {
|
||||||
isSending: false,
|
pageNum: 1,
|
||||||
sendInfo: {}
|
pageSize: 50,
|
||||||
|
deviceType: deviceType
|
||||||
|
}
|
||||||
|
deviceInfo(data).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
const newDevices = res.rows.map(device => ({
|
||||||
|
...device,
|
||||||
|
showConfirm: false,
|
||||||
|
checked: false
|
||||||
|
}));
|
||||||
|
this.total = res.total;
|
||||||
|
this.deviceList = newDevices
|
||||||
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 发送文本消息
|
||||||
|
async sendTextMessage() {
|
||||||
|
// 防重复提交
|
||||||
|
if (this.isSending) return;
|
||||||
|
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||||
|
const deviceIds = selectedDevices.map(item => item.id);
|
||||||
|
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
||||||
|
if (selectedDevices.length === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请选择一个设备',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.messageToSend) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入要发送的文字',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.isSending = true;
|
||||||
|
let loadingShown = false;
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '发送中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
loadingShown = true;
|
||||||
|
// 2. 准备请求数据
|
||||||
|
const batchId = generateShortId();
|
||||||
|
const data = {
|
||||||
|
sendMsg: this.messageToSend,
|
||||||
|
deviceIds: deviceIds,
|
||||||
|
batchId: batchId,
|
||||||
|
typeName: this.sendInfo.typeName,
|
||||||
|
batchId: batchId,
|
||||||
|
deviceImeiList: deviceImeiList
|
||||||
|
};
|
||||||
|
// 3.人员信息
|
||||||
|
const registerRes = await deviceSendMessage(data);
|
||||||
|
if (registerRes.code !== 200) {
|
||||||
|
uni.showToast({
|
||||||
|
title: registerRes.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 4. 获取设备状态
|
||||||
|
let deviceImei = this.sendInfo.deviceImei
|
||||||
|
let typeName = this.sendInfo.typeName
|
||||||
|
const statusRes = await getdeviceSTatus({
|
||||||
|
functionMode: 2,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei,
|
||||||
|
interval: 500
|
||||||
|
},
|
||||||
|
deviceRealTimeStatus
|
||||||
|
);
|
||||||
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
|
// 5. 显示成功弹窗
|
||||||
|
this.showPopupFlag = true
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
uni.showToast({
|
||||||
|
title: error.message,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading();
|
||||||
|
this.isSending = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
onPopupConfirm() {
|
||||||
onPullDownRefresh() {
|
this.showPopupFlag = false
|
||||||
// 执行下拉刷新时的操作,比如重新获取数据
|
uni.navigateBack()
|
||||||
this.getData();
|
console.log('用户点击了确定')
|
||||||
},
|
// 处理确认逻辑
|
||||||
/**
|
|
||||||
* 获取设备状态(带自动轮询)
|
|
||||||
* @param {number} val - 功能模式
|
|
||||||
* @param {string} batchId - 批次ID
|
|
||||||
* @param {number} [interval=1000] - 轮询间隔(毫秒)
|
|
||||||
*/
|
|
||||||
async getdeviceSTatus(val, batchId, interval = 800) {
|
|
||||||
const checkStatus = async () => {
|
|
||||||
try {
|
|
||||||
const data = {
|
|
||||||
functionMode: val,
|
|
||||||
batchId: batchId,
|
|
||||||
typeName: this.sendInfo.typeName,
|
|
||||||
deviceImei: this.sendInfo.deviceImei
|
|
||||||
};
|
|
||||||
const res = await deviceRealTimeStatus(data);
|
|
||||||
if (res.code !== 200) {
|
|
||||||
throw new Error(res.msg || '请求失败');
|
|
||||||
}
|
|
||||||
switch (res.data.functionAccess) {
|
|
||||||
case 'OK':
|
|
||||||
return res; // 成功完成
|
|
||||||
case 'ACTIVE':
|
|
||||||
await new Promise(r => setTimeout(r, interval));
|
|
||||||
return checkStatus(); // 继续轮询
|
|
||||||
case 'FAILED':
|
|
||||||
throw new Error('设备操作失败');
|
|
||||||
case 'TIMEOUT':
|
|
||||||
throw new Error('设备响应超时');
|
|
||||||
default:
|
|
||||||
throw new Error('未知状态');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return checkStatus();
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleSelect(index) {
|
|
||||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
|
||||||
this.$forceUpdate()
|
|
||||||
},
|
|
||||||
// 获取设备列表
|
|
||||||
getData(deviceType) {
|
|
||||||
this.loading = true;
|
|
||||||
let data = {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 50,
|
|
||||||
deviceType: deviceType
|
|
||||||
}
|
|
||||||
deviceInfo(data).then((res) => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
const newDevices = res.rows.map(device => ({
|
|
||||||
...device,
|
|
||||||
showConfirm: false,
|
|
||||||
checked: false
|
|
||||||
}));
|
|
||||||
this.total = res.total;
|
|
||||||
this.deviceList = newDevices
|
|
||||||
}
|
|
||||||
}).finally(() => {
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 发送文本消息
|
|
||||||
async sendTextMessage() {
|
|
||||||
// 防重复提交
|
|
||||||
if (this.isSending) return;
|
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
|
||||||
const deviceIds = selectedDevices.map(item => item.id);
|
|
||||||
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
|
||||||
if (selectedDevices.length === 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请选择一个设备',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.messageToSend) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请输入要发送的文字',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.isSending = true;
|
|
||||||
let loadingShown = false;
|
|
||||||
try {
|
|
||||||
uni.showLoading({
|
|
||||||
title: '发送中...',
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
loadingShown = true;
|
|
||||||
// 2. 准备请求数据
|
|
||||||
const batchId = generateShortId();
|
|
||||||
const data = {
|
|
||||||
sendMsg: this.messageToSend,
|
|
||||||
deviceIds: deviceIds,
|
|
||||||
batchId: batchId,
|
|
||||||
typeName: this.sendInfo.typeName,
|
|
||||||
batchId: batchId,
|
|
||||||
deviceImeiList: deviceImeiList
|
|
||||||
};
|
|
||||||
// 3.人员信息
|
|
||||||
const registerRes = await deviceSendMessage(data);
|
|
||||||
if (registerRes.code !== 200) {
|
|
||||||
uni.showToast({
|
|
||||||
title: registerRes.msg,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 4. 获取设备状态
|
|
||||||
const statusRes = await this.getdeviceSTatus(2, batchId);
|
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
|
||||||
// 5. 显示成功弹窗
|
|
||||||
this.showPopupFlag = true
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
uni.showToast({
|
|
||||||
title: error.message,
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
uni.hideLoading();
|
|
||||||
this.isSending = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onPopupConfirm() {
|
|
||||||
this.showPopupFlag = false
|
|
||||||
uni.navigateBack()
|
|
||||||
console.log('用户点击了确定')
|
|
||||||
// 处理确认逻辑
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
},
|
||||||
const eventChannel = this.getOpenerEventChannel();
|
onLoad(options) {
|
||||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
const eventChannel = this.getOpenerEventChannel();
|
||||||
eventChannel.on('deviceSend', (data) => {
|
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||||
console.log('Received detail data:', data);
|
eventChannel.on('deviceSend', (data) => {
|
||||||
this.getData(data.data.id)
|
console.log('Received detail data:', data);
|
||||||
this.sendInfo = data.data
|
this.getData(data.data.id)
|
||||||
});
|
this.sendInfo = data.data
|
||||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
});
|
||||||
eventChannel.emit('ack', {})
|
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||||
},
|
eventChannel.emit('ack', {})
|
||||||
}
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.container {
|
.container {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background-color: rgb(18, 18, 18);
|
background-color: rgb(18, 18, 18);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-list {
|
.device-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-card {
|
.device-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox {
|
.checkbox {
|
||||||
width: 40rpx;
|
width: 40rpx;
|
||||||
height: 40rpx;
|
height: 40rpx;
|
||||||
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
border-radius: 4rpx;
|
border-radius: 4rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox.checked {
|
.checkbox.checked {
|
||||||
background-color: rgb(187, 230, 0);
|
background-color: rgb(187, 230, 0);
|
||||||
border-color: rgb(187, 230, 0);
|
border-color: rgb(187, 230, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-content {
|
.device-content {
|
||||||
background-color: rgb(26, 26, 26);
|
background-color: rgb(26, 26, 26);
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
/* display: flex; */
|
/* display: flex; */
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-header {
|
.device-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 15rpx;
|
margin-bottom: 15rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-name {
|
.device-name {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
margin-left: 12rpx;
|
margin-left: 12rpx;
|
||||||
line-height: 50rpx;
|
line-height: 50rpx;
|
||||||
width: 83%;
|
width: 83%;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ID {
|
.ID {
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: rgba(255, 255, 255, 0.6);
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-status {
|
.device-status {
|
||||||
width: 122rpx;
|
width: 122rpx;
|
||||||
height: 52rpx;
|
height: 52rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
border-radius: 0px 8px 0px 8px;
|
border-radius: 0px 8px 0px 8px;
|
||||||
background-color: rgb(42, 42, 42);
|
background-color: rgb(42, 42, 42);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0rpx;
|
top: 0rpx;
|
||||||
right: 0rpx;
|
right: 0rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 52rpx;
|
line-height: 52rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.online {
|
.online {
|
||||||
color: rgb(187, 230, 0);
|
color: rgb(187, 230, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.unline {
|
.unline {
|
||||||
color: rgba(255, 255, 255, 0.4);
|
color: rgba(255, 255, 255, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-info {
|
.device-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
padding-top: 10rpx;
|
padding-top: 10rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.deviceIMG {
|
.deviceIMG {
|
||||||
width: 100rpx;
|
width: 100rpx;
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: rgba(42, 42, 42, 0.6);
|
background-color: rgba(42, 42, 42, 0.6);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.IMG {
|
.IMG {
|
||||||
width: 68rpx;
|
width: 68rpx;
|
||||||
height: 50rpx;
|
height: 50rpx;
|
||||||
margin-left: 17%;
|
margin-left: 17%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.onlines {
|
.onlines {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.onlines::before {
|
.onlines::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 15rpx;
|
width: 15rpx;
|
||||||
height: 15rpx;
|
height: 15rpx;
|
||||||
background: rgb(0, 171, 103);
|
background: rgb(0, 171, 103);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
top: 20rpx;
|
top: 20rpx;
|
||||||
left: -20rpx
|
left: -20rpx
|
||||||
}
|
}
|
||||||
|
|
||||||
.unlines {
|
.unlines {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unlines::before {
|
.unlines::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 15rpx;
|
width: 15rpx;
|
||||||
height: 15rpx;
|
height: 15rpx;
|
||||||
background: rgba(255, 255, 255, 0.4);
|
background: rgba(255, 255, 255, 0.4);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
top: 20rpx;
|
top: 20rpx;
|
||||||
left: -20rpx
|
left: -20rpx
|
||||||
}
|
}
|
||||||
|
|
||||||
.line {
|
.line {
|
||||||
width: 2rpx;
|
width: 2rpx;
|
||||||
height: 24rpx;
|
height: 24rpx;
|
||||||
background: linear-gradient(90deg,
|
background: linear-gradient(90deg,
|
||||||
rgba(0, 0, 0, 0) 0%,
|
rgba(0, 0, 0, 0) 0%,
|
||||||
rgb(255, 255, 255) 50%,
|
rgb(255, 255, 255) 50%,
|
||||||
rgba(255, 255, 255, 0) 100%);
|
rgba(255, 255, 255, 0) 100%);
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ql-editor {
|
.ql-editor {
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: rgba(255, 255, 255, 0.6);
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ql-input {
|
.ql-input {
|
||||||
width: 95.9%;
|
width: 95.9%;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 30rpx;
|
padding: 30rpx;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
background: rgb(26, 26, 26);
|
background: rgb(26, 26, 26);
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
color: rgba(255, 255, 255, 0.8);
|
color: rgba(255, 255, 255, 0.8);
|
||||||
background: rgba(42, 42, 42, 1);
|
background: rgba(42, 42, 42, 1);
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
padding: 10rpx;
|
padding: 10rpx;
|
||||||
height: 150rpx;
|
height: 150rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editInfmation {
|
.editInfmation {
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
border-radius: 40rpx 40rpx 0px 0px;
|
border-radius: 40rpx 40rpx 0px 0px;
|
||||||
background: rgba(28, 28, 28, 1);
|
background: rgba(28, 28, 28, 1);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 50rpx;
|
bottom: 50rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-btn {
|
.login-btn {
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
background-color: rgb(187, 230, 0);
|
background-color: rgb(187, 230, 0);
|
||||||
color: rgb(35, 35, 35);
|
color: rgb(35, 35, 35);
|
||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
.checkbox.disabled {
|
|
||||||
opacity: 0.5;
|
.checkbox.disabled {
|
||||||
background-color: rgba(255, 255, 255, 0.1) !important;
|
opacity: 0.5;
|
||||||
border-color: rgba(255, 255, 255, 0.2) !important;
|
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||||
pointer-events: none; /* 阻止点击事件 */
|
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||||
}
|
pointer-events: none;
|
||||||
/* 可选:离线设备的卡片整体置灰 */
|
/* 阻止点击事件 */
|
||||||
.device-card[data-offline="true"] {
|
}
|
||||||
opacity: 0.6;
|
|
||||||
}
|
/* 可选:离线设备的卡片整体置灰 */
|
||||||
|
.device-card[data-offline="true"] {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -2,15 +2,67 @@
|
|||||||
* 生成短ID (16位字符)
|
* 生成短ID (16位字符)
|
||||||
*/
|
*/
|
||||||
export const generateShortId = () => {
|
export const generateShortId = () => {
|
||||||
const crypto = window.crypto || window.msCrypto;
|
const crypto = window.crypto || window.msCrypto;
|
||||||
|
|
||||||
if (crypto?.getRandomValues) {
|
if (crypto?.getRandomValues) {
|
||||||
return Array.from(crypto.getRandomValues(new Uint32Array(3)))
|
return Array.from(crypto.getRandomValues(new Uint32Array(3)))
|
||||||
.map(n => n.toString(36))
|
.map(n => n.toString(36))
|
||||||
.join('')
|
.join('')
|
||||||
.slice(0, 16);
|
.slice(0, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Date.now().toString(36) + Math.random().toString(36).substr(2, 8);
|
return Date.now().toString(36) + Math.random().toString(36).substr(2, 8);
|
||||||
};
|
};
|
||||||
export default generateShortId;
|
export default generateShortId;
|
||||||
|
|
||||||
|
// 获取设备实时状态的
|
||||||
|
/**
|
||||||
|
* 获取设备状态(带自动轮询)
|
||||||
|
* @param {Object} options - 配置对象
|
||||||
|
* @param {number} options.functionMode - 功能模式
|
||||||
|
* @param {string} options.batchId - 批次ID
|
||||||
|
* @param {Object} options.sendInfo - 设备信息
|
||||||
|
* @param {string} options.sendInfo.typeName - 类型名称
|
||||||
|
* @param {string} options.sendInfo.deviceImei - 设备IMEI
|
||||||
|
* @param {number} [options.interval=500] - 轮询间隔(毫秒)
|
||||||
|
* @param {Function} apiClient - 接口调用函数
|
||||||
|
*/
|
||||||
|
export async function getdeviceSTatus({
|
||||||
|
functionMode,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei,
|
||||||
|
interval
|
||||||
|
}, apiClient) {
|
||||||
|
const checkStatus = async () => {
|
||||||
|
try {
|
||||||
|
const res = await apiClient({
|
||||||
|
functionMode,
|
||||||
|
batchId,
|
||||||
|
typeName,
|
||||||
|
deviceImei
|
||||||
|
});
|
||||||
|
if (res.code !== 200) {
|
||||||
|
throw new Error(res.msg || '请求失败');
|
||||||
|
}
|
||||||
|
switch (res.data.functionAccess) {
|
||||||
|
case 'OK':
|
||||||
|
return res;
|
||||||
|
case 'ACTIVE':
|
||||||
|
await new Promise(r => setTimeout(r, interval));
|
||||||
|
return checkStatus();
|
||||||
|
case 'FAILED':
|
||||||
|
throw new Error('设备操作失败');
|
||||||
|
case 'TIMEOUT':
|
||||||
|
throw new Error('设备响应超时');
|
||||||
|
default:
|
||||||
|
throw new Error('未知状态');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('设备状态轮询错误:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return checkStatus();
|
||||||
|
}
|
Reference in New Issue
Block a user