su-radio.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = {
  4. __name: "su-radio",
  5. props: {
  6. customStyle: {
  7. type: Object,
  8. default: () => ({})
  9. },
  10. ui: {
  11. type: String,
  12. default: "check"
  13. //check line
  14. },
  15. modelValue: {
  16. type: [String, Number, Boolean],
  17. default: false
  18. },
  19. disabled: {
  20. type: Boolean,
  21. default: false
  22. },
  23. bg: {
  24. type: String,
  25. default: "ui-BG-Main"
  26. },
  27. unbg: {
  28. type: String,
  29. default: "borderss"
  30. },
  31. src: {
  32. type: String,
  33. default: ""
  34. },
  35. label: {
  36. type: String,
  37. default: ""
  38. },
  39. labelStyle: {
  40. type: Object,
  41. default: () => ({})
  42. },
  43. none: {
  44. type: Boolean,
  45. default: false
  46. }
  47. },
  48. emits: ["change", "update:modelValue"],
  49. setup(__props, { emit: __emit }) {
  50. const state = common_vendor.reactive({
  51. currentValue: false
  52. });
  53. const emits = __emit;
  54. const props = __props;
  55. common_vendor.watchPostEffect(() => {
  56. state.currentValue = props.modelValue;
  57. emits("update:modelValue", state.currentValue);
  58. });
  59. const isChecked = common_vendor.computed(() => state.currentValue);
  60. const onRaido = () => {
  61. if (props.disabled)
  62. return;
  63. state.currentValue = !state.currentValue;
  64. emits("update:modelValue", state.currentValue);
  65. emits("change", {
  66. label: props.label,
  67. value: state.currentValue
  68. });
  69. };
  70. return (_ctx, _cache) => {
  71. return common_vendor.e({
  72. a: !__props.none
  73. }, !__props.none ? {
  74. b: common_vendor.n(isChecked.value ? "cur " + __props.bg : __props.unbg),
  75. c: common_vendor.n(__props.src ? "radius" : "round")
  76. } : {}, {
  77. d: __props.src
  78. }, __props.src ? {
  79. e: __props.src
  80. } : {
  81. f: common_vendor.t(__props.label),
  82. g: common_vendor.s(__props.labelStyle)
  83. }, {
  84. h: __props.ui.includes("card")
  85. }, __props.ui.includes("card") ? {
  86. i: common_vendor.n(isChecked.value ? "cur " + __props.bg : "")
  87. } : {}, {
  88. j: common_vendor.o(onRaido),
  89. k: common_vendor.n({
  90. disabled: __props.disabled
  91. }),
  92. l: common_vendor.n({
  93. img: __props.src
  94. }),
  95. m: common_vendor.n(__props.ui),
  96. n: common_vendor.s(__props.customStyle)
  97. });
  98. };
  99. }
  100. };
  101. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c395529d"], ["__file", "D:/zx/mall-front-app/sheep/ui/su-radio/su-radio.vue"]]);
  102. wx.createComponent(Component);