首页跳转传参方式

This commit is contained in:
fengerli
2025-07-15 16:34:58 +08:00
parent 56f05e7eec
commit 388b462b57
8 changed files with 15788 additions and 2169 deletions

View File

@ -7,7 +7,7 @@
<!-- 设备电量信息 -->
<view class="battery-section">
<view class="battery-sectionLeft">
<image src="/static/images/bip.6.png" class="bipImg"></image>
<image :src="itemInfo.devicePic" class="bipImg"></image>
</view>
<view>
<view class="battery-v1">
@ -59,7 +59,6 @@
<view class="control-card">
<slider :value="sliderValue" min="0" max="100" activeColor="rgb(187, 230, 0)"
backgroundColor="rgb(26, 26, 26)" show-value />
</view>
<!-- 灯光模式选择 -->
@ -217,13 +216,20 @@
</template>
<script>
import {
connectMQTT,
publishMessage,
onMessageReceived,
disconnectMQTT,
isMQTTConnected
} from '@/utils/mqtt'
export default {
data() {
return {
mainMode: 'string',
secondaryMode: 'string',
navBarHeight: 70 + uni.getSystemInfoSync().statusBarHeight,
navTitle: "6170",
navTitle: "",
sliderValue: 50,
lightModeA: false,
currentMainMode: '强光模式',
@ -232,7 +238,8 @@
lightModeC: false, //激光提示框
items: [],
isFormExpanded: true, // 默认展开
deviceID: ''
deviceID: '',
itemInfo: {}
}
},
computed: {
@ -241,6 +248,25 @@
}
},
methods: {
async initMQTT() {
try {
if (!isMQTTConnected()) {
await connectMQTT()
}
await publishMessage('/test/123/456/set', 'Hello MQTT!')
uni.showToast({
title: '消息发送成功'
})
} catch (error) {
console.error('发送失败:', error)
uni.showToast({
title: '发送失败',
icon: 'none'
})
}
},
selectMode(type) {
this.modeType = type;
this.lightModeA = true;
@ -312,7 +338,7 @@
this.lightModeB = false
},
// 操说明
// 操说明
operatingInst() {
uni.navigateTo({
url: `/pages/common/operatingInstruct/index?id=${this.deviceID}`
@ -343,9 +369,17 @@
},
},
onLoad(options) {
console.log(options.id) // 输出: 123
this.deviceID = options.id
}
const eventChannel = this.getOpenerEventChannel();
// 监听 'detailData' 事件,获取传过来的数据
eventChannel.on('deviceControl', (data) => {
this.itemInfo = data.data;
this.deviceID = data.data.id;
this.navTitle = data.data.deviceName;
console.log('Received detail data:', this.navTitle);
});
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
eventChannel.emit('ack', {})
},
}
</script>
@ -451,7 +485,7 @@
.mode-v3 {
color: rgba(255, 255, 255, 0.6);
font-size: 26rpx;