su-progress.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "AiProgress",
  5. components: {},
  6. props: {
  7. // 进度条的值
  8. percentage: {
  9. type: [Number, String],
  10. required: true
  11. },
  12. // 是否内联显示数据
  13. textInside: {
  14. type: Boolean,
  15. default: false
  16. },
  17. // 进度条高度
  18. strokeWidth: {
  19. type: [Number, String],
  20. default: 6
  21. },
  22. // 默认动画时长
  23. duration: {
  24. type: [Number, String],
  25. default: 2e3
  26. },
  27. // 是否有动画
  28. isAnimate: {
  29. type: Boolean,
  30. default: false
  31. },
  32. // 背景颜色
  33. bgColor: {
  34. type: String,
  35. default: "linear-gradient(90deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%)"
  36. },
  37. // 是否不显示数据
  38. noData: {
  39. type: Boolean,
  40. default: false
  41. },
  42. // 是否自定义显示内容
  43. lineData: {
  44. type: Boolean,
  45. default: false
  46. },
  47. // 自定义底色
  48. inBgColor: {
  49. type: String,
  50. default: "#ebeef5"
  51. }
  52. },
  53. data() {
  54. return {
  55. width: 0,
  56. timer: null,
  57. containerWidth: 0,
  58. contentWidth: 0
  59. };
  60. },
  61. methods: {
  62. start() {
  63. if (this.isAnimate) {
  64. const container = common_vendor.index.createSelectorQuery().in(this).selectAll("#container");
  65. common_vendor.index.createSelectorQuery().in(this).selectAll("#content");
  66. container.boundingClientRect().exec((res1) => {
  67. this.contentWidth = res1[0][0].width * 1 * (this.percentage * 1 / 100).toFixed(2) + "px";
  68. });
  69. }
  70. }
  71. },
  72. mounted() {
  73. this.$nextTick(() => {
  74. this.start();
  75. });
  76. },
  77. created() {
  78. },
  79. filters: {},
  80. computed: {},
  81. watch: {},
  82. directives: {}
  83. };
  84. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  85. return common_vendor.e({
  86. a: $props.lineData
  87. }, $props.lineData ? {} : {}, {
  88. b: $props.isAnimate
  89. }, $props.isAnimate ? common_vendor.e({
  90. c: $props.textInside && !$props.noData
  91. }, $props.textInside && !$props.noData ? {
  92. d: common_vendor.t($props.percentage)
  93. } : {}, {
  94. e: $props.strokeWidth + "px",
  95. f: $props.bgColor,
  96. g: $data.contentWidth,
  97. h: `width ${$props.duration / 1e3}s ease`
  98. }) : {}, {
  99. i: !$props.isAnimate
  100. }, !$props.isAnimate ? common_vendor.e({
  101. j: $props.textInside && !$props.noData
  102. }, $props.textInside && !$props.noData ? {
  103. k: common_vendor.t($props.percentage)
  104. } : {}, {
  105. l: $props.percentage + "%",
  106. m: $props.strokeWidth + "px",
  107. n: $props.bgColor
  108. }) : {}, {
  109. o: $props.inBgColor,
  110. p: !$props.textInside && !$props.lineData && !$props.noData && !$props.isAnimate
  111. }, !$props.textInside && !$props.lineData && !$props.noData && !$props.isAnimate ? {
  112. q: common_vendor.t($props.percentage)
  113. } : {});
  114. }
  115. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e717a0ca"], ["__file", "D:/zx/mall-front-app/sheep/ui/su-progress/su-progress.vue"]]);
  116. wx.createComponent(Component);