MerchantListSkeleton.uvue 2.12 KB
<template>
  <view class="merchant-skeleton-wrap">
    <view class="skeleton-grid-container">
      <view v-for="i in count" :key="i" 
            class="skeleton-item"
            :class="[(i + 1) % 2 === 0 ? 'item-even' : '']">
        <view class="skeleton-shimmer"></view>
        <view class="skeleton-badge"></view>
        <view class="skeleton-info">
          <view class="skeleton-line skeleton-name"></view>
          <view class="skeleton-line skeleton-id"></view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="uts">
defineProps({
  count: {
    type: Number,
    default: 6
  }
});
</script>

<style scoped lang="scss">
.merchant-skeleton-wrap {
  width: 100%;
  box-sizing: border-box;
}

.skeleton-grid-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
}

.skeleton-item {
  min-height: 72px;
  background-color: #f5f5f5;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 48%;
  margin-right: 4%;
  margin-bottom: 12px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  
  // 每行第二个元素去掉右边距
  &.item-even {
    margin-right: 0;
  }
  
  // 流光效果层
  .skeleton-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.3) 50%,
      transparent 100%
    );
    pointer-events: none;
  }
  
  .skeleton-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: #e0e0e0;
    margin-right: 10px;
    flex-shrink: 0;
  }
  
  .skeleton-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    
    .skeleton-line {
      height: 12px;
      border-radius: 6px;
      background-color: #e0e0e0;
      margin-bottom: 6px;
      
      &:last-child {
        margin-bottom: 0;
      }
    }
    
    .skeleton-name {
      width: 70%;
      height: 13px;
    }
    
    .skeleton-id {
      width: 50%;
      height: 10px;
    }
  }
}

</style>