<template>
	<view class="page">
		<!-- 导航栏 -->
		<navbar title="商品列表" leftClick @leftClick="$utils.navigateBack" bgColor="#E3441A" color="#fff" />

		<!-- 搜索栏 -->
		<view class="search">
			<uv-search placeholder="搜你喜欢的产品" bgColor="#fff" @search="getData" @custom="getData"
				v-model="queryParams.title"></uv-search>
		</view>

		<!-- 分类商品列表 -->
		<view class="category">
			<uv-vtabs :list="category" keyName="title" @change="change">
				<view class="list">
					<uv-vtabs-item>
						<productItem v-for="(item, index) in list" :key="index" :item="item"
							@click="$utils.navigateTo(`/pages_order/product/productDetail?id=${item.id}`)" />
					</uv-vtabs-item>
				</view>
			</uv-vtabs>
		</view>

		<!-- tabbar -->
		<tabber select="category" />
	</view>
</template>

<script>
	import productItem from '@/components/product/productItem.vue';
	import mixinsList from '@/mixins/list.js'
	import {
		mapState
	} from 'vuex'
	import tabber from '@/components/base/tabbar.vue'
	export default {
		mixins: [mixinsList],
		components: {
			productItem,
			tabber,
		},
		data() {
			return {
				mixinsListApi: 'getClassShopPageList',
			}
		},
		computed: {
			...mapState(['category'])
		},
		onLoad({
			search
		}) {
			if (search) {
				this.queryParams.title = search
			}
			this.$store.commit('getCategoryList')
			if (this.category.length > 0) {
				this.queryParams.classId = this.category[0].id
			}
		},
		methods: {
			change(e) {
				this.queryParams.classId = this.category[e].id
				this.getData()
			},
		}
	}
</script>

<style scoped lang="scss">
	.page {
		/deep/ .uv-vtabs {
			height: calc(100vh - 470rpx) !important;
		}

		/deep/ .uv-vtabs__bar {
			height: calc(100vh - 470rpx) !important;
		}

		/deep/ .uv-vtabs__content {
			height: calc(100vh - 470rpx) !important;
		}

		.search {
			position: relative;
			background: #FFFFFF;
			margin: 20rpx;
			border-radius: 41rpx;
			padding: 10rpx 20rpx;
			display: flex;
			align-items: center;

			/deep/ .uv-search__action {
				background-color: $uni-color;
				color: #FFFFFF;
				padding: 10rpx 20rpx;
				border-radius: 30rpx;
			}
		}

		&::v-deep .uv-vtabs__content {
			background: transparent !important;
		}
	}

	.category {
		font-size: 30rpx;
		color: #333;

		.list {
			width: 100%;
			padding: 0rpx 20rpx;
			box-sizing: border-box;
		}

	}
</style>