合并主分支
# Conflicts: # pages/210/deviceControl/index.vue # pages/650/HBY650.vue # pages/common/index/index.vue # unpackage/dist/dev/app-plus/static/tabs/device-HL.png # unpackage/dist/dev/app-plus/static/tabs/device.png # unpackage/dist/dev/app-plus/static/tabs/my-HL.png # unpackage/dist/dev/app-plus/static/tabs/my.png # utils/BleReceive.js # utils/loading.js
This commit is contained in:
@ -9,8 +9,8 @@
|
||||
<scroll-view class="tab-bar" scroll-x="true" scroll-with-animation>
|
||||
<view class="tab-container">
|
||||
<view v-for="(tab, index) in tabs" :key="index"
|
||||
:class="['tab-item', activeTab === index ? 'active' : '']" @click="switchTab(tab, index)">
|
||||
{{ tab.typeName }}
|
||||
:class="['tab-item', activeTab === index ? 'active' : '']" @click="switchTab(tab,index)">
|
||||
{{tab.typeName}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@ -18,70 +18,65 @@
|
||||
<image src="/static/images/common/more.png" mode="aspectFit" class="more"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sendFlex" v-if="activeTab && activeTab.id !== '' && activeTabInfo.communicationMode == 0">
|
||||
<view class="sendFlex"
|
||||
v-if="activeTab && activeTab.id !== ''&& activeTabInfo.communicationMode==0 && activeTabInfo.typeName=='BJQ6170'">
|
||||
<view class="callpolice" @click="callpolice">报警</view>
|
||||
<view class="Sendmessage" @click="location">位置</view>
|
||||
<view class="Sendmessage" @click="handleSend">发送信息</view>
|
||||
</view>
|
||||
<mescroll-uni v-if="deviceList.length > 0" class="device-list" @init="mescrollInit" @down="downCallback"
|
||||
@up="upCallback" :up="upOption" :down="downOption" :fixed="false"
|
||||
:style="{ height: mescrollHeight + 'px' }">
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options" @click="handleSwipeClick($event, item, index)"
|
||||
class="device-card"
|
||||
:style="{ border: item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{ item.deviceName }}</view>
|
||||
<view class="ID">
|
||||
<view class="ID" v-if="item.communicationMode == 0">ID:{{
|
||||
item.deviceImei }}
|
||||
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
|
||||
style="height:80vh;">
|
||||
<view v-if="deviceList.length>0">
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options"
|
||||
@click="handleSwipeClick($event, item, index)" class="device-card"
|
||||
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID" v-if="item.communicationMode==0">ID:{{item.deviceImei}}
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{item.deviceMac}}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{ item.deviceMac }}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1">在线
|
||||
</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 0">离线
|
||||
</view>
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 2">故障
|
||||
</view>
|
||||
<view>电量:{{ item.battery || '0' }}%</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode==1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode == 1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
</view>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
<!-- 加载状态提示 -->
|
||||
<view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
<!-- 加载状态提示 -->
|
||||
<view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</mescroll-uni>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')" catchtouchmove="true">
|
||||
@ -150,11 +145,11 @@
|
||||
deviceReName
|
||||
} from '@/api/common/index.js'
|
||||
import BleHelper from '@/utils/BleHelper.js';
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue'
|
||||
var ble = null;
|
||||
var ble=null;
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
onPullDownRefresh() {
|
||||
// 执行下拉刷新时的操作,比如重新获取数据
|
||||
this.onIntall();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -206,79 +201,24 @@
|
||||
action: 'share'
|
||||
}
|
||||
],
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: false
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 50,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
size: 12, // 每页条数
|
||||
size: 10, // 每页条数
|
||||
total: 0, // 总数据量
|
||||
loadedCount: 0,
|
||||
loading: false,
|
||||
finished: false,
|
||||
deviceId: '',
|
||||
deviceName: "", //重命名
|
||||
activeTabInfo: '',
|
||||
mescrollHeight: 0,
|
||||
activeTabInfo: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
const currentDeviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
const tempList = [...this.deviceList];
|
||||
// 重置分页参数
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
this.total = 0; // 重置总数
|
||||
this.getData(currentDeviceType)
|
||||
.then(() => {
|
||||
this.mescroll.endDownScroll(true);
|
||||
})
|
||||
.catch(() => {
|
||||
this.deviceList = tempList;
|
||||
this.mescroll.endDownScroll(false);
|
||||
});
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
if (this.loading) {
|
||||
this.mescroll.endUpScroll(false);
|
||||
return;
|
||||
}
|
||||
const currentDeviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
this.getData(currentDeviceType)
|
||||
.then(() => {
|
||||
// 如果本次加载的数据量为0,则说明没有更多数据
|
||||
const hasMore = this.deviceList.length > 0 && this.deviceList.length % this.size === 0;
|
||||
this.mescroll.endUpScroll(hasMore);
|
||||
})
|
||||
.catch(() => {
|
||||
this.page--;
|
||||
this.mescroll.endUpScroll(false);
|
||||
});
|
||||
},
|
||||
// 更多
|
||||
allMore() {
|
||||
this.showshare = !this.showshare;
|
||||
},
|
||||
// 所有分享,所有类型
|
||||
handleshareClick(item) {
|
||||
this.showshare = false;
|
||||
this.showshare = false; // 关闭弹窗
|
||||
switch (item.action) {
|
||||
case 'type':
|
||||
uni.navigateTo({
|
||||
@ -296,16 +236,17 @@
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
this.deleteShow = false;
|
||||
uni.showTabBar();
|
||||
uni.showTabBar(); // 显示TabBar
|
||||
} else if (type === 'rename') {
|
||||
this.RenameModel = false;
|
||||
uni.showTabBar();
|
||||
uni.showTabBar(); // 显示TabBar
|
||||
}
|
||||
},
|
||||
// tab导航切换栏
|
||||
getTab() {
|
||||
deviceTypeList({}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
//console.log("deviceTypeList=" + JSON.stringify(res.data));
|
||||
this.tabs = [{
|
||||
id: '',
|
||||
name: '全部设备',
|
||||
@ -325,66 +266,47 @@
|
||||
switchTab(tab, index) {
|
||||
this.deviceList = [];
|
||||
this.activeTab = index;
|
||||
this.activeTabInfo = tab;
|
||||
// 完全重置分页状态
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
this.total = 0; // 重置总数
|
||||
this.activeTabInfo = tab
|
||||
this.page = 1; // 重置页码
|
||||
this.finished = false; // 重
|
||||
// 明确传递参数,空字符串改为null或undefined
|
||||
const deviceType = tab.id === '' ? undefined : tab.id;
|
||||
this.$nextTick(() => {
|
||||
this.getSystemInfoSyncH();
|
||||
});
|
||||
this.getData(deviceType);
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll();
|
||||
}
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(deviceType = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.loading || this.finished) {
|
||||
reject('正在加载或已无更多数据');
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
deviceType: deviceType
|
||||
}
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
if (this.page === 1) {
|
||||
this.total = Number(res.total) || 0;
|
||||
this.deviceList = newDevices;
|
||||
this.loadedCount = newDevices.length;
|
||||
} else {
|
||||
this.deviceList = [...this.deviceList, ...newDevices];
|
||||
this.loadedCount += newDevices.length;
|
||||
}
|
||||
const hasMoreData = this.loadedCount < this.total;
|
||||
if (!hasMoreData) {
|
||||
this.finished = true;
|
||||
}
|
||||
if (hasMoreData) {
|
||||
this.page++;
|
||||
}
|
||||
resolve();
|
||||
if (this.loading || this.finished) return;
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
deviceType: deviceType // 使用传入的设备类型
|
||||
}
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
|
||||
// 如果是第一页或切换分类,替换数据
|
||||
this.deviceList = this.page === 1 ? newDevices : [...this.deviceList, ...newDevices];
|
||||
this.total = res.total;
|
||||
// 判断是否加载完成
|
||||
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
|
||||
this.finished = true;
|
||||
} else {
|
||||
reject(res.msg || '获取数据失败');
|
||||
this.page++;
|
||||
}
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 滚动触底事件处理
|
||||
onScrollToLower() {
|
||||
this.getData();
|
||||
},
|
||||
// 添加扫一扫图标
|
||||
scan() {
|
||||
this.showTooltip = !this.showTooltip;
|
||||
@ -395,59 +317,21 @@
|
||||
},
|
||||
// 添加设备,扫一扫,蓝牙
|
||||
handleMenuClick(item) {
|
||||
this.showTooltip = false;
|
||||
this.showTooltip = false; // 关闭弹窗
|
||||
switch (item.action) {
|
||||
case 'scan':
|
||||
// 扫一扫
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
let cleanedResult = res.result.trim();
|
||||
console.log("scanResult=", cleanedResult);
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
let url = '';
|
||||
try {
|
||||
let json = JSON.parse(cleanedResult);
|
||||
console.log("json=", json);
|
||||
if ('blue' in json) {
|
||||
let mac = json.blue;
|
||||
if (mac) {
|
||||
if (!mac.includes(':')) {
|
||||
mac = mac.replace(/(.{2})/g,'$1:').slice(0,-1)
|
||||
}
|
||||
url =`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(mac)}`;
|
||||
console.log("蓝牙设备",mac);
|
||||
}
|
||||
|
||||
|
||||
} else if ('imei' in json) {
|
||||
let imei = json.imei;
|
||||
if (iemi) {
|
||||
url =
|
||||
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(imei)}`;
|
||||
console.log("4G设备:",imei)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error("识别二维码失败,",error);
|
||||
} finally {
|
||||
|
||||
if(!url){
|
||||
url =
|
||||
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
|
||||
console.log("未知设备:",cleanedResult)
|
||||
}
|
||||
|
||||
resolve(url);
|
||||
}
|
||||
});
|
||||
promise.then(res => {
|
||||
uni.navigateTo({
|
||||
url: res
|
||||
});
|
||||
console.log('条码内容:', res);
|
||||
// 清除之前的数据
|
||||
this.previousScanResult = null;
|
||||
// 处理新的扫码结果
|
||||
const cleanedResult = res.result.trim();
|
||||
console.log('扫码结果:', cleanedResult);
|
||||
// 跳转并传递扫描结果
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
@ -461,13 +345,17 @@
|
||||
break;
|
||||
case 'bluetooth':
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip?search=all"
|
||||
url: "/pages/common/addBLE/addEquip"
|
||||
})
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 右滑点击事件处理
|
||||
handleSwipeClick(e, item, index) {
|
||||
const {
|
||||
content
|
||||
} = e
|
||||
console.log(item, 'eeeee');
|
||||
switch (e.content.text) {
|
||||
case '删除':
|
||||
this.handleDeleteDevice(item, index)
|
||||
@ -486,6 +374,9 @@
|
||||
// 确认删除
|
||||
handleBtn() {
|
||||
uni.showTabBar()
|
||||
let data = {
|
||||
id: this.deviceId.id
|
||||
}
|
||||
deviceUnbind(this.deviceId.id).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
@ -498,12 +389,10 @@
|
||||
this.getTab()
|
||||
}, 500);
|
||||
this.deleteShow = false
|
||||
if (this.$refs.swipeAction) {
|
||||
this.$refs.swipeAction.closeAll();
|
||||
}
|
||||
console.log("111111", this.deviceId);
|
||||
console.log("ble==null,", ble)
|
||||
ble && ble.DropDevice(null, this.deviceId.id);
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
|
||||
ble && ble.DropDevice(data.id);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -521,10 +410,11 @@
|
||||
},
|
||||
handleBtnName() {
|
||||
uni.showTabBar()
|
||||
deviceReName({
|
||||
let data = {
|
||||
id: this.deviceId.id,
|
||||
deviceName: this.deviceName
|
||||
}).then((res) => {
|
||||
}
|
||||
deviceReName(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -536,9 +426,8 @@
|
||||
}, 500);
|
||||
this.RenameModel = false
|
||||
this.deviceName = ''
|
||||
if (this.$refs.swipeAction) {
|
||||
this.$refs.swipeAction.closeAll();
|
||||
}
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -548,11 +437,16 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
// 报警
|
||||
// 报警
|
||||
callpolice() {
|
||||
const currentTab = this.tabs[this.activeTab];
|
||||
const deviceType = currentTab.id || '';
|
||||
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/callPolice/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('devicePolice', {
|
||||
data: currentTab
|
||||
@ -563,10 +457,16 @@
|
||||
// 发生短信
|
||||
handleSend() {
|
||||
const currentTab = this.tabs[this.activeTab];
|
||||
const deviceType = currentTab.id || '';
|
||||
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/send/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('deviceSend', {
|
||||
//data: deviceType,
|
||||
data: currentTab
|
||||
});
|
||||
}
|
||||
@ -576,7 +476,11 @@
|
||||
location() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('Map', {
|
||||
data: this.deviceList,
|
||||
});
|
||||
@ -586,47 +490,50 @@
|
||||
// 列表跳转
|
||||
handleFile(item) {
|
||||
let url = item.detailPageUrl;
|
||||
|
||||
// url="/pages/6331/BJQ6331";
|
||||
|
||||
|
||||
// console.log("url=",url);
|
||||
// if(!url){
|
||||
//url="/pages/670/HBY670"
|
||||
// }
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA'
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("ex=", ex);
|
||||
},fail(ex) {
|
||||
console.log("ex=",ex);
|
||||
}
|
||||
})
|
||||
},
|
||||
onIntall() {
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
this.total = 0;
|
||||
const deviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
this.getData(deviceType);
|
||||
this.getData(deviceType); // 重新加载第一页数据
|
||||
setTimeout(() => {
|
||||
// 停止下拉刷新动画
|
||||
uni.stopPullDownRefresh();
|
||||
}, 800);
|
||||
},
|
||||
updateDeviceStatus(data) {
|
||||
this.deviceList = this.deviceList
|
||||
.map(item => {
|
||||
if (!item) return null;
|
||||
if (!item) return null; // 如果 item 是 undefined/null,返回 null
|
||||
if (item.communicationMode == 0) {
|
||||
let messageData;
|
||||
try {
|
||||
messageData = data.message;
|
||||
} catch (e) {
|
||||
return item;
|
||||
return item; // 解析失败则返回原 item
|
||||
}
|
||||
const [deviceId, onlineStatus, battery] = messageData.state || [];
|
||||
console.log('我收到消息了没', item.battery);
|
||||
return {
|
||||
...item,
|
||||
battery: battery ?? item.battery,
|
||||
@ -638,31 +545,24 @@
|
||||
})
|
||||
.filter(Boolean);
|
||||
},
|
||||
// 动态计算屏幕高度
|
||||
getSystemInfoSyncH() {
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
const tabBarHeight = 80;
|
||||
const sendBarHeight = 60;
|
||||
const padding = 60;
|
||||
const totalTopHeight = (this.navBarHeight) + (tabBarHeight + sendBarHeight + padding) * (sysInfo
|
||||
.screenWidth / 750);
|
||||
this.mescrollHeight = sysInfo.screenHeight - totalTopHeight;
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getSystemInfoSyncH()
|
||||
this.getTab()
|
||||
this.onIntall()
|
||||
// 绑定页面做了监听,新增成功,刷新页面
|
||||
uni.$on('refreshDeviceList', () => {
|
||||
this.getTab()
|
||||
this.getTab() // 刷新数据
|
||||
this.onIntall()
|
||||
});
|
||||
// 监听设备状态更新事件
|
||||
uni.$on('deviceStatusUpdate', (data) => {
|
||||
console.log('列表收到消息了么');
|
||||
this.onIntall()
|
||||
});
|
||||
ble = BleHelper.getBleTool();
|
||||
ble=BleHelper.getBleTool();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 组件销毁前移除监听器
|
||||
uni.$off('refreshDeviceList');
|
||||
},
|
||||
onUnload() {
|
||||
@ -673,7 +573,7 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 保持原有样式不变 */
|
||||
/* 页面整体样式 */
|
||||
.device-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -686,6 +586,7 @@
|
||||
width: 100%;
|
||||
color: rgb(255, 255, 255);
|
||||
white-space: nowrap;
|
||||
/* 禁止换行 */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
@ -696,12 +597,17 @@
|
||||
cursor: pointer;
|
||||
margin-bottom: 40rpx;
|
||||
padding-right: 80rpx;
|
||||
/* 预留更多按钮空间 */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
font-size: 28rpx;
|
||||
/* min-width: 120rpx; */
|
||||
padding: 0 30rpx;
|
||||
/* 左右内边距 */
|
||||
text-align: center;
|
||||
/* 文字居中 */
|
||||
/* 设置最小宽度 */
|
||||
}
|
||||
|
||||
.active {
|
||||
@ -721,12 +627,16 @@
|
||||
|
||||
.tab-bar-wrap {
|
||||
display: flex;
|
||||
/* 横向排列 */
|
||||
align-items: baseline;
|
||||
/* 垂直居中 */
|
||||
position: relative;
|
||||
/* 可选(若需要绝对定位 fallback) */
|
||||
}
|
||||
|
||||
.tab-more {
|
||||
margin-left: 10rpx;
|
||||
/* 与Tab的间距 */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: linear-gradient(-88.60deg, rgba(18, 18, 18, 1), rgba(18, 18, 18, 0) 100%);
|
||||
@ -823,6 +733,22 @@
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.device-id {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
position: relative;
|
||||
padding: 0rpx 0rpx 30rpx 30rpx;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
@ -870,6 +796,16 @@
|
||||
left: -20rpx
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 2rpx;
|
||||
height: 24rpx;
|
||||
background: linear-gradient(90deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
rgb(255, 255, 255) 50%,
|
||||
rgba(255, 255, 255, 0) 100%);
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.loading-status {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
@ -908,6 +844,18 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 100%;
|
||||
height: 50%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
bottom: 0rpx;
|
||||
}
|
||||
|
||||
.agreement-popupC {
|
||||
width: 60%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
@ -959,6 +907,7 @@
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: #FFC84E;
|
||||
color: #232323;
|
||||
@ -984,6 +933,7 @@
|
||||
position: fixed;
|
||||
right: 18rpx;
|
||||
top: 140rpx;
|
||||
/* 根据导航栏高度调整 */
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
@ -991,6 +941,7 @@
|
||||
position: fixed;
|
||||
right: 18rpx;
|
||||
top: 230rpx;
|
||||
/* 根据导航栏高度调整 */
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
|
||||
@ -5,13 +5,17 @@
|
||||
<image src="/static/images/common/svg.png" class="svg"></image>
|
||||
<view class="scanT">ID: {{ deviceId }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 连接中状态 -->
|
||||
<view class="connecting-container" v-else>
|
||||
<view class="device-info">
|
||||
<view class="">
|
||||
<image src="/static/images/common/svg.png" class="svg"></image>
|
||||
</view>
|
||||
|
||||
<!-- <view>
|
||||
<image src="/static/images/bip.6.png" class="bip"></image>
|
||||
</view> -->
|
||||
|
||||
<text class="device-name">设备名:{{deviceId}}</text>
|
||||
<text class="device-model1">ID:{{deviceId}}</text>
|
||||
</view>
|
||||
@ -67,7 +71,6 @@
|
||||
})
|
||||
console.log(this.deviceId, res);
|
||||
if (res.code == 200) {
|
||||
|
||||
this.isConnectNo = false
|
||||
this.isSuccess = true
|
||||
uni.hideLoading()
|
||||
|
||||
@ -1,34 +1,23 @@
|
||||
<template>
|
||||
<view class="share">
|
||||
<!-- 下拉刷新区域 -->
|
||||
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" :down="downOption">
|
||||
<view class="device-title">已分享用户</view>
|
||||
<view class="" v-if="deviceList.length>0">
|
||||
<view class="device-info" v-for="(item, index) in deviceList" :key="index">
|
||||
<view class="device-header" @click.stop="handleFile(item)">
|
||||
<view class="deviceIMG">
|
||||
<image src="@/static/images/common/user.png" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>用户名:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">{{item.phonenumber}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-delete">
|
||||
<text class="delete" @click.stop="handleDelete(item)">移除</text>
|
||||
<view class="device-title">已分享用户</view>
|
||||
<view class="device-info" v-for="(item, index) in deviceList" :key="index">
|
||||
<view class="device-header" @click.stop="handleFile(item)">
|
||||
<view class="deviceIMG">
|
||||
<image src="@/static/images/common/user.png" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>用户名:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">{{item.phonenumber}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
<view class="device-delete">
|
||||
<text class="delete" @click.stop="handleDelete(item)">移除</text>
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
<view class="agreement-popup" @click.stop>
|
||||
@ -53,62 +42,16 @@
|
||||
deviceShareList,
|
||||
deviceShareDelete
|
||||
} from '@/api/6170/share.js'
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
deleteShow: false,
|
||||
delelteItemInfo: '',
|
||||
itemInfo: '',
|
||||
mescroll: null, // mescroll实例对象
|
||||
downOption: {
|
||||
auto: false // 不自动加载
|
||||
},
|
||||
upOption: {
|
||||
auto: false, // 不自动加载
|
||||
noMoreSize: 5, // 如果列表已无数据,可设置列表的总数量要大于等于5条才显示无更多数据
|
||||
empty: {
|
||||
tip: '暂无相关数据'
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
size: 10, // 每页条数
|
||||
total: 0 // 总数据量
|
||||
itemInfo: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// mescroll组件初始化的回调,可获取到mescroll对象
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新的回调
|
||||
downCallback() {
|
||||
// 重置分页参数
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(res => {
|
||||
// 数据请求成功后,隐藏下拉刷新的状态
|
||||
this.mescroll.endSuccess();
|
||||
}).catch(() => {
|
||||
// 请求失败,隐藏下拉刷新的状态
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
// 上拉加载的回调
|
||||
upCallback() {
|
||||
this.getData(this.itemInfo.id).then(res => {
|
||||
// 根据是否有数据来决定是否显示无更多数据的提示
|
||||
const hasNext = this.deviceList.length < this.total;
|
||||
this.mescroll.endSuccess(this.deviceList.length, hasNext);
|
||||
}).catch(() => {
|
||||
// 请求失败,隐藏上拉加载的状态
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
@ -130,43 +73,25 @@
|
||||
icon: 'none'
|
||||
})
|
||||
this.deleteShow = false
|
||||
// 删除后刷新列表
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(() => {
|
||||
this.mescroll.resetUpScroll();
|
||||
})
|
||||
this.getData()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
//
|
||||
},
|
||||
getData(val) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let data = {
|
||||
deviceId: val,
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
let data = {
|
||||
deviceId: val
|
||||
}
|
||||
deviceShareList(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceList = res.rows
|
||||
}
|
||||
deviceShareList(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.total = res.total;
|
||||
if (this.page === 1) {
|
||||
// 如果是第一页,直接替换数据
|
||||
this.deviceList = res.rows;
|
||||
} else {
|
||||
// 如果不是第一页,追加数据
|
||||
this.deviceList = this.deviceList.concat(res.rows);
|
||||
}
|
||||
resolve(res);
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
// 跳转分享详情
|
||||
@ -184,6 +109,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
@ -191,14 +117,7 @@
|
||||
eventChannel.on('shareManagement', (data) => {
|
||||
console.log(data, 'data1t111');
|
||||
this.itemInfo = data.data;
|
||||
// 初始化加载数据
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(() => {
|
||||
// 数据加载完成后,如果需要可以手动触发下拉刷新结束
|
||||
if (this.mescroll) {
|
||||
this.mescroll.endSuccess();
|
||||
}
|
||||
})
|
||||
this.getData(this.itemInfo.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -213,7 +132,7 @@
|
||||
|
||||
.device-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding: 30rpx;
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
@ -245,7 +164,7 @@
|
||||
|
||||
.deviceIMG {
|
||||
/* width: 100rpx; */
|
||||
/* height: 100rpx; */
|
||||
/* height: 100rpx; */
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -256,12 +175,6 @@
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.noDATA {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
transform: translate(-0%, 100%);
|
||||
}
|
||||
|
||||
.delete {
|
||||
border-radius: 32px;
|
||||
background: rgba(255, 200, 78, 0.06);
|
||||
|
||||
Reference in New Issue
Block a user