1
0
forked from dyf/APP

首页修改,删除、重命名成功后,前端直接修改数据源

This commit is contained in:
liub
2025-12-24 11:40:36 +08:00
parent 637658a762
commit fce2f2ebcf
2 changed files with 35 additions and 51 deletions

View File

@ -88,9 +88,7 @@
}); });
this.txt=""; this.txt="";
hideLoading(this); hideLoading(this);
},800); },800);
}, },
closePop: function() { closePop: function() {

View File

@ -223,7 +223,7 @@
textNoMore: '没有更多数据了' textNoMore: '没有更多数据了'
}, },
mescrollHeight: 0, mescrollHeight: 0,
page: 0, // 当前页码
size: 10, // 每页条数 size: 10, // 每页条数
total: 0, // 总数据量 total: 0, // 总数据量
@ -250,44 +250,28 @@
}, },
// 下拉刷新 // 下拉刷新
downCallback() { downCallback() {
debugger;
console.log("下拉加载")
this.mescroll && this.mescroll.resetUpScroll(false);
// 重置分页参数
console.log("下拉加载")
if(this.mescroll){
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0,0);
}
this.getData(); this.getData();
}, },
// 上拉加载 // 上拉加载
upCallback() { upCallback() {
debugger;
console.log("上拉加载") console.log("上拉加载")
this.page += 1;
this.getData(); this.getData();
}, },
bleStateRecovery() { bleStateRecovery() {
console.log("蓝牙适配器恢复可用,重连断开的设备"); console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices(); ble.linkAllDevices();
// if (ble.data && ble.data.LinkedList) {
// for (var i = 0; i < this.deviceList.length; i++) {
// if (this.deviceList[i].communicationMode !== '0' || this.deviceList[i].communicationMode !== 0) {
// ble.data.LinkedList.find(v => {
// if (v.macAddress && v.device && v.device.id && v.device.id == this.deviceList[i]
// .id) {
// ble.LinkBlue(v.deviceId);
// return true;
// }
// });
// }
// }
// }
}, },
bleBreak(res) { bleBreak(res) {
console.log("蓝牙断开连接", res); console.log("蓝牙断开连接", res);
@ -356,7 +340,7 @@
}, },
// 点击弹框外的区域关闭 // 点击弹框外的区域关闭
closePopup(type) { closePopup(type) {
debugger;
if (type === 'delete') { if (type === 'delete') {
this.deleteShow = false; this.deleteShow = false;
uni.showTabBar(); // 显示TabBar uni.showTabBar(); // 显示TabBar
@ -390,10 +374,10 @@
this.deviceList = []; this.deviceList = [];
this.activeTab = index; this.activeTab = index;
this.activeTabInfo = tab this.activeTabInfo = tab
this.page = 1; // 重置页码
this.getData(); this.downCallback();
}, },
// 获取设备列表 // 获取设备列表
getData() { getData() {
@ -452,10 +436,7 @@
//防止下拉刷新的同时会调用一次上拉加载的问题 //防止下拉刷新的同时会调用一次上拉加载的问题
timeout = setTimeout(task, 50); timeout = setTimeout(task, 50);
}, },
// 滚动触底事件处理
onScrollToLower() {
this.getData();
},
// 添加扫一扫图标 // 添加扫一扫图标
scan() { scan() {
this.showTooltip = !this.showTooltip; this.showTooltip = !this.showTooltip;
@ -520,9 +501,7 @@
}, },
// 右滑点击事件处理 // 右滑点击事件处理
handleSwipeClick(e, item, index) { handleSwipeClick(e, item, index) {
const { const {content} = e
content
} = e
setTimeout(() => { setTimeout(() => {
console.log(item, 'eeeee'); console.log(item, 'eeeee');
switch (e.content.text) { switch (e.content.text) {
@ -557,10 +536,14 @@
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}); });
setTimeout(() => {
this.onIntall(); this.deviceList.find((v,i)=>{
this.getTab() if(v.id==data.id){
}, 500); this.deviceList.splice(i,1);
return true;
}
return false;
});
this.deleteShow = false this.deleteShow = false
// 关闭所有滑动项 // 关闭所有滑动项
this.$refs.swipeAction.closeAll(); this.$refs.swipeAction.closeAll();
@ -594,9 +577,14 @@
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}); });
setTimeout(() => {
this.onIntall(); this.deviceList.find((v,i)=>{
}, 500); if(v.id===data.id){
this.$set(this.deviceList[i],'deviceName',data.deviceName);
return true;
}
return false;
});
this.RenameModel = false this.RenameModel = false
this.deviceName = '' this.deviceName = ''
// 关闭所有滑动项 // 关闭所有滑动项
@ -685,9 +673,7 @@
} }
}) })
}, },
onIntall() {
this.downCallback();
},
updateDeviceStatus(data) { updateDeviceStatus(data) {
this.deviceList = this.deviceList this.deviceList = this.deviceList
.map(item => { .map(item => {
@ -716,16 +702,16 @@
onLoad() { onLoad() {
console.error("首页加载"); console.error("首页加载");
this.getTab() this.getTab()
this.onIntall() this.downCallback();
// 绑定页面做了监听,新增成功,刷新页面 // 绑定页面做了监听,新增成功,刷新页面
uni.$on('refreshDeviceList', () => { uni.$on('refreshDeviceList', () => {
this.getTab() // 刷新数据 this.getTab() // 刷新数据
this.onIntall() this.downCallback();
}); });
// 监听设备状态更新事件 // 监听设备状态更新事件
uni.$on('deviceStatusUpdate', (data) => { uni.$on('deviceStatusUpdate', (data) => {
console.log('列表收到消息了么'); console.log('列表收到消息了么');
this.onIntall() this.downCallback();
}); });
ble = BleHelper.getBleTool(); ble = BleHelper.getBleTool();