增加分类搜索

This commit is contained in:
TOP糯米 2023-03-19 13:58:40 +08:00
parent 6fa9b0a895
commit b64efac97f
3 changed files with 33 additions and 3 deletions

View File

@ -6,7 +6,7 @@
<input
class="input"
type="text"
:model="keywords"
v-model="keywords"
placeholder="搜索您需要的服务"
placeholder-class="placeholder-style-1"
/>
@ -25,6 +25,11 @@ export default {
created() {},
mounted() {},
destroyed() {},
watch: {
keywords(value) {
this.$emit("input", value);
},
},
methods: {},
};
</script>

View File

@ -1,6 +1,6 @@
<template>
<app-layout headerBackgroundColor="#4B65ED" textColor="light" btnType="city" title="熊熊安装队">
<view class="search-component">
<view class="search-component" @click="utils.toPage('/pages/service/cate', {}, 'switch')">
<widget-search />
</view>
<view class="banner">

View File

@ -1,7 +1,7 @@
<template>
<app-layout minHeight="unset" btnType="unset" title="分类">
<view class="search-component">
<widget-search />
<widget-search @input="inputKeywords" />
</view>
<view class="cate">
<app-cate
@ -46,6 +46,8 @@ export default {
currentId: 0,
newId: 0,
data: [],
keywordsTimer: null,
keywords: "",
};
},
components: {
@ -105,6 +107,9 @@ export default {
let list = [];
await this.$request({
api: "service.hotCate",
data: {
keys: this.keywords,
},
}).then((response) => {
response.data.forEach((item) => {
list.push({
@ -123,6 +128,9 @@ export default {
loadCate() {
this.$request({
api: "service.cate",
data: {
keys: this.keywords,
},
})
.then((response) => {
response.data.forEach((item) => {
@ -151,6 +159,23 @@ export default {
this.newId = parentId;
this.$utils.toPage("/pages/service/list?id=" + id);
},
/**
* 搜索
*/
inputKeywords(kw) {
this.keywords = kw;
clearTimeout(this.keywordsTimer);
this.keywordsTimer = setTimeout(async () => {
this.data = [];
this.data.push({
id: 0,
name: "热门推荐",
cover: "",
child: await this.hotCate(),
});
this.loadCate();
}, 1000);
},
},
};
</script>