<template>
	<view>
		<view class="tab">
			<u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
		</view>
		<view class="goodsManageList">
			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<view class="top">
					<view class="title omit">八角茴香(未磨) (可食用)八角茴香(未磨) (可食用)八角茴香(未磨) (可食用)</view>
					<view class="icon">&#xe852;</view>
					<view class="clear"></view>
				</view>
				<view class="con">
					<view class="flex fs">
						<view class="f left" style="flex: 0.5">
							<view class="tag">净重：50吨</view>
						</view>
						<view class="f left">
							<view class="tag">2023-08-03 22:37:02</view>
						</view>
					</view>
				</view>
				<view class="op">
					<view class="flex">
						<view class="f rline">
							<text class="icon" style="color: #ff660d">&#xe668;</text>
							<text>编辑</text>
						</view>
						<view class="f">
							<text class="icon" style="color: #0081ff">&#xe743;</text>
							<text>发布</text>
						</view>
					</view>
				</view>
				<view class="clear"></view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			tab: [
				{ name: '全部', goodsStatus: '' },
				{ name: '待发布', goodsStatus: 1 },
				{ name: '发布中', goodsStatus: 0 },
				{ name: '已接单', goodsStatus: 0 },
				{ name: '已确认', goodsStatus: 0 },
				{ name: '已完成', goodsStatus: 0 }
			],
			list: [{}, {}, {}, {}, {}],
			param: { pageNo: 1, pageSize: 10 },
			loadMore: true
		};
	},
	onLoad(e) {
		//this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/level-one-server/app/TbGoodsTransit/getTransitList',
				data: this.param,
				loading: 'false',
				success: res => {
					this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
					this.list.push(...res.data.data);
				}
			});
		},
		//点击tab切换
		click(e) {
			this.param.goodsStatus = e.goodsStatus;
			this.refresh();
		},
		detail(item) {
			uni.navigateTo({ url: '/pages/market/two/purchaser/buy/detail?id=' + item.id });
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNo = 1;
			this.list = [];
			this.getData();
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.refresh();
			uni.stopPullDownRefresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNo++;
			this.getData();
		}
	},
	onNavigationBarButtonTap() {
		uni.navigateTo({ url: '/pages/market/two/purchaser/buy/add' });
	}
};
</script>

<style lang="scss">
page {
	background-color: $pg;
}
</style>
