su-radio.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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: emits }) {
  50. const props = __props;
  51. const state = common_vendor.reactive({
  52. currentValue: false
  53. });
  54. common_vendor.watchPostEffect(() => {
  55. state.currentValue = props.modelValue;
  56. emits("update:modelValue", state.currentValue);
  57. });
  58. const isChecked = common_vendor.computed(() => state.currentValue);
  59. const onRaido = () => {
  60. if (props.disabled)
  61. return;
  62. state.currentValue = !state.currentValue;
  63. emits("update:modelValue", state.currentValue);
  64. emits("change", {
  65. label: props.label,
  66. value: state.currentValue
  67. });
  68. };
  69. return (_ctx, _cache) => {
  70. return common_vendor.e({
  71. a: !__props.none
  72. }, !__props.none ? {
  73. b: common_vendor.n(common_vendor.unref(isChecked) ? "cur " + __props.bg : __props.unbg),
  74. c: common_vendor.n(__props.src ? "radius" : "round")
  75. } : {}, {
  76. d: __props.src
  77. }, __props.src ? {
  78. e: __props.src
  79. } : {
  80. f: common_vendor.t(__props.label),
  81. g: common_vendor.s(__props.labelStyle)
  82. }, {
  83. h: __props.ui.includes("card")
  84. }, __props.ui.includes("card") ? {
  85. i: common_vendor.n(common_vendor.unref(isChecked) ? "cur " + __props.bg : "")
  86. } : {}, {
  87. j: common_vendor.o(onRaido),
  88. k: common_vendor.n({
  89. disabled: __props.disabled
  90. }),
  91. l: common_vendor.n({
  92. img: __props.src
  93. }),
  94. m: common_vendor.n(__props.ui),
  95. n: common_vendor.s(__props.customStyle)
  96. });
  97. };
  98. }
  99. };
  100. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c395529d"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/ui/su-radio/su-radio.vue"]]);
  101. wx.createComponent(Component);