Commit 46a35dca by amateur

修改搜索历史记录

1 parent 7f292850
<template>
<div class="history">
<div class="history_title" v-if="list.length">
<div class="history_title" v-if="historys.length">
<span>搜索历史</span>
<img :src="require('@/assets/icon/trash.png')" @click="handleClear">
</div>
<div class="historyList" v-if="list.length">
<div class="historyList" v-if="historys.length">
<ul>
<li v-for="(item,index) in list" :key="index" @jump="jumItem(item)">{{item}}</li>
<li v-for="(item,index) in historys" :key="index" @jump="jumItem(item)">{{item}}</li>
</ul>
</div>
<div class="noData" v-else>
......@@ -15,19 +15,25 @@
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'SearchHistory',
props: {
list: {
type: Array,
default: () => []
stateKey: String,
},
computed: {
...mapState('search', [this.stateKey]),
historys () {
return this[this.stateKey] || []
}
},
methods: {
jumItem(val) {
jumItem (val) {
this.$emit('jumpPage', val)
},
handleClear() {
handleClear () {
this.$store.dispatch('search/ACleanHistory', this.stateKey)
this.$emit('clear')
}
}
......
export default {
namespaced: true,
state: {
Home: []
},
mutations: {
MSetHomeSearch (state, datas) {
state.Home = datas
},
MCleanHistory (state, stateKey) {
state[stateKey] = []
}
},
actions: {
ACleanHistory ({ commit }, stateKey) {
commit('MCleanHistory', stateKey)
}
},
modules: {
}
}
......@@ -4,20 +4,14 @@
<SearchInput class="search-input" v-model="keyword" :placeholder="$t('home.searchPlaceholder')" @search="handleSearch" />
</nafm-header>
<main>
<div class="search-history-title">
<!-- <div class="search-history-title">
<span>搜索历史</span>
<div class="clear">
<img src="" alt="">
<img src="@/assets/icon/trash.png" alt="">
</div>
</div>
<div class="search-history-values">
<span>ksdj离开</span>
<span>ksdj离开</span>
<span>ksdj离开水电费会计师</span>
<span>ksdj离开水电费会计师</span>
<span>水电费会计师</span>
<span>电费会计师</span>
</div>
</div> -->
</main>
</div>
</template>
......@@ -63,7 +57,10 @@ export default {
.clear {
width: 25px;
height: 25px;
background: white;
img {
width: 100%;
height: 100%;
}
}
}
.search-history-values {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!