fa-add.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view
  3. @tap="goAdd"
  4. class="fa-add"
  5. :class="['fa-add--mode--' + mode]"
  6. :style="[
  7. {
  8. bottom: bottom + 'rpx',
  9. right: right + 'rpx',
  10. borderRadius: mode == 'circle' ? '10000rpx' : '8rpx',
  11. zIndex: zIndex
  12. },
  13. customStyle
  14. ]"
  15. >
  16. <view class="" v-if="!$slots.default">
  17. <u-icon :name="icon" :custom-style="iconStyle"></u-icon>
  18. <view class="fa-add__tips">{{ tips }}</view>
  19. </view>
  20. <slot v-else />
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'fa-add',
  26. props: {
  27. // 发布问题的形状,circle-圆形,square-方形
  28. mode: {
  29. type: String,
  30. default: 'circle'
  31. },
  32. // 自定义图标
  33. icon: {
  34. type: String,
  35. default: 'edit-pen'
  36. },
  37. // 提示文字
  38. tips: {
  39. type: String,
  40. default: ''
  41. },
  42. // 发布问题按钮到底部的距离,单位rpx
  43. bottom: {
  44. type: [Number, String],
  45. default: 300
  46. },
  47. // 发布问题按钮到右边的距离,单位rpx
  48. right: {
  49. type: [Number, String],
  50. default: 40
  51. },
  52. // 层级
  53. zIndex: {
  54. type: [Number, String],
  55. default: '9'
  56. },
  57. // 图标的样式,对象形式
  58. iconStyle: {
  59. type: Object,
  60. default() {
  61. return {
  62. color: '#909399',
  63. fontSize: '38rpx'
  64. };
  65. }
  66. },
  67. // 整个组件的样式
  68. customStyle: {
  69. type: Object,
  70. default() {
  71. return {};
  72. }
  73. }
  74. },
  75. data() {
  76. return {};
  77. },
  78. methods: {
  79. goAdd() {
  80. this.$emit('click');
  81. }
  82. }
  83. };
  84. </script>
  85. <style lang="scss" scoped>
  86. .fa-add {
  87. width: 80rpx;
  88. height: 80rpx;
  89. position: fixed;
  90. z-index: 9;
  91. display: flex;
  92. flex-direction: column;
  93. justify-content: center;
  94. background-color: #e1e1e1;
  95. color: $u-content-color;
  96. align-items: center;
  97. transition: opacity 0.4s;
  98. &__tips {
  99. font-size: 24rpx;
  100. transform: scale(0.8);
  101. line-height: 1;
  102. }
  103. }
  104. </style>