searchbar.vue 2.16 KB
Newer Older
王建威's avatar
王建威 committed
1 2 3 4
<template>
	<view class="flex_searchbar" :style="{'background':wrapper_props.bg_color}">
		<i class="logo" :style="{'background-image': 'url('+wrapper_props.logo_url+')'}"></i>
		<view class="search_view flex">
王建威's avatar
王建威 committed
5
			<icon type="search" class="search_icon" size="16" @click="search"></icon>
王建威's avatar
王建威 committed
6
			<input type="text" @click="search" class="search_input" v-model="keyword" placeholder="请输入商品名称" :value="wrapper_props.placeholder">
王建威's avatar
王建威 committed
7 8
		</view>
		<text class="login_btn" @click="jumpPhpPage('app=member&act=login')" v-if="!isLogin">登录</text>
王建威's avatar
王建威 committed
9
		<i v-else class="eosfont person_icon" @click="jumpPhpPage('app=member')">&#xe636;</i>
王建威's avatar
王建威 committed
10 11 12 13 14 15 16 17 18 19 20
	</view>
</template>

<script>
	import { php } from '../../../common/host.js';
	import uniIcons from "@/components/uni-icons/uni-icons.vue";
	export default {
		props: {
			wrapper_props: {
				type: Object,
				required: true
王建威's avatar
王建威 committed
21 22 23 24
			},
			isLogin: {
				type: Number,
				default: 0
王建威's avatar
王建威 committed
25 26 27 28
			}
		},
		data() {
			return {
王建威's avatar
王建威 committed
29
				keyword: this.wrapper_props.placeholder
王建威's avatar
王建威 committed
30 31 32 33 34 35
			}
		},
		methods: {
			jumpPhpPage(url) {
				let link = url ? `${php}${url}` : php;
				window.location.href =  link;
王建威's avatar
王建威 committed
36 37 38
			},
			search() {
				uni.navigateTo({
王建威's avatar
王建威 committed
39
				    url: `/pages/searchhistory/searchhistory?keyword=${this.keyword}`
王建威's avatar
王建威 committed
40
				});
王建威's avatar
王建威 committed
41 42 43 44 45 46 47 48 49
			}
		},
		components: {
			uniIcons
		}
	}
</script>

<style lang="less" scoped>
王建威's avatar
王建威 committed
50 51 52 53
	.person_icon {
		font-size: 48rpx;
		line-height: 60rpx;
	}
王建威's avatar
王建威 committed
54 55 56
	.flex_searchbar {
		display: flex;
		justify-content: space-between;
王建威's avatar
王建威 committed
57 58 59 60 61 62 63
		padding: 20rpx 24rpx;
		position: fixed;
		width: 100%;
		top: 0;
		left: 0;
		box-sizing: border-box;
		z-index: 100;
王建威's avatar
王建威 committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
		.flex {
			display: flex;
		}
		.logo {
			width: 192rpx;
			height: 60rpx;
			background-size: 100% 100%;
			background-repeat: no-repeat;
		}
		.search_view {
			width: 380rpx;
			height: 60rpx;
			background: #F5F5F5;
			border-radius: 30rpx;
		}
		.search_icon {
王建威's avatar
王建威 committed
80 81 82
			display: flex;
			justify-content: center;
			align-items: center;
王建威's avatar
王建威 committed
83 84 85 86 87
			width: 56rpx;
			height: 56rpx;
		}
		.search_input {
			height: 60rpx;
王建威's avatar
王建威 committed
88
			font-size: 28rpx;
王建威's avatar
王建威 committed
89 90 91 92 93 94 95 96 97 98 99 100 101
		}
		.login_btn {
			width: 92rpx;
			height: 60rpx;
			line-height: 60rpx;
			background: #FFCD00;
			border-radius: 16rpx;
			color: #212121;
			font-size: 28rpx;
			text-align: center;
		}
	}
</style>