Files
APP/pages/6170/deviceControl/index.vue

1217 lines
28 KiB
Vue
Raw Normal View History

2025-07-05 14:49:26 +08:00
<template>
<view>
2025-07-22 17:47:38 +08:00
<!-- 添加全局加载遮罩 -->
<view v-if="pageLoading" class="page-loading-mask">
</view>
2025-07-05 14:49:26 +08:00
<!-- 使用自定义导航栏 -->
2025-07-22 17:47:38 +08:00
<view v-show="!pageLoading">
<custom-navbar :title="navTitle" :showBack="true" color="#FFFFFF"
:rightIcon="isRightIconVisible ? '/static/images/shape.png' : ''"
@right-click="shareUp"></custom-navbar>
<view class="device-detail-container" :style="{ paddingTop: navBarHeight + 'px' }">
<!-- 设备电量信息 -->
<view class="battery-section">
<view class="battery-sectionLeft">
<image :src="deviceInfo.devicePic" class="bipImg"></image>
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
<view>
<view class="battery-v1">
<image src="/static/images/dl.png" class="dlIMG"></image>
<view>
<view class="battery-v2">90%</view>
<view class="battery-v3">电量</view>
</view>
</view>
<view class="battery-v1">
<image src="/static/images/nz.png" class="dlIMG"></image>
<view>
<view class="battery-v2">1小时</view>
<view class="battery-v3">续航时间</view>
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<view>
</view>
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
<!-- 设备基本信息 -->
<view class="info-card">
<view class="info-row">
<text class="info-label">IMEI号</text>
2025-07-25 17:08:23 +08:00
<text class="info-value status-running">{{deviceInfo.deviceImei}}</text>
2025-07-22 17:47:38 +08:00
</view>
<view class="info-row">
<text class="info-label">设备状态</text>
<text class="info-value status-running">运行中</text>
</view>
<view class="info-row">
<text class="info-label">定位信息</text>
2025-07-25 17:08:23 +08:00
<view class="info-value status-running" @click="gpsPosition">
2025-07-22 17:47:38 +08:00
<view class="info-value status-running">114.72 30.28</view>
<view class="info-value status-running">深圳市龙华区富源晟</view>
</view>
</view>
2025-07-05 14:49:26 +08:00
</view>
<view class="info-row">
2025-07-22 17:47:38 +08:00
<text class="info-label">灯光亮度</text>
<text class="info-value status-running">{{ sliderValue }}%</text>
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
<!-- 灯光亮度控制 -->
<view class="control-card">
<slider :value="sliderValue" min="0" max="100" activeColor="rgb(187, 230, 0)"
backgroundColor="rgb(26, 26, 26)" :show-value="false" @changing="onSliderChanging"
@change="onSliderChanging" />
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
<!-- 灯光模式选择 -->
<view class="mode-section">
<view class="mode-buttons">
<view class="mode-v1" v-if="hasPermission('1')">
<view class="mode-v2" @click="selectMode('main')">
<image src="/static/images/set.png" class="setIMG"></image>
<view>
<view class="battery-v2">灯光模式</view>
<view class="mode-v3">{{ currentMainMode }}</view>
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<view class="mode-v1" v-if="hasPermission('2')">
<view class="mode-v2" @click="lasermode">
<image src="/static/images/jg.png" class="setIMG"></image>
<view>
<view class="battery-v2">激光模式</view>
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<view class="mode-v1" v-if="hasPermission('3')">
<view class="mode-v2" @click="uploadStartup">
<image src="/static/images/path7.png" class="setIMG"></image>
<view>
<view class="battery-v2">开机画面</view>
<view class="mode-v3">上传</view>
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
</view>
</view>
2025-07-22 17:47:38 +08:00
<!-- 人员信息登记 -->
<view class="form-section" v-if="hasPermission('4')">
<view class="mode-buttons">
<view class="section-title">人员信息登记</view>
<view class="right-icons">
<uni-icons @click="toggleForm" :type="isFormExpanded ? 'arrowup' : 'down'" size="20"
color="rgba(255, 255, 255, 0.87" class="toggle-icon" />
</view>
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
<view class="form-content" v-if="isFormExpanded">
<button class="send-btn1" @click="sendPersonnelInfo">发送</button>
<view class="form-row">
<text class="form-label">单位</text>
<input class="form-input" placeholder="请输入单位" v-model="personnelInfo.unitName" />
</view>
<view class="form-row">
<text class="form-label">姓名</text>
<input class="form-input" placeholder="请输入姓名" v-model="personnelInfo.name" />
</view>
<view class="form-row">
<text class="form-label">职位</text>
<input class="form-input" placeholder="请输入职位" v-model="personnelInfo.position" />
</view>
<view class="form-row">
<text class="form-label">ID</text>
<input class="form-input" placeholder="请输入ID号" v-model="personnelInfo.code" />
</view>
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
</view>
<!-- 人员信息登记 -->
<view class="form-section" v-if="hasPermission('5')">
<view class="mode-buttons">
<view class="section-title">发送信息</view>
<button class="send-btn" @click="sendTextMessage">发送</button>
2025-07-05 14:49:26 +08:00
</view>
2025-07-22 17:47:38 +08:00
2025-07-05 14:49:26 +08:00
<view class="form-row">
2025-07-22 17:47:38 +08:00
<input class="form-input" placeholder="请输入文字" v-model="messageToSend" />
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<!-- 产品信息 -->
<view v-if="hasPermission('6')">
<view class="section-title">产品信息</view>
<view class="mode-buttons">
<view class="mode_1" @click="productparams">
<image src="/static/images/cp.png" mode="" class="cpIMG"></image>
<view class="">产品参数</view>
</view>
<view class="mode_1" @click="operatingInst">
<image src="/static/images/sm.png" mode="" class="cpIMG"></image>
<view class="">操作说明</view>
</view>
<view class="mode_1" @click="operatingVideo">
<image src="/static/images/sp.png" mode="" class="cpIMG"></image>
<view class="">操作视频</view>
</view>
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<!-- 弹框 -->
<view class="agreement-mask" v-if="lightModeA">
2025-07-24 10:05:17 +08:00
<!-- 灯光模式弹窗 -->
2025-07-22 17:47:38 +08:00
<view class="agreement-popup" @click.stop>
<!-- 标题 -->
<view class="popup-title"> {{ popupTitle }}</view>
<view class="popup-content">
<view v-for="(item, index) in items" :key="index">
<view class="item" :class="{'selected': item.selected}" @click="onItemClick(index)">
<image :src="item.image" class="setIMG"></image>
{{item.text}}
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<!-- 按钮组 -->
<view class="popup-buttons">
<button class="agree" @click="handleSumbit">确定</button>
</view>
2025-07-05 14:49:26 +08:00
</view>
</view>
2025-07-22 17:47:38 +08:00
<!-- 上传开机画面弹框 -->
<view class="agreement-mask" v-if="lightModeB">
<!-- 上传画面弹窗 -->
<view class="agreement-popupB">
<!-- 标题 -->
<view class="popup-title">上传开机画面</view>
<view class="popup-content">
<view class="example-body">
2025-07-25 17:08:23 +08:00
<!-- <uni-file-picker limit="1" class="custom-file-picker"></uni-file-picker> -->
<view class="icoContent" @click="checkImgUpload">
2025-07-26 16:48:31 +08:00
<!-- <image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png">
</image> -->
<image v-if="selectedImage" :src="selectedImage" mode="aspectFit" class="img"
style="width: 100%; height: 100%;"></image>
<image v-else mode="aspectFit" class="img"
src="/static/images/6155/DeviceDetail/add.png"></image>
2025-07-25 17:08:23 +08:00
</view>
<!-- <view class="example_title">点击上传图片</view> -->
2025-07-22 17:47:38 +08:00
</view>
</view>
<!-- 按钮组 -->
<view class="popup-buttons">
<button class="agree" @click="handleupload">确定</button>
2025-07-05 14:49:26 +08:00
</view>
</view>
</view>
2025-07-22 17:47:38 +08:00
<!--===================== 激光提示框================== -->
<view class="agreement-mask" v-if="lightModeC">
<!-- 上传画面弹窗 -->
<view class="agreement-popupC">
<!-- 标题 -->
<view class="popup-title">确认开启激光模式</view>
<view class="popup-content">
<view class="popup-Title">
<view>注意事项</view>
<view>1.禁止直视光源或反射面</view>
<view>2.避免直射人或易燃物</view>
<view>3.需佩戴相应专业防护眼镜</view>
</view>
</view>
<!-- 按钮组 -->
<view class="popup-buttons">
<button class="btn disagree" @click="handleDisagree">取消</button>
<button class="btn agreeBtn" @click="handleBtn">确定</button>
2025-07-05 14:49:26 +08:00
</view>
</view>
</view>
2025-07-24 10:05:17 +08:00
<!-- 人员信息成功提示弹框 -->
2025-07-25 17:08:23 +08:00
<CustomPopup :show="showPopupFlag" :message="popupMessage" icon="/static/images/sendSucc.png"
:confirm-text="popupConfirmText" :show-cancel="false" @confirm="onPopupConfirm" />
2025-07-05 14:49:26 +08:00
</view>
</view>
</template>
<script>
2025-07-16 11:16:19 +08:00
import MqttClient from '@/utils/mqtt.js';
2025-07-22 17:47:38 +08:00
import {
deviceDetail,
registerPersonInfo,
deviceSendMessage,
deviceShareId
} from '@/api/6170/deviceControl.js'
import {
getDeviceId
} from '../../../store/BLETools';
2025-07-26 16:48:31 +08:00
import {
baseURL,
getToken,
clientid
} from '@/utils/request'
2025-07-05 14:49:26 +08:00
export default {
data() {
return {
2025-07-22 17:47:38 +08:00
pageLoading: true,
2025-07-05 14:49:26 +08:00
mainMode: 'string',
secondaryMode: 'string',
navBarHeight: 70 + uni.getSystemInfoSync().statusBarHeight,
2025-07-15 16:34:58 +08:00
navTitle: "",
2025-07-05 14:49:26 +08:00
sliderValue: 50,
lightModeA: false,
currentMainMode: '强光模式',
lightModeB: false,
lightModeC: false, //激光提示框
items: [],
isFormExpanded: true, // 默认展开
2025-07-15 16:34:58 +08:00
deviceID: '',
2025-07-16 11:16:19 +08:00
itemInfo: {},
mqttClient: null,
messageToSend: '',
personnelInfo: {
2025-07-22 17:47:38 +08:00
unitName: '',
2025-07-16 11:16:19 +08:00
name: '',
position: '',
2025-07-22 17:47:38 +08:00
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, // 标记是否来自分享
2025-07-24 10:05:17 +08:00
isRightIconVisible: false,
showPopupFlag: false, //是否显示弹框
popupMessage: '',
popupConfirmText: '确认',
2025-07-26 16:48:31 +08:00
showUploadPopup: false,
selectedImage: null, // 添加这个变量来存储选择的图片
file: ''
2025-07-05 14:49:26 +08:00
}
},
computed: {
popupTitle() {
return this.modeType === 'main' ? '灯光模式' : '激光模式';
}
},
methods: {
2025-07-25 17:08:23 +08:00
// *******定位******
2025-07-26 16:48:31 +08:00
gpsPosition() {
2025-07-25 17:08:23 +08:00
uni.navigateTo({
2025-07-26 16:48:31 +08:00
url: '/pages/common/map/index'
2025-07-25 17:08:23 +08:00
})
},
// ***********进度条***********
onSliderChanging(e) {
this.sliderValue = e.detail.value;
2025-07-15 16:34:58 +08:00
},
2025-07-05 14:49:26 +08:00
selectMode(type) {
this.modeType = type;
this.lightModeA = true;
if (type === 'main') {
this.items = [{
text: '强光',
selected: this.currentMainMode === '强光模式',
image: '/static/images/sett.png'
},
{
text: '弱光',
selected: this.currentMainMode === '弱光模式',
image: '/static/images/sett.png'
},
{
text: '爆闪',
selected: this.currentMainMode === '爆闪模式',
image: '/static/images/bs.png'
},
{
text: '泛光',
selected: this.currentMainMode === '泛光模式',
image: '/static/images/settt.png'
},
];
}
},
// 激光模式
lasermode() {
this.lightModeC = true
},
toggleForm() {
this.isFormExpanded = !this.isFormExpanded;
},
onItemClick(index) {
const selectedItem = this.items[index];
if (selectedItem.text === '激光') {
2025-07-24 10:05:17 +08:00
this.lightModeC = true;
2025-07-05 14:49:26 +08:00
} else {
2025-07-24 10:05:17 +08:00
// 更新选中状态
2025-07-22 17:47:38 +08:00
this.items = this.items.map((item, i) => ({
...item,
selected: i === index
}));
2025-07-24 10:05:17 +08:00
this.currentMainMode = selectedItem.text;
2025-07-22 17:47:38 +08:00
this.selectedItemIndex = index;
2025-07-24 10:05:17 +08:00
// 强制更新视图(如果需要)
this.$forceUpdate();
2025-07-05 14:49:26 +08:00
}
},
2025-07-22 17:47:38 +08:00
// 灯光模式的确认
2025-07-05 14:49:26 +08:00
handleSumbit() {
2025-07-22 17:47:38 +08:00
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
const instruction = this.modeInstructions[selectedItem.text];
2025-07-24 10:05:17 +08:00
console.log(selectedItem, 'selectedItemselectedItem');
this.selectedItemIndex = selectedItem.text;
2025-07-22 17:47:38 +08:00
if (instruction) {
const topic = `B/${this.itemInfo.deviceImei}`;
const message = JSON.stringify(instruction);
this.mqttClient.publish(topic, message);
console.log('已发送指令:', instruction);
}
this.lightModeA = false;
2025-07-05 14:49:26 +08:00
},
// 上传开机画面
uploadStartup() {
this.lightModeB = true
},
2025-07-25 17:08:23 +08:00
// 上传开机画面
checkImgUpload() {
uni.chooseImage({
count: 1,
2025-07-26 16:48:31 +08:00
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
// 将选择的图片赋值给selectedImage
const file = res.tempFiles[0];
const fileSize = file.size || 0;
if (fileSize > 2 * 1024 * 1024) {
console.log(`文件过大: ${fileSize} 字节`); // 调试日志
uni.showToast({
title: '图片大小不能超过2MB',
icon: 'none',
duration: 3000
});
return;
}
this.selectedImage = res.tempFilePaths[0];
console.log('选择的图片:', res);
this.file = res.tempFiles[0].file
},
fail: (err) => {
console.error('选择图片失败:', err);
uni.showToast({
title: '选择图片失败',
icon: 'none'
2025-07-25 17:08:23 +08:00
});
}
});
},
2025-07-05 14:49:26 +08:00
// 上传开机画面确认按键
handleupload() {
2025-07-26 16:48:31 +08:00
uni.uploadFile({
url: baseURL + '/app/device/uploadLogo',
filePath: this.selectedImage,
name:this.file,
formData: {
deviceId: this.deviceID,
},
header: {
'Authorization': 'Bearer ' + getToken(),
'clientid': clientid(),
},
complete: (res) => {
console.log(res, 'resss');
try {
const responseData = JSON.parse(res.data);
if (responseData.code === 200) {
uni.showToast({
title: responseData.msg,
icon: 'success'
});
this.selectedImage=''
this.lightModeB = false
} else {
uni.showToast({
title: responseData.msg,
icon: 'none'
});
}
} catch (e) {
uni.showToast({
title: '上传失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
}
})
2025-07-05 14:49:26 +08:00
},
2025-07-16 16:43:22 +08:00
// 分享
2025-07-19 10:22:48 +08:00
shareUp() {
2025-07-16 16:43:22 +08:00
uni.navigateTo({
2025-07-19 10:22:48 +08:00
url: '/pages/6170/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('share', {
data: this.itemInfo,
});
}
2025-07-16 16:43:22 +08:00
})
},
2025-07-05 14:49:26 +08:00
2025-07-15 16:34:58 +08:00
// 操作说明
2025-07-05 14:49:26 +08:00
operatingInst() {
uni.navigateTo({
url: `/pages/common/operatingInstruct/index?id=${this.deviceID}`
2025-07-05 14:49:26 +08:00
})
},
// 产品参数
productparams() {
uni.navigateTo({
url: `/pages/common/productDes/index?id=${this.deviceID}`
})
2025-07-05 14:49:26 +08:00
},
// 操作视频
operatingVideo() {
uni.navigateTo({
url: `/pages/common/operationVideo/index?id=${this.deviceID}`
2025-07-05 14:49:26 +08:00
})
},
2025-07-22 17:47:38 +08:00
// 激光确认框
2025-07-05 14:49:26 +08:00
handleBtn() {
this.lightModeC = false
},
2025-07-22 17:47:38 +08:00
//取消
2025-07-05 14:49:26 +08:00
handleDisagree() {
this.lightModeC = false
},
2025-07-16 11:16:19 +08:00
// 发送人员信息
sendPersonnelInfo() {
2025-07-22 17:47:38 +08:00
// 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) {
2025-07-16 16:43:22 +08:00
uni.showToast({
2025-07-22 17:47:38 +08:00
title: '单位名称不能为空',
2025-07-16 16:43:22 +08:00
icon: 'none'
});
2025-07-16 11:16:19 +08:00
return;
}
2025-07-22 17:47:38 +08:00
if (!this.personnelInfo.name) {
2025-07-16 16:43:22 +08:00
uni.showToast({
2025-07-22 17:47:38 +08:00
title: '姓名不能为空',
2025-07-16 16:43:22 +08:00
icon: 'none'
});
2025-07-16 11:16:19 +08:00
return;
}
2025-07-22 17:47:38 +08:00
if (!this.personnelInfo.position) {
uni.showToast({
title: '职位不能为空',
icon: 'none'
});
return;
}
if (!this.personnelInfo.code) {
uni.showToast({
title: 'ID不能为空',
icon: 'none'
});
return;
}
uni.showLoading({
title: '发送中...',
mask: true
})
let data = {
code: this.personnelInfo.code,
name: this.personnelInfo.name,
position: this.personnelInfo.position,
unitName: this.personnelInfo.unitName,
deviceId: this.deviceID
}
registerPersonInfo(data).then((res) => {
if (res.code == 200) {
uni.hideLoading()
2025-07-24 10:05:17 +08:00
this.showPopupFlag = true
this.popupMessage = '人员信息发送成功'
2025-07-22 17:47:38 +08:00
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
})
},
2025-07-24 10:05:17 +08:00
onPopupConfirm() {
this.showPopupFlag = false
console.log('用户点击了确定')
},
2025-07-22 17:47:38 +08:00
// 发送文本消息
sendTextMessage() {
2025-07-16 11:16:19 +08:00
if (!this.messageToSend) {
2025-07-16 16:43:22 +08:00
uni.showToast({
title: '请输入要发送的文字',
icon: 'none'
});
2025-07-16 11:16:19 +08:00
return;
}
2025-07-22 17:47:38 +08:00
uni.showLoading({
title: '发送中...',
mask: true
})
let data = {
sendMsg: this.messageToSend,
deviceIds: [this.deviceID]
}
deviceSendMessage(data).then((res) => {
if (res.code == 200) {
uni.hideLoading()
2025-07-24 10:05:17 +08:00
this.showPopupFlag = true
this.popupMessage = '发送信息成功'
2025-07-22 17:47:38 +08:00
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
})
// const topic = `device/command/${this.deviceID}/message`;
// this.mqttClient.publish(topic, this.messageToSend);
// uni.showToast({
// title: '消息已发送',
// icon: 'success'
// });
},
// 统一处理返回方法
handleDeviceData(res, isFromShared = false) {
if (res.code == 200) {
// 最后关闭加载状态
this.pageLoading = false
this.deviceInfo = res.data
this.personnelInfo = {
unitName: res.data.personnelInfo?.unitName || '',
name: res.data.personnelInfo?.name || '',
code: res.data.personnelInfo?.code || '',
position: res.data.personnelInfo?.position || '',
}
// 将权限字符串转换为数组 ["1", "2"]
if (isFromShared) {
this.isSharedDevice = true
this.activePermissions = res.data.permission ?
res.data.permission.split(',') : []
} else {
this.isSharedDevice = false
this.activePermissions = [] // 非分享设备清空权限
}
this.messageToSend = res.data.sendMsg || ''
// 关闭加载中
2025-07-24 10:05:17 +08:00
uni.hideLoading()
2025-07-22 17:47:38 +08:00
}
},
// 检查权限的方法
hasPermission(permissionCode) {
// 如果还在加载中直接返回false
if (this.pageLoading) return false
// 如果不是分享设备,默认有全部权限
if (!this.isSharedDevice) return true
return this.activePermissions.includes(permissionCode)
},
// 获取设备详情(普通详情)
async fetchDeviceDetail(id) {
try {
const res = await deviceDetail(id)
this.handleDeviceData(res, false)
} catch (error) {
uni.showToast({
title: '获取详情失败',
icon: 'none'
})
}
},
// 获取分享设备详情
async fetchSharedDeviceDetail(id) {
try {
const res = await deviceShareId(id)
this.handleDeviceData(res, true)
} catch (error) {
uni.showToast({
title: '获取分享详情失败',
icon: 'none'
})
}
2025-07-16 11:16:19 +08:00
}
},
onLoad(options) {
2025-07-15 16:34:58 +08:00
const eventChannel = this.getOpenerEventChannel();
// 监听 'detailData' 事件,获取传过来的数据
2025-07-22 17:47:38 +08:00
uni.showLoading({
title: '加载中...'
})
2025-07-15 16:34:58 +08:00
eventChannel.on('deviceControl', (data) => {
this.itemInfo = data.data;
this.deviceID = data.data.id;
this.navTitle = data.data.deviceName;
2025-07-22 17:47:38 +08:00
this.apiType = data.apiType
// 根据 apiType 设置右图标的显示状态
this.isRightIconVisible = this.apiType === 'listA';
2025-07-16 11:16:19 +08:00
// 初始化并连接MQTT
this.mqttClient = new MqttClient();
this.mqttClient.connect(() => {
console.log('MQTT 连接成功,开始订阅主题');
// 订阅来自设备的状态更新
2025-07-22 17:47:38 +08:00
const statusTopic = `A/${this.itemInfo.deviceImei}`;
2025-07-16 11:16:19 +08:00
this.mqttClient.subscribe(statusTopic, (payload) => {
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
2025-07-26 16:48:31 +08:00
// uni.showModal({
// title: '收到设备消息',
// content: payload,
// showCancel: false
// });
2025-07-16 11:16:19 +08:00
});
});
2025-07-22 17:47:38 +08:00
if (this.apiType === 'listA') {
this.fetchDeviceDetail(data.data.id)
} else {
this.fetchSharedDeviceDetail(data.data.deviceId)
}
2025-07-15 16:34:58 +08:00
});
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
eventChannel.emit('ack', {})
2025-07-22 17:47:38 +08:00
2025-07-15 16:34:58 +08:00
},
2025-07-16 11:16:19 +08:00
onUnload() {
// 页面卸载时断开MQTT连接
if (this.mqttClient) {
this.mqttClient.disconnect();
}
},
2025-07-05 14:49:26 +08:00
}
</script>
2025-07-16 16:43:22 +08:00
<style scoped>
2025-07-22 17:47:38 +08:00
.page-loading-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #121212;
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
2025-07-24 10:05:17 +08:00
2025-07-22 17:47:38 +08:00
/* 优化权限控制区域的显示 */
.mode-section,
.form-section {
transition: opacity 0.3s ease;
}
2025-07-05 14:49:26 +08:00
.device-detail-container {
padding: 30rpx;
background: #121212;
min-height: 100vh;
}
.status-bar {
display: flex;
justify-content: space-between;
margin-bottom: 40rpx;
}
.time {
font-size: 36rpx;
font-weight: bold;
}
.battery {
font-size: 36rpx;
}
.battery-section {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
padding: 30rpx;
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
align-items: center;
}
.battery-info,
.duration {
display: flex;
flex-direction: column;
align-items: center;
}
.bipImg {
width: 204rpx;
height: 144rpx;
margin-top: 30rpx;
2025-07-19 10:22:48 +08:00
object-fit: contain;
2025-07-05 14:49:26 +08:00
}
.dlIMG {
width: 52rpx;
height: 52rpx;
}
.cpIMG {
width: 66rpx;
height: 66rpx;
}
.battery-sectionLeft {
width: 308rpx;
height: 220rpx;
background: rgba(42, 42, 42, 0.5);
border-radius: 16rpx;
text-align: center;
align-items: center;
line-height: 220rpx;
}
.percentage {
font-size: 48rpx;
font-weight: bold;
color: #007AFF;
}
.label {
font-size: 28rpx;
color: #666;
margin-top: 10rpx;
}
.battery-v1 {
display: flex;
align-items: center;
margin-bottom: 10rpx;
}
.battery-v2 {
color: rgba(255, 255, 255, 0.87);
margin-left: 18rpx;
font-size: 32rpx;
}
.battery-v3 {
color: rgba(255, 255, 255, 0.6);
margin-left: 25rpx;
font-size: 26rpx;
}
.mode-v3 {
color: rgba(255, 255, 255, 0.6);
font-size: 26rpx;
padding-top: 10rpx;
}
.info-card {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
padding: 10rpx 30rpx 5rpx 30rpx;
margin-bottom: 20rpx;
}
.info-row {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
}
.info-label {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.87);
}
.info-value {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.87);
}
.status-running {
color: rgba(255, 255, 255, 0.6);
text-align: end;
}
.control-card {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
margin-bottom: 20rpx;
position: relative;
}
.light {
position: absolute;
/* top:10rpx; */
color: rgba(74, 74, 74, 0.87);
top: 58rpx;
left: 108rpx
}
.section-title {
font-size: 32rpx;
margin-bottom: 20rpx;
display: block;
color: rgba(255, 255, 255, 0.87);
}
.slider-container {
display: flex;
align-items: center;
}
.slider {
flex: 1;
margin: 0 20rpx;
}
.mode-buttons {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.mode_1 {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx;
background: rgb(26, 26, 26);
align-items: center;
text-align: center;
color: rgba(255, 255, 255, 0.6);
padding-top: 37rpx;
}
.mode-v1 {
background: #1A1A1A;
border-radius: 18rpx;
height: 150rpx;
margin-bottom: 20rpx;
width: 47%;
display: flex;
text-align: center;
}
.mode-v2 {
display: flex;
align-items: center;
text-align: center;
margin-left: 40rpx;
}
.example-body {
position: absolute;
left: 50%;
2025-07-25 17:08:23 +08:00
top: 65%;
2025-07-05 14:49:26 +08:00
width: 100%;
2025-07-25 17:08:23 +08:00
transform: translate(-20%, -100%);
}
.icoContent {
width: 320rpx;
height: 160rpx;
border-radius: 8rpx;
background: rgba(58, 58, 58, 1);
text-align: center;
2025-07-26 16:48:31 +08:00
line-height: 200rpx;
2025-07-25 17:08:23 +08:00
}
2025-07-25 17:08:23 +08:00
.img {
width: 62rpx;
height: 62rpx;
2025-07-05 14:49:26 +08:00
}
.example_title {
color: rgba(255, 255, 255, 0.87);
}
.mode-btn {
width: 48%;
height: 80rpx;
line-height: 80rpx;
background-color: #f5f5f5;
color: #333;
border-radius: 8rpx;
font-size: 28rpx;
border: none;
}
.mode-btn.active {
background-color: #007AFF;
color: #fff;
}
.form-section {
background-color: rgb(26, 26, 26);
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
}
.form-row {
display: flex;
align-items: center;
margin-bottom: 20rpx;
2025-07-15 19:01:49 +08:00
background: rgba(42, 42, 42, 1);
2025-07-05 14:49:26 +08:00
border-radius: 16rpx;
padding-left: 20rpx;
}
.form-label {
font-size: 32rpx;
color: rgba(255, 255, 255, 0.87);
}
.form-input {
height: 80rpx;
border: 1rpx solid transparent;
font-size: 32rpx;
color: rgba(255, 255, 255, 0.87);
}
.product-section {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
.product-tabs {
display: flex;
margin-top: 20rpx;
}
.tab {
padding: 15rpx 30rpx;
font-size: 28rpx;
color: #666;
border-bottom: 4rpx solid transparent;
}
.tab.active {
color: #007AFF;
border-bottom-color: #007AFF;
}
.action-buttons {
padding: 30rpx 0;
}
.send-btn {
background-color: rgb(187, 230, 0);
color: rgba(35, 35, 35, 0.87);
height: 50rpx;
line-height: 50rpx;
border-radius: 16rpx;
font-size: 26rpx;
width: 112rpx;
white-space: nowrap;
text-align: center;
position: absolute;
right: 70rpx;
}
.send-btn1 {
background-color: rgb(187, 230, 0);
color: rgba(35, 35, 35, 0.87);
height: 50rpx;
line-height: 50rpx;
border-radius: 16rpx;
font-size: 26rpx;
width: 112rpx;
white-space: nowrap;
text-align: center;
position: absolute;
right: 0rpx;
top: -70rpx
}
/* 遮罩层 */
.agreement-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
/* 弹窗主体 */
.agreement-popup {
width: 100%;
2025-07-24 10:05:17 +08:00
height: 40%;
2025-07-05 14:49:26 +08:00
background-color: rgb(42, 42, 42);
border-radius: 60rpx 60rpx 0rpx 0rpx;
padding: 40rpx;
2025-07-16 16:43:22 +08:00
box-sizing: border-box;
position: absolute;
bottom: 0rpx;
}
.agreement-popupB {
width: 100%;
2025-07-25 17:08:23 +08:00
height: 32%;
2025-07-16 16:43:22 +08:00
background-color: rgb(42, 42, 42);
border-radius: 60rpx 60rpx 0rpx 0rpx;
padding: 40rpx;
2025-07-05 14:49:26 +08:00
box-sizing: border-box;
position: absolute;
bottom: 0rpx;
}
.agreement-popupC {
width: 80%;
background-color: rgb(42, 42, 42);
border-radius: 40rpx;
padding: 40rpx;
box-sizing: border-box;
border: 1px solid rgba(255, 200, 78, 1);
}
.popup-Title {
color: rgba(255, 200, 78, 1);
}
/* 标题 */
.popup-title {
font-size: 36rpx;
text-align: center;
margin-bottom: 30rpx;
color: rgba(255, 255, 255, 0.87);
}
/* 内容文本 */
.popup-content {
font-size: 30rpx;
line-height: 1.6;
color: rgba(255, 255, 255, 0.87);
margin-bottom: 50rpx;
}
.item {
padding: 10px;
margin: 5px 0;
display: flex;
align-items: center;
cursor: pointer;
transition: background-color 0.3s;
}
.setIMG {
width: 24px;
height: 24px;
margin-right: 10px;
}
.item.selected {
background-color: rgb(58, 58, 58);
color: rgba(255, 255, 255, 0.87);
border-radius: 8rpx;
}
/* 按钮容器 */
.popup-buttons {
display: flex;
justify-content: space-between;
}
/*确定按钮 */
.agree {
background-color: rgb(187, 230, 0);
color: #232323;
border: none;
font-size: 24rpx;
height: 88rpx;
line-height: 88rpx;
font-size: 32rpx;
width: 100%;
position: absolute;
bottom: 0rpx;
left: 0rpx
}
/* 通用按钮样式 */
.btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
font-size: 32rpx;
margin: 0 20rpx;
}
/* 不同意按钮 */
.disagree {
background-color: transparent;
color: rgba(255, 255, 255, 0.87);
border: 1px solid rgba(255, 200, 78, 0.7);
font-size: 24rpx;
color: rgba(255, 200, 78, 1);
}
/* 同意按钮 */
.agreeBtn {
background-color: rgba(255, 200, 78, 1);
color: #232323;
border: none;
font-size: 24rpx;
}
.right-icons {
/* display: flex; */
align-items: center;
}
.toggle-icon {
cursor: pointer;
font-size: 16px;
margin-top: -40rpx;
}
.icon {
font-size: 14px;
color: #fff;
}
.form-content {
transition: all 0.3s ease;
margin-top: 60rpx;
position: relative;
}
</style>