xiaoran-circle.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="box">
  3. <view class="view_box">
  4. <iCircle
  5. :percent="percent"
  6. :size="200"
  7. :stroke-color="color"
  8. :dashboard="true"
  9. BgId="BgId1"
  10. InId="InId1"
  11. >
  12. <icon v-if="percent == 100" type="success" size="60" color="#5cb85c" />
  13. <text v-else style="font-size:24px; color: #FFFFFF;">{{ percent }}%</text>
  14. <view slot="canvas">
  15. <canvas
  16. class="CanvasBox strokeCanvas"
  17. canvas-id="BgId1"
  18. ></canvas>
  19. <canvas
  20. class="CanvasBox trailCanvas"
  21. canvas-id="InId1"
  22. ></canvas>
  23. </view>
  24. </iCircle>
  25. <iCircle
  26. :percent="percent"
  27. :size="200"
  28. :stroke-color="color"
  29. BgId="BgId"
  30. InId="InId"
  31. >
  32. <icon v-if="percent == 100" type="success" size="60" color="#5cb85c" />
  33. <text v-else style="font-size:24px; color: #FFFFFF;">{{ percent }}%</text>
  34. <view slot="canvas">
  35. <canvas
  36. class="CanvasBox strokeCanvas"
  37. canvas-id="BgId"
  38. ></canvas>
  39. <canvas
  40. class="CanvasBox trailCanvas"
  41. canvas-id="InId"
  42. ></canvas>
  43. </view>
  44. </iCircle>
  45. </view>
  46. <view class="button_box">
  47. <button type="primary" class="button_item" @click="add">+</button>
  48. <button type="primary" class="button_item" @click="minus">-</button>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import iCircle from '@/components/xiaoran-circle/xiaoran-circle.vue';
  54. export default {
  55. components: {
  56. iCircle
  57. },
  58. data() {
  59. return {
  60. percent: 50
  61. }
  62. },
  63. computed: {
  64. color() {
  65. let color = '#2db7f5';
  66. if (this.percent == 100) {
  67. color = '#5cb85c';
  68. }
  69. return color;
  70. }
  71. },
  72. methods: {
  73. add() {
  74. if (this.percent >= 100) {
  75. return false;
  76. }
  77. this.percent += 10;
  78. },
  79. minus() {
  80. if (this.percent <= 0) {
  81. return false;
  82. }
  83. this.percent -= 10;
  84. }
  85. }
  86. }
  87. </script>
  88. <style>
  89. .box {
  90. /* margin-top: var(--status-bar-height); */
  91. flex: 1;
  92. }
  93. .view_box {
  94. width: 100%;
  95. background: #000000;
  96. display: flex;
  97. align-items: center; justify-content: center;
  98. }
  99. .button_box {
  100. display: flex;
  101. flex-direction: column;
  102. align-items: stretch;
  103. justify-content: flex-start;
  104. padding: 0 30upx;
  105. }
  106. .button_item {
  107. width: 100%;
  108. margin-top: 30upx;
  109. }
  110. .CanvasBox {
  111. width: 100%;
  112. height: 100%;
  113. position: absolute;
  114. top: 0px;
  115. left: 0px;
  116. display: flex;
  117. justify-content: center;
  118. align-items: center;
  119. }
  120. </style>