<template>
  <view class="status-display">
    <!-- 加载状态 -->
    <view v-if="type === 'loading'" class="loading">
      <text>{{ loadingText }}</text>
    </view>
    <!-- 空数据提示 -->
    <view v-else-if="type === 'empty'" class="empty">
      <text>{{ emptyText }}</text>
    </view>
  </view>
</template>

<script>
export default {
  name: 'StatusDisplay',
  props: {
    // 状态类型：loading, empty
    type: {
      type: String,
      required: true,
      validator: value => ['loading', 'empty'].includes(value)
    },
    // 加载文本
    loadingText: {
      type: String,
      default: '加载中...'
    },
    // 空数据文本
    emptyText: {
      type: String,
      default: '暂无数据'
    }
  }
}
</script>

<style lang="scss" scoped>
.status-display {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loading, .empty {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #999;
  font-size: 28rpx;
  background-color: #FFFBF5;
  padding: 40rpx 0;
}
</style> 