diff --git a/pages/common/index/index.vue b/pages/common/index/index.vue index 2632008..3f40384 100644 --- a/pages/common/index/index.vue +++ b/pages/common/index/index.vue @@ -13,8 +13,7 @@ - - + 报警 位置 发送信息 @@ -46,7 +45,6 @@ 已连接 未连接 - @@ -177,7 +175,7 @@ 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: '全部设备', @@ -353,8 +351,19 @@ }, // 发生短信 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 + }); + } }) }, // 位置 @@ -402,13 +411,21 @@ onIntall() { this.page = 1; this.finished = false; - this.getData(); // 重新加载第一页数据 + this.getData(this.deviceType); // 重新加载第一页数据 }, }, - onShow() { + onLoad() { this.getTab() this.onIntall() - } + // 绑定页面做了监听,新增成功,刷新页面 + uni.$on('refreshDeviceList', () => { + this.getTab() // 刷新数据 + }); + }, + beforeDestroy() { + // 组件销毁前移除监听器 + uni.$off('refreshDeviceList'); + }, } diff --git a/pages/common/login/index.vue b/pages/common/login/index.vue index 36d7434..751fd6b 100644 --- a/pages/common/login/index.vue +++ b/pages/common/login/index.vue @@ -146,6 +146,7 @@ tenantId: '894078' //租户ID }) if (res.code == 200) { + console.log(res,'ressss'); uni.hideLoading() uni.setStorageSync('token', res.data.access_token) // 缓存token uni.setStorageSync('clientID', res.data.client_id) // 缓存token diff --git a/pages/common/qrcode/qrcode.vue b/pages/common/qrcode/qrcode.vue index 40e33a5..088b5e9 100644 --- a/pages/common/qrcode/qrcode.vue +++ b/pages/common/qrcode/qrcode.vue @@ -35,18 +35,21 @@ return { deviceId: '', isConnecting: false, // 是否正在连接 - isConnected: false ,// 是否连接成功 - isConnectNo:false, - isSuccess:false + isConnected: false, // 是否连接成功 + isConnectNo: false, + isSuccess: false } }, methods: { async handleConnect() { if (this.isConnecting) { + // 绑定成功,确认按钮跳转到首页并通知刷新数据 + uni.$emit('refreshDeviceList'); // 发出刷新事件 // 绑定成功,确认按钮跳转到首页 uni.switchTab({ url: '/pages/common/index/index' }) + } else { // 开始连接逻辑 uni.showLoading({ @@ -54,7 +57,7 @@ title: '加载中....' }) this.isConnecting = true; - this.isConnectNo=true + this.isConnectNo = true try { // 调用绑定设备接口 const res = await deviceBind({ @@ -62,10 +65,10 @@ deviceMac: '', communicationMode: '0', //0是4g,1是蓝牙 }) - console.log(this.deviceId,'deerer ere'); + console.log(this.deviceId, 'deerer ere'); if (res.code == 200) { - this.isConnectNo=false - this.isSuccess =true + this.isConnectNo = false + this.isSuccess = true uni.hideLoading() uni.showToast({ title: res.data, @@ -73,7 +76,7 @@ }); this.isConnecting = true; } else { - this.isConnectNo=false + this.isConnectNo = false uni.showToast({ title: res.msg, }); diff --git a/pages/common/send/index.vue b/pages/common/send/index.vue index 9b792a9..6fd1677 100644 --- a/pages/common/send/index.vue +++ b/pages/common/send/index.vue @@ -11,14 +11,17 @@ - + - 设备:001-00 - ID:{{ item.id }} + 设备:{{item.deviceName}} + ID:{{ item.deviceImei }} - 已连接 + + 已连接 + 未连接 + 在线 @@ -39,14 +42,13 @@ @@ -146,7 +180,9 @@ .online { color: rgb(187, 230, 0); } - +.unline { + color: rgba(255, 255, 255, 0.4); + } .device-info { display: flex; justify-content: space-evenly;