解决版本冲突
This commit is contained in:
@ -6,7 +6,7 @@ const config = {
|
|||||||
API_PREFIX: '',
|
API_PREFIX: '',
|
||||||
// MQTT 配置
|
// MQTT 配置
|
||||||
MQTT_HOST: '47.120.79.150',
|
MQTT_HOST: '47.120.79.150',
|
||||||
MQTT_PORT: 8083,
|
MQTT_PORT: 9083,
|
||||||
MQTT_USERNAME: 'admin',
|
MQTT_USERNAME: 'admin',
|
||||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||||
},
|
},
|
||||||
@ -16,7 +16,7 @@ const config = {
|
|||||||
API_PREFIX: '',
|
API_PREFIX: '',
|
||||||
// MQTT 配置
|
// MQTT 配置
|
||||||
MQTT_HOST: '47.120.79.150',
|
MQTT_HOST: '47.120.79.150',
|
||||||
MQTT_PORT: 8083,
|
MQTT_PORT: 9083,
|
||||||
MQTT_USERNAME: 'admin',
|
MQTT_USERNAME: 'admin',
|
||||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||||
}
|
}
|
||||||
|
|||||||
69
pages.json
69
pages.json
@ -1,21 +1,16 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/common/login/index",
|
"path": "pages/common/login/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/common/index/index",
|
"path": "pages/common/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom",
|
||||||
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -39,7 +34,8 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/common/send/index",
|
"path": "pages/common/send/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "发送信息"
|
"navigationBarTitleText": "发送信息",
|
||||||
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -66,6 +62,18 @@
|
|||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/6170/callPolice/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "报警"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/210/deviceControl/index",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/common/operationVideo/index",
|
"path": "pages/common/operationVideo/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -94,29 +102,25 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/common/addBLE/addEquip",
|
"path": "pages/common/addBLE/addEquip",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
|
||||||
"navigationBarTitleText": "添加设备"
|
"navigationBarTitleText": "添加设备"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/common/addBLE/LinkBle",
|
"path": "pages/common/addBLE/LinkBle",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
|
||||||
"navigationBarTitleText": "扫描到的设备"
|
"navigationBarTitleText": "扫描到的设备"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/6155/deviceDetail",
|
"path": "pages/6155/deviceDetail",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
|
||||||
"navigationBarTitleText": "HBY 6155"
|
"navigationBarTitleText": "HBY 6155"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/6155/ImgCrop",
|
"path": "pages/6155/ImgCrop",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
|
||||||
"navigationBarTitleText": "图像裁剪",
|
"navigationBarTitleText": "图像裁剪",
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"fullscreen": true
|
"fullscreen": true
|
||||||
@ -124,8 +128,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/650/HBY650",
|
"path": "pages/650/HBY650",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
|
||||||
"navigationBarTitleText": "HBY650"
|
"navigationBarTitleText": "HBY650"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -147,7 +150,6 @@
|
|||||||
"navigationBarTitleText": "所有分享"
|
"navigationBarTitleText": "所有分享"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/6170/share/index",
|
"path": "pages/6170/share/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -165,15 +167,38 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "分享管理"
|
"navigationBarTitleText": "分享管理"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/210/onlineDevice/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "联机设备"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/210/addDevice/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "添加联机设备"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/210/historyRecords/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "历史记录"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/210/call/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "呼叫"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
"color": "#fff",
|
"color": "#fff",
|
||||||
"selectedColor": "#BBE600",
|
"selectedColor": "#BBE600",
|
||||||
"backgroundColor": "#202020",
|
"backgroundColor": "#202020",
|
||||||
"list": [{
|
"list": [
|
||||||
|
{
|
||||||
"pagePath": "pages/common/index/index",
|
"pagePath": "pages/common/index/index",
|
||||||
"text": "我的设备",
|
"text": "我的设备",
|
||||||
"iconPath": "/static/tabs/device.png",
|
"iconPath": "/static/tabs/device.png",
|
||||||
|
|||||||
@ -249,14 +249,10 @@
|
|||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.onIntall()
|
this.onIntall()
|
||||||
// 绑定页面做了监听,新增成功,刷新页面
|
|
||||||
uni.$on('refreshDeviceList', () => {
|
|
||||||
this.onIntall()
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
// 组件销毁前移除监听器
|
// 组件销毁前移除监听器
|
||||||
uni.$off('refreshDeviceList');
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -3,9 +3,10 @@
|
|||||||
<!-- 设备列表 -->
|
<!-- 设备列表 -->
|
||||||
<view class="allSelect" @click="selectAll"> 全选</view>
|
<view class="allSelect" @click="selectAll"> 全选</view>
|
||||||
<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="toggleSelect(index)">
|
<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 }">
|
<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>
|
||||||
<!-- 设备信息 -->
|
<!-- 设备信息 -->
|
||||||
@ -47,12 +48,18 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||||
|
import {
|
||||||
|
generateShortId
|
||||||
|
} from '@/utils/function.js';
|
||||||
import {
|
import {
|
||||||
deviceInfo,
|
deviceInfo,
|
||||||
} from '@/api/common/index.js'
|
} from '@/api/common/index.js'
|
||||||
import {
|
import {
|
||||||
deviceSendAlarmMessage
|
deviceSendAlarmMessage
|
||||||
} from '@/api/6170/callPolice.js'
|
} from '@/api/6170/callPolice.js'
|
||||||
|
import {
|
||||||
|
deviceRealTimeStatus //设备状态
|
||||||
|
} from '@/api/6170/deviceControl.js'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
CustomPopup
|
CustomPopup
|
||||||
@ -60,13 +67,13 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
deviceList: [],
|
deviceList: [],
|
||||||
messageToSend: '', //发送信息
|
|
||||||
showPopupFlag: false,
|
showPopupFlag: false,
|
||||||
popupTitle: '',
|
popupTitle: '',
|
||||||
popupMessage: '确认要对所选设备开启强制报警?',
|
popupMessage: '确认要对所选设备开启强制报警?',
|
||||||
popupConfirmText: '确认',
|
popupConfirmText: '确认',
|
||||||
popupType: 'force', // 'force' or 'cancel'
|
popupType: 'force', // 'force' or 'cancel'
|
||||||
pendingAlarmAction: ''
|
pendingAlarmAction: '',
|
||||||
|
sendInfo: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -82,6 +89,44 @@
|
|||||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 获取设备状态(带自动轮询)
|
||||||
|
* @param {number} val - 功能模式
|
||||||
|
* @param {string} batchId - 批次ID
|
||||||
|
* @param {number} [interval=1000] - 轮询间隔(毫秒)
|
||||||
|
*/
|
||||||
|
async getdeviceSTatus(val, batchId, interval =500) {
|
||||||
|
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();
|
||||||
|
},
|
||||||
// 全选/取消全选
|
// 全选/取消全选
|
||||||
selectAll() {
|
selectAll() {
|
||||||
console.log('123');
|
console.log('123');
|
||||||
@ -97,7 +142,7 @@
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
let data = {
|
let data = {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 20,
|
pageSize: 50,
|
||||||
deviceType: deviceType
|
deviceType: deviceType
|
||||||
}
|
}
|
||||||
deviceInfo(data).then((res) => {
|
deviceInfo(data).then((res) => {
|
||||||
@ -117,7 +162,6 @@
|
|||||||
// 强制报警
|
// 强制报警
|
||||||
forceAlarm() {
|
forceAlarm() {
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||||
const deviceIds = selectedDevices.map(item => item.id);
|
|
||||||
if (selectedDevices.length === 0) {
|
if (selectedDevices.length === 0) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请选择一个设备',
|
title: '请选择一个设备',
|
||||||
@ -146,18 +190,40 @@
|
|||||||
this.showPopupFlag = true;
|
this.showPopupFlag = true;
|
||||||
this.pendingAlarmAction = 0
|
this.pendingAlarmAction = 0
|
||||||
},
|
},
|
||||||
sendAlarmCommand(type) {
|
// 确认
|
||||||
|
async sendAlarmCommand() {
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked);
|
const selectedDevices = this.deviceList.filter(item => item.checked);
|
||||||
const deviceIds = selectedDevices.map(item => item.id);
|
const deviceIds = selectedDevices.map(item => item.id);
|
||||||
|
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
||||||
|
const isAlarming = this.pendingAlarmAction == 1;
|
||||||
|
try {
|
||||||
|
|
||||||
let data = {
|
uni.showLoading({
|
||||||
|
title: isAlarming ? '设备报警中...' : '解除报警中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
// 2. 准备请求数据
|
||||||
|
const batchId = generateShortId();
|
||||||
|
const data = {
|
||||||
deviceIds: deviceIds,
|
deviceIds: deviceIds,
|
||||||
instructValue: this.pendingAlarmAction, // '强制或者解除'
|
typeName: this.sendInfo.typeName,
|
||||||
}
|
deviceImeiList: deviceImeiList,
|
||||||
deviceSendAlarmMessage(data).then((res) => {
|
batchId: batchId,
|
||||||
if (res.code == 200) {
|
instructValue: this.pendingAlarmAction == 1 ? '1' : '0'
|
||||||
|
};
|
||||||
|
const registerRes = await deviceSendAlarmMessage(data);
|
||||||
|
if (registerRes.code !== 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: registerRes.msg,
|
||||||
|
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
|
this.showPopupFlag = false
|
||||||
@ -165,18 +231,19 @@
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 500)
|
}, 500)
|
||||||
} else {
|
}
|
||||||
|
} catch (error) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: error.message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 点击确认状态
|
// 点击确认状态
|
||||||
onPopupConfirm() {
|
onPopupConfirm() {
|
||||||
this.sendAlarmCommand(this.popupType);
|
this.sendAlarmCommand(this.popupType);
|
||||||
|
|
||||||
// 处理确认逻辑
|
// 处理确认逻辑
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -184,7 +251,8 @@
|
|||||||
const eventChannel = this.getOpenerEventChannel();
|
const eventChannel = this.getOpenerEventChannel();
|
||||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||||
eventChannel.on('devicePolice', (data) => {
|
eventChannel.on('devicePolice', (data) => {
|
||||||
this.getData(data.data)
|
this.getData(data.data.id)
|
||||||
|
this.sendInfo = data.data
|
||||||
});
|
});
|
||||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||||
eventChannel.emit('ack', {})
|
eventChannel.emit('ack', {})
|
||||||
@ -410,4 +478,17 @@
|
|||||||
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 {
|
||||||
|
opacity: 0.5;
|
||||||
|
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||||
|
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||||
|
pointer-events: none;
|
||||||
|
/* 阻止点击事件 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 可选:离线设备的卡片整体置灰 */
|
||||||
|
.device-card[data-offline="true"] {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -309,6 +309,7 @@ export default {
|
|||||||
lightModeB: false,
|
lightModeB: false,
|
||||||
lightModeC: false, //激光提示框
|
lightModeC: false, //激光提示框
|
||||||
items: [],
|
items: [],
|
||||||
|
pendingMainMode: null, // 选中的索引
|
||||||
isFormExpanded: true, // 默认展开
|
isFormExpanded: true, // 默认展开
|
||||||
deviceID: '',
|
deviceID: '',
|
||||||
itemInfo: {},
|
itemInfo: {},
|
||||||
@ -350,16 +351,9 @@ export default {
|
|||||||
* @param {number} val - 功能模式
|
* @param {number} val - 功能模式
|
||||||
* @param {string} batchId - 批次ID
|
* @param {string} batchId - 批次ID
|
||||||
* @param {number} [interval=800] - 轮询间隔(毫秒)
|
* @param {number} [interval=800] - 轮询间隔(毫秒)
|
||||||
* @param {number} [maxRetries=10] - 最大重试次数
|
|
||||||
*/
|
*/
|
||||||
async getdeviceSTatus(val, batchId, interval = 800) {
|
async getdeviceSTatus(val, batchId, interval = 800) {
|
||||||
//let retries = 0;
|
|
||||||
const checkStatus = async () => {
|
const checkStatus = async () => {
|
||||||
// if (retries >= maxRetries) {
|
|
||||||
// throw new Error('超过最大重试次数');
|
|
||||||
// }
|
|
||||||
// retries++;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
functionMode: val,
|
functionMode: val,
|
||||||
@ -477,6 +471,7 @@ export default {
|
|||||||
uni.vibrateShort({
|
uni.vibrateShort({
|
||||||
type: 'light'
|
type: 'light'
|
||||||
});
|
});
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
deviceId: this.computedDeviceId,
|
deviceId: this.computedDeviceId,
|
||||||
instructValue: this.sliderValue + '.00',
|
instructValue: this.sliderValue + '.00',
|
||||||
@ -490,6 +485,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSliderChangeEnd(e) {
|
onSliderChangeEnd(e) {
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
let value = e.detail.value;
|
let value = e.detail.value;
|
||||||
if (value < 10) {
|
if (value < 10) {
|
||||||
value = 10;
|
value = 10;
|
||||||
@ -552,28 +554,51 @@ export default {
|
|||||||
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 selectedItem = this.items[index];
|
const item = this.items[index];
|
||||||
if (selectedItem.text === '激光') {
|
// 激光模式特殊处理
|
||||||
|
if (item.text === '激光') {
|
||||||
this.lightModeC = true;
|
this.lightModeC = true;
|
||||||
} else {
|
return;
|
||||||
// 更新选中状态
|
}
|
||||||
|
// 只更新临时选中状态
|
||||||
|
this.selectedItemIndex = index;
|
||||||
|
// UI高亮效果(不影响实际模式)
|
||||||
this.items = this.items.map((item, i) => ({
|
this.items = this.items.map((item, i) => ({
|
||||||
...item,
|
...item,
|
||||||
selected: i === index
|
selected: i === index
|
||||||
}));
|
}));
|
||||||
this.currentMainMode = selectedItem.text;
|
// 显示临时选中的模式名称(视觉反馈)
|
||||||
this.selectedItemIndex = index;
|
this.pendingMainMode = item.text;
|
||||||
// 强制更新视图(如果需要)
|
|
||||||
this.$forceUpdate();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// 灯光模式的确认
|
// 灯光模式的确认
|
||||||
async handleSumbit() {
|
handleSumbit() {
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 防重复提交
|
// 防重复提交
|
||||||
if (this.isProcessing) return;
|
if (this.isProcessing) return;
|
||||||
let loadingShown = false;
|
let loadingShown = false;
|
||||||
try {
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '处理中...',
|
title: '处理中...',
|
||||||
mask: true
|
mask: true
|
||||||
@ -582,52 +607,52 @@ export default {
|
|||||||
this.isProcessing = true
|
this.isProcessing = true
|
||||||
if (this.selectedItemIndex === null) return;
|
if (this.selectedItemIndex === null) return;
|
||||||
const selectedItem = this.items[this.selectedItemIndex];
|
const selectedItem = this.items[this.selectedItemIndex];
|
||||||
// 准备请求数据
|
|
||||||
let data = {
|
let data = {
|
||||||
deviceId: this.computedDeviceId,
|
deviceId: this.computedDeviceId,
|
||||||
instructValue: selectedItem.instructValue,
|
instructValue: selectedItem.instructValue,
|
||||||
deviceImei: this.itemInfo.deviceImei,
|
deviceImei: this.itemInfo.deviceImei,
|
||||||
typeName: this.itemInfo.typeName,
|
typeName: this.itemInfo.typeName,
|
||||||
};
|
};
|
||||||
// 第一个请求:设置灯光模式
|
lightModeSettings(data).then((res) => {
|
||||||
const res = await lightModeSettings(data);
|
if (res.code == 200) {
|
||||||
if (res.code !== 200) {
|
// 只有确认成功才更新实际模式,选中模式
|
||||||
|
this.currentMainMode = this.pendingMainMode;
|
||||||
|
this.selectedItemIndex = selectedItem;
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
|
||||||
// 第二个请求:获取设备状态
|
|
||||||
const statusRes = await this.getdeviceSTatus(1);
|
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'none',
|
|
||||||
title: statusRes.msg
|
|
||||||
});
|
|
||||||
// 关闭弹窗
|
|
||||||
this.lightModeA = false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
uni.showToast({
|
|
||||||
title: error.message,
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
this.lightModeA = false;
|
||||||
this.isProcessing = false
|
this.isProcessing = false
|
||||||
|
loadingShown = false
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.isProcessing = false
|
||||||
|
loadingShown = false
|
||||||
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
// 激光模式
|
// 激光模式
|
||||||
lasermode() {
|
lasermode() {
|
||||||
this.lightModeC = true
|
this.lightModeC = true
|
||||||
},
|
},
|
||||||
// 激光确认框提交
|
// 激光确认框提交
|
||||||
async handleBtn() {
|
handleBtn() {
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 防重复提交
|
// 防重复提交
|
||||||
if (this.isProcessing) return;
|
if (this.isProcessing) return;
|
||||||
let loadingShown = false;
|
let loadingShown = false;
|
||||||
try {
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '处理中...',
|
title: '处理中...',
|
||||||
mask: true
|
mask: true
|
||||||
@ -641,37 +666,27 @@ export default {
|
|||||||
deviceImei: this.itemInfo.deviceImei,
|
deviceImei: this.itemInfo.deviceImei,
|
||||||
typeName: this.itemInfo.typeName,
|
typeName: this.itemInfo.typeName,
|
||||||
};
|
};
|
||||||
// 第一个请求
|
laserModeSettings(data).then((res) => {
|
||||||
const res = await laserModeSettings(data);
|
if (res.code == 200) {
|
||||||
if (res.code !== 200) {
|
|
||||||
uni.showToast({
|
|
||||||
title: res.msg,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 第二个请求
|
|
||||||
const statusRes = await this.getdeviceSTatus(1);
|
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: statusRes.msg // 添加默认提示
|
title: res.msg
|
||||||
});
|
});
|
||||||
// 更新状态
|
// 更新状态
|
||||||
this.isLaserOn = !this.isLaserOn;
|
this.isLaserOn = !this.isLaserOn;
|
||||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||||
this.lightModeC = false;
|
this.lightModeC = false;
|
||||||
}
|
this.isProcessing = false
|
||||||
|
loadingShown = false
|
||||||
} catch (error) {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message,
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
} finally {
|
this.isProcessing = false
|
||||||
uni.hideLoading();
|
loadingShown = false
|
||||||
this.isProcessing = false;
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
//激光取消
|
//激光取消
|
||||||
handleDisagree() {
|
handleDisagree() {
|
||||||
@ -721,18 +736,25 @@ export default {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 显示上传加载状态
|
// 显示上传加载状态
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '图片上传中...',
|
title: '图片上传中...',
|
||||||
mask: true
|
mask: true
|
||||||
});
|
});
|
||||||
loadingShown = true
|
loadingShown = true;
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: baseURL + '/app/bjq/device/uploadLogo',
|
url: baseURL + '/app/bjq/device/uploadLogo',
|
||||||
filePath: this.selectedImage,
|
filePath: this.selectedImage,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
formData: {
|
formData: {
|
||||||
deviceId: this.computedDeviceId,
|
deviceId: this.apiType === 'listA' ? this.deviceID : this.itemInfo.deviceId,
|
||||||
deviceImei: this.itemInfo.deviceImei,
|
deviceImei: this.itemInfo.deviceImei,
|
||||||
typeName: this.itemInfo.typeName,
|
typeName: this.itemInfo.typeName,
|
||||||
},
|
},
|
||||||
@ -740,43 +762,47 @@ export default {
|
|||||||
'Authorization': 'Bearer ' + getToken(),
|
'Authorization': 'Bearer ' + getToken(),
|
||||||
'clientid': clientid(),
|
'clientid': clientid(),
|
||||||
},
|
},
|
||||||
complete: (res) => { // 使用 complete 确保 hideLoading 总能被调用
|
complete: async (res) => {
|
||||||
try {
|
try {
|
||||||
|
uni.hideLoading(); // 首先关闭“
|
||||||
const responseData = JSON.parse(res.data);
|
const responseData = JSON.parse(res.data);
|
||||||
if (responseData.code === 200) {
|
if (responseData.code === 200) {
|
||||||
// 异步操作链
|
uni.showLoading({
|
||||||
this.getdeviceSTatus(1)
|
title: '等待设备响应...',
|
||||||
.then(statusRes => {
|
mask: true
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// 获取设备状态
|
||||||
|
const statusRes = await this.getdeviceSTatus(1);
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
|
uni.hideLoading();
|
||||||
this.selectedImage = '';
|
this.selectedImage = '';
|
||||||
|
this.file = null;
|
||||||
this.popupType = 'logo';
|
this.popupType = 'logo';
|
||||||
this.showPopupFlag = true;
|
this.showPopupFlag = true;
|
||||||
this.popupMessage = '上传成功';
|
this.popupMessage = '上传成功';
|
||||||
this.lightModeB = false;
|
this.lightModeB = false;
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
.catch(error => {
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message,
|
title: error.message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
.finally(() => {
|
|
||||||
uni.hideLoading(); // 在所有异步操作完成后关闭loading
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: responseData.msg || '上传失败',
|
title: responseData.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
uni.hideLoading();
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '解析响应失败',
|
title: e.message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
uni.hideLoading();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -795,8 +821,6 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// 发送人员信息
|
// 发送人员信息
|
||||||
async sendPersonnelInfo() {
|
async sendPersonnelInfo() {
|
||||||
if (this.isSending) return;
|
if (this.isSending) return;
|
||||||
@ -830,6 +854,13 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.isSending = true;
|
this.isSending = true;
|
||||||
let loadingShown = false;
|
let loadingShown = false;
|
||||||
try {
|
try {
|
||||||
@ -847,26 +878,20 @@ export default {
|
|||||||
deviceId: this.computedDeviceId,
|
deviceId: this.computedDeviceId,
|
||||||
deviceImei: this.itemInfo.deviceImei
|
deviceImei: this.itemInfo.deviceImei
|
||||||
};
|
};
|
||||||
// 3. 注册人员信息
|
|
||||||
const registerRes = await registerPersonInfo(data);
|
const registerRes = await registerPersonInfo(data);
|
||||||
if (registerRes.code !== 200) {
|
if (registerRes.code == 200) {
|
||||||
|
this.popupType = 'person';
|
||||||
|
this.showPopupFlag = true;
|
||||||
|
this.popupMessage = '人员信息发送成功';
|
||||||
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: registerRes.msg,
|
title: registerRes.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 4. 获取设备状态
|
|
||||||
const statusRes = await this.getdeviceSTatus(1);
|
|
||||||
// 只有当状态为'OK'时才显示成功弹窗
|
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
|
||||||
this.popupType = 'person';
|
|
||||||
this.showPopupFlag = true;
|
|
||||||
this.popupMessage = '人员信息发送成功';
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message,
|
title: error.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
@ -886,6 +911,13 @@ export default {
|
|||||||
},
|
},
|
||||||
// 解除报警逻辑
|
// 解除报警逻辑
|
||||||
async onPopupConfirmPolice() {
|
async onPopupConfirmPolice() {
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '解除告警中...',
|
title: '解除告警中...',
|
||||||
@ -900,7 +932,7 @@ export default {
|
|||||||
deviceImeiList: [this.itemInfo.deviceImei],
|
deviceImeiList: [this.itemInfo.deviceImei],
|
||||||
instructValue: 0, // '解除报警'
|
instructValue: 0, // '解除报警'
|
||||||
};
|
};
|
||||||
// 3.人员信息
|
// 3.解除告警状态
|
||||||
const registerRes = await deviceSendAlarmMessage(data);
|
const registerRes = await deviceSendAlarmMessage(data);
|
||||||
if (registerRes.code !== 200) {
|
if (registerRes.code !== 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -909,17 +941,22 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 4. 获取设备状态 ,批量的报警,解除报警,发送信息,都传2,单次的都传1
|
// 4. 获取设备状态
|
||||||
const statusRes = await this.getdeviceSTatus(2, batchId);
|
const statusRes = await this.getdeviceSTatus(2, batchId);
|
||||||
if (statusRes.data.functionAccess === 'OK') {
|
if (statusRes.data.functionAccess === 'OK') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: statusRes.msg,
|
title: statusRes.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
// 刷新详情接口
|
|
||||||
this.fetchDeviceDetail(this.computedDeviceId, true);
|
|
||||||
uni.$emit('deviceStatusUpdate', {});
|
uni.$emit('deviceStatusUpdate', {});
|
||||||
this.showPopupFlag = false
|
this.showPopupFlag = false
|
||||||
|
if (this.apiType === 'listA') {
|
||||||
|
this.fetchDeviceDetail(this.computedDeviceId)
|
||||||
|
} else {
|
||||||
|
// 分享权限详情
|
||||||
|
this.fetchSharedDeviceDetail(this.itemInfo.id)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -932,6 +969,13 @@ export default {
|
|||||||
},
|
},
|
||||||
// 发送文本消息
|
// 发送文本消息
|
||||||
async sendTextMessage() {
|
async sendTextMessage() {
|
||||||
|
if (this.deviceInfo.onlineStatus !== 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设备已离线',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 防重复提交
|
// 防重复提交
|
||||||
if (this.isSending) return;
|
if (this.isSending) return;
|
||||||
if (!this.messageToSend) {
|
if (!this.messageToSend) {
|
||||||
@ -981,6 +1025,7 @@ export default {
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
console.log('失败还是成功了');
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
this.isSending = false;
|
this.isSending = false;
|
||||||
}
|
}
|
||||||
@ -1002,25 +1047,9 @@ export default {
|
|||||||
this.messageToSend = res.data.sendMsg || '';
|
this.messageToSend = res.data.sendMsg || '';
|
||||||
this.sliderValue = res.data.lightBrightness || '25'
|
this.sliderValue = res.data.lightBrightness || '25'
|
||||||
let mainLightMode = parseInt(res.data.mainLightMode);
|
let mainLightMode = parseInt(res.data.mainLightMode);
|
||||||
switch (mainLightMode) {
|
// 取主灯光模式初始值
|
||||||
case 0:
|
this.currentMainMode = this.getMainLightModeLabel(mainLightMode)
|
||||||
this.currentMainMode = '关闭';
|
console.log(this.currentMainMode, 'this.currentMainMode');
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
this.currentMainMode = '强光';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
this.currentMainMode = '弱光';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
this.currentMainMode = '爆闪';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
this.currentMainMode = '泛光';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log('未知的灯光模式:', mainLightMode);
|
|
||||||
}
|
|
||||||
const laserMode = res.data.LaserLightMode;
|
const laserMode = res.data.LaserLightMode;
|
||||||
this.isLaserOn = laserMode === 1;
|
this.isLaserOn = laserMode === 1;
|
||||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||||
@ -1033,10 +1062,11 @@ export default {
|
|||||||
this.isSharedDevice = false;
|
this.isSharedDevice = false;
|
||||||
this.activePermissions = []; // 非分享设备清空权限
|
this.activePermissions = []; // 非分享设备清空权限
|
||||||
}
|
}
|
||||||
|
if (!isUpdate) {
|
||||||
// 关闭加载中
|
// 关闭加载中
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 检查权限的方法
|
// 检查权限的方法
|
||||||
hasPermission(permissionCode) {
|
hasPermission(permissionCode) {
|
||||||
@ -1050,25 +1080,48 @@ export default {
|
|||||||
async fetchDeviceDetail(id, isUpdate = false) {
|
async fetchDeviceDetail(id, isUpdate = false) {
|
||||||
try {
|
try {
|
||||||
const res = await deviceDetail(id)
|
const res = await deviceDetail(id)
|
||||||
|
if (res.code == 200) {
|
||||||
this.handleDeviceData(res, false, isUpdate)
|
this.handleDeviceData(res, false, isUpdate)
|
||||||
} catch (error) {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '获取详情失败',
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
if (!isUpdate) {
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (!isUpdate) {
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
// uni.showToast({
|
||||||
|
// title: error.msg,
|
||||||
|
// icon: 'none'
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 获取分享设备详情
|
// 获取分享设备详情
|
||||||
async fetchSharedDeviceDetail(id) {
|
async fetchSharedDeviceDetail(id) {
|
||||||
try {
|
try {
|
||||||
const res = await deviceShareId(id)
|
const res = await deviceShareId(id)
|
||||||
|
if (res.code == 200) {
|
||||||
this.handleDeviceData(res, true)
|
this.handleDeviceData(res, true)
|
||||||
} catch (error) {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '获取分享详情失败',
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
uni.showToast({
|
||||||
|
title: error.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 操作说明
|
// 操作说明
|
||||||
operatingInst() {
|
operatingInst() {
|
||||||
@ -1103,6 +1156,17 @@ export default {
|
|||||||
console.log('MQTT not connected, cannot query status.');
|
console.log('MQTT not connected, cannot query status.');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 灯光模式共用封装共其他地方使用
|
||||||
|
getMainLightModeLabel(mode) {
|
||||||
|
const modeMap = {
|
||||||
|
0: '关闭',
|
||||||
|
1: '强光',
|
||||||
|
2: '弱光',
|
||||||
|
3: '爆闪',
|
||||||
|
4: '泛光'
|
||||||
|
}
|
||||||
|
return modeMap[mode] || (console.log('未知的灯光模式:', mode), '未知');
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
@ -1127,68 +1191,59 @@ export default {
|
|||||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||||
try {
|
try {
|
||||||
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
||||||
//收到电量上报。
|
|
||||||
const parsedMessage = typeof payload === 'string' ? JSON.parse(
|
const parsedMessage = typeof payload === 'string' ? JSON.parse(
|
||||||
payload) :
|
payload) :
|
||||||
payload;
|
payload;
|
||||||
const deviceState = parsedMessage.state; // 直接取 state 数组
|
const deviceState = parsedMessage.state; // 直接取 state 数组
|
||||||
if (deviceState && deviceState[0] === 12) {
|
// 切换主灯光模式,亮度值设备同步
|
||||||
// 根据协议直接更新设备状态,提供即时反馈
|
if (!deviceState) return;
|
||||||
const mainLightMode = deviceState[1];
|
// 1设备切换灯光实时返回
|
||||||
switch (mainLightMode) {
|
switch (deviceState[0]) {
|
||||||
case 0:
|
|
||||||
this.currentMainMode = '关闭';
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
this.currentMainMode = '强光';
|
this.currentMainMode = this.getMainLightModeLabel(deviceState[
|
||||||
|
1]);
|
||||||
|
this.sliderValue = deviceState[2];
|
||||||
|
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
||||||
break;
|
break;
|
||||||
case 2:
|
// 12为设备实时上报
|
||||||
this.currentMainMode = '弱光';
|
case 12:
|
||||||
break;
|
this.currentMainMode = this.getMainLightModeLabel(deviceState[
|
||||||
case 3:
|
1]);
|
||||||
this.currentMainMode = '爆闪';
|
this.isLaserOn = deviceState[2] === 1;
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
this.currentMainMode = '泛光';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log('未知的灯光模式:', mainLightMode);
|
|
||||||
}
|
|
||||||
const laserMode = deviceState[2];
|
|
||||||
this.isLaserOn = laserMode === 1;
|
|
||||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||||
|
|
||||||
if (this.deviceInfo) {
|
if (this.deviceInfo) {
|
||||||
this.deviceInfo.batteryPercentage = deviceState[3];
|
this.deviceInfo.batteryPercentage = deviceState[3];
|
||||||
this.deviceInfo.chargeState = deviceState[4];
|
this.deviceInfo.chargeState = deviceState[4];
|
||||||
this.deviceInfo.batteryRemainingTime = deviceState[5];
|
this.deviceInfo.batteryRemainingTime = deviceState[5];
|
||||||
}
|
}
|
||||||
// 这里的10秒延迟是为了解决一个特定的后端问题:
|
|
||||||
// GPS坐标上报后,逆地址解析(将坐标转换为地址)需要一些时间。
|
|
||||||
// 如果立即请求设备详情,地址字段可能尚未更新。
|
|
||||||
// 这是一个临时解决方案,理想情况下应由后端通过消息通知或其他机制来确保数据一致性。
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.fetchDeviceDetail(data.data.id, true).then(() => {
|
if (this.deviceInfo.batteryPercentage <
|
||||||
// 在获取到最新信息后,再判断电量
|
20) {
|
||||||
if (this.deviceInfo.batteryPercentage < 20) {
|
|
||||||
this.popupType = 'bettery';
|
this.popupType = 'bettery';
|
||||||
this.popupMessage = '请及时充电';
|
this.popupMessage = '请及时充电';
|
||||||
this.showPopupFlag = true;
|
this.showPopupFlag = true;
|
||||||
}
|
}
|
||||||
});
|
if (this.apiType === 'listA') {
|
||||||
|
this.fetchDeviceDetail(data.data.id)
|
||||||
|
} else {
|
||||||
|
// 分享权限详情
|
||||||
|
this.fetchSharedDeviceDetail(data.data.id)
|
||||||
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
// 上报电量,在列表里面同步
|
||||||
// ✅ 发送全局事件通知主页面更新
|
|
||||||
uni.$emit('deviceStatusUpdate', {
|
uni.$emit('deviceStatusUpdate', {
|
||||||
message: parsedMessage, // 消息内容
|
message: parsedMessage,
|
||||||
timestamp: new Date().getTime() // 时间戳
|
timestamp: new Date().getTime()
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('未知的 deviceState 类型:', deviceState[0]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
|
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 连接成功后,立即查询一次设备状态
|
// mqtt连接成功后,上报一次设备状态
|
||||||
this.queryDeviceStatus();
|
this.queryDeviceStatus();
|
||||||
})
|
})
|
||||||
if (this.apiType === 'listA') {
|
if (this.apiType === 'listA') {
|
||||||
@ -1199,7 +1254,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
|
||||||
eventChannel.emit('ack', {
|
eventChannel.emit('ack', {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
<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="toggleSelect(index)">
|
<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 }">
|
<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>
|
||||||
<!-- 设备信息 -->
|
<!-- 设备信息 -->
|
||||||
@ -17,11 +17,9 @@
|
|||||||
<view>设备:{{ item.deviceName }}</view>
|
<view>设备:{{ item.deviceName }}</view>
|
||||||
<view class="ID">
|
<view class="ID">
|
||||||
<view class="ID">ID:{{ item.deviceImei }}</view>
|
<view class="ID">ID:{{ item.deviceImei }}</view>
|
||||||
<view class="onlines"
|
<view class="onlines" v-if="item.onlineStatus == 1">在线</view>
|
||||||
v-if="item.onlineStatus==1">在线</view>
|
|
||||||
<!-- 离线状态 -->
|
<!-- 离线状态 -->
|
||||||
<view class="unlines"
|
<view class="unlines" v-if="item.onlineStatus == 0">离线</view>
|
||||||
v-if="item.onlineStatus==0">离线</view>
|
|
||||||
<view>电量:{{ item.battery || '0' }}%</view>
|
<view>电量:{{ item.battery || '0' }}%</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -34,12 +32,13 @@
|
|||||||
<textarea placeholder-style="color:rgba(255, 255, 255, 0.4)" placeholder="请输入内容" class="textarea"
|
<textarea placeholder-style="color:rgba(255, 255, 255, 0.4)" placeholder="请输入内容" class="textarea"
|
||||||
v-model="messageToSend" :maxlength="20" />
|
v-model="messageToSend" :maxlength="20" />
|
||||||
</view>
|
</view>
|
||||||
<button class="login-btn" @click="sendTextMessage">发送</button>
|
<button class="login-btn" @click.stop="sendTextMessage">发送</button>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<!-- 成功提示弹框 -->
|
<!-- 成功提示弹框 -->
|
||||||
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage" icon="/static/images/common/sendSucc.png"
|
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage"
|
||||||
:confirm-text="popupConfirmText" :show-cancel="false" @confirm="onPopupConfirm" />
|
icon="/static/images/common/sendSucc.png" :confirm-text="popupConfirmText" :show-cancel="false"
|
||||||
|
@confirm="onPopupConfirm" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -49,8 +48,12 @@
|
|||||||
deviceInfo,
|
deviceInfo,
|
||||||
} from '@/api/common/index.js'
|
} from '@/api/common/index.js'
|
||||||
import {
|
import {
|
||||||
deviceSendMessage
|
deviceSendMessage,
|
||||||
|
deviceRealTimeStatus //设备状态
|
||||||
} from '@/api/6170/deviceControl.js'
|
} from '@/api/6170/deviceControl.js'
|
||||||
|
import {
|
||||||
|
generateShortId
|
||||||
|
} from '@/utils/function.js';
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
CustomPopup
|
CustomPopup
|
||||||
@ -62,10 +65,55 @@
|
|||||||
showPopupFlag: false,
|
showPopupFlag: false,
|
||||||
popupTitle: '',
|
popupTitle: '',
|
||||||
popupMessage: '信息发送成功!',
|
popupMessage: '信息发送成功!',
|
||||||
popupConfirmText: '确认'
|
popupConfirmText: '确认',
|
||||||
|
isSending: false,
|
||||||
|
sendInfo: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onPullDownRefresh() {
|
||||||
|
// 执行下拉刷新时的操作,比如重新获取数据
|
||||||
|
this.getData();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 获取设备状态(带自动轮询)
|
||||||
|
* @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) {
|
toggleSelect(index) {
|
||||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
@ -75,7 +123,7 @@
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
let data = {
|
let data = {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 20,
|
pageSize: 50,
|
||||||
deviceType: deviceType
|
deviceType: deviceType
|
||||||
}
|
}
|
||||||
deviceInfo(data).then((res) => {
|
deviceInfo(data).then((res) => {
|
||||||
@ -93,9 +141,12 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 发送文本消息
|
// 发送文本消息
|
||||||
sendTextMessage() {
|
async sendTextMessage() {
|
||||||
|
// 防重复提交
|
||||||
|
if (this.isSending) return;
|
||||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||||
const deviceIds = selectedDevices.map(item => item.id);
|
const deviceIds = selectedDevices.map(item => item.id);
|
||||||
|
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
||||||
if (selectedDevices.length === 0) {
|
if (selectedDevices.length === 0) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请选择一个设备',
|
title: '请选择一个设备',
|
||||||
@ -105,25 +156,53 @@
|
|||||||
}
|
}
|
||||||
if (!this.messageToSend) {
|
if (!this.messageToSend) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请输入要发送的内容',
|
title: '请输入要发送的文字',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let data = {
|
this.isSending = true;
|
||||||
|
let loadingShown = false;
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '发送中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
loadingShown = true;
|
||||||
|
// 2. 准备请求数据
|
||||||
|
const batchId = generateShortId();
|
||||||
|
const data = {
|
||||||
sendMsg: this.messageToSend,
|
sendMsg: this.messageToSend,
|
||||||
deviceIds: deviceIds
|
deviceIds: deviceIds,
|
||||||
}
|
batchId: batchId,
|
||||||
deviceSendMessage(data).then((res) => {
|
typeName: this.sendInfo.typeName,
|
||||||
if (res.code == 200) {
|
batchId: batchId,
|
||||||
this.showPopupFlag = true
|
deviceImeiList: deviceImeiList
|
||||||
} else {
|
};
|
||||||
|
// 3.人员信息
|
||||||
|
const registerRes = await deviceSendMessage(data);
|
||||||
|
if (registerRes.code !== 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
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'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading();
|
||||||
|
this.isSending = false;
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
onPopupConfirm() {
|
onPopupConfirm() {
|
||||||
this.showPopupFlag = false
|
this.showPopupFlag = false
|
||||||
@ -137,7 +216,8 @@
|
|||||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||||
eventChannel.on('deviceSend', (data) => {
|
eventChannel.on('deviceSend', (data) => {
|
||||||
console.log('Received detail data:', data);
|
console.log('Received detail data:', data);
|
||||||
this.getData(data.data)
|
this.getData(data.data.id)
|
||||||
|
this.sendInfo = data.data
|
||||||
});
|
});
|
||||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||||
eventChannel.emit('ack', {})
|
eventChannel.emit('ack', {})
|
||||||
@ -342,4 +422,14 @@
|
|||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
.checkbox.disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||||
|
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||||
|
pointer-events: none; /* 阻止点击事件 */
|
||||||
|
}
|
||||||
|
/* 可选:离线设备的卡片整体置灰 */
|
||||||
|
.device-card[data-offline="true"] {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -6,7 +6,7 @@
|
|||||||
<image src="/static/images/common/logo.png" class="logo"></image>
|
<image src="/static/images/common/logo.png" class="logo"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-right">
|
<view class="user-right">
|
||||||
<view class="user-title">富源晟科技</view>
|
<view class="user-title">武汉研创</view>
|
||||||
<view class="ID">ID:123456</view>
|
<view class="ID">ID:123456</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import config from '../config/index.js';
|
import config from '../config/index.js';
|
||||||
const env = 'development'; //production development //开发of线上 改这里就行
|
const env = 'production'; //production development //开发of线上 改这里就行
|
||||||
const BASE = config[env];
|
const BASE = config[env];
|
||||||
const request = (options) => {
|
const request = (options) => {
|
||||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||||
@ -20,7 +20,7 @@ const request = (options) => {
|
|||||||
method: options.method || 'GET',
|
method: options.method || 'GET',
|
||||||
data: options.method !== 'GET' ? options.data : {},
|
data: options.method !== 'GET' ? options.data : {},
|
||||||
header: options.header || {},
|
header: options.header || {},
|
||||||
timeout: 10000,
|
timeout: 30000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user