微信小店联盟带货小程序

goods-skeleton.vue 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="skeleton" :class="{ 'skeleton--animate': animate }">
  3. <!-- 轮播图骨架 -->
  4. <view class="skeleton__banner"></view>
  5. <!-- 价格区域骨架 -->
  6. <view class="skeleton__price">
  7. <view class="skeleton__price-main"></view>
  8. <view class="skeleton__price-market"></view>
  9. </view>
  10. <!-- 标题骨架 -->
  11. <view class="skeleton__title">
  12. <view class="skeleton__title-line"></view>
  13. <view class="skeleton__title-line" style="width: 80%;"></view>
  14. </view>
  15. <!-- 标签骨架 -->
  16. <view class="skeleton__tags">
  17. <view class="skeleton__tag"></view>
  18. <view class="skeleton__tag"></view>
  19. <view class="skeleton__tag"></view>
  20. </view>
  21. <!-- 规格骨架 -->
  22. <view class="skeleton__specs">
  23. <view class="skeleton__spec-item"></view>
  24. <view class="skeleton__spec-item"></view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'goods-skeleton',
  31. props: {
  32. animate: {
  33. type: Boolean,
  34. default: true
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang="scss">
  40. .skeleton {
  41. padding: 30rpx;
  42. background: #fff;
  43. &--animate {
  44. .skeleton__banner,
  45. .skeleton__price-main,
  46. .skeleton__price-market,
  47. .skeleton__title-line,
  48. .skeleton__tag,
  49. .skeleton__spec-item {
  50. background: linear-gradient(
  51. 90deg,
  52. #f2f2f2 25%,
  53. #e6e6e6 37%,
  54. #f2f2f2 63%
  55. );
  56. background-size: 400% 100%;
  57. animation: skeleton-loading 1.4s ease infinite;
  58. }
  59. }
  60. &__banner {
  61. width: 100%;
  62. height: 750rpx;
  63. background: #f2f2f2;
  64. border-radius: 12rpx;
  65. margin-bottom: 30rpx;
  66. }
  67. &__price {
  68. margin-bottom: 20rpx;
  69. &-main {
  70. width: 200rpx;
  71. height: 56rpx;
  72. background: #f2f2f2;
  73. border-radius: 6rpx;
  74. margin-bottom: 12rpx;
  75. }
  76. &-market {
  77. width: 160rpx;
  78. height: 32rpx;
  79. background: #f2f2f2;
  80. border-radius: 4rpx;
  81. }
  82. }
  83. &__title {
  84. margin-bottom: 20rpx;
  85. &-line {
  86. width: 100%;
  87. height: 40rpx;
  88. background: #f2f2f2;
  89. border-radius: 4rpx;
  90. margin-bottom: 12rpx;
  91. &:last-child {
  92. margin-bottom: 0;
  93. }
  94. }
  95. }
  96. &__tags {
  97. display: flex;
  98. flex-wrap: wrap;
  99. margin: 0 -8rpx 20rpx;
  100. }
  101. &__tag {
  102. width: 120rpx;
  103. height: 48rpx;
  104. background: #f2f2f2;
  105. border-radius: 24rpx;
  106. margin: 8rpx;
  107. }
  108. &__specs {
  109. display: flex;
  110. flex-direction: column;
  111. gap: 20rpx;
  112. }
  113. &__spec-item {
  114. width: 100%;
  115. height: 88rpx;
  116. background: #f2f2f2;
  117. border-radius: 8rpx;
  118. }
  119. }
  120. @keyframes skeleton-loading {
  121. 0% {
  122. background-position: 100% 50%;
  123. }
  124. 100% {
  125. background-position: 0 50%;
  126. }
  127. }
  128. </style>