<template>
	<view class="order-list">
		<z-paging ref="paging" v-model="dataList" @query="queryList">
			<view class="page-box">
				<uv-list>
					<uv-list-item v-for="(item,index) in dataList" :key="item.id" border>
						<template #body>
							<view style="width: 100%;">
								<good-item :item="item"></good-item>
							</view>
						</template>
					</uv-list-item>
				</uv-list>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import {
		getGoodByQuery
	} from '@/request/api/shop.js'
	import goodItem from '@/components/common/goodItem.vue';
	export default {
		data() {
			return {
				idCategory: '',
				dataList: []
			};
		},
		components: {
			goodItem
		},
		onLoad(body) {
			this.idCategory = body.idCategory;
		},
		computed: {},
		methods: {
			async queryList(index, size) {
				let filterOption = {
					page: index,
					limit: size,
					idCategory: this.idCategory
				};
				uni.showLoading()
				let orderData = await getGoodByQuery(filterOption);
				if (orderData.state) {
					uni.hideLoading();
					this.$refs.paging.complete(orderData.data.records);
					return
				}
				this.$refs.paging.complete(false);
			}
		}
	};
</script>

<style lang="scss" scoped>
	.page-box {
		padding-top: 30rpx;
	}
</style>