Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-06-09 09:02:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5b8015018389653ec3ce235edf266decb72aaff0
5b801501
1 parent
5eee98e1
✨ feat(爱心书籍列表页): 新增书籍列表搜索功能
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
src/views/business/index.vue
src/views/client/chooseBook.vue
src/views/business/index.vue
View file @
5b80150
...
...
@@ -117,6 +117,7 @@ watch(
}
}
)
/**************************************************/
</script>
<style lang="less" scoped>
...
...
src/views/client/chooseBook.vue
View file @
5b80150
...
...
@@ -37,8 +37,13 @@
<div class="ding right" />
</div>
<div class="book-list">
<!-- NOTICE: 新增搜索功能,需要时放出 -->
<!-- <van-sticky>
<van-search v-model="search_value" placeholder="请输入书籍名称" @search="onSearch" />
</van-sticky> -->
<template v-for="(item, key) in kgInfo.book_list" :key="key">
<book-card :type="USER_ROLE.CLIENT" :item="item" @on-click="go('/client/bookDetail', { id: item.id, kg_id })" />
<book-card v-if="item.show" :type="USER_ROLE.CLIENT" :item="item"
@on-click="go('/client/bookDetail', { id: item.id, kg_id })" />
</template>
<van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无书籍信息" />
</div>
...
...
@@ -57,7 +62,7 @@ import { useGo } from '@/hooks/useGo';
import { killPages, store } from '@/hooks/useKeepAlive';
import { Cookies } from '@/utils/generatePackage.js'
import { DonateBar } from '@/utils/generateModules.js'
import { computed, ref } from 'vue'
import { computed, ref
, watch
} from 'vue'
import { USER_ROLE, USER_TYPE } from '@/constant'
const go = useGo();
...
...
@@ -81,6 +86,27 @@ const userType = Cookies.get('userType')
const donateType = computed(() => {
return userType === 'client' ? USER_TYPE.KINDERGARTEN : USER_TYPE.VISIT;
})
/********************* 搜索功能栏 **********************/
const search_value = ref('')
const onSearch = () => { // 前端过滤搜索结果
kgInfo.value.book_list.forEach(item => {
if (item.name.indexOf(search_value.value) === -1) {
item.show = false;
}
});
}
watch(
search_value,
(v) => {
if (!v) {
kgInfo.value.book_list.forEach(item => {
item.show = true;
});
}
}
)
/**************************************************/
</script>
<style lang="less" scoped>
...
...
Please
register
or
login
to post a comment