feat: 搜索页面

This commit is contained in:
裴浩宇 2024-02-01 14:48:56 +08:00
parent 1921dda860
commit d7e0abb288
2 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1706749916307" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6345" data-spm-anchor-id="a313x.search_index.0.i6.75a23a81BhBy2o" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M888 128H170.4c-39.6 0-71.9 32.2-72 71.7-0.3 2.7-0.4 5.5-0.4 8.2v607.6c0 2.8 0.1 5.5 0.4 8.3 0.2 39.5 32.4 71.7 72 71.7h4.6c1 0 2 0.1 3 0.1h29c1 0 2 0 3-0.1h678c39.7 0 72-32.3 72-72V200c0-39.7-32.3-72-72-72z m-220 72v623.6H515.5V200H668zM192.5 447.1c-19.9 0-36-16.1-36-36s16.1-36 36-36 36 16.1 36 36-16.1 36-36 36z m0-118.3c-19.9 0-36-16.1-36-36s16.1-36 36-36 36 16.1 36 36-16.1 36-36 36zM286.6 200h157v623.6h-157c0.3-2.6 0.4-5.3 0.4-7.9V208c0-2.7-0.2-5.4-0.4-8zM888 823.6H740V200h148v623.6z" p-id="6346" data-spm-anchor-id="a313x.search_index.0.i0.75a23a81BhBy2o" class="selected" fill="#383838"></path><path d="M329.8 256.3h72v120h-72zM555.8 256.3h72v120h-72zM777.2 256.3h72v120h-72z" p-id="6347" data-spm-anchor-id="a313x.search_index.0.i3.75a23a81BhBy2o" class="" fill="#2189FF"></path></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,128 @@
<template>
<view class="seach">
<uni-search-bar :focus="true" cancelButton="none" v-model="searchValue" @input="search">
</uni-search-bar>
<uni-section :title="item.label" type="line" v-for="item in list" :key="item.label">
<no-data :loading="loading" :text="'暂无' + item.label + '记录'" v-if="item.options.length < 1" />
<uni-list>
<uni-list-item v-for="one in item.options" :key="one.id" clickable showArrow :title="one.title" />
</uni-list>
</uni-section>
</view>
</template>
<script>
import {
fullRetrieval
} from '@/api/px/index.js'
export default {
data() {
return {
//
searchValue: '',
//
loading: false,
//
list: [{
label: '待办事项',
options: []
},
{
label: '生活账本',
options: []
}, {
label: '日记',
options: []
},
{
label: '笔记',
options: []
}
]
};
},
methods: {
/**
* 翻译账单类型
* @param record
* @returns {string}
*/
billType(record) {
if (record.typeObject && record.typeObject.typeDifference === '0') {
return '收入'
}
if (record.typeObject && record.typeObject.typeDifference === '1') {
return '支出'
}
if (record.typeObject && record.typeObject.typeDifference === '2') {
return '转账'
}
if (record.typeObject && record.typeObject.typeDifference === '3') {
return '修改余额'
}
},
/**
* 搜索
*/
search() {
this.$debounce(() => {
if (!this.searchValue) {
this.list = [{
label: '待办事项',
options: []
},
{
label: '生活账本',
options: []
}, {
label: '日记',
options: []
},
{
label: '笔记',
options: []
}
];
return
}
this.loading = true;
fullRetrieval({
searchCode: this.searchValue
}).then(res => {
this.list = res.data;
this.list.map(item => {
if (item.label === '待办事项') {
item.options.map(option => {
option.title = option.content;
})
}
if (item.label === '生活账本') {
item.options.map(option => {
option.title =
`${option.typeObject && option.typeObject.typeName}${option.remark ? '-' + option.remark : ''}-${option.money}-${option.accountObject && option.accountObject.accountName}-${this.billType(option)}`;
})
}
if (item.label === '日记') {
item.options.map(option => {
option.title = option.content.replace(this.regex, "");
})
}
if (item.label === '笔记') {
item.options = item.options.filter(option => Boolean(option
.content))
}
return item
})
this.loading = false;
})
}, 1200)()
}
}
}
</script>
<style lang="scss">
.seach {
padding-bottom: 1rem;
}
</style>