解决版本冲突

This commit is contained in:
liub
2025-08-18 08:49:46 +08:00
8 changed files with 2195 additions and 1949 deletions

View File

@ -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'
} }

View File

@ -1,197 +1,222 @@
{ {
"pages": [ "pages": [
{
"path": "pages/common/login/index",
{ "style": {
"path": "pages/common/login/index", "navigationStyle": "custom"
"style": { }
"navigationStyle": "custom" },
} {
}, "path": "pages/common/index/index",
"style": {
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
{ },
"path": "pages/common/index/index", {
"style": { "path": "pages/common/user/index",
"navigationStyle": "custom" "style": {
} "navigationBarTitleText": "我的"
}, }
{ },
"path": "pages/common/user/index", {
"style": { "path": "pages/common/scan/scan",
"navigationBarTitleText": "我的" "style": {
} "navigationBarTitleText": "扫描"
}, }
{ },
"path": "pages/common/scan/scan", {
"style": { "path": "pages/common/qrcode/qrcode",
"navigationBarTitleText": "扫描" "style": {
} "navigationBarTitleText": "扫描到的设备"
}, }
{ },
"path": "pages/common/qrcode/qrcode", {
"style": { "path": "pages/common/send/index",
"navigationBarTitleText": "扫描到的设备" "style": {
} "navigationBarTitleText": "发送信息",
}, "enablePullDownRefresh": true
{ }
"path": "pages/common/send/index", },
"style": { {
"navigationBarTitleText": "发送信息" "path": "pages/common/userAgreement/index",
} "style": {
}, "navigationBarTitleText": "用户协议"
{ }
"path": "pages/common/userAgreement/index", },
"style": { {
"navigationBarTitleText": "用户协议" "path": "pages/common/privacyAgreement/index",
} "style": {
}, "navigationBarTitleText": "隐私协议"
{ }
"path": "pages/common/privacyAgreement/index", },
"style": { {
"navigationBarTitleText": "隐私协议" "path": "pages/common/aboutUs/index",
} "style": {
}, "navigationBarTitleText": "关于我们"
{ }
"path": "pages/common/aboutUs/index", },
"style": { {
"navigationBarTitleText": "关于我们" "path": "pages/6170/deviceControl/index",
} "style": {
}, "navigationStyle": "custom"
{ }
"path": "pages/6170/deviceControl/index", },
"style": { {
"navigationStyle": "custom" "path": "pages/6170/callPolice/index",
} "style": {
}, "navigationBarTitleText": "报警"
{ }
"path": "pages/common/operationVideo/index", },
"style": { {
"navigationStyle": "custom" "path": "pages/210/deviceControl/index",
} "style": {
}, "navigationStyle": "custom"
{ }
"path": "pages/common/addvideo/index", },
"style": { {
"navigationStyle": "custom" "path": "pages/common/operationVideo/index",
} "style": {
}, "navigationStyle": "custom"
// 操作说明 }
{ },
"path": "pages/common/operatingInstruct/index", {
"style": { "path": "pages/common/addvideo/index",
"navigationStyle": "custom" "style": {
} "navigationStyle": "custom"
}, }
// 产品说明 },
{ // 操作说明
"path": "pages/common/productDes/index", {
"style": { "path": "pages/common/operatingInstruct/index",
"navigationStyle": "custom" "style": {
} "navigationStyle": "custom"
}, }
{ },
"path" : "pages/common/addBLE/addEquip", // 产品说明
"style" : {
{ "path": "pages/common/productDes/index",
"navigationBarTitleText" : "添加设备" "style": {
} "navigationStyle": "custom"
}, }
{ },
"path" : "pages/common/addBLE/LinkBle", {
"style" : "path": "pages/common/addBLE/addEquip",
{ "style": {
"navigationBarTitleText" : "扫描到的设备" "navigationBarTitleText": "添加设备"
} }
}, },
{ {
"path" : "pages/6155/deviceDetail", "path": "pages/common/addBLE/LinkBle",
"style" : "style": {
{ "navigationBarTitleText": "扫描到的设备"
"navigationBarTitleText" : "HBY 6155" }
} },
}, {
{ "path": "pages/6155/deviceDetail",
"path" : "pages/6155/ImgCrop", "style": {
"style" : "navigationBarTitleText": "HBY 6155"
{ }
"navigationBarTitleText" : "图像裁剪", },
"navigationStyle": "custom", {
"fullscreen": true "path": "pages/6155/ImgCrop",
} "style": {
}, "navigationBarTitleText": "图像裁剪",
{ "navigationStyle": "custom",
"path" : "pages/650/HBY650", "fullscreen": true
"style" : }
{ },
"navigationBarTitleText" : "HBY650" {
} "path": "pages/650/HBY650",
}, "style": {
{ "navigationBarTitleText": "HBY650"
"path": "pages/common/map/index", }
"style": { },
"navigationBarTitleText": "地图" {
} "path": "pages/common/map/index",
}, "style": {
{ "navigationBarTitleText": "地图"
"path": "pages/common/allType/index", }
"style": { },
"navigationBarTitleText": "所有类型" {
} "path": "pages/common/allType/index",
}, "style": {
{ "navigationBarTitleText": "所有类型"
"path": "pages/6170/allShare/index", }
"style": { },
"navigationBarTitleText": "所有分享" {
} "path": "pages/6170/allShare/index",
}, "style": {
"navigationBarTitleText": "所有分享"
{ }
"path": "pages/6170/share/index", },
"style": { {
"navigationBarTitleText": "分享" "path": "pages/6170/share/index",
} "style": {
}, "navigationBarTitleText": "分享"
{ }
"path": "pages/6170/shareDevices/index", },
"style": { {
"navigationBarTitleText": "分享设备" "path": "pages/6170/shareDevices/index",
} "style": {
}, "navigationBarTitleText": "分享设备"
{ }
"path": "pages/6170/shareManagement/index", },
"style": { {
"navigationBarTitleText": "分享管理" "path": "pages/6170/shareManagement/index",
} "style": {
} "navigationBarTitleText": "分享管理"
}
},
], {
"tabBar": { "path": "pages/210/onlineDevice/index",
"color": "#fff", "style": {
"selectedColor": "#BBE600", "navigationBarTitleText": "联机设备"
"backgroundColor": "#202020", }
"list": [{ },
"pagePath": "pages/common/index/index", {
"text": "我的设备", "path": "pages/210/addDevice/index",
"iconPath": "/static/tabs/device.png", "style": {
"selectedIconPath": "/static/tabs/device-HL.png" "navigationBarTitleText": "添加联机设备"
}, }
{ },
"pagePath": "pages/common/user/index", {
"text": "我的", "path": "pages/210/historyRecords/index",
"iconPath": "/static/tabs/my.png", "style": {
"selectedIconPath": "/static/tabs/my-HL.png" "navigationBarTitleText": "历史记录"
} }
] },
}, {
"globalStyle": { "path": "pages/210/call/index",
"navigationBarTextStyle": "white", "style": {
"navigationBarTitleText": "uni-app", "navigationBarTitleText": "呼叫"
"navigationBarBackgroundColor": "#121212", }
"backgroundColor": "#121212" }
}, ],
"uniIdRouter": {} "tabBar": {
"color": "#fff",
"selectedColor": "#BBE600",
"backgroundColor": "#202020",
"list": [
{
"pagePath": "pages/common/index/index",
"text": "我的设备",
"iconPath": "/static/tabs/device.png",
"selectedIconPath": "/static/tabs/device-HL.png"
},
{
"pagePath": "pages/common/user/index",
"text": "我的",
"iconPath": "/static/tabs/my.png",
"selectedIconPath": "/static/tabs/my-HL.png"
}
]
},
"globalStyle": {
"navigationBarTextStyle": "white",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#121212",
"backgroundColor": "#121212"
},
"uniIdRouter": {}
} }

View File

@ -249,14 +249,10 @@
}, },
onLoad() { onLoad() {
this.onIntall() this.onIntall()
// 绑定页面做了监听,新增成功,刷新页面
uni.$on('refreshDeviceList', () => {
this.onIntall()
});
}, },
beforeDestroy() { beforeDestroy() {
// 组件销毁前移除监听器 // 组件销毁前移除监听器
uni.$off('refreshDeviceList');
}, },
} }
</script> </script>

View File

@ -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>
<!-- 设备信息 --> <!-- 设备信息 -->
@ -15,13 +16,13 @@
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image> <image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view> </view>
<view class="device-name"> <view class="device-name">
<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" v-if="item.onlineStatus==1">在线</view> <view class="onlines" v-if="item.onlineStatus == 1">在线</view>
<!-- 离线状态 --> <!-- 离线状态 -->
<view class="unlines" v-if="item.onlineStatus==0">离线</view> <view class="unlines" v-if="item.onlineStatus == 0">离线</view>
<view>电量{{item.battery || '0'}}%</view> <view>电量{{ item.battery || '0' }}%</view>
</view> </view>
</view> </view>
</view> </view>
@ -46,368 +47,448 @@
</template> </template>
<script> <script>
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue' import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
import { import {
deviceInfo, generateShortId
} from '@/api/common/index.js' } from '@/utils/function.js';
import { import {
deviceSendAlarmMessage deviceInfo,
} from '@/api/6170/callPolice.js' } from '@/api/common/index.js'
export default { import {
components: { deviceSendAlarmMessage
CustomPopup } from '@/api/6170/callPolice.js'
import {
deviceRealTimeStatus //设备状态
} from '@/api/6170/deviceControl.js'
export default {
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
}, },
data() { toggleSelect(index) {
return { this.deviceList[index].checked = !this.deviceList[index].checked
deviceList: [], this.$forceUpdate()
messageToSend: '', //发送信息
showPopupFlag: false,
popupTitle: '',
popupMessage: '确认要对所选设备开启强制报警?',
popupConfirmText: '确认',
popupType: 'force', // 'force' or 'cancel'
pendingAlarmAction: ''
}
}, },
computed: { /**
selectedDeviceIds() { * 获取设备状态(带自动轮询)
return this.deviceList.filter(item => item.checked).map(item => item.id); * @param {number} val - 功能模式
} * @param {string} batchId - 批次ID
}, * @param {number} [interval=1000] - 轮询间隔(毫秒)
methods: { */
onclosePopup() { async getdeviceSTatus(val, batchId, interval =500) {
this.showPopupFlag = false const checkStatus = async () => {
}, try {
toggleSelect(index) { const data = {
this.deviceList[index].checked = !this.deviceList[index].checked functionMode: val,
this.$forceUpdate() batchId: batchId,
}, typeName: this.sendInfo.typeName,
// 全选/取消全选 deviceImei: this.sendInfo.deviceImei
selectAll() { };
console.log('123'); const res = await deviceRealTimeStatus(data);
const allSelected = this.deviceList.every(item => item.checked); if (res.code !== 200) {
this.deviceList.forEach(item => { throw new Error(res.msg || '请求失败');
item.checked = !allSelected;
});
this.$forceUpdate();
},
// 获取设备列表
getData(deviceType) {
this.loading = true;
let data = {
pageNum: 1,
pageSize: 20,
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(() => { switch (res.data.functionAccess) {
this.loading = false; case 'OK':
}); return res; // 成功完成
}, case 'ACTIVE':
// 强制报警 await new Promise(r => setTimeout(r, interval));
forceAlarm() { return checkStatus(); // 继续轮询
const selectedDevices = this.deviceList.filter(item => item.checked) case 'FAILED':
const deviceIds = selectedDevices.map(item => item.id); throw new Error('设备操作失败');
if (selectedDevices.length === 0) { case 'TIMEOUT':
uni.showToast({ throw new Error('设备响应超时');
title: '请选择一个设备', default:
icon: 'none' throw new Error('未知状态');
});
return;
}
this.popupType = 'force';
this.popupMessage = '确认要对所选设备开启强制报警?';
this.showPopupFlag = true;
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
},
sendAlarmCommand(type) {
const selectedDevices = this.deviceList.filter(item => item.checked);
const deviceIds = selectedDevices.map(item => item.id);
let data = {
deviceIds: deviceIds,
instructValue: this.pendingAlarmAction, // '强制或者解除'
}
deviceSendAlarmMessage(data).then((res) => {
if (res.code == 200) {
uni.showToast({
title: res.msg,
icon: 'none'
});
this.showPopupFlag = false
uni.$emit('deviceStatusUpdate', {});
setTimeout(() => {
uni.navigateBack()
}, 500)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
} }
}); } catch (error) {
}, throw error;
// 点击确认状态 }
onPopupConfirm() { };
this.sendAlarmCommand(this.popupType); return checkStatus();
// 处理确认逻辑
},
}, },
onLoad(options) { // 全选/取消全选
const eventChannel = this.getOpenerEventChannel(); selectAll() {
// 监听 'deviceSend' 事件,获取传过来的数据 console.log('123');
eventChannel.on('devicePolice', (data) => { const allSelected = this.deviceList.every(item => item.checked);
this.getData(data.data) this.deviceList.forEach(item => {
item.checked = !allSelected;
}); });
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
eventChannel.emit('ack', {}) 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';
this.popupMessage = '确认要对所选设备开启强制报警?';
this.showPopupFlag = true;
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({
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'
});
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) {
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 {
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>

File diff suppressed because it is too large Load Diff

View File

@ -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>
<!-- 设备信息 --> <!-- 设备信息 -->
@ -14,15 +14,13 @@
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image> <image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view> </view>
<view class="device-name"> <view class="device-name">
<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>
</view> </view>
@ -32,14 +30,15 @@
<view class="ql-editor">编辑信息</view> <view class="ql-editor">编辑信息</view>
<view class="ql-input"> <view class="ql-input">
<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,12 +48,16 @@
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
}, },
data() { data() {
return { return {
deviceList: [], deviceList: [],
@ -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;
sendMsg: this.messageToSend, let loadingShown = false;
deviceIds: deviceIds try {
} uni.showLoading({
deviceSendMessage(data).then((res) => { title: '发送中...',
if (res.code == 200) { mask: true
this.showPopupFlag = true });
} else { 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({ uni.showToast({
title: res.msg, title: registerRes.msg,
icon: 'none' 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() { 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>

View File

@ -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>

View File

@ -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);
}, },