searchBox.js 1.5 KB
"use strict";
var common_vendor = require("../common/vendor.js");
const _sfc_main = {
  props: {
    disabled: {
      type: Boolean,
      default: true
    },
    keyWord: {
      type: String,
      default: ""
    }
  },
  emits: ["doSearchs", "input"],
  setup(__props, { emit }) {
    const props = __props;
    let inputText = common_vendor.ref("");
    common_vendor.onMounted(() => {
      inputText.value = props.keyWord;
    });
    const doSearchs = (e) => {
      if (e == 0) {
        if (inputText.value.trim() == "")
          return;
        emit("doSearchs", inputText.value);
      } else {
        emit("doSearchs", e.detail.value);
      }
    };
    const input = (e) => {
      if (e.detail.value == "") {
        emit("input", e.detail.value);
      }
    };
    const jump = () => {
      props.disabled ? common_vendor.index.navigateTo({ url: "/pages/index/search" }) : "";
    };
    return (_ctx, _cache) => {
      return {
        a: __props.disabled,
        b: common_vendor.o(doSearchs),
        c: common_vendor.o([($event) => common_vendor.isRef(inputText) ? inputText.value = $event.detail.value : inputText = $event.detail.value, input]),
        d: common_vendor.unref(inputText),
        e: common_vendor.o(($event) => doSearchs(0)),
        f: common_vendor.o(jump)
      };
    };
  }
};
var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/componets/searchBox.vue"]]);
wx.createComponent(Component);