<template>
|
<view class="p15 bg-white">
|
<view class="search-container m-t-12 flex">
|
<view class="flex1 input">
|
<u-input placeholder="请输入花名" v-model="search_flow">
|
<template slot="suffix">
|
<uni-icons color="#20613D" type="search" size="24" @click="buttonSearchFlow"></uni-icons>
|
</template>
|
</u-input>
|
</view>
|
</view>
|
<view class="m-t-12">
|
<view class="title">搜索历史</view>
|
<view class="m-t-12 flex flex-wrap-normal history-item-list">
|
<view class="history-item" v-for="item of history" :key="item" @click="searchBy(item)">
|
{{item}}
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
search_flow: '',
|
history: [],
|
}
|
},
|
onShow() {
|
var k = this.$storage.getItem("cache_home_search")
|
this.history = k && JSON.parse(k) || []
|
},
|
onHide() {
|
this.$storage.setItem("cache_home_search", JSON.stringify(this.history))
|
},
|
methods: {
|
buttonSearchFlow() {
|
if (this.history.indexOf(name) >= 0) {
|
this.history.splice(this.history.indexOf(name), 1)
|
}
|
this.history.unshift(name)
|
|
console.log('buttonSearchFlow')
|
uni.navigateTo({
|
url: '/sub_pages/customer/trade/list?name=' + this.search_flow
|
})
|
},
|
searchBy(name) {
|
if (this.history.indexOf(name) >= 0) {
|
this.history.splice(this.history.indexOf(name), 1)
|
}
|
this.history.unshift(name)
|
|
uni.navigateTo({
|
url: '/sub_pages/customer/trade/list?name=' + name
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.history-item-list {
|
.history-item {
|
margin-right: 20rpx;
|
min-width: 100rpx;
|
padding: 10rpx 20rpx;
|
margin-bottom: 20rpx;
|
text-align: center;
|
height: 30rpx;
|
line-height: 30rpx;
|
font-size: 28rpx;
|
}
|
}
|
</style>
|