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()
  }
} 