From c7d7149d2f5d9692d99d5e8f9bea290e88f4f262 Mon Sep 17 00:00:00 2001
From: fengerli <528575642@qq.com>
Date: Thu, 31 Jul 2025 14:03:28 +0800
Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=81=AF=E5=85=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/6170/deviceControl.js | 33 ++++++
pages/6170/deviceControl/index.vue | 167 +++++++++++++++++------------
pages/common/index/index.vue | 80 +++++++++-----
pages/common/login/index.vue | 2 +-
static/images/close.png | Bin 0 -> 474 bytes
static/images/rg.png | Bin 0 -> 597 bytes
6 files changed, 191 insertions(+), 91 deletions(-)
create mode 100644 static/images/close.png
create mode 100644 static/images/rg.png
diff --git a/api/6170/deviceControl.js b/api/6170/deviceControl.js
index 44b4601..75b1f25 100644
--- a/api/6170/deviceControl.js
+++ b/api/6170/deviceControl.js
@@ -29,3 +29,36 @@ export function deviceSendMessage(data) {
data: data
})
}
+// 灯光模式设置
+export function lightModeSettings(data) {
+ return request({
+ url: `/app/device/lightModeSettings`,
+ method: 'post',
+ data: data
+ })
+}
+// 激光模式设置
+export function laserModeSettings(data) {
+ return request({
+ url: `/app/device/laserModeSettings`,
+ method: 'post',
+ data: data
+ })
+}
+// 灯光亮度设置
+
+export function lightBrightnessSettings(data) {
+ return request({
+ url: `/app/device/lightBrightnessSettings`,
+ method: 'post',
+ data: data
+ })
+}
+// 地图逆解析
+export function mapReverseGeocoding(data) {
+ return request({
+ url: `/app/device/mapReverseGeocoding`,
+ method: 'post',
+ data: data
+ })
+}
\ No newline at end of file
diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue
index 8c96320..7517bc3 100644
--- a/pages/6170/deviceControl/index.vue
+++ b/pages/6170/deviceControl/index.vue
@@ -48,7 +48,11 @@
定位信息
114.72 30.28
- 深圳市龙华区富源晟
+
+
+ 深圳市龙华区富源晟
+
@@ -194,7 +198,6 @@
-
@@ -237,7 +240,11 @@
deviceDetail,
registerPersonInfo,
deviceSendMessage,
- deviceShareId
+ deviceShareId,
+ lightModeSettings, //灯光模式设置
+ laserModeSettings, //激光模式设置
+ lightBrightnessSettings, //灯光亮度设置
+ mapReverseGeocoding //地图逆解析
} from '@/api/6170/deviceControl.js'
import {
getDeviceId
@@ -273,13 +280,7 @@
code: '',
},
deviceInfo: {},
- modeInstructions: {
- '关灯': [1, 0, 0, 0, 0],
- '强光': [1, 1, 0, 0, 0],
- '弱光': [1, 2, 0, 0, 0],
- '爆闪': [1, 3, 0, 0, 0],
- '泛光': [1, 4, 0, 0, 0]
- },
+
activePermissions: [], // 存储当前设备的权限数组
isSharedDevice: false, // 标记是否来自分享
isRightIconVisible: false,
@@ -312,7 +313,19 @@
},
// ***********进度条***********
onSliderChanging(e) {
+ console.log('这是我滑动的吗');
this.sliderValue = e.detail.value;
+ let data = {
+ deviceld: this.deviceID,
+ instructValue: this.sliderValue + '.00'
+ }
+ lightBrightnessSettings(data).then((res) => {
+ if (res.code == 200) {
+
+ } else {
+
+ }
+ })
},
selectMode(type) {
this.modeType = type;
@@ -322,29 +335,36 @@
text: '强光',
selected: this.currentMainMode === '强光', // 修正匹配条件
image: '/static/images/sett.png',
+ instructValue: '1'
},
{
text: '弱光',
selected: this.currentMainMode === '弱光',
- image: '/static/images/sett.png'
+ image: '/static/images/rg.png',
+ instructValue: '2'
},
{
text: '爆闪',
selected: this.currentMainMode === '爆闪',
- image: '/static/images/bs.png'
+ image: '/static/images/bs.png',
+ instructValue: '3'
},
{
text: '泛光',
selected: this.currentMainMode === '泛光',
- image: '/static/images/settt.png'
+ image: '/static/images/settt.png',
+ instructValue: '4'
+ },
+ {
+ text: '关闭',
+ selected: this.currentMainMode === '关闭',
+ image: '/static/images/close.png',
+ instructValue: '0'
},
];
}
},
- // 激光模式
- lasermode() {
- this.lightModeC = true
- },
+ // 人员信息登录
toggleForm() {
this.isFormExpanded = !this.isFormExpanded;
},
@@ -366,28 +386,59 @@
},
// 灯光模式的确认
handleSumbit() {
- if (this.selectedItemIndex === null) return;
- const selectedItem = this.items[this.selectedItemIndex];
- const instruction = this.modeInstructions[selectedItem.text];
- console.log(selectedItem, 'selectedItemselectedItem');
- // 修正这里的赋值错误,应该保存索引而不是文本
- this.selectedItemIndex = this.selectedItemIndex;
- console.log(this.selectedItemIndex,'this.selectedItemIndexthis.selectedItemIndex');
- // if (instruction) {
- // const topic = `B/${this.itemInfo.deviceImei}`;
- // const message = JSON.stringify(instruction);
- // // 确保mqttClient已连接
- // if (this.mqttClient && this.mqttClient.client && this.mqttClient.client.isConnected()) {
- // this.mqttClient.publish(topic, message);
- // console.log('已发送指令:', instruction);
- // } else {
- // uni.showToast({
- // title: 'MQTT未连接',
- // icon: 'none'
- // });
- // }
- // }
- this.lightModeA = false;
+ if (this.selectedItemIndex === null) return;
+ const selectedItem = this.items[this.selectedItemIndex];
+ console.log(selectedItem, 'selectedItemselectedItem');
+ // 修正这里的赋值错误,应该保存索引而不是文本
+ this.selectedItemIndex = this.selectedItemIndex;
+ let data = {
+ deviceld: this.deviceID,
+ instructValue: selectedItem.instructValue
+ }
+ lightModeSettings(data).then((res) => {
+ if (res.code == 200) {
+ uni.showToast({
+ icon: 'none',
+ title: res.msg
+ })
+ this.lightModeA = false;
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: res.msg
+ })
+ }
+ })
+ },
+ // 激光模式
+ lasermode() {
+ this.lightModeC = true
+ },
+ // 激光确认框提交
+ handleBtn() {
+ let data = {
+ deviceld: this.deviceID,
+ instructValue: 1
+ }
+ laserModeSettings(data).then((res) => {
+ if (res.code == 200) {
+ uni.showToast({
+ icon: 'none',
+ title: res.msg
+ })
+ this.lightModeC = false
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: res.msg
+ })
+ }
+ })
+
+ },
+ //激光取消
+ handleDisagree() {
+ this.lightModeC = false
},
// 上传开机画面
uploadStartup() {
@@ -509,31 +560,9 @@
})
},
- // 激光确认框
- handleBtn() {
- this.lightModeC = false
- },
- //取消
- handleDisagree() {
- this.lightModeC = false
- },
+
// 发送人员信息
sendPersonnelInfo() {
- // if (!this.mqttClient || !this.mqttClient.client.isConnected()) {
- // uni.showToast({
- // title: 'MQTT未连接',
- // icon: 'none'
- // });
- // return;
- // }
- // const topic = `device/command/${this.deviceID}/personnel`;
- // const message = JSON.stringify(this.personnelInfo);
- // this.mqttClient.publish(topic, message);
- // uni.showToast({
- // title: '人员信息已发送',
- // icon: 'success'
- // });
-
if (!this.personnelInfo.unitName) {
uni.showToast({
title: '单位名称不能为空',
@@ -703,7 +732,7 @@
this.mqttClient.connect(() => {
console.log('MQTT 连接成功,开始订阅主题');
// 订阅来自设备的状态更新
- const statusTopic = `A/${this.itemInfo.deviceImei}`;
+ const statusTopic = `A/${this.itemInfo.nnnnnnnnnnnnnnnnnnn}`;
this.mqttClient.subscribe(statusTopic, (payload) => {
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
// uni.showModal({
@@ -711,6 +740,11 @@
// content: payload,
// showCancel: false
// });
+ // ✅ 发送全局事件通知主页面更新
+ uni.$emit('deviceStatusUpdate', {
+ message: JSON.stringify(payload), // 消息内容
+ timestamp: new Date().getTime() // 时间戳
+ });
});
});
if (this.apiType === 'listA') {
@@ -721,7 +755,9 @@
});
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
- eventChannel.emit('ack', {})
+ eventChannel.emit('ack', {
+
+ })
},
onUnload() {
@@ -796,7 +832,6 @@
width: 204rpx;
height: 144rpx;
margin-top: 30rpx;
- object-fit: contain;
}
.dlIMG {
@@ -1100,7 +1135,7 @@
/* 弹窗主体 */
.agreement-popup {
width: 100%;
- height: 40%;
+ height: 50%;
background-color: rgb(42, 42, 42);
border-radius: 60rpx 60rpx 0rpx 0rpx;
padding: 40rpx;
diff --git a/pages/common/index/index.vue b/pages/common/index/index.vue
index ac6cf8a..75ec93c 100644
--- a/pages/common/index/index.vue
+++ b/pages/common/index/index.vue
@@ -5,17 +5,19 @@
rightIcon="/static/images/add.png" @right-click="scan">
-
-
-
- {{tab.typeName}}
+
+
+
+
+ {{tab.typeName}}
+
+
+
+
-
-
-
-
+
位置
@@ -346,6 +348,7 @@
});
setTimeout(() => {
this.onIntall();
+ this.getTab()
}, 500);
this.deleteShow = false
// 关闭所有滑动项
@@ -439,9 +442,7 @@
uni.navigateTo({
url: "/pages/6155/deviceDetail",
events: {
- ack: function(data) {
-
- }
+ ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('detailData', {
@@ -450,14 +451,28 @@
}
})
}
-
-
},
onIntall() {
this.page = 1;
this.finished = false;
this.getData(this.deviceType); // 重新加载第一页数据
},
+ updateDeviceStatus(data) {
+ // 只更新 communicationMode == 0 的设备
+ this.deviceList = this.deviceList.map(item => {
+ console.log(item,'item2222');
+ if (item.communicationMode === 0) {
+ // 这里根据消息内容更新设备状态
+ // 示例:如果消息包含特定字段,则更新设备状态
+ return {
+ ...item,
+ //status: data.message.status || item.status, // 假设消息中有status字段
+ lastUpdate: data.timestamp // 更新时间戳
+ };
+ }
+ return item;
+ });
+ }
},
onLoad() {
this.getTab()
@@ -472,6 +487,17 @@
// 组件销毁前移除监听器
uni.$off('refreshDeviceList');
},
+ onShow() {
+ // 监听设备状态更新事件
+ uni.$on('deviceStatusUpdate', (data) => {
+ console.log('收到设备状态更新通知:', data);
+ this.updateDeviceStatus(data);
+ });
+ },
+ onHide() {
+ // 页面隐藏时取消监听,避免内存泄漏
+ uni.$off('deviceStatusUpdate');
+ },
}
@@ -498,11 +524,10 @@
.tab-container {
display: flex;
- /* justify-content: space-around; */
cursor: pointer;
margin-bottom: 40rpx;
- /* min-width: 100%; */
- /* 最小宽度 */
+ padding-right: 80rpx;
+ /* 预留更多按钮空间 */
}
.tab-item {
@@ -530,19 +555,26 @@
font-size: 28rpx;
}
- .uniui-more {
+ .tab-bar-wrap {
+ display: flex;
+ /* 横向排列 */
+ align-items: baseline;
+ /* 垂直居中 */
position: relative;
- width: 100%;
+ /* 可选(若需要绝对定位 fallback) */
+ }
+
+ .tab-more {
+ margin-left: 10rpx;
+ /* 与Tab的间距 */
+ display: flex;
+ align-items: center;
+ background: linear-gradient(-88.60deg, rgba(18, 18, 18, 1), rgba(18, 18, 18, 0) 100%);
}
.more {
width: 40rpx;
height: 8rpx;
- /* position: absolute; */
- /* right: 0rpx;
- z-index: 100; */
- float: right;
- top: -95rpx
}
.gprs {
diff --git a/pages/common/login/index.vue b/pages/common/login/index.vue
index fef908c..e13a2f0 100644
--- a/pages/common/login/index.vue
+++ b/pages/common/login/index.vue
@@ -61,7 +61,7 @@
data() {
return {
showView: false,
- phone: '13058067817', //手机号码
+ phone: '13800138001', //手机号码
code: "", //验证码
agreed: false,
isCounting: false,
diff --git a/static/images/close.png b/static/images/close.png
new file mode 100644
index 0000000000000000000000000000000000000000..978e04ad5de07f379f6eb3e6d0a5dada27994dd7
GIT binary patch
literal 474
zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL3?$vW53m6##^NA%C&rs6b?Si}n*g5>S0L>P
z1K!@=US3|Ip`j2)Sy@>_Lqktb&x;o?y1KeLIyx3ETv$|8G;`+60|yRtcXzY@eDxTp
zU!)|+FPMQnb>o}=Y$eUg?1hE&XXd-FBdAp;)P2X8J_uD*5bdwsb1
zt;)G(*MtL3{Is=W^FGg|D0O*D?0bioyUP~L5#^e@+3TIuTdVD1mG?CtTk}h;E9Tv5
zRp33B?~Y*3xp$W*_r0ETkWD&g!$G$Fr_xq4zu$8|`@rJY{9GTN$lbRMXmO75xT$;S
zjkwV1JkGwYdAvGB+6gm%Tk4e9w@tP_$0~7do%`X<-EI2szJIvOxN}!b$!YgluVWlJ
z3#V#lny)K#-72Xa6Dj|>_jT$z0l&Nt85T?G4jkTD{@}wMYeAmp?~hH~_@PwJMx?GJ
z@WW(n8+lcWv&@Gd+N2j$OpdYHbN2t^g4^FXZp?l5`^nR5VlD6d@4etPyOGe$YxZM*
z!dBMqTV5WyomXERXuh{7Ab;!1?LDee8(u$7GdjP|X+?Q?(S8kJxH5RU`njxgN@xNA
D9NyYT
literal 0
HcmV?d00001
diff --git a/static/images/rg.png b/static/images/rg.png
new file mode 100644
index 0000000000000000000000000000000000000000..8fd7bba1fbb1808512b60371144fec57a2ae0962
GIT binary patch
literal 597
zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL3?$vW53m6##^NA%C&rs6b?Skfq5z)|S0L>P
z1K!@=US3|Ip`j2)U|?WbSy^IY;>L{|U%YrRd-m+Kw6yEjuW#G7t+~0mwzhW9o;_#J
zp3TY0nKEU{k|j$XKYkn?9Szie_wL=*t5^5-_HN(4eb=sCot>Szxw%C}MF$QXm^pK%
zyVkjBKwH&Hg8YIR*i$#Y`Oj9e{XahNx=Hd7(CzV_E{-7;bKc%O*>}i*hwVX0VdU9;
z?=O7%x8CC1g+NW0uJ$A1Dfj<$*PK$^Iw6NAbW)n7%PJdh?%;5Bv0veH+i&;2Wh!xf
zm)-p?#$yLVr)TPeD=9_=X^Zx5E_>>Bj5Q!4u~jt8LhH_J{+N#o?sK=acP##1(qh5W
zGBN9qR9~(XhkwV6eQm*9>Wv@H#O2*P_sncI>!A$_DL4D3iRjim-}B*AT>jrVYjQVn
zwIw>ADZBn-m%do%qQ~S(bUGrrYsc%yM`qdcNv}8MY3k|(Mh=6gtDnm{
Hr-UW|5Vs@?
literal 0
HcmV?d00001