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

140 lines
3.8 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
2024-10-01 09:15:35 +08:00
const common_vendor = require("../../../../../common/vendor.js");
const modules_mall_sheep_index = require("../../index.js");
2024-09-19 07:20:14 +08:00
if (!Array) {
const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
_easycom_uni_search_bar2();
}
2024-10-01 09:15:35 +08:00
const _easycom_uni_search_bar = () => "../../../../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.js";
2024-09-19 07:20:14 +08:00
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) {
2024-10-01 09:15:35 +08:00
modules_mall_sheep_index.sheep.$router.go("/modules/mall/goods/list", { keyword: e.value });
2024-09-19 07:20:14 +08:00
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),
2024-10-01 09:15:35 +08:00
b: common_vendor.o(($event) => common_vendor.unref(modules_mall_sheep_index.sheep).$router.go("/modules/mall/goods/list", {
2024-09-19 07:20:14 +08:00
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
})
});
};
}
};
2024-10-01 09:15:35 +08:00
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a665b6a1"]]);
2024-09-19 07:20:14 +08:00
wx.createComponent(Component);