u-circle-progress.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="u-circle-progress">
  3. <view class="u-circle-progress__left">
  4. <view
  5. class="u-circle-progress__left__circle"
  6. :style="[leftSyle]"
  7. ref="left-circle"
  8. >
  9. </view>
  10. </view>
  11. <view
  12. class="u-circle-progress__right"
  13. >
  14. <view
  15. class="u-circle-progress__right__circle"
  16. ref="right-circle"
  17. :style="[rightSyle]"
  18. >
  19. </view>
  20. </view>
  21. <view class="u-circle-progress__circle">
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import props from './props.js';
  27. import mpMixin from '../../libs/mixin/mpMixin.js';
  28. import mixin from '../../libs/mixin/mixin.js';
  29. // #ifdef APP-NVUE
  30. const animation = uni.requireNativePlugin('animation')
  31. // #endif
  32. /**
  33. * CircleProgress 圆形进度条 TODO: 待完善
  34. * @description 展示操作或任务的当前进度,比如上传文件,是一个圆形的进度环。
  35. * @tutorial https://ijry.github.io/uview-plus/components/circleProgress.html
  36. * @property {String | Number} percentage 圆环进度百分比值,为数值类型,0-100 (默认 30 )
  37. * @example
  38. */
  39. export default {
  40. name: 'u-circle-progress',
  41. mixins: [mpMixin, mixin, props],
  42. data() {
  43. return {
  44. leftBorderColor: 'rgb(200, 200, 200)',
  45. rightBorderColor: 'rgb(200, 200, 200)',
  46. }
  47. },
  48. computed: {
  49. leftSyle() {
  50. const style = {}
  51. style.borderTopColor = this.leftBorderColor
  52. style.borderRightColor = this.leftBorderColor
  53. return style
  54. },
  55. rightSyle() {
  56. const style = {}
  57. style.borderLeftColor = this.rightBorderColor
  58. style.borderBottomColor = this.rightBorderColor
  59. return style
  60. }
  61. },
  62. mounted() {
  63. uni.$u.sleep().then(() => {
  64. this.rightBorderColor = 'rgb(66, 185, 131)'
  65. // this.init()
  66. })
  67. },
  68. methods: {
  69. init() {
  70. animation.transition(this.$refs['right-circle'].ref, {
  71. styles: {
  72. transform: 'rotate(45deg)',
  73. transformOrigin: 'center center'
  74. },
  75. }, () => {
  76. this.rightBorderColor = 'rgb(66, 185, 131)'
  77. // animation.transition(this.$refs['right-circle'].ref, {
  78. // styles: {
  79. // transform: 'rotate(225deg)',
  80. // transformOrigin: 'center center'
  81. // },
  82. // duration: 3000,
  83. // }, () => {
  84. // animation.transition(this.$refs['left-circle'].ref, {
  85. // styles: {
  86. // transform: 'rotate(45deg)',
  87. // transformOrigin: 'center center'
  88. // },
  89. // }, () => {
  90. // this.leftBorderColor = 'rgb(66, 185, 131)'
  91. // animation.transition(this.$refs['left-circle'].ref, {
  92. // styles: {
  93. // transform: 'rotate(225deg)',
  94. // transformOrigin: 'center center'
  95. // },
  96. // duration: 1500,
  97. // }, () => {
  98. // })
  99. // })
  100. // })
  101. })
  102. }
  103. },
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. @import "../../libs/css/components.scss";
  108. .u-circle-progress {
  109. @include flex(row);
  110. position: relative;
  111. border-radius: 100px;
  112. height: 100px;
  113. width: 100px;
  114. // transform: rotate(0deg);
  115. // background-color: rgb(66, 185, 131);
  116. background-color: rgb(200, 200, 200);
  117. overflow: hidden;
  118. justify-content: space-between;
  119. &__circle {
  120. border-radius: 100px;
  121. height: 90px;
  122. width: 90px;
  123. transform: translate(-50%, -50%);
  124. background-color: rgb(255, 255, 255);
  125. left: 50px;
  126. top: 50px;
  127. position: absolute;
  128. }
  129. &__left {
  130. position: absolute;
  131. left: 0;
  132. width: 50px;
  133. height: 100px;
  134. overflow: hidden;
  135. box-sizing: border-box;
  136. // background-color: rgb(66, 185, 131);
  137. // background-color: rgb(200, 200, 200);
  138. // transform-origin: left center;
  139. &__circle {
  140. box-sizing: border-box;
  141. // background-color: red;
  142. border-left-color: transparent;
  143. border-bottom-color: transparent;
  144. border-top-left-radius: 50px;
  145. border-top-right-radius: 50px;
  146. border-bottom-right-radius: 50px;
  147. // border-left-color: rgb(66, 185, 131);
  148. // border-bottom-color: rgb(66, 185, 131);
  149. border-top-color: rgb(66, 185, 131);
  150. border-right-color: rgb(66, 185, 131);
  151. border-width: 5px;
  152. width: 100px;
  153. height: 100px;
  154. transform: rotate(225deg);
  155. // border-radius: 100px;
  156. }
  157. }
  158. &__right {
  159. position: absolute;
  160. right: 0;
  161. width: 50px;
  162. height: 100px;
  163. overflow: hidden;
  164. &__circle {
  165. position: absolute;
  166. right: 0;
  167. box-sizing: border-box;
  168. // background-color: red;
  169. border-top-color: transparent;
  170. border-right-color: transparent;
  171. border-top-left-radius: 50px;
  172. border-bottom-left-radius: 50px;
  173. border-bottom-right-radius: 50px;
  174. // border-left-color: rgb(66, 185, 131);
  175. // border-bottom-color: rgb(66, 185, 131);
  176. border-left-color: rgb(200, 200, 200);
  177. border-bottom-color: rgb(200, 200, 200);
  178. border-width: 5px;
  179. width: 100px;
  180. height: 100px;
  181. transform: rotate(45deg);
  182. transform-origin: center center;
  183. // border-radius: 100px;
  184. }
  185. }
  186. }
  187. </style>