<template>
	<view class="page">
		<view v-if="list.length>0" class="item"
		@click="toDetail(item)"
		v-for="(item, index) in list" :key="index">
			<view class="top">
				<view class="service">
					<text>{{ item.specsName }}</text>
				</view>
				<view class="status">
					<text>库存：{{ item.num }}</text>
				</view>
			</view>

			<view class="zhuti">

				<view class="left">
					<image :src="item.pic" style="width: 100%;height: 100%;" 
					mode="aspectFill"/>
				</view>

				<view class="right">
					<view class="text-hidden-1">
						单价 ：{{ item.price }}
					</view>
					<view class="text-hidden-1">
						{{ $t('other.pickupAddress') }}：{{ item.address }}
					</view>
					<view class="text-hidden-1">
						{{ $t('other.pickupDate') }}：{{ item.createTime }}
					</view>
				</view>

				<!--审核状态 0审核中 1 审核通过 2审核未通过-->
				<!-- <view class="tip" v-if="item.showStatus == 0">
					<img v-if="item.auditStatus==0" src="/pages_order/static/order/3.svg" style="width: 100%;height: 100%;" />
					<img v-if="item.auditStatus==1" src="/pages_order/static/order/1.svg" style="width: 100%;height: 100%;" />
					<img v-if="item.auditStatus==2" src="/pages_order/static/order/2.svg" style="width: 100%;height: 100%;" />
				</view> -->

			</view>

			<!--撤单按钮-->
			<view class="bottom">
			
				<view @click.stop="showVideo(item)" class="btn"
				v-if="item.reportVideo"
				>
					检测视频
				</view>
				
				<view @click.stop="showImage(item)" class="btn"
				v-if="item.report"
				>
					检测报告
				</view>
				
				<view @click.stop="immediatePurchase(item)" class="btn a"
				>
					立即下单
				</view>
			</view>
		</view>

		<!--无历史记录-->
		<view style="padding: 100rpx 0;" v-else>
			<uv-empty mode="history" textSize="28rpx" iconSize="100rpx" />
		</view>
	</view>
</template>

<script>
	export default {
		name: "orderList",
		props: {
			list: {
				type: Array,
				default: false
			},
			showBackOrder: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {}
		},
		methods: {
			// 立即购买
			immediatePurchase(item) {
				
				if(!uni.getStorageSync('token')){
					return this.$utils.toLogin()
				}
				
				console.log("====")
				// var itemStr = encodeURIComponent(JSON.stringify(item));
				this.$store.state.productDetail = item
				uni.navigateTo({
					url: `/pages_order/tradingPlatform/nowOrder`,
				});
			},
			showImage(item){
				uni.previewImage({
					urls : item.report.split(','),
					current : 0,
				})
			},
			showVideo(item, index = 0){
				this.$emit('previewVideo', {
					urls : item.reportVideo.split(','), // 需要预览的资源列表
					index, // 当前显示的资源序号
				})
			},
			toDetail(item){
				this.$store.state.productDetail = item
				uni.navigateTo({
					url: '/pages_order/product/productDetail'
				})
			},
		}
	}
</script>


<style scoped lang="scss">
	.page {
		display: flex;
		flex-direction: column;
		gap: 20rpx;

		// height: calc(90vh - 180rpx);


		.item {
			margin: 0 20rpx;
			padding: 20rpx;
			border-radius: 40rpx;
			background-color: #fff;
      //overflow: hidden;
      //height:300px;

			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 30rpx;

				.service {
					color: #000;
				}

				.status {
					color: #8d8d8d;
					font-size: 26rpx;
					font-weight: 600;
				}
			}

			.zhuti {
				display: flex;
				margin: 10rpx 0;
				position: relative;


				.left {
					width: 150rpx;
					height: 150rpx;
					border-radius: 10rpx;

					image {
						width: 150rpx;
						height: 150rpx;
						border-radius: 10rpx;
					}
				}

				.right {

					width: calc(100% - 160rpx);
					color: #777;
					font-size: 24rpx;
					padding-left: 20rpx;
					line-height: 40rpx;
					background-color: #f8f8f8;
				}

				.tip {
					width: 80rpx;
					height: 80rpx;
					position: absolute;
					bottom: -20rpx;
					right: -20rpx;
				}
			}

			.bottom {
				display: flex;
				justify-content: flex-end;
				.btn {
					display: flex;
					align-items: center;
					justify-content: center;
					// width: ;
					padding: 0 24rpx;
					height: 50rpx;
					border-radius: 40rpx;
					color: $uni-color;
					font-size: 24rpx;
					margin: 20rpx 10rpx 0 0;
					background: #ffffff;
					border: 1px solid $uni-color;
					//margin-top: 20rpx;
					border-radius: 40rpx;
				}
				.a{
					background-color: $uni-color;
					color: #fff;
				}
			}
		}

	}
</style>