爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
907 B

export default {
data() {
return {
isRefreshing: false
}
},
methods: {
async refreshData() {
if (this.isRefreshing) return
this.isRefreshing = true
try {
// 如果页面有自己的刷新逻辑,优先使用页面的
if (typeof this.onRefresh === 'function') {
await this.onRefresh()
} else {
// 默认刷新逻辑
await new Promise(resolve => setTimeout(resolve, 1000))
}
uni.showToast({
title: '刷新成功',
icon: 'success'
})
} catch (error) {
console.error('刷新失败:', error)
uni.showToast({
title: '刷新失败',
icon: 'none'
})
} finally {
this.isRefreshing = false
uni.stopPullDownRefresh()
}
}
},
onPullDownRefresh() {
this.refreshData()
}
}