Files
hht-ximenzi-uni/components/SearchBox.vue

73 lines
1.5 KiB
Vue
Raw Normal View History

2024-08-19 15:45:30 +08:00
<template>
<view class="search_wraper">
<input
type="text"
class="filter_input pdr120"
2024-09-03 14:55:40 +08:00
confirm-type="go"
2024-08-19 15:45:30 +08:00
:value="value"
:focus="focusState"
2024-09-03 14:55:40 +08:00
@focus="handleFocus"
@blur="handleBlur"
@confirm="handleSend">
2024-08-19 15:45:30 +08:00
<view class="zd-row buttons_wraper">
2024-09-03 14:55:40 +08:00
<uni-icons v-show="value !== '' && value !== null && value !== undefined" class="pdr10" type="clear" size="24" color="#666" @tap="toDel"></uni-icons>
<uni-icons type="scan" size="22" :color="focusState ? '#ff6a00' : '#4e6ef2'" @tap="focusState=true"></uni-icons>
2024-08-19 15:45:30 +08:00
</view>
</view>
</template>
<script>
import permision from "@/utils/permission.js"
export default {
data() {
return {
focusState: false
};
},
model: {
prop: 'value',
event: 'input'
},
props: {
2024-09-03 14:55:40 +08:00
value: String
2024-08-19 15:45:30 +08:00
},
methods: {
2024-09-03 14:55:40 +08:00
handleFocus () {
this.focusState = true
2024-08-19 15:45:30 +08:00
},
2024-09-03 14:55:40 +08:00
handleBlur (e) {
this.$emit('input', e.target.value)
// if (e.target.value.length) {
// this.$emit('handleChange', e.target.value)
// }
this.focusState = false
2024-08-19 15:45:30 +08:00
},
toDel () {
this.$emit('input', '')
},
2024-09-03 14:55:40 +08:00
handleSend (e) {
this.$emit('input', e.target.value)
if (e.target.value.length) {
this.$emit('handleChange', e.target.value)
2024-08-19 15:45:30 +08:00
}
}
}
}
</script>
<style lang="stylus">
@import '../common/style/mixin.styl';
.search_wraper
position relative
_wh(100%, 80rpx)
.pdr120
padding-right: 120rpx;
.buttons_wraper
position absolute
top 0
right 10rpx
_wh(auto, 80rpx)
.pdr10
padding-right 10rpx
</style>