<template>
  <view class="tile-grid">
    <view class="tile-item" v-for="(item, index) in tileCount" :key="index">
      <image :src="tileImageSrc" mode="aspectFit" class="tile-image"></image>
    </view>
  </view>
</template>

<script>
  import CommonEnum from '@/enum/common.js'

  export default {
    name: 'TileGrid',
    data() {
      return {
        CommonEnum,
      }
    },
    props: {
      // 瓦片数量
      tileCount: {
        type: Number,
        default: 10,
      },
      // 瓦片图片URL，如果不传则使用默认瓦片
      tileImage: {
        type: String,
        default: '',
      },
    },
    computed: {
      // 瓦片图片源，优先使用传入的tileImage，否则使用默认瓦片
      tileImageSrc() {
        return this.tileImage || this.CommonEnum.TILE
      },
    },
  }
</script>

<style lang="scss" scoped>
  .tile-grid {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
  }

  .tile-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .tile-image {
    width: 75rpx;
    height: 48rpx;
  }
</style>
