s-menu-grid.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <uni-grid :showBorder="Boolean(data.border)" :column="data.col">
  3. <uni-grid-item
  4. v-for="(item, index) in data.list"
  5. :key="index"
  6. @tap="sheep.$router.go(item.url)"
  7. >
  8. <view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center">
  9. <view class="img-box">
  10. <view
  11. class="tag-box"
  12. v-if="item.badge.show"
  13. :style="[{ background: item.badge.bgColor, color: item.badge.color }]"
  14. >
  15. {{ item.badge.text }}
  16. </view>
  17. <image class="menu-image" :src="sheep.$url.cdn(item.src)"></image>
  18. </view>
  19. <view class="title-box ss-flex ss-flex-col ss-row-center ss-col-center">
  20. <view class="grid-text" :style="[{ color: item.title.color }]">
  21. {{ item.title.text }}
  22. </view>
  23. <view class="grid-tip" :style="[{ color: item.tip.color }]">
  24. {{ item.tip.text }}
  25. </view>
  26. </view>
  27. </view>
  28. </uni-grid-item>
  29. </uni-grid>
  30. </template>
  31. <script setup>
  32. import sheep from '@/sheep';
  33. const props = defineProps({
  34. data: {
  35. type: Object,
  36. default() {},
  37. },
  38. });
  39. </script>
  40. <style lang="scss" scoped>
  41. .menu-image {
  42. width: 24px;
  43. height: 24px;
  44. }
  45. .grid-item-box {
  46. flex: 1;
  47. display: flex;
  48. flex-direction: column;
  49. align-items: center;
  50. justify-content: center;
  51. height: 100%;
  52. .img-box {
  53. position: relative;
  54. .tag-box {
  55. position: absolute;
  56. z-index: 2;
  57. top: 0;
  58. right: 0;
  59. font-size: 2em;
  60. line-height: 1;
  61. padding: 0.4em 0.6em 0.3em;
  62. transform: scale(0.4) translateX(0.5em) translatey(-0.6em);
  63. transform-origin: 100% 0;
  64. border-radius: 200rpx;
  65. white-space: nowrap;
  66. }
  67. }
  68. .title-box {
  69. .grid-tip {
  70. font-size: 24rpx;
  71. white-space: nowrap;
  72. text-align: center;
  73. }
  74. }
  75. }
  76. </style>