<template>
	<view>
		<mcalendar v-model="show" @confirm="confirm" @clear="clear" @today="today"></mcalendar>
		<view class="goodsList">
			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<view class="title">
				<view style="font-size: 14px;">{{ item.enterpriseName }}</view>
					<view class="state" v-if="item.peopleConfirmStatus == 0">
						<text class="icon">&#xe830;</text>
						<text>未确认</text>
					</view>
					<view class="state" v-if="item.peopleConfirmStatus == 1">
						<text class="icon" style="color: #13ce66">&#xe830;</text>
						<text>已确认</text>
					</view>
				</view>

				<!-- <image src="../../../../static/news.jpg" mode="aspectFill" class="pic"></image> -->
				<view class="con">
					<view class="productName omit">{{ item.goodsNames }}</view>
					<view class="desc omit">
						<text>重量 {{ item.totalWeight }}kg</text>
						<text>{{ item.tradeAreaName }}</text>
					</view>
					<view class="price">¥ {{ item.totalPrice }}</view>
				</view>
				<view class="clear"></view>
				<view class="op">
					<view class="date">确认时间 {{ item.peopleConfirmTime }}</view>
					<template v-if="item.peopleConfirmStatus == 0">
						<view class="an" style="color: #f44336" @click.stop="confirmOrder(item.id)">边民确认</view>
					</template>
				</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 {
			show: false,
			param: {
				pageNo: 1,
				pageSize: 10,
				//peopleConfirmStatus: 0, //边民确认状态
				// cooperEntrustStatus: 0, //互助委托申报确认状态
				// applyConfirmStatus: 0, //进口申报确认状态
				finishStatus: 0, //订单完成状态
				resaleStatus: 0, //订单转售状态
				confirmType: 'people_confirm_time'
			},
			list: [],
			loadMore: true
		};
	},
	onLoad() {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/level-one-server/app/TbOrder/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);
					}
				}
			});
		},
		//边民确认订单
		confirmOrder(id) {
			this.http.request({
				url: '/level-one-server/app/TbOrder/confirmOrder',
				data: { orderId: id },
				success: resp => {
					uni.showToast({ title: '订单确认成功' });
					this.refresh();
				}
			});
		},
		confirm(e) {
			this.param.dateBegin = e[0];
			let end = e.length - 1;
			this.param.dateEnd = e[end];
			this.show = false;
			this.refresh();
		},
		today(e) {
			this.param.dateBegin = e[0];
			this.param.dateEnd = e[1];
			this.refresh();
		},
		clear() {
			this.param.dateBegin = '';
			this.param.dateEnd = '';
			this.refresh();
		},
		detail(item) {
			uni.navigateTo({ url: '/pages/market/one/leader/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();
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: $pg;
}
.state {
	margin-right: -70px;
}
</style>
