You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
4.8 KiB

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