1
0
forked from dyf/APP

修复类型页面图片全都显示一样的问题。

This commit is contained in:
liub
2026-01-13 09:58:42 +08:00
parent 779017919b
commit 90e0ee2271
3 changed files with 157 additions and 107 deletions

View File

@ -156,7 +156,7 @@
components: {
MescrollUni
},
data() {
return {
mescroll: null,
@ -225,7 +225,7 @@
textNoMore: '没有更多数据了'
},
mescrollHeight: 0,
size: 10, // 每页条数
total: 0, // 总数据量
@ -252,31 +252,31 @@
},
// 下拉刷新
downCallback() {
console.log("下拉加载")
if(this.mescroll){
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0,0);
}
this.mescroll.scrollTo(0, 0);
}
this.getData();
},
// 上拉加载
upCallback() {
console.log("上拉加载")
this.getData();
},
bleStateBreak(){
bleStateBreak() {
console.error("蓝牙适配器不可用");
this.updateBleStatu();
},
bleStateRecovery() {
console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices();
},
bleBreak(res) {
console.error("蓝牙断开连接", res);
@ -298,37 +298,35 @@
for (var i = 0; i < this.deviceList.length; i++) {
let f=null;
let f = null;
if (ble.data && ble.data.LinkedList) {
f=ble.data.LinkedList.find(v => {
f = ble.data.LinkedList.find(v => {
if (v.macAddress && v.device && v.device.id) {
return v.device.id == this.deviceList[i].id;
}
return false;
});
}
if(f){
if (f) {
this.$set(this.deviceList[i], 'bleStatu', f.Linked);
if(f.formData){
let battary=0;
if('battary' in f.formData){
battary=f.formData.battary;
if (f.formData) {
let battary = 0;
if ('battary' in f.formData) {
battary = f.formData.battary;
} else if ('sta_PowerPercent' in f.formData) {
battary = f.formData.sta_PowerPercent;
} else if ('sta_battery' in f.formData) {
battary = f.formData.sta_battery;
}
else if('sta_PowerPercent' in f.formData){
battary=f.formData.sta_PowerPercent;
}
else if('sta_battery' in f.formData){
battary=f.formData.sta_battery;
}
this.$set(this.deviceList[i], 'battery',battary);
this.$set(this.deviceList[i], 'battery', battary);
}
}
}
@ -343,22 +341,22 @@
// 所有分享,所有类型
handleshareClick(item) {
this.showshare = false; // 关闭弹窗
var that=this;
var that = this;
switch (item.action) {
case 'type':
uni.navigateTo({
url: '/pages/common/allType/index',
events:{
index(data){
if(data && data.id){
that.tabs.find((v,i)=>{
if(v.id===data.id){
that.switchTab(v,i);
return true;
}
return false;
})
}
events: {
index(data) {
if (data && data.id) {
that.tabs.find((v, i) => {
if (v.id === data.id) {
that.switchTab(v, i);
return true;
}
return false;
})
}
}
}
});
@ -366,14 +364,14 @@
case 'share':
uni.navigateTo({
url: "/pages/common/allShare/index",
})
break;
}
},
// 点击弹框外的区域关闭
closePopup(type) {
if (type === 'delete') {
this.deleteShow = false;
uni.showTabBar(); // 显示TabBar
@ -407,7 +405,7 @@
this.deviceList = [];
this.activeTab = index;
this.activeTabInfo = tab
this.downCallback();
@ -422,10 +420,10 @@
pageNum: this.mescroll.num,
pageSize: this.size,
deviceType: this.activeTabInfo ? this.activeTabInfo.id : '', // 使用传入的设备类型
isAsc:'desc',
orderByColumn:'bindingTime'
isAsc: 'desc',
orderByColumn: 'bindingTime'
}
if(!data.pageNum){
if (!data.pageNum) {
this.mescroll.endSuccess(0, false);
resolve();
return;
@ -439,33 +437,34 @@
}));
// 如果是第一页或切换分类,替换数据
if(data.pageNum === 1){
this.deviceList =newDevices
}else{
if (data.pageNum === 1) {
this.deviceList = newDevices
} else {
//防止后端返回的数据包含已有数据
for (var i = 0; i < newDevices.length; i++) {
let device=newDevices[i];
let f=this.deviceList.find(v=>{
return v.id===device.id;
let device = newDevices[i];
let f = this.deviceList.find(v => {
return v.id === device.id;
});
if(!f){
if (!f) {
this.deviceList.push(device);
}
}
}
}
this.updateBleStatu();
this.total = res.total;
// 判断是否加载完成
let hasNext = true;
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
if (res.rows.length < this.size || this.deviceList.length >= this
.total) {
hasNext = false;
} else {
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
}else{
} else {
this.mescroll.endSuccess(0, false);
}
}).finally(() => {
@ -477,16 +476,16 @@
//防止下拉刷新的同时会调用一次上拉加载的问题
timeout = setTimeout(task, 50);
},
// 添加扫一扫图标
scan() {
this.showTooltip = !this.showTooltip;
},
closePopMenu(){
setTimeout(()=>{
closePopMenu() {
setTimeout(() => {
this.showTooltip = false;
this.showshare = false;
},100);
}, 100);
},
closePopupTooltip() {
this.showTooltip = !this.showTooltip
@ -548,7 +547,9 @@
},
// 右滑点击事件处理
handleSwipeClick(e, item, index) {
const {content} = e
const {
content
} = e
setTimeout(() => {
console.log(item, 'eeeee');
switch (e.content.text) {
@ -583,10 +584,10 @@
icon: 'none',
duration: 1000
});
this.deviceList.find((v,i)=>{
if(v.id==data.id){
this.deviceList.splice(i,1);
this.deviceList.find((v, i) => {
if (v.id == data.id) {
this.deviceList.splice(i, 1);
return true;
}
return false;
@ -624,10 +625,10 @@
icon: 'none',
duration: 1000
});
this.deviceList.find((v,i)=>{
if(v.id===data.id){
this.$set(this.deviceList[i],'deviceName',data.deviceName);
this.deviceList.find((v, i) => {
if (v.id === data.id) {
this.$set(this.deviceList[i], 'deviceName', data.deviceName);
return true;
}
return false;
@ -720,7 +721,7 @@
}
})
},
updateDeviceStatus(data) {
this.deviceList = this.deviceList
.map(item => {
@ -746,15 +747,16 @@
.filter(Boolean);
},
},
onShow(){
if(ble){
onShow() {
if (ble) {
//因为vue视图只能后退不能隐藏后再显示
//所以回到首页后将其他所有页面的订阅都删除
ble.removeAllCallbackByRetain(pagePath);
}
},
onLoad() {
debugger;
console.error("首页加载");
this.getTab()
this.downCallback();
@ -787,17 +789,17 @@
console.log("蓝牙适配器恢复可用的回调");
this.bleStateRecovery();
}, pagePath);
//蓝牙适配器不可用的回调
ble.addStateBreakCallback(res=>{
ble.addStateBreakCallback(res => {
console.error("蓝牙适配器不可用的回调");
this.bleStateBreak();
},pagePath);
}, pagePath);
//接收到消息的回调
ble.addReceiveCallback((rec,f,path,arr)=>{
ble.addReceiveCallback((rec, f, path, arr) => {
this.updateBleStatu();
},pagePath);
}, pagePath);
this.getSystemInfoSyncH();
},
@ -807,6 +809,7 @@
uni.$off('refreshDeviceList');
},
onUnload() {
uni.$off('deviceStatusUpdate');
ble && ble.removeAllCallback(pagePath);
}
@ -1181,13 +1184,15 @@
background-color: rgba(35, 35, 35, 0.87);
color: rgba(255, 255, 255, 1);
}
.mask{
.mask {
position: fixed;
width: 100%;
height: 100%;
z-index: 9998;
background-color: #00000000;
}
/* 提示框样式 */
.tooltip-box {
position: fixed;