<template>
	<view class="search">
		<view class="header">
			<view class="head_ss">
				<image src="/static/shop/search.png"></image>
				<input type="text" confirm-type="search" @confirm="tosearch_result(title)" placeholder="在此搜索商品"
					v-model="title" />
			</view>
		</view>

		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
			<view class="goods_ls_zc">
				<view class="goods_ls_bx_it" v-for="(a,b) in tui_data" :key="b"
					@click="gotoPage('/pages/shop/detail?goods_id='+a.id)">
					<image :src="a.image"></image>
					<view class="hang2">{{a.title}}</view>
					<view class="zuanshi"> ￥{{a.price}} </view>
				</view>
			</view>

		</mescroll-body>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				xz_index: -1,
				head_index: 1,
				top_show: true,
				bottom_show: false,
				tui_data: [],
				downOption: {
					auto: false
				},
				cate_id2: '',
				title: '',
				sort: 1

			}
		},
		onLoad(e) {
			uni.setNavigationBarTitle({
				title: '商品列表'
			})
			this.cate_id2 = e.id ? e.id : ''
			this.title = e.title ? e.title : ''
		},
		methods: {

			tosearch_result(e) {
				let that = this;
				// if (e != '') {
				this.loadData(1);
				// } else {
				// 	uni.showToast({
				// 		title: '请输入商品名称',
				// 		icon: 'none',
				// 		duration: 1500
				// 	})
				// }

			},
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				this.loadData(page.num);
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: 'shop_seckill_product',
					Loading: true,
					data: {
						page: pageNo,
						title: that.title,
						cate_id2: that.cate_id2,
					},
					success(res) {
						that.mescroll.endByPage(res.data.data.length, res.data.last_page);
						if (pageNo == 1) {
							that.tui_data = res.data.data;
						} else {
							that.tui_data = that.tui_data.concat(res.data.data);
						}
					}
				})
			},


		}
	}
</script>

<style>
	.goods_ls_zc {
		padding: 30rpx;
		position: relative;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		color: #FFFFFF;
	}

	.goods_ls_bx_it {
		width: 330rpx;
		border-radius: 10rpx;
		overflow: hidden;
		margin-bottom: 26rpx;
	}

	.goods_ls_bx_it>image {
		width: 330rpx;
		height: 330rpx;
		border-radius: 16rpx;
		border: 2px solid;
		border-image: linear-gradient(108deg, #376232, #574C37, #336365, #692F6B, #718958) 2 2;
		box-sizing: border-box;
	}

	.goods_ls_bx_it>view:nth-of-type(1) {
		font-size: 28rpx;
		padding: 0 22rpx;
		padding-top: 10rpx;
	}

	.zuanshi {
		font-size: 32rpx;
		padding: 0 22rpx;
		margin: 14rpx 0 8rpx 0;
		color: #0FEFFF;
	}

	.search {
		width: 100vw;
		min-height: 100vh;
		background: #000000;
		padding-top: 100rpx;
		box-sizing: border-box;
	}

	.header {
		height: 100rpx;
		padding: 0 24rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		background: #000000;
		position: fixed;
		/* #ifdef APP */
		top: 0;
		/* #endif */
		/* #ifndef APP */
		top: 88rpx;
		/* #endif */
		z-index: 15;
	}

	.head_ss {
		width: 690rpx;
		height: 68rpx;
		background: #161616;
		border-radius: 34rpx;
		display: flex;
		align-items: center;
		margin: 20rpx 0;
		box-sizing: border-box;
	}

	.head_ss>image {
		width: 40rpx;
		height: 40rpx;
		margin: 0 20rpx;
	}

	.head_ss input {
		width: 80%;
		font-size: 28rpx;
		color: #FFFFFF;
	}
</style>
