cmd-progress.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <view class="cmd-progress cmd-progress-default" :class="setStatusClass">
  3. <block v-if="type == 'circle' || type == 'dashboard'">
  4. <view class="cmd-progress cmd-progress-default" :class="setStatusClass">
  5. <view class="cmd-progress-inner" :style="setCircleStyle">
  6. <!-- 绘制圈 start -->
  7. <!-- #ifdef H5 -->
  8. <svg viewBox="0 0 100 100" class="cmd-progress-circle">
  9. <path
  10. :d="setCirclePath"
  11. stroke="#f3f3f3"
  12. :stroke-linecap="strokeShape"
  13. :stroke-width="strokeWidth"
  14. fill-opacity="0"
  15. class="cmd-progress-circle-trail"
  16. :style="setCircleTrailStyle"
  17. ></path>
  18. <path :d="setCirclePath" :stroke-linecap="strokeShape" :stroke-width="strokeWidth" fill-opacity="0" class="cmd-progress-circle-path" :style="setCirclePathStyle"></path>
  19. </svg>
  20. <!-- #endif -->
  21. <!-- #ifndef H5 -->
  22. <text :style="setCircle"></text>
  23. <!-- #endif -->
  24. <!-- 绘制圈 end -->
  25. <!-- 状态文本 start -->
  26. <block v-if="showInfo">
  27. <text class="cmd-progress-text" :title="setFormat">
  28. <block v-if="status != 'success' && status != 'exception' && setProgress < 100">{{ setFormat }}</block>
  29. <!-- #ifdef H5 -->
  30. <svg v-if="status == 'exception'" viewBox="64 64 896 896" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true">
  31. <path
  32. d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
  33. ></path>
  34. </svg>
  35. <svg
  36. v-if="status == 'success' || setProgress == 100"
  37. viewBox="64 64 896 896"
  38. data-icon="check"
  39. width="1em"
  40. height="1em"
  41. fill="currentColor"
  42. aria-hidden="true"
  43. :style="{ color: strokeColor ? strokeColor : '' }"
  44. >
  45. <path
  46. d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"
  47. ></path>
  48. </svg>
  49. <!-- #endif -->
  50. <!-- #ifndef H5 -->
  51. <text v-if="status == 'exception' || status == 'success' || setProgress == 100" :style="setCircleIcon"></text>
  52. <!-- #endif -->
  53. </text>
  54. </block>
  55. <!-- 状态文本 end -->
  56. </view>
  57. </view>
  58. </block>
  59. <block v-if="type == 'line'">
  60. <view class="title">{{ title }}</view>
  61. <!-- 进度条 start -->
  62. <view class="cmd-progress-outer">
  63. <view class="cmd-progress-inner" :style="{ 'border-radius': strokeShape == 'square' ? 0 : '100px' }">
  64. <view class="cmd-progress-bg" :style="setLineStyle"></view>
  65. <view v-if="successPercent" class="cmd-progress-success-bg" :style="setLineSuccessStyle"></view>
  66. </view>
  67. </view>
  68. <!-- 进度条 end -->
  69. <!-- 进度条是否显示信息 start -->
  70. <block v-if="showInfo">
  71. <text class="cmd-progress-text" :title="setFormat">
  72. <block v-if="status != 'success' && status != 'exception' && setProgress <= 100">{{ setFormat }}</block>
  73. <!-- #ifdef H5 -->
  74. <svg v-if="status == 'exception'" viewBox="64 64 896 896" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">
  75. <path
  76. d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 0 1-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"
  77. ></path>
  78. </svg>
  79. <!-- <svg
  80. v-if="status == 'success' || setProgress == 100"
  81. viewBox="64 64 896 896"
  82. data-icon="check-circle"
  83. width="1em"
  84. height="1em"
  85. fill="currentColor"
  86. aria-hidden="true"
  87. :style="{ color: strokeColor ? strokeColor : '' }"
  88. >
  89. <path
  90. d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 0 1-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
  91. ></path>
  92. </svg> -->
  93. <!-- #endif -->
  94. <!-- #ifndef H5 -->
  95. <!-- <text v-if="status == 'exception' || status == 'success' || setProgress == 100" :style="setLineStatusIcon"></text> -->
  96. <!-- #endif -->
  97. </text>
  98. </block>
  99. <!-- 进度条是否显示信息 end -->
  100. </block>
  101. </view>
  102. </template>
  103. <script>
  104. /**
  105. * 进度条组件
  106. * @description 显示一个操作完成的百分比时,为用户显示该操作的当前进度和状态。
  107. * @tutorial https://ext.dcloud.net.cn/plugin?id=259
  108. * @property {String} type 进度类型 - 线型:line、圆圈形:circle、仪表盘:dashboard,默认线型:line
  109. * @property {Number} percent 进度百分比值 - 显示范围0-100 ,可能数比较大就需要自己转成百分比的值
  110. * @property {Number} success-percent 进度已完成的百分几 - 仅支持进度线型:line
  111. * @property {String} status 进度状态 - 涌动:active(仅支持线型:line)、正常:normal、完成:success、失败:exception,默认正常:normal
  112. * @property {Boolean} show-info 进度状态信息 - 是否显示进度数值或状态图标,默认true
  113. * @property {Number} stroke-width 进度线条的宽度 - 建议在条线的宽度范围:1-50,与进度条显示宽度有关,默认8
  114. * @property {String} stroke-color 进度线条的颜色 - 渐变色仅支持线型:line
  115. * @property {String} stroke-shape 进度线条两端的形状 - 圆:round、方块直角:square,默认圆:round
  116. * @property {Number} width 进度画布宽度 - 仅支持圆圈形:circle、仪表盘:dashboard,默认80
  117. * @property {String} gap-degree 进度圆形缺口角度 - 可取值 0 ~ 360,仅支持圆圈形:circle、仪表盘:dashboard
  118. * @property {String} gap-position 进度圆形缺口位置 - 可取值'top', 'bottom', 'left', 'right',仅支持圆圈形:circle、仪表盘:dashboard
  119. * @example <cmd-progress :percent="30"></cmd-progress>
  120. */
  121. export default {
  122. name: 'cmd-progress',
  123. props: {
  124. /**
  125. * 类型默认:line,可选 line circle dashboard
  126. */
  127. type: {
  128. validator: val => {
  129. return ['line', 'circle', 'dashboard'].includes(val)
  130. },
  131. default: 'line'
  132. },
  133. /**
  134. * 百分比
  135. */
  136. percent: {
  137. type: Number,
  138. default: 0
  139. },
  140. /**
  141. * 已完成的分段百分,仅支持类型line
  142. */
  143. successPercent: {
  144. type: Number,
  145. default: 0
  146. },
  147. /**
  148. * 是否显示进度数值或状态图标
  149. */
  150. showInfo: {
  151. type: Boolean,
  152. default: true
  153. },
  154. /**
  155. * 进度状态,可选:normal success exception (active仅支持类型line
  156. */
  157. status: {
  158. validator: val => {
  159. return ['normal', 'success', 'exception', 'active'].includes(val)
  160. },
  161. default: 'normal'
  162. },
  163. /**
  164. * 条线的宽度1-50,与width有关
  165. */
  166. strokeWidth: {
  167. type: Number,
  168. default: 6
  169. },
  170. /**
  171. * 条线的颜色,渐变色仅支持类型line
  172. */
  173. strokeColor: {
  174. type: String,
  175. default: ''
  176. },
  177. /**
  178. * 条线两端的形状 可选:'round', 'square'
  179. */
  180. strokeShape: {
  181. validator: val => {
  182. return ['round', 'square'].includes(val)
  183. },
  184. default: 'round'
  185. },
  186. /**
  187. * 圆形进度条画布宽度,支持类型circle dashboard
  188. */
  189. width: {
  190. type: Number,
  191. default: 80
  192. },
  193. /**
  194. * 圆形进度条缺口角度,可取值 0 ~ 360,支持类型circle dashboard
  195. */
  196. gapDegree: {
  197. type: Number,
  198. default: 0
  199. },
  200. /**
  201. * 圆形进度条缺口位置,可取值'top', 'bottom', 'left', 'right' ,支持类型circle dashboard
  202. */
  203. gapPosition: {
  204. validator: val => {
  205. return ['top', 'bottom', 'left', 'right'].includes(val)
  206. },
  207. default: 'top'
  208. },
  209. /**
  210. * 100%时的数值
  211. */
  212. total: {
  213. type: Number,
  214. default: 100
  215. },
  216. /**
  217. * 绑定值
  218. */
  219. value: {
  220. type: Number,
  221. default: 0
  222. },
  223. /**
  224. * 暂时值替换百分比
  225. */
  226. showVlue: {
  227. type: Boolean,
  228. default: true
  229. },
  230. /**
  231. * 名称
  232. */
  233. title: {
  234. type: String,
  235. default: ''
  236. }
  237. },
  238. computed: {
  239. /**
  240. * 如果需要自定义格式就在这改
  241. */
  242. setFormat () {
  243. if (this.showVlue) {
  244. return `${this.value}`
  245. }
  246. return `${this.setProgress}%`
  247. },
  248. /**
  249. * 设置显示进度值,禁止小于0和超过100
  250. */
  251. setProgress () {
  252. let percent = this.percent
  253. if (this.value || this.total > 0) {
  254. percent = (this.value * 100) / this.total
  255. } else if (!this.percent || this.percent < 0) {
  256. percent = 0
  257. } else if (this.percent >= 100) {
  258. percent = 100
  259. }
  260. return percent
  261. },
  262. /**
  263. * 进度圈svg大小
  264. */
  265. setCircleStyle () {
  266. return `width: ${this.width}px;
  267. height: ${this.width}px;
  268. fontSize: ${this.width * 0.15 + 6}px;`
  269. },
  270. /**
  271. * 圈底色
  272. */
  273. setCircleTrailStyle () {
  274. const radius = 50 - this.strokeWidth / 2
  275. const len = Math.PI * 2 * radius
  276. const gapDeg = this.gapDegree || (this.type === 'dashboard' && 75)
  277. return `stroke-dasharray: ${len - (gapDeg || 0)}px, ${len}px;
  278. stroke-dashoffset: -${(gapDeg || 0) / 2}px;
  279. transition: stroke-dashoffset 0.3s ease 0s, stroke-dasharray 0.3s ease 0s, stroke 0.3s;`
  280. },
  281. /**
  282. * 圈进度
  283. */
  284. setCirclePathStyle () {
  285. const radius = 50 - this.strokeWidth / 2
  286. const len = Math.PI * 2 * radius
  287. const gapDeg = this.gapDegree || (this.type === 'dashboard' && 75)
  288. return `stroke: ${this.strokeColor};
  289. stroke-dasharray: ${(this.setProgress / 100) * (len - (gapDeg || 0))}px, ${len}px;
  290. stroke-dashoffset: -${(gapDeg || 0) / 2}px;
  291. transition: stroke-dashoffset 0.3s ease 0s, stroke-dasharray 0.3s ease 0s, stroke 0.3s, stroke-width 0.06s ease 0.3s;`
  292. },
  293. /**
  294. * 绘制圈
  295. */
  296. setCirclePath () {
  297. const radius = 50 - this.strokeWidth / 2
  298. let beginPositionX = 0
  299. let beginPositionY = -radius
  300. let endPositionX = 0
  301. let endPositionY = -2 * radius
  302. const gapPos = (this.type === 'dashboard' && 'bottom') || this.gapPosition || 'top'
  303. switch (gapPos) {
  304. case 'left':
  305. beginPositionX = -radius
  306. beginPositionY = 0
  307. endPositionX = 2 * radius
  308. endPositionY = 0
  309. break
  310. case 'right':
  311. beginPositionX = radius
  312. beginPositionY = 0
  313. endPositionX = -2 * radius
  314. endPositionY = 0
  315. break
  316. case 'bottom':
  317. beginPositionY = radius
  318. endPositionY = 2 * radius
  319. break
  320. default:
  321. break
  322. }
  323. return `M 50,50 m ${beginPositionX},${beginPositionY} a ${radius},${radius} 0 1 1 ${endPositionX},${-endPositionY} a ${radius},${radius} 0 1 1 ${-endPositionX},${endPositionY}`
  324. },
  325. // #ifndef H5
  326. /**
  327. * 非H5端,绘制进度圈svg转base URL
  328. */
  329. setCircle () {
  330. const radius = 50 - this.strokeWidth / 2
  331. const len = Math.PI * 2 * radius
  332. const gapDeg = this.gapDegree || (this.type === 'dashboard' && 75)
  333. let currentColor = '#108ee9'
  334. // 异常进度
  335. if (this.status == 'exception') {
  336. currentColor = '#f5222d'
  337. }
  338. // 完成进度
  339. if (this.status == 'success' || this.setProgress >= 100 || this.strokeColor) {
  340. currentColor = this.strokeColor || '#52c41a'
  341. }
  342. const svgToBase = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' class='cmd-progress-circle'%3E%3Cpath d='${
  343. this.setCirclePath
  344. }' stroke='%23f3f3f3' stroke-linecap='${this.strokeShape}' stroke-width='${
  345. this.strokeWidth
  346. }' fill-opacity='0' class='cmd-progress-circle-trail' style='stroke-dasharray: ${len - (gapDeg || 0)}px, ${len}px;stroke-dashoffset: -${(gapDeg || 0) /
  347. 2}px;transition: stroke-dashoffset 0.3s ease 0s, stroke-dasharray 0.3s ease 0s, stroke 0.3s;'%3E%3C/path%3E%3Cpath d='${this.setCirclePath}' stroke-linecap='${
  348. this.strokeShape
  349. }' stroke-width='${this.strokeWidth}' fill-opacity='0' class='cmd-progress-circle-path' style='stroke: ${escape(currentColor)};stroke-dasharray: ${(this.setProgress / 100) *
  350. (len - (gapDeg || 0))}px, ${len}px;stroke-dashoffset: -${(gapDeg || 0) /
  351. 2}px;transition: stroke-dashoffset 0.3s ease 0s, stroke-dasharray 0.3s ease 0s, stroke 0.3s, stroke-width 0.06s ease 0.3s;'%3E%3C/path%3E%3C/svg%3E`
  352. return `background-image: url("${svgToBase}");
  353. background-size: cover;
  354. display: inline-block;
  355. ${this.setCircleStyle}`
  356. },
  357. /**
  358. * 设置进度圈状态图标
  359. */
  360. setCircleIcon () {
  361. let currentColor = '#108ee9'
  362. let svgToBase = ''
  363. // 异常进度
  364. if (this.status == 'exception') {
  365. currentColor = '#f5222d'
  366. svgToBase = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' data-icon='close' width='1em' height='1em' fill='${escape(
  367. currentColor
  368. )}' aria-hidden='true'%3E %3Cpath d='M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z'%3E%3C/path%3E %3C/svg%3E`
  369. }
  370. // 完成进度
  371. if (this.status == 'success' || this.setProgress >= 100) {
  372. currentColor = this.strokeColor || '#52c41a'
  373. svgToBase = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' data-icon='check' width='1em' height='1em' fill='${escape(
  374. currentColor
  375. )}' aria-hidden='true'%3E %3Cpath d='M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z'%3E%3C/path%3E %3C/svg%3E`
  376. }
  377. return `background-image: url("${svgToBase}");
  378. background-size: cover;
  379. display: inline-block;
  380. width: 1em;
  381. height: 1em;`
  382. },
  383. // #endif
  384. /**
  385. * 设置进度条样式
  386. */
  387. setLineStyle () {
  388. return `width: ${this.setProgress}%;
  389. height: ${this.strokeWidth}px;
  390. background: ${this.strokeColor};
  391. border-radius: ${this.strokeShape === 'square' ? 0 : '100px'};`
  392. },
  393. /**
  394. * 设置已完成分段进度
  395. */
  396. setLineSuccessStyle () {
  397. let successPercent = this.successPercent
  398. if (!this.successPercent || this.successPercent < 0 || this.setProgress < this.successPercent) {
  399. successPercent = 0
  400. } else if (this.successPercent >= 100) {
  401. successPercent = 100
  402. }
  403. return `width: ${successPercent}%;
  404. height: ${this.strokeWidth}px;
  405. border-radius: ${this.strokeShape === 'square' ? 0 : '100px'};`
  406. },
  407. // #ifndef H5
  408. /**
  409. * 设置进度条状态图标
  410. */
  411. setLineStatusIcon () {
  412. let currentColor = '#108ee9'
  413. let svgToBase = ''
  414. // 异常进度
  415. if (this.status == 'exception') {
  416. currentColor = '#f5222d'
  417. svgToBase = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' data-icon='close-circle' width='1em' height='1em' fill='${escape(
  418. currentColor
  419. )}' aria-hidden='true'%3E %3Cpath d='M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 0 1-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z'%3E%3C/path%3E %3C/svg%3E`
  420. }
  421. // 完成进度
  422. if (this.status == 'success' || this.setProgress >= 100) {
  423. currentColor = this.strokeColor || '#52c41a'
  424. svgToBase = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' data-icon='check-circle' width='1em' height='1em' fill='${escape(
  425. currentColor
  426. )}' aria-hidden='true'%3E %3Cpath d='M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 0 1-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z'%3E%3C/path%3E %3C/svg%3E`
  427. }
  428. return `background-image: url("${svgToBase}");
  429. background-size: cover;
  430. display: inline-block;
  431. width: 1em;
  432. height: 1em;`
  433. },
  434. // #endif
  435. /**
  436. * 状态样式
  437. */
  438. setStatusClass () {
  439. const statusClass = []
  440. // 异常进度
  441. if (this.status == 'exception') {
  442. statusClass.push('cmd-progress-status-exception')
  443. }
  444. // 完成进度
  445. if (this.status == 'success' || this.setProgress >= 100) {
  446. statusClass.push('cmd-progress-status-success')
  447. }
  448. // 活动进度条
  449. if (this.status == 'active') {
  450. statusClass.push('cmd-progress-status-active')
  451. }
  452. // 是否显示信息
  453. if (this.showInfo) {
  454. statusClass.push('cmd-progress-show-info')
  455. }
  456. // 进度条类型
  457. if (this.type === 'line') {
  458. statusClass.push('cmd-progress-line')
  459. }
  460. // 进度圈、仪表盘类型
  461. if (this.type === 'circle' || this.type === 'dashboard') {
  462. statusClass.push('cmd-progress-circle')
  463. }
  464. statusClass.push('cmd-progress-status-normal')
  465. return statusClass
  466. }
  467. }
  468. }
  469. </script>
  470. <style>
  471. .cmd-progress {
  472. box-sizing: border-box;
  473. margin: 0;
  474. padding: 0;
  475. list-style: none;
  476. display: inline-block;
  477. }
  478. .cmd-progress-line {
  479. width: 100%;
  480. font-size: 28upx;
  481. position: relative;
  482. display: flex;
  483. flex-direction: row;
  484. justify-content: center;
  485. align-items: center;
  486. }
  487. .cmd-progress-outer {
  488. display: inline-block;
  489. width: 100%;
  490. margin-right: 0;
  491. padding-right: 0;
  492. }
  493. .cmd-progress-show-info .cmd-progress-outer {
  494. flex: 1;
  495. }
  496. .cmd-progress-inner {
  497. display: inline-block;
  498. width: 100%;
  499. background-color: #f5f5f5;
  500. border-radius: 200upx;
  501. vertical-align: middle;
  502. position: relative;
  503. }
  504. .cmd-progress-circle-trail {
  505. stroke: #f5f5f5;
  506. }
  507. .cmd-progress-circle-path {
  508. stroke: #1890ff;
  509. animation: appear 0.3s;
  510. }
  511. .cmd-progress-success-bg,
  512. .cmd-progress-bg {
  513. background-color: #1890ff;
  514. transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
  515. position: relative;
  516. }
  517. .cmd-progress-success-bg {
  518. background-color: #52c41a;
  519. position: absolute;
  520. top: 0;
  521. left: 0;
  522. }
  523. .cmd-progress-text {
  524. word-break: normal;
  525. width: 60upx;
  526. text-align: left;
  527. margin-left: 16upx;
  528. vertical-align: middle;
  529. display: inline-block;
  530. white-space: nowrap;
  531. color: rgba(0, 0, 0, 0.45);
  532. line-height: 1;
  533. }
  534. .cmd-progress-status-active .cmd-progress-bg:before {
  535. content: '';
  536. opacity: 0;
  537. position: absolute;
  538. top: 0;
  539. left: 0;
  540. right: 0;
  541. bottom: 0;
  542. background: #fff;
  543. border-radius: 20upx;
  544. -webkit-animation: cmd-progress-active 2.4s cubic-bezier(0.23, 1, 0.32, 1) infinite;
  545. animation: cmd-progress-active 2.4s cubic-bezier(0.23, 1, 0.32, 1) infinite;
  546. }
  547. .cmd-progress-status-exception .cmd-progress-bg {
  548. background-color: #f5222d;
  549. }
  550. .cmd-progress-status-exception .cmd-progress-text {
  551. color: #f5222d;
  552. }
  553. .cmd-progress-status-exception .cmd-progress-circle-path {
  554. stroke: #f5222d;
  555. }
  556. .cmd-progress-status-success .cmd-progress-bg {
  557. background-color: #52c41a;
  558. }
  559. .cmd-progress-status-success .cmd-progress-text {
  560. /* color: #52c41a; */
  561. }
  562. .cmd-progress-status-success .cmd-progress-circle-path {
  563. stroke: #52c41a;
  564. }
  565. .cmd-progress-circle .cmd-progress-inner {
  566. position: relative;
  567. line-height: 1;
  568. background-color: transparent;
  569. }
  570. .cmd-progress-circle .cmd-progress-text {
  571. display: block;
  572. position: absolute;
  573. width: 100%;
  574. text-align: center;
  575. line-height: 1;
  576. top: 50%;
  577. -webkit-transform: translateY(-50%);
  578. transform: translateY(-50%);
  579. left: 0;
  580. margin: 0;
  581. color: rgba(0, 0, 0, 0.65);
  582. white-space: normal;
  583. }
  584. .cmd-progress-circle .cmd-progress-status-exception .cmd-progress-text {
  585. color: #f5222d;
  586. }
  587. .cmd-progress-circle .cmd-progress-status-success .cmd-progress-text {
  588. color: #52c41a;
  589. }
  590. .cmd-progress .title {
  591. width: 35%;
  592. color: #909090;
  593. font-size: 30rpx;
  594. overflow: hidden;
  595. text-overflow: ellipsis;
  596. white-space: nowrap
  597. }
  598. @keyframes cmd-progress-active {
  599. 0% {
  600. opacity: 0.1;
  601. width: 0;
  602. }
  603. 20% {
  604. opacity: 0.5;
  605. width: 0;
  606. }
  607. 100% {
  608. opacity: 0;
  609. width: 100%;
  610. }
  611. }
  612. </style>