增加分类搜索

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

View File

@ -1,6 +1,6 @@
<template> <template>
<app-layout headerBackgroundColor="#4B65ED" textColor="light" btnType="city" title="熊熊安装队"> <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 /> <widget-search />
</view> </view>
<view class="banner"> <view class="banner">

View File

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