index.vue 2.8 KB

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