index.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <uni-shadow-root class="weapp-lib-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'] = 'weapp/lib/progress/index'
  13. "use strict";
  14. Object.defineProperty(exports, "__esModule", { value: true });
  15. var component_1 = require("../common/component");
  16. var color_1 = require("../common/color");
  17. var utils_1 = require("../common/utils");
  18. (0, component_1.VantComponent)({
  19. props: {
  20. inactive: Boolean,
  21. percentage: {
  22. type: Number,
  23. observer: 'setLeft',
  24. },
  25. pivotText: String,
  26. pivotColor: String,
  27. trackColor: String,
  28. showPivot: {
  29. type: Boolean,
  30. value: true,
  31. },
  32. color: {
  33. type: String,
  34. value: color_1.BLUE,
  35. },
  36. textColor: {
  37. type: String,
  38. value: '#fff',
  39. },
  40. strokeWidth: {
  41. type: null,
  42. value: 4,
  43. },
  44. },
  45. data: {
  46. right: 0,
  47. },
  48. mounted: function () {
  49. this.setLeft();
  50. },
  51. methods: {
  52. setLeft: function () {
  53. var _this = this;
  54. Promise.all([
  55. (0, utils_1.getRect)(this, '.van-progress'),
  56. (0, utils_1.getRect)(this, '.van-progress__pivot'),
  57. ]).then(function (_a) {
  58. var portion = _a[0], pivot = _a[1];
  59. if (portion && pivot) {
  60. _this.setData({
  61. right: (pivot.width * (_this.data.percentage - 100)) / 100,
  62. });
  63. }
  64. });
  65. },
  66. },
  67. });
  68. export default global['__wxComponents']['weapp/lib/progress/index']
  69. </script>
  70. <style platform="mp-weixin">
  71. @import '../common/index.css';.van-progress{background:var(--progress-background-color,#ebedf0);border-radius:var(--progress-height,4px);height:var(--progress-height,4px);position:relative}.van-progress__portion{background:var(--progress-color,#1989fa);border-radius:inherit;height:100%;left:0;position:absolute}.van-progress__pivot{background-color:var(--progress-pivot-background-color,#1989fa);border-radius:1em;box-sizing:border-box;color:var(--progress-pivot-text-color,#fff);font-size:var(--progress-pivot-font-size,10px);line-height:var(--progress-pivot-line-height,1.6);min-width:3.6em;padding:var(--progress-pivot-padding,0 5px);position:absolute;text-align:center;top:50%;transform:translateY(-50%);word-break:keep-all}
  72. </style>