hls_crm/pagesA/crm/search/search.vue

191 lines
4.1 KiB
Vue

<template>
<view>
<!-- 搜索框 -->
<view class="search">
<u-search
:autofocus="true"
show-action
placeholder="请输入搜索关键词"
@change="onSearch"
v-model="value"
:show-action="false"
></u-search>
</view>
<view class="searchbox">
<!-- 按指定类型搜索 -->
<view class="search_text">
按指定类型搜索
</view>
<!-- 搜索类型 -->
<view class="search_type">
<view class="search_item" @click="searchType(1)">
<image :src="BASE_IMG_URL+'kehu1.png'" mode="scaleToFill"></image>
<view class="item_content">客户</view>
</view>
<view class="search_item" @click="searchType(2)">
<image :src="BASE_IMG_URL+'xiansuo1.png'" mode="scaleToFill"></image>
<view class="item_content">线索</view>
</view>
<view class="search_item" @click="searchType(3)">
<image :src="BASE_IMG_URL+'dh.png'" mode="scaleToFill"></image>
<view class="item_content">联系人</view>
</view>
</view>
</view>
<!-- 搜索历史 -->
<view class="search_history">
<view class="history_head">
<view>搜索历史</view>
<view class="clear_title" @click="clearHistory">
<image :src="BASE_IMG_URL+'clus_del.png'" class="delimg" mode=""></image>
<view>清除</view>
</view>
</view>
<view class="history_body" v-for="(item,index) in searchHistory" :key="index" @click="historySearch(item)">
<view class="body_first">{{index+1}}</view>
<view class="body_second">{{item}}</view>
<view class="iconfont icon-search"></view>
</view>
<view style="height: 100rpx;"></view>
<u-empty v-if="searchHistory.length == 0" text="暂无更多" mode="list"></u-empty>
</view>
</view>
</template>
<script>
import { BASE_IMG_URL } from '@/util/api.js'
export default {
data() {
return {
BASE_IMG_URL:BASE_IMG_URL,
value: '',
searchHistory:[], //这里模拟搜索历史
}
},
onShow() {
if(uni.getStorageSync('searchword')){
this.searchHistory = uni.getStorageSync('searchword')
}
},
methods: {
changeValue(e) {
this.value = e
},
onSearch(val) {
this.value = val
let searlist = uni.getStorageSync('searchword')
if(searlist){
if(searlist.indexOf(this.value) != -1) {
let index = searlist.indexOf(this.value)
searlist.splice(index,1)
}
if(searlist.length >= 10) {
searlist.shift()
searlist.push(this.value)
}else{
searlist.push(this.value)
}
}else{
searlist = []
searlist.push(this.value)
}
uni.setStorageSync('searchword',searlist)
uni.navigateTo({
url:'/pagesA/crm/search/searchList?type=0&word='+this.value
})
},
//清除
clearHistory() {
this.searchHistory = []
uni.removeStorageSync('searchword')
},
onCancel(){
uni.navigateBack({
delta:1
})
},
searchType(type) {
uni.navigateTo({
url:'/pagesA/crm/search/searchList?type='+type+'&word='+this.value
})
},
historySearch(value){
this.value = value;
uni.navigateTo({
url:'/pagesA/crm/search/searchList?type=0&word='+this.value
})
}
}
}
</script>
<style lang="scss">
.searchbox{
background:#fff;
}
.search_text {
width: 100%;
padding: 30rpx 0;
text-align: center;
}
.search_type {
display: flex;
margin-bottom: 60rpx;
justify-content: space-between;
align-items: center;
padding:30rpx 50rpx;
.search_item {
text-align: center;
image {
width: 60rpx;
height: 60rpx;
// border-radius: 50%;
margin-bottom: 10rpx;
}
}
}
.search_history {
.history_head {
display: flex;
justify-content: space-between;
padding: 0 16rpx;
margin-bottom: 20rpx;
.clear_title {
display: flex;
.delimg{
width:39rpx;
height:39rpx;
margin-right:8rpx;
}
:last-child {
color: $uni-text-color;
}
}
}
}
.history_body {
display: flex;
margin: 0 24rpx;
background-color: #fff;
padding: 20rpx 0;
border-radius: 8rpx;
margin-bottom: 20rpx;
.body_first {
width: 25rpx;
margin-left: 20rpx;
}
.body_second {
flex: 1;
}
.icon-search {
margin-right: 20rpx;
}
}
</style>