my-badge.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view class="f-size-24 state-base-class" :style="[showStyle]">{{ text }}</view>
  3. </template>
  4. <script>
  5. export default {
  6. props: {
  7. text: {
  8. // 按钮显示文本
  9. type: String,
  10. default: ''
  11. },
  12. status: {
  13. // 按钮显示文本
  14. type: String,
  15. default: 'success'
  16. },
  17. badgeStyle: {
  18. type: Object,
  19. default: () => ({})
  20. }
  21. },
  22. data() {
  23. return {};
  24. },
  25. computed: {
  26. showStyle: function () {
  27. let myShowStyle = { ...{ color: '#52c41a' } };
  28. if (this.status === 'success') {
  29. myShowStyle = {
  30. ...myShowStyle,
  31. ...{ color: '#00b148', 'background-color': '#e2ffee' }
  32. };
  33. }
  34. if (this.status === 'error') {
  35. myShowStyle = {
  36. ...myShowStyle,
  37. ...{ color: '#FF3C3C', 'background-color': '#FFEBEB' }
  38. };
  39. }
  40. if (this.status === 'default') {
  41. myShowStyle = {
  42. ...myShowStyle,
  43. ...{ color: '#999', 'background-color': '#EEEEEE' }
  44. };
  45. }
  46. if (this.status === 'processing') {
  47. myShowStyle = {
  48. ...myShowStyle,
  49. ...{ color: '#0082FF', 'background-color': '#E4F5FF' }
  50. };
  51. }
  52. if (this.status === 'green') {
  53. myShowStyle = {
  54. ...myShowStyle,
  55. ...{ color: '#00b148', 'background-color': '#e2ffee' }
  56. };
  57. }
  58. if (this.status === 'warning') {
  59. myShowStyle = {
  60. ...myShowStyle,
  61. ...{ color: '#FFA200', 'background-color': '#FFF4DD' }
  62. };
  63. }
  64. myShowStyle = { ...myShowStyle, ...this.badgeStyle };
  65. return myShowStyle;
  66. }
  67. },
  68. created() {},
  69. updated: function () {}
  70. };
  71. </script>
  72. <style scoped>
  73. .state-base-class {
  74. padding: 10rpx 30rpx;
  75. border-radius: 24rpx 0rpx 0rpx 24rpx;
  76. }
  77. </style>