index.vue 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <uni-shadow-root class="vant-dist-progress-index"><view class="van-progress custom-class" :style="computed.rootStyle({ strokeWidth, trackColor })">
  3. <view class="van-progress__portion" :style="computed.portionStyle({ percentage, inactive, color })">
  4. <view v-if="showPivot && computed.pivotText(pivotText, percentage)" :style="computed.pivotStyle({ textColor, pivotColor, inactive, color, right })" class="van-progress__pivot">
  5. {{ computed.pivotText(pivotText, percentage) }}
  6. </view>
  7. </view>
  8. </view></uni-shadow-root>
  9. </template>
  10. <wxs src="../wxs/utils.wxs" module="utils"></wxs><wxs src="./index.wxs" module="computed"></wxs>
  11. <script>
  12. global['__wxRoute'] = 'vant/dist/progress/index'
  13. import { VantComponent } from '../common/component';
  14. import { BLUE } from '../common/color';
  15. import { getRect } from '../common/utils';
  16. VantComponent({
  17. props: {
  18. inactive: Boolean,
  19. percentage: {
  20. type: Number,
  21. observer: 'setLeft',
  22. },
  23. pivotText: String,
  24. pivotColor: String,
  25. trackColor: String,
  26. showPivot: {
  27. type: Boolean,
  28. value: true,
  29. },
  30. color: {
  31. type: String,
  32. value: BLUE,
  33. },
  34. textColor: {
  35. type: String,
  36. value: '#fff',
  37. },
  38. strokeWidth: {
  39. type: null,
  40. value: 4,
  41. },
  42. },
  43. data: {
  44. right: 0,
  45. },
  46. mounted() {
  47. this.setLeft();
  48. },
  49. methods: {
  50. setLeft() {
  51. Promise.all([
  52. getRect(this, '.van-progress'),
  53. getRect(this, '.van-progress__pivot'),
  54. ]).then(([portion, pivot]) => {
  55. if (portion && pivot) {
  56. this.setData({
  57. right: (pivot.width * (this.data.percentage - 100)) / 100,
  58. });
  59. }
  60. });
  61. },
  62. },
  63. });
  64. export default global['__wxComponents']['vant/dist/progress/index']
  65. </script>
  66. <style platform="mp-weixin">
  67. @import '../common/index.css';.van-progress{position:relative;height:4px;height:var(--progress-height,4px);border-radius:4px;border-radius:var(--progress-height,4px);background:#ebedf0;background:var(--progress-background-color,#ebedf0)}.van-progress__portion{position:absolute;left:0;height:100%;border-radius:inherit;background:#1989fa;background:var(--progress-color,#1989fa)}.van-progress__pivot{position:absolute;top:50%;box-sizing:border-box;min-width:3.6em;text-align:center;word-break:keep-all;border-radius:1em;transform:translateY(-50%);color:#fff;color:var(--progress-pivot-text-color,#fff);padding:0 5px;padding:var(--progress-pivot-padding,0 5px);font-size:10px;font-size:var(--progress-pivot-font-size,10px);line-height:1.6;line-height:var(--progress-pivot-line-height,1.6);background-color:#1989fa;background-color:var(--progress-pivot-background-color,#1989fa)}
  68. </style>