diff --git a/pages/6170/allShare/index.vue b/pages/6170/allShare/index.vue index 8d60e92..4cdfb9d 100644 --- a/pages/6170/allShare/index.vue +++ b/pages/6170/allShare/index.vue @@ -33,7 +33,7 @@ - + 设备:{{item.deviceName}} @@ -67,7 +67,7 @@ - + {{ tabs[activeTab].name === '我的分享' ? '确定停止分享该设备' : '确定移除他人分享给你的这台设备' }} diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue index bf0db50..8c96320 100644 --- a/pages/6170/deviceControl/index.vue +++ b/pages/6170/deviceControl/index.vue @@ -12,7 +12,7 @@ - + @@ -23,7 +23,7 @@ - + 1小时 续航时间 @@ -61,7 +61,7 @@ - @@ -80,7 +80,7 @@ - + 激光模式 @@ -88,7 +88,7 @@ - + 开机画面 上传 @@ -143,22 +143,22 @@ 产品信息 - + 产品参数 - + 操作说明 - + 操作视频 - + @@ -178,9 +178,9 @@ - + - + 上传开机画面 @@ -204,9 +204,9 @@ - + - + 确认开启激光模式? @@ -220,7 +220,7 @@ - + @@ -255,9 +255,9 @@ secondaryMode: 'string', navBarHeight: 70 + uni.getSystemInfoSync().statusBarHeight, navTitle: "", - sliderValue: 50, + sliderValue: 30, lightModeA: false, - currentMainMode: '强光模式', + currentMainMode: '强光', lightModeB: false, lightModeC: false, //激光提示框 items: [], @@ -288,7 +288,8 @@ popupConfirmText: '确认', showUploadPopup: false, selectedImage: null, // 添加这个变量来存储选择的图片 - file: '' + file: '', + selectedItemIndex: 0 } }, computed: { @@ -319,22 +320,22 @@ if (type === 'main') { this.items = [{ text: '强光', - selected: this.currentMainMode === '强光模式', - image: '/static/images/sett.png' + selected: this.currentMainMode === '强光', // 修正匹配条件 + image: '/static/images/sett.png', }, { text: '弱光', - selected: this.currentMainMode === '弱光模式', + selected: this.currentMainMode === '弱光', image: '/static/images/sett.png' }, { text: '爆闪', - selected: this.currentMainMode === '爆闪模式', + selected: this.currentMainMode === '爆闪', image: '/static/images/bs.png' }, { text: '泛光', - selected: this.currentMainMode === '泛光模式', + selected: this.currentMainMode === '泛光', image: '/static/images/settt.png' }, ]; @@ -365,18 +366,28 @@ }, // 灯光模式的确认 handleSumbit() { - if (this.selectedItemIndex === null) return; - const selectedItem = this.items[this.selectedItemIndex]; - const instruction = this.modeInstructions[selectedItem.text]; - console.log(selectedItem, 'selectedItemselectedItem'); - this.selectedItemIndex = selectedItem.text; - if (instruction) { - const topic = `B/${this.itemInfo.deviceImei}`; - const message = JSON.stringify(instruction); - this.mqttClient.publish(topic, message); - console.log('已发送指令:', instruction); - } - this.lightModeA = false; + 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; }, // 上传开机画面 uploadStartup() { diff --git a/pages/6170/shareDevices/index.vue b/pages/6170/shareDevices/index.vue index 1ec3e4b..8766f08 100644 --- a/pages/6170/shareDevices/index.vue +++ b/pages/6170/shareDevices/index.vue @@ -4,7 +4,7 @@ - + 设备:{{itemInfo.deviceName}} @@ -48,7 +48,7 @@ - + 设备分享成功 diff --git a/pages/6170/shareManagement/index.vue b/pages/6170/shareManagement/index.vue index 46b862a..91e7a96 100644 --- a/pages/6170/shareManagement/index.vue +++ b/pages/6170/shareManagement/index.vue @@ -4,7 +4,7 @@ - + 用户名:{{item.deviceName}} diff --git a/pages/common/index/index.vue b/pages/common/index/index.vue index 6ab24fe..ac6cf8a 100644 --- a/pages/common/index/index.vue +++ b/pages/common/index/index.vue @@ -12,56 +12,63 @@ {{tab.typeName}} + + + - - - 报警 + + 位置 发送信息 - - - - - - - - - - - 设备:{{item.deviceName}} - - ID:{{item.deviceImei}} + + + + + + + + + + + 设备:{{item.deviceName}} + + ID:{{item.deviceImei}} + + ID:{{item.deviceMac}} + 在线 + 电量:90% - ID:{{item.deviceMac}} - 在线 - 电量:90% + + 已连接 + 未连接 + - - 已连接 - 未连接 - - - - - - - - - - 加载中... - 没有更多数据了 + + + + + + + 加载中... + 没有更多数据了 + + + + + + 暂无数据 - - + + @@ -76,13 +83,14 @@ - - + + 设备名称 - + @@ -103,6 +111,17 @@ + + + + + + + {{ item.text }} + + + @@ -121,6 +140,7 @@ tabs: [], activeTab: 0, showTooltip: false, + showshare: false, Options: [{ text: '重命名', style: { @@ -152,21 +172,63 @@ action: 'bluetooth' } ], + shareItems: [{ + text: '所有类型', + icon: '/static/images/type.png', + action: 'type' + }, + { + text: '所有分享', + icon: '/static/images/share.png', + action: 'share' + } + ], page: 1, // 当前页码 size: 10, // 每页条数 total: 0, // 总数据量 loading: false, finished: false, deviceId: '', - deviceName: "" //重命名 + deviceName: "", //重命名 + activeTabInfo: '' } }, methods: { + // 更多 + allMore() { + this.showshare = !this.showshare; + }, + // 所有分享,所有类型 + handleshareClick(item) { + this.showshare = false; // 关闭弹窗 + switch (item.action) { + case 'type': + uni.navigateTo({ + url: '/pages/common/allType/index' + }); + break; + case 'share': + uni.navigateTo({ + url: "/pages/6170/allShare/index" + }) + break; + } + }, + // 点击弹框外的区域关闭 + closePopup(type) { + if (type === 'delete') { + this.deleteShow = false; + uni.showTabBar(); // 显示TabBar + } else if (type === 'rename') { + this.RenameModel = false; + uni.showTabBar(); // 显示TabBar + } + }, // tab导航切换栏 getTab() { deviceTypeList({}).then((res) => { if (res.code == 200) { - console.log("deviceTypeList=" + JSON.stringify(res.data)); + //console.log("deviceTypeList=" + JSON.stringify(res.data)); this.tabs = [{ id: '', name: '全部设备', @@ -186,6 +248,7 @@ switchTab(tab, index) { this.deviceList = []; this.activeTab = index; + this.activeTabInfo = tab this.page = 1; // 重置页码 this.finished = false; // 重 // 明确传递参数,空字符串改为null或undefined @@ -226,10 +289,11 @@ onScrollToLower() { this.getData(); }, + // 添加扫一三图标 scan() { this.showTooltip = !this.showTooltip; }, - + // 添加设备,扫一扫,蓝牙 handleMenuClick(item) { this.showTooltip = false; // 关闭弹窗 switch (item.action) { @@ -239,15 +303,6 @@ }); break; case 'bluetooth': - // uni.navigateTo({ - // url: 'pages/common/addBLE/AddDevice', - // success:(res)=>{ - // res.eventChannel.emit('key', { data: 'data from starter page' }) - // },fail: (ex) => { - // console.log("跳转失败了",JSON.stringify(ex)); - // } - // }); - uni.navigateTo({ url: "/pages/common/addBLE/addEquip" }) @@ -256,8 +311,11 @@ }, // 右滑点击事件处理 handleSwipeClick(e, item, index) { - const {content} = e - console.log(e, 'eeeee'); + + const { + content + } = e + console.log(item, 'eeeee'); switch (e.content.text) { case '删除': this.handleDeleteDevice(item, index) @@ -290,6 +348,8 @@ this.onIntall(); }, 500); this.deleteShow = false + // 关闭所有滑动项 + this.$refs.swipeAction.closeAll(); } else { uni.showToast({ title: res.msg, @@ -323,6 +383,8 @@ }, 500); this.RenameModel = false this.deviceName = '' + // 关闭所有滑动项 + this.$refs.swipeAction.closeAll(); } else { uni.showToast({ title: res.msg, @@ -334,57 +396,84 @@ }, // 发生短信 handleSend() { + const currentTab = this.tabs[this.activeTab]; + const deviceType = currentTab.id || 'all'; + console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`); uni.navigateTo({ - url: '/pages/common/send/index' + url: '/pages/common/send/index', + events: { + ack: function(data) {} + }, + success: (res) => { + res.eventChannel.emit('deviceSend', { + data: deviceType + }); + } }) }, // 位置 - location(){ + location() { uni.navigateTo({ - url:'/pages/common/map/index' + url: '/pages/common/map/index' }) }, handleFile(item) { - console.log('item' + JSON.stringify(item)); + //console.log('item' + JSON.stringify(item)); // communicationMode 0是4G 1是蓝牙 if (item.communicationMode == 0) { uni.navigateTo({ - url: `/pages/6170/deviceControl/index?id=${item.id}` + url: "/pages/6170/deviceControl/index", + events: { + ack: function(data) {} + }, + success: (res) => { + // 页面跳转成功后的回调函数 + res.eventChannel.emit('deviceControl', { + data: item, + apiType: 'listA' // 自定义标识,详情哪里根据这个参数不同信息 + }); + } + }) + } + if (item.typeName == '6155') { + uni.navigateTo({ + url: "/pages/6155/deviceDetail", + events: { + ack: function(data) { - }); - return; - } - - if (item.typeName == '6155') { - uni.navigateTo({ - url: "/pages/650/HBY650", - events: { - ack: function(data) { - - } - }, - success: (res) => { - res.eventChannel.emit('detailData', { - data: item - }); } - }) - } + }, + success: (res) => { + res.eventChannel.emit('detailData', { + data: item + }); + } + }) + } - }, - onIntall() { - this.page = 1; - this.finished = false; - this.getData(); // 重新加载第一页数据 - }, }, - onShow() { - this.getTab() + onIntall() { + this.page = 1; + this.finished = false; + this.getData(this.deviceType); // 重新加载第一页数据 + }, + }, + onLoad() { + this.getTab() + this.onIntall() + // 绑定页面做了监听,新增成功,刷新页面 + uni.$on('refreshDeviceList', () => { + this.getTab() // 刷新数据 this.onIntall() - } + }); + }, + beforeDestroy() { + // 组件销毁前移除监听器 + uni.$off('refreshDeviceList'); + }, - } + }