u-badge.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-badge",
  5. mixins: [common_vendor.mpMixin, common_vendor.props$12, common_vendor.mixin],
  6. computed: {
  7. // 是否将badge中心与父组件右上角重合
  8. boxStyle() {
  9. let style = {};
  10. return style;
  11. },
  12. // 整个组件的样式
  13. badgeStyle() {
  14. const style = {};
  15. if (this.color) {
  16. style.color = this.color;
  17. }
  18. if (this.bgColor && !this.inverted) {
  19. style.backgroundColor = this.bgColor;
  20. }
  21. if (this.absolute) {
  22. style.position = "absolute";
  23. if (this.offset.length) {
  24. const top = this.offset[0];
  25. const right = this.offset[1] || top;
  26. style.top = common_vendor.index.$u.addUnit(top);
  27. style.right = common_vendor.index.$u.addUnit(right);
  28. }
  29. }
  30. return style;
  31. },
  32. showValue() {
  33. switch (this.numberType) {
  34. case "overflow":
  35. return Number(this.value) > Number(this.max) ? this.max + "+" : this.value;
  36. case "ellipsis":
  37. return Number(this.value) > Number(this.max) ? "..." : this.value;
  38. case "limit":
  39. return Number(this.value) > 999 ? Number(this.value) >= 9999 ? Math.floor(this.value / 1e4 * 100) / 100 + "w" : Math.floor(this.value / 1e3 * 100) / 100 + "k" : this.value;
  40. default:
  41. return Number(this.value);
  42. }
  43. }
  44. }
  45. };
  46. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  47. return common_vendor.e({
  48. a: _ctx.show && ((Number(_ctx.value) === 0 ? _ctx.showZero : true) || _ctx.isDot)
  49. }, _ctx.show && ((Number(_ctx.value) === 0 ? _ctx.showZero : true) || _ctx.isDot) ? {
  50. b: common_vendor.t(_ctx.isDot ? "" : $options.showValue),
  51. c: common_vendor.n(_ctx.isDot ? "u-badge--dot" : "u-badge--not-dot"),
  52. d: common_vendor.n(_ctx.inverted && "u-badge--inverted"),
  53. e: common_vendor.n(_ctx.shape === "horn" && "u-badge--horn"),
  54. f: common_vendor.n(`u-badge--${_ctx.type}${_ctx.inverted ? "--inverted" : ""}`),
  55. g: common_vendor.s(_ctx.$u.addStyle(_ctx.customStyle)),
  56. h: common_vendor.s($options.badgeStyle)
  57. } : {});
  58. }
  59. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-aa9883b1"], ["__file", "D:/project/二手车/car_applet/node_modules/uview-plus/components/u-badge/u-badge.vue"]]);
  60. wx.createComponent(Component);