<template>
	<view>
		<view class="tab">
			<u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
		</view>
		<view class="goodsList">
			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<view class="title">{{item.shopName}}</view>
				<view class="con">
					<view class="productName omit">{{ item.goodsNames }}</view>
					<view class="desc omit">
						<text>{{ item.sumGrossWt }} kg</text>
						<text>{{ item.fieldName }}</text>
					</view>
					<view class="price">¥ {{ item.sumAmt }}</view>
				</view>
				<view class="clear"></view>
				<view class="op">
					<view class="date">{{ item.declTime }}</view>

				</view>
			</view>
			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tab: [
				],
				param: {
					pageNo: 1,
					pageSize: 10
				},
				list: [],
				loadMore: true,
				show: false,
				value: 0
			};
		},
		onLoad() {
			
			this.getData();
			uni.$on("refreshPage", res => {
				this.refresh();
			})
		},
		methods: {
			getData() {
				this.http.request({
					url: '/level-one-server/app/HtTradeSettlement/getList',
					loading: 'false',
					data: this.param,
					success: res => {
						this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
						if (res.data.data) {
							this.list.push(...res.data.data);
						}
						this.list.map(item => {
							if (item.callCarStatus == 1) {
								item.enterpriseConfirm = 3
							} else if (item.callCarStatus == 2) {
								item.enterpriseConfirm = 4
							}
						})
					}
				});
			},
			// 商家确认
			confirm(id, goodsId, status, content) {
				//enterprise_confirm：'商铺确认情况[0=待确认,1=已确认,2=拒绝]'
				uni.showModal({
					title: '提示',
					content: content,
					success: res => {
						if (res.confirm) {
							this.http.request({
								url: '/level-one-server/app/TbOrder/updateEnterpriseConfirm',
								data: {
									id: id,
									goodsId: goodsId,
									enterpriseConfirm: status
								},
								method: 'POST',
								success: resp => {
									uni.showToast({
										title: '操作成功'
									});
									this.refresh();
								}
							});
						}
					}
				});
			},
			//点击tab切换
			click(e) {
				this.param.enterpriseConfirm = e.enterpriseConfirm;
				this.param.isOrders = e.isOrders;
				this.refresh();
			},
			detail(item) {
				uni.navigateTo({
					url: '/pages/market/one/enterprise/detail?id=' + item.id
				});
			},
			//刷新数据
			refresh() {
				this.loadMore = true;
				this.param.pageNo = 1;
				this.list = [];
				this.getData();
			},
			// 弹窗显示司机信息
			showPop(item) {
				// this.show = !this.show
				uni.navigateTo({
					url: '/pages/market/one/merchant/order/vehice?item=' + JSON.stringify(item)
				})
			},
			close() {
				this.show = false
				this.refresh()
			},
		},
		//下拉刷新
		onPullDownRefresh() {
			setTimeout(() => {
				this.refresh();
				uni.stopPullDownRefresh();
			}, 1000);
		},
		//上拉加载
		onReachBottom() {
			if (this.loadMore) {
				this.param.pageNo++;
				this.getData();
			}
		}
	};
</script>

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