u-box.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="u-box" :style="[{height: height}, addStyle(customStyle)]">
  3. <view class="u-box__left" :style="{borderRadius: borderRadius, backgroundColor: bgColors[0]}">
  4. <slot name="left">
  5. <view class="flex flex-row items-center justify-center">
  6. <u-icon size="36" :name="leftIcon"></u-icon>
  7. <text class="ml-2 text-16px">{{leftTitle}}</text>
  8. </view>
  9. </slot>
  10. </view>
  11. <view class="u-box__gap" :style="{width: gap, height: height}"></view>
  12. <view class="u-box__right">
  13. <view class="u-box__right-top" :style="{borderRadius: borderRadius, backgroundColor: bgColors[1]}">
  14. <slot name="rightTop">
  15. <view class="flex flex-row items-center justify-center">
  16. <u-icon size="36" :name="rightTopIcon"></u-icon>
  17. <text class="ml-2 text-15px">{{rightTopTitle}}</text>
  18. </view>
  19. </slot>
  20. </view>
  21. <view class="u-box__right-gap" :style="{height: gap}"></view>
  22. <view class="u-box__right-bottom" :style="{borderRadius: borderRadius, backgroundColor: bgColors[2]}">
  23. <slot name="rightBottom">
  24. <view class="flex flex-row items-center justify-center">
  25. <u-icon size="36" :name="rightBottomIcon"></u-icon>
  26. <text class="ml-2 text-15px">{{rightBottomTitle}}</text>
  27. </view>
  28. </slot>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { propsBox } from './props';
  35. import { mpMixin } from '../../libs/mixin/mpMixin';
  36. import { mixin } from '../../libs/mixin/mixin';
  37. import { addStyle } from '../../libs/function/index';
  38. import test from '../../libs/function/test';
  39. /**
  40. * box 盒子
  41. * @description box盒子一般为左边一个盒子,右侧两个等高的半盒组成,常用于App首页座位重点突出。
  42. * @tutorial https://uview-plus.jiangruyi.com/components/box.html
  43. * @property {Array} bgColors 背景色
  44. * @property {String} height 高度
  45. * @property {String} borderRadius 圆角
  46. * @property {Object} customStyle 定义需要用到的外部样式
  47. *
  48. * @event {Function} click 点击cell列表时触发
  49. * @example <up-box colors=['blue', 'red', 'yellow'] height="200px"></up-box>
  50. */
  51. export default {
  52. name: 'up-box',
  53. data() {
  54. return {
  55. }
  56. },
  57. mixins: [mpMixin, mixin, propsBox],
  58. computed: {
  59. },
  60. emits: [],
  61. methods: {
  62. addStyle,
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .u-box {
  68. /* #ifndef APP-NVUE */
  69. /* #endif */
  70. @include flex();
  71. flex: 1;
  72. &__left {
  73. @include flex();
  74. justify-content: center;
  75. align-items: center;
  76. flex: 1;
  77. }
  78. &__gap {
  79. @include flex();
  80. flex-direction: column;
  81. }
  82. &__right {
  83. @include flex();
  84. flex-direction: column;
  85. flex: 1;
  86. }
  87. &__right-top {
  88. @include flex();
  89. flex: 1;
  90. justify-content: center;
  91. align-items: center;
  92. }
  93. &__right-bottom {
  94. @include flex();
  95. flex: 1;
  96. justify-content: center;
  97. align-items: center;
  98. }
  99. }
  100. </style>