<template>
	<view>
		
		<u-list class="list" width="100%" @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in orders" :key="index">
				<view class="item-box">
					<view class="goods-item">
						<u-row>
							<u-col span="5" @click="toDetails(item.id)">
								<u--image :showLoading="true" src="" width="270rpx" height="220rpx"></u--image>
							</u-col>
							<u-col span="7">
								<view class="t1 txt" @click="toDetails(item.id)">
									<text>{{item.goodsName}}</text>
								</view>
								<view class="txt">
									<text v-if="item.grossWeight">{{item.grossWeight}}吨</text>
								</view>
								<view class="txt" v-if="item.tradeAreaName">
									<u-tag style="width: 250rpx" :text="item.tradeAreaName" plain size="mini"></u-tag>
								</view>
								<view class="t4">
									<view class="price">￥{{item.price}}</view>
									<!-- 接受 商铺确认情况[0=待确认,1=已确认,2=拒绝]-->
									<view class="edit" @click="orderConfirm(item.id,1)">
										<u-icon color="#fff" name="edit-pen-fill" size="30"></u-icon>
									</view>
									<!-- 拒绝 -->
									<view class="delete" @click="orderConfirm(item.id,2)">
										<u-icon color="#fff" name="edit-pen-fill" size="30"></u-icon>
									</view>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</u-list-item>
		</u-list>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadmoreStatus: 'loadmore',
				form: {},
				orders: [],
			}
		},
		onLoad() {
			this.getOrderTransitList()
		},
		methods: {
			// 订单列表
			getOrderTransitList() {
				this.form = {
					isOrders: 1,//是否已被下单[0=未被下单,1=已被下单]
					enterpriseConfirm: 0,//商铺确认情况[0=待确认,1=已确认,2=拒绝]
					goodsStatus: 1,//商品状态(0=下架,1=在售)
				}
				this.http.request({
					url: '/level-one-server/app/TbGoodsTransit/getTransitList',
					data: this.form,
					method: 'POST',
					success: resp => {
						console.log('resp',resp)
						this.orders = resp.data.data;
						this.orders.forEach((item, index) => {
							if (index === this.orders.length - 1) {
								this.loadmoreStatus = 'nomore'
							} else {
								this.loadmoreStatus = 'loadmore'
							}
						})
					}
				});
			},
			// 商家确认
			orderConfirm(id,status) {
				this.form = {
					id: id,
					//isOrders: 0,//是否已被下单[0=未被下单,1=已被下单]
					enterpriseConfirm: status,//商铺确认情况[0=待确认,1=已确认,2=拒绝]
					//goodsStatus: 1,//商品状态(0=下架,1=在售)
				}
				this.http.request({
					url: '/level-one-server/app/TbGoodsTransit/update',
					data: this.form,
					method: 'POST',
					success: resp => {
						console.log('resp',resp)
						uni.showToast({ title: '操作成功' });
					}
				});
			},
			scrolltolower() {
				this.getOrderTransitList()
			}
		}
	}
</script>

<style lang="scss">
	.list {
		height: auto;
		border-radius: 10rpx;
		margin: 15rpx;
	}

	.goods-item {
		margin-bottom: 8rpx;
	}

	.item-box {
		height: 230rpx;
		width: 90%;
		padding: 20rpx;
		background-color: #fff;
		border: 1rpx #FFF solid;
		margin: 10rpx 0rpx;
		border-radius: 10rpx;
	}

	.txt {
		/* height: 50rpx; */
		margin-bottom: 20rpx;
	}

	.t1 {
		font-size: 32rpx;
		font-weight: bold;
		word-wrap: break-word;
		position: relative;
		top: 1rpx;
		right: 5rpx;
	}

	.t4 {
		display: flex;
		position: relative;
		bottom: 1rpx;
		right: 5rpx;
	}
	
	.price {
		color: #ef732a;
		width: 400rpx;
		font-weight: bold;
	}

	.edit {
		background-color: #0081ff;
		width: 60rpx;
		height: 60rpx;
		border-radius: 30rpx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.delete {
		background-color: indianred;
		width: 60rpx;
		height: 60rpx;
		border-radius: 30rpx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
