<template>
	<view class="body">
		<view class="search">
			<p>
				<image style="width: 5vw; height: 5vw; margin-top: 1vw; " src="../../static/search.png"></image>
			</p>
			<p style="margin-left: 2vw;"> <input style="font-size: 0.75rem; width: 60vw; height: 10vw;" type="text"
				 v-model="productName"	name="" id="" placeholder="搜索你想要的商品" @blur="search"> </p>
		</view>
		<!-- 滑动搜索 -->
		<view class="slideSearch">
			<p :class="index==int? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(item,int)"  v-for="(item,int) in typeProduct" :key="int" >{{item.name}}</p>
	<!-- 		<p :class="index==1? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(1)">车载用品</p>
			<p :class="index==2? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(2)">美容清洗</p>
			<p :class="index==3? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(3)">运动户外</p>
			<p :class="index==4? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(4)">智能家电</p>
			<p :class="index==5? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(5)">科技数码</p>
			<p :class="index==6? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(6)">箱包服饰</p> -->
		</view>
		<!-- 搜索 -->
	<!-- 	<scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="refresherTriggered"
			@refresherrefresh="refresherrefresh" @scrolltolower="scrolltolowerEvent(event)"
			lower-threshold="100">
			</scroll-view> -->
			<view class="content">
				<view class="model" v-for="(item,index) in productList " :key="index" @click="ShopDetial(item.id)">
					<p> <image style="width: 45vw; height: 45vw;" :src="item.cover_url.url"></image> </p>
					<p style="font-size: 1rem; font-weight: 550;">{{item.name}}</p>
					<p style="font-size: 0.75rem; margin-top: 2vw;"> <span style="font-size: 1rem; color: red;">￥{{item.price_f}}起</span> <!-- <span style="color: grey; text-decoration: line-through;">￥85</span> -->  </p>
					<!-- <p style="font-size: 0.65rem; margin-top: 1vw; margin-bottom: 2vw;">恒信豆最高可抵实付全额 <span style="color: red; margin-left: 1vw; ">5%</span> </p> -->
				</view>
			</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				index: 0,
				productList:[],
				productName:'',
				index:'',
				typeProduct:[],
				typeId:''
			}
		},
		onLoad() {
			
		},
		onTabItemTap(e){
			this.ProductList(this.productName,this.typeId)
			this.ProductType()
		},
		methods: {
			search(){
			this.ProductList(this.productName,this.typeId)
			},
			// 商品类别
			ProductType(){
				this.$api.getProductType(res=>{
					if(res.code==0){
						this.typeProduct=res.data
					}
				})
			},
			selectInfo(item,index) {
				this.index = index
				this.ProductList(this.productName,item.id)
			},
			ShopDetial(id){
				uni.navigateTo({
					url:'/pages/shopStore/detial?id='+id
				})
			},
			// 商品列表
			ProductList(name,id){
				this.$api.getProductList(name,id,res=>{
					if(res.code==0){
						this.productList=res.data
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		width: 100vw;
		height: 100vh;
		background-color: white;
		overflow: hidden;

		.search {
			box-sizing: border-box;
			padding: 0 4vw;
			width: 90vw;
			margin-left: 5vw;
			height: 12vw;
			border-radius: 7vw;
			background-color: #f8f8f8;
			display: flex;
			margin-top: 1vw;
			align-items: center;
		}

		.slideSearch {
			max-width: 100vw;
			height: 13vw;
			margin-top: 2vw;
			display: flex;
			white-space: nowrap;
			/*不允许折行*/
			overflow-x: auto;
			/*启动横向滚动条*/
			align-items: center;
		}
		.content{
			width: 100vw;
			height: 83vh;
			display: flex;
			flex-wrap: wrap; // 强制换行
			padding:0 2vw;
			box-sizing: border-box;
			overflow-y: auto;
			.model{
				width: 48vw;
				// height: 65vw;
				display: flex;
				flex-direction: column;
				// justify-content: center;
				background-color: white;
				box-sizing: border-box;
				padding: 0 2vw;
				margin-top: 2vw;
			}
		}

		.noxuanzhong {
			width: 20vw;
			height: 7vw;
			box-sizing: border-box;
			padding-left: 2vw;
			padding-right: 2vw;
			font-size: 0.8rem;
			line-height: 7vw;
			text-align: center;
		}

		.xuanzhong {
			width: 20vw;
			height: 7vw;
			box-sizing: border-box;
			padding-left: 2vw;
			padding-right: 2vw;
			font-size: 0.8rem;
			color: red;
			border-radius: 20px;
			border: 1px solid red;
			line-height: 7vw;
			text-align: center;
			margin-right: 4vw;
		}
	}
</style>