search.vue
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
<view>
<view class="searchWrap">
<view class="searchLeft">
<image src="../../../static/image/icon_search.png" mode=""></image>
<input type="text" v-model="keyword" placeholder="请输入关键字" @confirm="search"/>
<image @click="clearInput" src="../../../static/image/icon_clear.png" mode=""></image>
</view>
<view class="searchRight" @click="close">
取消
</view>
</view>
</view>
</template>
<script>
import {mapState} from 'vuex'
export default {
data() {
return {
keyword:this.$store.state.keyword
}
},
comments:{
...mapState(["keyword"])
},
onBackPress() {
this.$store.commit('defaultKeyword')
uni.redirectTo({
url:'check'
})
},
methods: {
close(){
this.$store.commit('defaultKeyword')
uni.redirectTo({
url:'check'
})
},
clearInput(){
this.keyword = ''
},
search(){
if(this.keyword == ''){
uni.showToast({
title:'请输入关键字',
icon:'none'
})
return
}
this.$store.commit('setKeyword',{keyword:this.keyword})
uni.navigateTo({
url:'check'
})
}
}
}
</script>
<style>
.searchWrap{height: 72rpx;padding: 16rpx 32rpx;display: flex;}
.searchWrap .searchLeft{flex: 1;background: #f2f3f5;border-radius: 68rpx;padding: 0 16rpx 0 32rpx;display: flex;align-items: center;}
.searchLeft image{width: 32rpx;height: 32rpx;}
.searchLeft input{flex: 1;font-size: 28rpx;padding:0 8rpx;}
.searchWrap .searchRight{width: 100rpx;display: flex;justify-content: flex-end;color: #646566;font-size: 34rpx;line-height: 72rpx;}
</style>