jiangping
2023-08-21 2837bdd57f72e386bbf9a725e7b3a13e5eb9e930
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
    <div class="search">
        <div class="search_input">
            <img src="@/assets/icon/ic_search@2x.png" alt="">
            <input v-model="text" @keyup.enter="searchInput" type="text" :placeholder="props.placeholder" />
        </div>
        <div class="search_operation" v-if="props.isShow">
<!--            <img src="@/assets/icon/3@2x.png" alt="">-->
            <div class="search_operation_w"></div>
            <img @click="openCate" src="@/assets/icon/@2x.png" alt="">
        </div>
        <van-popup v-model:show="open" round position="bottom" :style="{ height: '80%' }">
            <div class="content">
                <slot name="content"></slot>
            </div>
            <div class="zhanwei"></div>
            <div class="footer">
                <div class="footer_close" @click="closes">重置</div>
                <div class="footer_submit" @click="submit">确定</div>
            </div>
        </van-popup>
    </div>
</template>
 
<script setup lang="ts">
    import { ref, defineProps, defineEmits } from 'vue'
 
    const props = defineProps({
        isShow: {
            type: Boolean,
            required: false,
            default: false
        },
        placeholder: {
            type: String,
            required: false,
            default: '请输入'
        }
    })
 
    // 向父组件提交两个方法
    const emit = defineEmits(['searchInput', 'submit', 'reset'])
 
    const open = ref<Boolean>(false)
 
    const text = ref<string>('')
 
    // 搜索框搜索
    const searchInput = () => {
        emit('searchInput', text.value)
    }
 
    const openCate = () => {
        open.value = true
    }
 
    // 重置
    const closes = () => {
        open.value = false
        text.value = ''
        emit('reset', text.value)
    }
 
    // 搜索提交
    const submit = () => {
        open.value = false
        emit('submit', '')
    }
 
    // 向父组件暴漏数据
    defineExpose({
        text
    })
</script>
 
<style lang="scss" scoped>
.search {
    width: 100%;
    height: 68px;
    display: flex;
    align-items: center;
    .zhanwei {
        height: 180px;
        background: #ffffff;
    }
    .content {
        padding: 30px 30px 0 30px;
    }
    .footer {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-left: 40px;
        padding-right: 40px;
        padding-bottom: 64px;
        box-sizing: border-box;
        position: fixed;
        bottom: 0;
        left: 0;
        background: #ffffff;
        z-index: 99;
        .footer_close {
            flex: 1;
            padding: 28px 0;
            box-sizing: border-box;
            margin-right: 22px;
            font-size: 32px;
            font-weight: 500;
            color: #999999;
            background: #F7F7F7;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .footer_submit {
            flex: 1;
            padding: 28px 0;
            box-sizing: border-box;
            font-size: 32px;
            font-weight: 500;
            color: #ffffff;
            background: $nav-color;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
    .search_input {
        flex: 1;
        height: 100%;
        background: #F7F7F7;
        border-radius: 8px;
        display: flex;
        align-items: center;
        padding: 15px 30px;
        box-sizing: border-box;
        img {
            width: 28px;
            height: 28px;
            margin-right: 10px;
        }
        input {
            width: 100%;
            border: none;
            outline: none;
            background: #F7F7F7;
            font-size: 26px;
        }
        input::-webkit-input-placeholder { /* WebKit browsers */
            font-size: 26px;
            font-weight: 400;
            color: #B2B2B2;
        }
        input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            font-size: 26px;
            font-weight: 400;
            color: #B2B2B2;
        }
        input::-moz-placeholder { /* Mozilla Firefox 19+ */
            font-size: 26px;
            font-weight: 400;
            color: #B2B2B2;
        }
        input:-ms-input-placeholder { /* Internet Explorer 10+ */
            font-size: 26px;
            font-weight: 400;
            color: #B2B2B2;
        }
    }
    .search_operation {
        flex-shrink: 0;
        /*width: 150px;*/
        display: flex;
        justify-content: flex-end;
        align-items: center;
        /*margin-left: 30px;*/
        img {
            width: 44px;
            height: 44px;
        }
        .search_operation_w {
            width: 30px;
        }
    }
}
</style>