searchBox.vue
2.1 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
<!-- 搜索框 -->
<view class="boxs">
<view class="searchInput flexJ" @click="jump">
<view class="left flexA">
<image src="/static/indexIc/indexSearchIc.png" mode=""></image>
<input :disabled="disabled" confirm-type="search" v-model="inputText" @confirm="doSearchs" @input="input" type="text" placeholder="请输入" placeholder-class="ples">
</view>
<view class="right flexA" @click="doSearchs(0)">
<view class="line"></view>
<text>搜索</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref,onMounted,defineEmits } from 'vue'
const props = defineProps({
disabled:{
type:Boolean,
default:true
},
keyWord:{
type:String,
default:''
}
})
let inputText = ref('') //输入框文字
onMounted(()=> {
inputText.value = props.keyWord
// console.log('首艘',props.disabled)
})
const emit = defineEmits(['doSearchs','input'])
// 回车事件
const doSearchs = (e)=> {
if(e==0) {
if(inputText.value.trim() == '') return
emit('doSearchs',inputText.value)
} else {
emit('doSearchs',e.detail.value)
}
}
// 输入框为空
const input = (e)=> {
if(e.detail.value == '') {
emit('input',e.detail.value)
}
}
// // 点击搜索按钮
// const search = ()=> {
// console.log('搜索为你做')
// }
const jump = ()=> {
props.disabled ? uni.navigateTo({url:'/pages/index/search'}) : ''
}
</script>
<style lang="scss">
.boxs {
width: 100%;
height: 96rpx;
padding: 18rpx 32rpx;
box-sizing: border-box;
.searchInput {
width: 100%;
height: 100%;
background-color: #FFFFFF;
border-radius: 38rpx;
padding: 14rpx 24rpx;
box-sizing: border-box;
.left {
image {
margin-right: 8rpx;
width: 32rpx;
height: 32rpx;
}
input {
width: 500rpx !important;
}
.ples {
color: #00000042;
font-size: 26rpx;
}
}
.right {
.line {
height: 30rpx;
width: 1rpx;
background-color: #FC6A3D;
margin-right: 14rpx;
}
text {
font-size: 28rpx;
font-weight: 700;
color: #FB753C;
}
}
}
}
</style>