发送信息列表接口联调,

This commit is contained in:
fengerli
2025-07-16 11:33:26 +08:00
parent f3a3778452
commit 80dd83bb3d
4 changed files with 85 additions and 28 deletions

View File

@ -13,8 +13,7 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view class="sendFlex"> <view class="sendFlex" v-if="activeTab && activeTab.id !== ''">
<view class="callpolice">报警</view> <view class="callpolice">报警</view>
<view class="Sendmessage" @click="location">位置</view> <view class="Sendmessage" @click="location">位置</view>
<view class="Sendmessage" @click="handleSend">发送信息</view> <view class="Sendmessage" @click="handleSend">发送信息</view>
@ -46,7 +45,6 @@
<view class="device-status online">已连接</view> <view class="device-status online">已连接</view>
<view class="device-status unline">未连接</view> <view class="device-status unline">未连接</view>
</view> </view>
</view> </view>
<image src="/static/images/cires.png" class="circle"></image> <image src="/static/images/cires.png" class="circle"></image>
</uni-swipe-action-item> </uni-swipe-action-item>
@ -177,7 +175,7 @@
getTab() { getTab() {
deviceTypeList({}).then((res) => { deviceTypeList({}).then((res) => {
if (res.code == 200) { if (res.code == 200) {
console.log("deviceTypeList=" + JSON.stringify(res.data)); //console.log("deviceTypeList=" + JSON.stringify(res.data));
this.tabs = [{ this.tabs = [{
id: '', id: '',
name: '全部设备', name: '全部设备',
@ -353,8 +351,19 @@
}, },
// 发生短信 // 发生短信
handleSend() { handleSend() {
const currentTab = this.tabs[this.activeTab];
const deviceType = currentTab.id || 'all';
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
uni.navigateTo({ 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() { onIntall() {
this.page = 1; this.page = 1;
this.finished = false; this.finished = false;
this.getData(); // 重新加载第一页数据 this.getData(this.deviceType); // 重新加载第一页数据
}, },
}, },
onShow() { onLoad() {
this.getTab() this.getTab()
this.onIntall() this.onIntall()
} // 绑定页面做了监听,新增成功,刷新页面
uni.$on('refreshDeviceList', () => {
this.getTab() // 刷新数据
});
},
beforeDestroy() {
// 组件销毁前移除监听器
uni.$off('refreshDeviceList');
},
} }
</script> </script>

View File

@ -146,6 +146,7 @@
tenantId: '894078' //租户ID tenantId: '894078' //租户ID
}) })
if (res.code == 200) { if (res.code == 200) {
console.log(res,'ressss');
uni.hideLoading() uni.hideLoading()
uni.setStorageSync('token', res.data.access_token) // 缓存token uni.setStorageSync('token', res.data.access_token) // 缓存token
uni.setStorageSync('clientID', res.data.client_id) // 缓存token uni.setStorageSync('clientID', res.data.client_id) // 缓存token

View File

@ -35,18 +35,21 @@
return { return {
deviceId: '', deviceId: '',
isConnecting: false, // 是否正在连接 isConnecting: false, // 是否正在连接
isConnected: false ,// 是否连接成功 isConnected: false, // 是否连接成功
isConnectNo:false, isConnectNo: false,
isSuccess:false isSuccess: false
} }
}, },
methods: { methods: {
async handleConnect() { async handleConnect() {
if (this.isConnecting) { if (this.isConnecting) {
// 绑定成功,确认按钮跳转到首页并通知刷新数据
uni.$emit('refreshDeviceList'); // 发出刷新事件
// 绑定成功,确认按钮跳转到首页 // 绑定成功,确认按钮跳转到首页
uni.switchTab({ uni.switchTab({
url: '/pages/common/index/index' url: '/pages/common/index/index'
}) })
} else { } else {
// 开始连接逻辑 // 开始连接逻辑
uni.showLoading({ uni.showLoading({
@ -54,7 +57,7 @@
title: '加载中....' title: '加载中....'
}) })
this.isConnecting = true; this.isConnecting = true;
this.isConnectNo=true this.isConnectNo = true
try { try {
// 调用绑定设备接口 // 调用绑定设备接口
const res = await deviceBind({ const res = await deviceBind({
@ -62,10 +65,10 @@
deviceMac: '', deviceMac: '',
communicationMode: '0', //0是4g,1是蓝牙 communicationMode: '0', //0是4g,1是蓝牙
}) })
console.log(this.deviceId,'deerer ere'); console.log(this.deviceId, 'deerer ere');
if (res.code == 200) { if (res.code == 200) {
this.isConnectNo=false this.isConnectNo = false
this.isSuccess =true this.isSuccess = true
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
title: res.data, title: res.data,
@ -73,7 +76,7 @@
}); });
this.isConnecting = true; this.isConnecting = true;
} else { } else {
this.isConnectNo=false this.isConnectNo = false
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
}); });

View File

@ -11,14 +11,17 @@
<view class="device-content"> <view class="device-content">
<view class="device-header"> <view class="device-header">
<view class="deviceIMG"> <view class="deviceIMG">
<image src="/static/images/device.png" mode="" class="IMG"></image> <image :src="item.devicePic" mode="" class="IMG"></image>
</view> </view>
<view class="device-name"> <view class="device-name">
<view>设备:001-00</view> <view>设备:{{item.deviceName}}</view>
<view class="ID">ID:{{ item.id }}</view> <view class="ID">ID:{{ item.deviceImei }}</view>
</view> </view>
</view> </view>
<view class="" v-if="item.communicationMode==1">
<view class="device-status online">已连接</view> <view class="device-status online">已连接</view>
<view class="device-status unline">未连接</view>
</view>
<view class="device-info"> <view class="device-info">
<text class="onlines">在线</text> <text class="onlines">在线</text>
<text class="line"></text> <text class="line"></text>
@ -39,14 +42,13 @@
</template> </template>
<script> <script>
import {
deviceInfo,
} from '@/api/common/index.js'
export default { export default {
data() { data() {
return { return {
deviceList: Array(6).fill().map((_, i) => ({ deviceList:[],
id: `1321615${i}`,
checked: false,
showConfirm: false
})),
} }
}, },
methods: { methods: {
@ -61,8 +63,40 @@
title: `已发送到${selectedDevices.length}台设备`, title: `已发送到${selectedDevices.length}台设备`,
icon: 'success' icon: 'success'
}) })
},
// 获取设备列表
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;
});
},
},
onLoad(options) {
const eventChannel = this.getOpenerEventChannel();
// 监听 'deviceSend' 事件,获取传过来的数据
eventChannel.on('deviceSend', (data) => {
console.log('Received detail data:', data);
this.getData(data.data)
});
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
eventChannel.emit('ack', {})
},
} }
</script> </script>
@ -146,7 +180,9 @@
.online { .online {
color: rgb(187, 230, 0); color: rgb(187, 230, 0);
} }
.unline {
color: rgba(255, 255, 255, 0.4);
}
.device-info { .device-info {
display: flex; display: flex;
justify-content: space-evenly; justify-content: space-evenly;