acdr-ui/dist/dev/mp-weixin/sheep/components/s-search-block/s-search-block.js

141 lines
3.8 KiB
JavaScript

"use strict";
const common_vendor = require("../../../common/vendor.js");
const sheep_index = require("../../index.js");
if (!Array) {
const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
_easycom_uni_search_bar2();
}
const _easycom_uni_search_bar = () => "../../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.js";
if (!Math) {
_easycom_uni_search_bar();
}
const _sfc_main = {
__name: "s-search-block",
props: {
data: {
type: Object,
default: () => ({})
},
// 输入框背景色
elBackground: {
type: String,
default: ""
},
height: {
type: Number,
default: 36
},
// 图标颜色
iconColor: {
type: String,
default: "#b0b3bf"
},
// 字体颜色
fontColor: {
type: String,
default: "#b0b3bf"
},
// placeholder
placeholder: {
type: String,
default: "这是一个搜索框"
},
radius: {
type: Number,
default: 10
},
width: {
type: String,
default: "100%"
},
navbar: {
type: Boolean,
default: true
}
},
emits: ["click"],
setup(__props, { emit: __emit }) {
const state = common_vendor.reactive({
searchVal: ""
});
const emits = __emit;
const props = __props;
const click = () => {
emits("click");
};
function onSearch(e) {
if (e.value) {
sheep_index.sheep.$router.go("/modules/mall/goods/list", { keyword: e.value });
setTimeout(() => {
state.searchVal = "";
}, 100);
}
}
return (_ctx, _cache) => {
return common_vendor.e({
a: __props.navbar
}, __props.navbar ? {
b: common_vendor.s({
color: props.iconColor
}),
c: common_vendor.t(__props.placeholder),
d: common_vendor.s({
color: __props.fontColor,
width: __props.width
})
} : {}, {
e: !__props.navbar
}, !__props.navbar ? {
f: common_vendor.o(onSearch),
g: common_vendor.o(($event) => state.searchVal = $event),
h: common_vendor.p({
radius: __props.data.borderRadius,
placeholder: __props.data.placeholder,
cancelButton: "none",
clearButton: "none",
modelValue: state.searchVal
})
} : {}, {
i: common_vendor.f(__props.data.hotKeywords, (item, index, i0) => {
return {
a: common_vendor.t(item),
b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/modules/mall/goods/list", {
keyword: item
}), index),
c: index
};
}),
j: common_vendor.s({
color: __props.data.textColor
}),
k: __props.data.hotKeywords && __props.data.hotKeywords.length && __props.navbar
}, __props.data.hotKeywords && __props.data.hotKeywords.length && __props.navbar ? {
l: common_vendor.f(__props.data.hotKeywords, (item, index, i0) => {
return {
a: common_vendor.t(item),
b: index
};
}),
m: common_vendor.s({
color: __props.data.textColor,
marginRight: "10rpx"
})
} : {}, {
n: common_vendor.o(click),
o: common_vendor.s({
borderRadius: __props.radius + "px",
background: __props.elBackground,
height: __props.height + "px",
width: __props.width
}),
p: common_vendor.n({
"border-content": __props.navbar
})
});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-fd75520f"]]);
wx.createComponent(Component);
//# sourceMappingURL=s-search-block.js.map