index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template name="zai-lattice">
  2. <view class="zai-lattice-box" :class="shadow?'zai-lattice-box-shadow':''" :style="{'background':backgroundColor}">
  3. <view class="zai-lattice-box-p">
  4. <progress :percent="progressPercent" class="zai-progress" active stroke-width="5" :backgroundColor="backgroundColor"
  5. :activeColor="progressColor" />
  6. <view class="zai-lattice-title" :style="{color:titleColor}">{{title}}</view>
  7. <view class="zai-lattice-num">
  8. <text class="zai-lattice-num-title" :style="{color:numColor}">{{num}}</text>
  9. <text class="zai-lattice-num-unit" :style="{color:unitColor}">{{unit}}</text>
  10. </view>
  11. <view class="zai-lattice-icon" v-if="type=='icon'" :class="icon"
  12. :style="{color:iconColor,'font-size':fontSize}"></view>
  13. <view class="zai-lattice-img" v-if="type=='img'" :style="{width:fontSize,height:fontSize}"
  14. @click="onClick()">
  15. <image :src="src" mode="aspectFit" class="zai-lattice-image" :style="{width:fontSize,height:fontSize}">
  16. </image>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: "zai-lattice",
  24. props: {
  25. //背景颜色
  26. backgroundColor: {
  27. type: [String],
  28. default: '#4F496C'
  29. },
  30. //是否开启阴影
  31. shadow: Boolean,
  32. //进度条颜色
  33. progressColor: {
  34. type: [String],
  35. default: '#2086D8'
  36. },
  37. //进度条位置
  38. progressPercent: {
  39. type: [Number],
  40. default: 0
  41. },
  42. //名称
  43. title: String,
  44. //数量
  45. num: {
  46. type: [Number, String],
  47. default: 0
  48. },
  49. //单位
  50. unit: String,
  51. //字体图标
  52. icon: String,
  53. //图片地址
  54. src: {
  55. type: [String],
  56. default: '../../static/img/control/close.png'
  57. },
  58. //图标颜色
  59. iconColor: {
  60. type: [String],
  61. default: '#A1A0B5'
  62. },
  63. //单位颜色
  64. unitColor: {
  65. type: [String],
  66. default: '#A1A0B5'
  67. },
  68. //数量颜色
  69. numColor: {
  70. type: [String],
  71. default: '#ffffff'
  72. },
  73. //名称颜色
  74. titleColor: {
  75. type: [String],
  76. default: '#EFEEF2'
  77. },
  78. //图标或图片大小
  79. size: {
  80. type: [Number, String],
  81. default: 33
  82. },
  83. //图标类型
  84. type: {
  85. type: [String],
  86. default: 'icon'
  87. },
  88. },
  89. computed: {
  90. fontSize() {
  91. var size = Number(this.size)
  92. size = isNaN(size) ? 33 : size
  93. return `${size}px`
  94. }
  95. },
  96. methods: {
  97. onClick() {
  98. this.$emit('click')
  99. }
  100. }
  101. }
  102. </script>
  103. <style>
  104. @import "./index.css";
  105. </style>