s-menu-grid.vue 2.0 KB

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