<template>
	<view class="searchBg" :style="{background: `${bg}`}">
		<view class="flex">
			<view class="searchIcon">
				<image src="@/static/images/index/searchIcon.png" mode=""></image>
			</view>
			
			<view class="inputBox">
				<u-search :placeholder="placeholder" v-model="keyword" :color="'#fff'" :disabled="disable" placeholderColor="#fff" style="pointer-events: none;" :bgColor="'transparent'"  @change="$u.debounce(searchFn, 1500)" :showAction="false" @search="$u.debounce(searchFn, 500)" @clear="clearSearchFn"></u-search>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		// props: ['placeholder', 'disable', 'bg'],
		props: {
			placeholder: {
				type: String,
				default: ''
			},
			disable: {
				type: Boolean,
				default: false
			},
			bg: {
				type: String,
				default: '#ddd'
			}
		},
		data() {
			return {
				keyword: ''
			}
		},
		methods: {
			searchFn() {
				this.$emit('searchFn', this.keyword)
			},
			clearSearchFn() {
				this.keyword = ''
			}
		}
	}
</script>

<style lang="scss" scoped>
	.searchBg {
		width: 100%;
		height: 72rpx;
		border-radius: 16rpx;
		line-height: 72rpx;
		
		.flex {
			height: 100%;
			padding: 0 28rpx;
	
			.searchIcon {
				width: 40rpx;
				height: 40rpx;
			}
	
			.inputBox {
				flex: 1;
				color: #fff;
				font-size: 28rpx;
			}
		}
	}
	.textColor {
		font-size: 26rpx;
		color: #fff;
		line-height: 72rpx;
		padding-left: 14rpx;
	}
</style>

