1
0
forked from dyf/APP

设备发送

This commit is contained in:
fengerli
2025-08-14 16:05:16 +08:00
parent a773823c3f
commit 9bac0995a3
3 changed files with 1363 additions and 1357 deletions

View File

@ -66,7 +66,6 @@
data() {
return {
deviceList: [],
messageToSend: '', //发送信息
showPopupFlag: false,
popupTitle: '',
popupMessage: '确认要对所选设备开启强制报警?',
@ -88,7 +87,7 @@
* @param {string} batchId - 批次ID
* @param {number} [interval=1000] - 轮询间隔(毫秒)
*/
async getdeviceSTatus(val, batchId, interval =800) {
async getdeviceSTatus(val, batchId, interval = 800) {
let retries = 0;
const checkStatus = async () => {
try {
@ -163,7 +162,6 @@
// 强制报警
forceAlarm() {
const selectedDevices = this.deviceList.filter(item => item.checked)
const deviceIds = selectedDevices.map(item => item.id);
if (selectedDevices.length === 0) {
uni.showToast({
title: '请选择一个设备',
@ -192,25 +190,25 @@
this.showPopupFlag = true;
this.pendingAlarmAction = 0
},
async sendAlarmCommand(type) {
// 确认
async sendAlarmCommand() {
const selectedDevices = this.deviceList.filter(item => item.checked);
const deviceIds = selectedDevices.map(item => item.id);
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
let loadingShown = false;
const isAlarming = this.pendingAlarmAction == 1;
try {
uni.showLoading({
title: '报警中...',
title: isAlarming ? '设备报警中...' : '解除报警中...',
mask: true
});
loadingShown = true;
// 2. 准备请求数据
const batchId = generateShortId();
const data = {
sendMsg: this.messageToSend,
deviceIds: deviceIds,
batchId: batchId,
typeName: this.sendInfo.typeName,
deviceImeiList: deviceImeiList
deviceImeiList: deviceImeiList,
instructValue: this.pendingAlarmAction == 1 ? '1' : '0'
};
// 3.人员信息
const registerRes = await deviceSendAlarmMessage(data);

View File

@ -63,11 +63,9 @@
{{ deviceInfo.address }}
</view>
</view>
</view>
</view>
<view class="callpolice" v-if="deviceInfo.onlineStatus == 0 && deviceInfo.alarmStatus == 1">
<view class="callpolice" v-if="deviceInfo.onlineStatus == 1 && deviceInfo.alarmStatus == 1">
<view class="">设备强制报警中</view>
<view>
<uni-icons type="closeempty" size="15" color="rgba(255, 255, 255, 0.9)"
@ -78,8 +76,6 @@
<text class="info-label">灯光亮度</text>
<text class="info-value status-running">{{ sliderValue }}%</text>
</view>
<!-- 灯光亮度控制 -->
<view class="control-card" @touchstart="cardTouchStart" @touchmove="cardTouchMove"
@touchend="cardTouchEnd">
@ -164,8 +160,7 @@
</view>
<view class="form-row">
<input class="form-input1" maxlength="20" placeholder="请输入文字" v-model="messageToSend"
@input="filterChinese" />
<input class="form-input1" maxlength="20" placeholder="请输入文字" v-model="messageToSend" />
</view>
</view>
<!-- 产品信息 -->
@ -274,11 +269,11 @@
</template>
<script>
import MqttClient from '@/utils/mqtt.js';
import {
import MqttClient from '@/utils/mqtt.js';
import {
generateShortId
} from '@/utils/function.js';
import {
} from '@/utils/function.js';
import {
deviceDetail,
registerPersonInfo,
deviceSendMessage,
@ -287,16 +282,16 @@
laserModeSettings, //激光模式设置
lightBrightnessSettings, //灯光亮度设置
deviceRealTimeStatus //设备状态
} from '@/api/6170/deviceControl.js'
import {
} from '@/api/6170/deviceControl.js'
import {
baseURL,
getToken,
clientid
} from '@/utils/request'
import {
} from '@/utils/request'
import {
deviceSendAlarmMessage
} from '@/api/6170/callPolice.js'
export default {
} from '@/api/6170/callPolice.js'
export default {
data() {
return {
lastBrightnessTime: 0,
@ -390,15 +385,6 @@
};
return checkStatus();
},
filterChinese(e) {
const value = e.detail.value;
// 允许中文和常见中文标点
this.messageToSend = value.replace(/[^\u4e00-\u9fa5“”【】《》…—]/g, '');
// 修复某些平台输入法兼容性问题
this.$nextTick(() => {
e.target.value = this.messageToSend;
});
},
// 点击弹框外的区域关闭
closePopup() {
this.lightModeA = false;
@ -413,7 +399,7 @@
uni.navigateTo({
url: '/pages/common/map/index',
events: {
ack: function(data) {}
ack: function (data) { }
},
success: (res) => {
res.eventChannel.emit('Map', {
@ -422,12 +408,7 @@
}
})
},
// 强制报警()
handlePolice() {
this.popupType = 'cancel';
this.popupMessage = '确认要解除所选设备的报警状态';
this.showPopupFlag = true;
},
// ***********进度条***********
cardTouchStart(e) {
if (!this.cardRect) return;
@ -803,7 +784,7 @@
uni.navigateTo({
url: '/pages/6170/share/index',
events: {
ack: function(data) {}
ack: function (data) { }
},
success: (res) => {
res.eventChannel.emit('share', {
@ -891,34 +872,61 @@
this.isSending = false;
}
},
// 所有弹框,确定关闭按钮
onPopupConfirm() {
this.showPopupFlag = false
},
// 解除报警
onPopupConfirmPolice() {
let data = {
// 强制报警()
handlePolice() {
this.popupType = 'cancel';
this.popupMessage = '确认要解除所选设备的报警状态';
this.showPopupFlag = true;
},
// 解除报警逻辑
async onPopupConfirmPolice() {
try {
uni.showLoading({
title: '解除告警中...',
mask: true
});
// 2. 准备请求数据
const batchId = generateShortId();
const data = {
deviceIds: this.apiType === 'listA' ? [this.deviceID] : [this.itemInfo.deviceId],
batchId: batchId,
typeName: this.itemInfo.typeName,
deviceImeiList: [this.itemInfo.deviceImei],
instructValue: 0, // '解除报警'
}
deviceSendAlarmMessage(data).then((res) => {
if (res.code == 200) {
};
// 3.人员信息
const registerRes = await deviceSendAlarmMessage(data);
if (registerRes.code !== 200) {
uni.showToast({
title: res.msg,
title: registerRes.msg,
icon: 'none'
})
return
}
// 4. 获取设备状态 批量的报警解除报警发送信息都传2单次的都传1
const statusRes = await this.getdeviceSTatus(2, batchId);
if (statusRes.data.functionAccess === 'OK') {
uni.showToast({
title: statusRes.msg,
icon: 'none'
});
this.showPopupFlag = false
setTimeout(() => {
// 刷新详情接口
this.fetchDeviceDetail(this.deviceID);
uni.$emit('deviceStatusUpdate', {});
}, 500)
} else {
this.showPopupFlag = false
}
} catch (error) {
uni.showToast({
title: res.msg,
title: error.message,
icon: 'none'
});
} finally {
uni.hideLoading();
}
});
},
// 发送文本消息
async sendTextMessage() {
@ -1129,11 +1137,11 @@
}
},
}
}
</script>
<style scoped>
.page-loading-mask {
.page-loading-mask {
position: fixed;
top: 0;
left: 0;
@ -1144,36 +1152,36 @@
justify-content: center;
align-items: center;
z-index: 9999;
}
}
/* 优化权限控制区域的显示 */
.mode-section,
.form-section {
/* 优化权限控制区域的显示 */
.mode-section,
.form-section {
transition: opacity 0.3s ease;
}
}
.device-detail-container {
.device-detail-container {
padding: 30rpx;
background: #121212;
min-height: 100vh;
}
}
.status-bar {
.status-bar {
display: flex;
justify-content: space-between;
margin-bottom: 40rpx;
}
}
.time {
.time {
font-size: 36rpx;
font-weight: bold;
}
}
.battery {
.battery {
font-size: 36rpx;
}
}
.battery-section {
.battery-section {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
padding: 30rpx;
@ -1181,38 +1189,38 @@
justify-content: space-between;
margin-bottom: 20rpx;
align-items: center;
}
}
.battery-info,
.duration {
.battery-info,
.duration {
display: flex;
flex-direction: column;
align-items: center;
}
}
.bipImg {
.bipImg {
width: 204rpx;
height: 144rpx;
margin-top: 30rpx;
}
}
.dlIMG {
.dlIMG {
width: 52rpx;
height: 52rpx;
}
}
.chargeStateIMG {
.chargeStateIMG {
width: 27rpx;
height: 37rpx;
margin-left: 10rpx;
}
}
.cpIMG {
.cpIMG {
width: 66rpx;
height: 66rpx;
}
}
.battery-sectionLeft {
.battery-sectionLeft {
width: 308rpx;
height: 220rpx;
background: rgba(42, 42, 42, 0.5);
@ -1220,121 +1228,121 @@
text-align: center;
align-items: center;
line-height: 220rpx;
}
}
.percentage {
.percentage {
font-size: 48rpx;
font-weight: bold;
color: #007AFF;
}
}
.label {
.label {
font-size: 28rpx;
color: #666;
margin-top: 10rpx;
}
}
.battery-v1 {
.battery-v1 {
display: flex;
align-items: center;
margin-bottom: 10rpx;
}
}
.battery-v2 {
.battery-v2 {
color: rgba(255, 255, 255, 0.87);
margin-left: 18rpx;
font-size: 32rpx;
}
}
.battery-v3 {
.battery-v3 {
color: rgba(255, 255, 255, 0.6);
margin-left: 25rpx;
font-size: 26rpx;
}
}
.mode-v3 {
.mode-v3 {
color: rgba(255, 255, 255, 0.6);
font-size: 26rpx;
padding-top: 10rpx;
}
}
.info-card {
.info-card {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
padding: 10rpx 20rpx 5rpx 20rpx;
margin-bottom: 20rpx;
}
}
.info-row {
.info-row {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
}
}
.info-label {
.info-label {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.87);
white-space: nowrap;
}
}
.info-value {
.info-value {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.87);
}
}
.status-running {
.status-running {
color: rgba(255, 255, 255, 0.6);
text-align: end;
}
}
.locationGPS {
.locationGPS {
width: 88%;
text-align: end;
float: right;
line-height: 50rpx;
}
}
.control-card {
.control-card {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
margin-bottom: 20rpx;
position: relative;
}
}
.light {
.light {
position: absolute;
/* top:10rpx; */
color: rgba(74, 74, 74, 0.87);
top: 58rpx;
left: 108rpx
}
}
.section-title {
.section-title {
font-size: 32rpx;
margin-bottom: 20rpx;
display: block;
color: rgba(255, 255, 255, 0.87);
}
}
.slider-container {
.slider-container {
display: flex;
align-items: center;
}
}
.slider {
.slider {
flex: 1;
margin: 0 20rpx;
}
}
.mode-buttons {
.mode-buttons {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
}
.mode_1 {
.mode_1 {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx;
@ -1343,9 +1351,9 @@
text-align: center;
color: rgba(255, 255, 255, 0.6);
padding-top: 37rpx;
}
}
.mode-v1 {
.mode-v1 {
background: #1A1A1A;
border-radius: 18rpx;
height: 150rpx;
@ -1353,17 +1361,17 @@
width: 47%;
display: flex;
text-align: center;
}
}
.mode-v2 {
.mode-v2 {
display: flex;
align-items: center;
text-align: center;
margin-left: 40rpx;
}
}
.callpolice {
.callpolice {
display: flex;
justify-content: space-between;
border-radius: 16rpx;
@ -1373,35 +1381,35 @@
color: #fff;
line-height: 35rpx;
font-size: 26rpx;
}
}
.example-body {
.example-body {
position: absolute;
left: 50%;
top: 65%;
width: 100%;
transform: translate(-20%, -100%);
}
}
.icoContent {
.icoContent {
width: 320rpx;
height: 160rpx;
border-radius: 8rpx;
background: rgba(58, 58, 58, 1);
text-align: center;
line-height: 200rpx;
}
}
.img {
.img {
width: 62rpx;
height: 62rpx;
}
}
.example_title {
.example_title {
color: rgba(255, 255, 255, 0.87);
}
}
.mode-btn {
.mode-btn {
width: 48%;
height: 80rpx;
line-height: 80rpx;
@ -1410,82 +1418,82 @@
border-radius: 8rpx;
font-size: 28rpx;
border: none;
}
}
.mode-btn.active {
.mode-btn.active {
background-color: #007AFF;
color: #fff;
}
}
.form-section {
.form-section {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
}
}
.form-row {
.form-row {
display: flex;
align-items: center;
margin-bottom: 20rpx;
background: rgba(42, 42, 42, 1);
border-radius: 16rpx;
padding-left: 20rpx;
}
}
.form-label {
.form-label {
font-size: 32rpx;
color: rgba(255, 255, 255, 0.87);
white-space: nowrap;
}
}
.form-input {
.form-input {
height: 80rpx;
border: 1rpx solid transparent;
font-size: 32rpx;
color: rgba(255, 255, 255, 0.87);
width: 100%;
}
}
.form-input1 {
.form-input1 {
height: 80rpx;
border: 1rpx solid transparent;
font-size: 32rpx;
color: rgba(255, 255, 255, 0.87);
width: 98%;
}
}
.product-section {
.product-section {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
}
.product-tabs {
.product-tabs {
display: flex;
margin-top: 20rpx;
}
}
.tab {
.tab {
padding: 15rpx 30rpx;
font-size: 28rpx;
color: #666;
border-bottom: 4rpx solid transparent;
}
}
.tab.active {
.tab.active {
color: #007AFF;
border-bottom-color: #007AFF;
}
}
.action-buttons {
.action-buttons {
padding: 30rpx 0;
}
}
.send-btn {
.send-btn {
background-color: rgb(187, 230, 0);
color: rgba(35, 35, 35, 0.87);
height: 50rpx;
@ -1498,9 +1506,9 @@
position: absolute;
right: 70rpx;
}
}
.send-btn1 {
.send-btn1 {
background-color: rgb(187, 230, 0);
color: rgba(35, 35, 35, 0.87);
height: 50rpx;
@ -1513,11 +1521,11 @@
position: absolute;
right: 0rpx;
top: -70rpx
}
}
/* 遮罩层 */
.agreement-mask {
/* 遮罩层 */
.agreement-mask {
position: fixed;
top: 0;
left: 0;
@ -1528,10 +1536,10 @@
justify-content: center;
align-items: center;
z-index: 9999;
}
}
/* 弹窗主体 */
.agreement-popup {
/* 弹窗主体 */
.agreement-popup {
width: 100%;
height: 50%;
background-color: rgb(42, 42, 42);
@ -1540,9 +1548,9 @@
box-sizing: border-box;
position: absolute;
bottom: 0rpx;
}
}
.agreement-popupB {
.agreement-popupB {
width: 100%;
height: 32%;
background-color: rgb(42, 42, 42);
@ -1551,66 +1559,66 @@
box-sizing: border-box;
position: absolute;
bottom: 0rpx;
}
}
.agreement-popupC {
.agreement-popupC {
width: 80%;
background-color: rgb(42, 42, 42);
border-radius: 40rpx;
padding: 40rpx;
box-sizing: border-box;
border: 1px solid rgba(255, 200, 78, 1);
}
}
.popup-Title {
.popup-Title {
color: rgba(255, 200, 78, 1);
}
}
/* 标题 */
.popup-title {
/* 标题 */
.popup-title {
font-size: 36rpx;
text-align: center;
margin-bottom: 30rpx;
color: rgba(255, 255, 255, 0.87);
}
}
/* 内容文本 */
.popup-content {
/* 内容文本 */
.popup-content {
font-size: 30rpx;
line-height: 1.6;
color: rgba(255, 255, 255, 0.87);
margin-bottom: 50rpx;
}
}
.item {
.item {
padding: 10px;
margin: 5px 0;
display: flex;
align-items: center;
cursor: pointer;
transition: background-color 0.3s;
}
}
.setIMG {
.setIMG {
width: 24px;
height: 24px;
margin-right: 10px;
}
}
.item.selected {
.item.selected {
background-color: rgb(58, 58, 58);
color: rgba(255, 255, 255, 0.87);
border-radius: 8rpx;
}
}
/* 按钮容器 */
.popup-buttons {
/* 按钮容器 */
.popup-buttons {
display: flex;
justify-content: space-between;
}
}
/*确定按钮 */
.agree {
/*确定按钮 */
.agree {
background-color: rgb(187, 230, 0);
color: #232323;
border: none;
@ -1622,54 +1630,54 @@
position: absolute;
bottom: 0rpx;
left: 0rpx
}
}
/* 通用按钮样式 */
.btn {
/* 通用按钮样式 */
.btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
font-size: 32rpx;
margin: 0 20rpx;
}
}
/* 不同意按钮 */
.disagree {
/* 不同意按钮 */
.disagree {
background-color: transparent;
color: rgba(255, 255, 255, 0.87);
border: 1px solid rgba(255, 200, 78, 0.7);
font-size: 24rpx;
color: rgba(255, 200, 78, 1);
}
}
/* 同意按钮 */
.agreeBtn {
/* 同意按钮 */
.agreeBtn {
background-color: rgba(255, 200, 78, 1);
color: #232323;
border: none;
font-size: 24rpx;
}
}
.right-icons {
.right-icons {
/* display: flex; */
align-items: center;
}
}
.toggle-icon {
.toggle-icon {
cursor: pointer;
font-size: 16px;
margin-top: -40rpx;
}
}
.icon {
.icon {
font-size: 14px;
color: #fff;
}
}
.form-content {
.form-content {
transition: all 0.3s ease;
margin-top: 60rpx;
position: relative;
}
}
</style>

View File

@ -31,7 +31,7 @@
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
<uni-swipe-action-item :right-options="Options"
@click="handleSwipeClick($event, item, index)" class="device-card"
:style="{ border: item.communicationMode==0 && item.onlineStatus==0 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
<view @click.stop="handleFile(item)">
<view class="device-header">
<view class="deviceIMG">
@ -54,7 +54,7 @@
</view>
</view>
<view class="device-callpolice"
v-if="item.communicationMode==0 && item.onlineStatus==0 && item.alarmStatus==1">
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
报警中</view>
<view v-if="item.communicationMode==1">
<view class="device-status online">已连接</view>