searchBox.vue
2.5 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
108
109
110
111
<template>
<!-- 搜索框 -->
<view class="boxs">
<view class="searchInput flexJ" @click="jump">
<u-search @search="doSearchs" @custom="doSearchs" :disabled="disabled" placeholder="请输入" v-model="inputText" bgColor="#fff" searchIconColor="#fda9a3" :actionStyle="actionStyle"></u-search>
<!-- <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('') //输入框文字
const actionStyle = ref({
fontSize: '28rpx',
fontWeight: 700,
color: '#fb753c'
})
onMounted(() => {
inputText.value = props.keyWord
// console.log('首艘',props.disabled)
})
const emit = defineEmits(['doSearchs', 'input'])
// 回车事件
const doSearchs = e => {
emit('doSearchs', inputText.value)
// 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%;
padding: 18rpx 24rpx;
box-sizing: border-box;
.searchInput {
width: 100%;
height: 100%;
background-color: #ffffff;
border-radius: 38rpx;
.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>