shopping-search.vue 1.9 KB
Newer Older
宋雄's avatar
宋雄 committed
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
<template>
	<view class="condition-box">
		<view class="search-box">
			<image :src="icon" class="icon"></image>

			<input class="uni-input" :value="searchValue" confirm-type="search" @confirm="onSearch" @input="onInput"
				:placeholder="placeholder" @keyup.enter.native="onSearch" placeholder-style="color:#B9B9B9" />
		</view>
		<view class="screen-box" @click="onScreen">
			<image class="image" mode="aspectFill" :src="web('shaixuan.png')"></image>
		</view>
	</view>
</template>

<script>
	/**
	 * 自营商城模块
	 * @description 标题栏
	 * @property {String} placeholder  搜索框placeholder
	 */
	import {
		web
	} from '@/utils/util.js'
	export default {
		props: {
			placeholder: {
				type: String,
				default: '请输入'
			}
		},
		data() {
			return {
				searchValue: '',
				icon: web('icon_search.png')
			}
		},
		watch: {

		},
		methods: {
			web(name) {
				return web(name)
			},
			onInput({
				detail
			}) {
				this.searchValue = detail.value
			},
			onSearch() {
				this.$emit('search', this.searchValue)
			},
			onScreen() {
				this.$emit('screen')
			}
		}
	}
</script>
<style lang="scss">
	.condition-box {
		display: flex;
		align-items: center;

		.search-box {
			flex: auto;
			position: relative;

			.uni-input {
				font-size: 14px;
				color: #333;
				height: 88rpx;
				line-height: 66rpx;

				border-radius: 12rpx;
				padding-left: 42px;
				padding-right: 10px;
				background: #F3F3F3;
			}

			.icon {
				position: absolute;
				left: 10px;
				top: 10px;
				width: 48rpx;
				height: 48rpx;
				z-index: 1;
			}
		}

		.screen-box {
			flex: none;
			height: 100%;
			display: flex;
			align-items: center;
			margin-left: 30rpx;

			.text {
				font-size: 28rpx;
				color: #99A0AF;
			}

			.image {
				width: 48rpx;
				height: 48rpx;
				margin-left: 5px;
			}
		}
	}
</style>