<template>
	<view class="center">
		<view v-for="(item, index) in list" :key="index" class="order-item">
			<view class="goods-box-single">
				<image class="goods-img" :src="item.image" mode="scaleToFill"></image>
				<view class="right">
					<view class="flex-start">
						<text class="title clamp1">{{ item.name }}</text>
					</view>
					<view class="create-time">所属场次：{{ item.nickname }}</view>
					<view class="price">{{ item.price }}</view>
				</view>
			</view>
			<view class="buy-box">
				<view class="buy-info">
					<view class="font">挂售价格：{{ item.hanging_price }}</view>
				</view>
				<view class="buy-info">
					<view class="font">挂售时间：{{ item.update_time }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { user_product } from '@/api/user.js';
import { getTime } from '@/utils/rocessor.js';
export default {
	data() {
		return {
			list: [],
			page: 1,
			limit: 10,
			loadingType: 'more'
		};
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		loadData() {
			const obj = this;
			if (obj.loadingType == 'nomore' || obj.loadingType == 'loading') {
				return;
			}
			obj.loadingType = 'loading';
			user_product({
				page: obj.page,
				limit: obj.limit
			}).then(({ data }) => {
				console.log(data);
				data.forEach(e => {
					e.g_time = getTime(e.add_time);
				});
				obj.list = data;
				if (data.length != obj.limit) {
					obj.loadingType == 'noMore';
				} else {
					obj.page++;
					obj.loadingType == 'more';
				}
			});
		}
	}
};
</script>

<style lang="scss">
.center {
	background: #f3f5f4;
}
.order-item {
	display: flex;
	flex-direction: column;
	background: #fff;
	margin-top: 20rpx;

	.i-top {
		display: flex;
		align-items: center;
		height: 80rpx;
		font-size: $font-base;
		color: $font-color-dark;
		position: relative;
		padding: 0 30rpx;

		.time {
			flex: 1;
		}

		.state {
			color: $base-color;
		}

		.del-btn {
			padding: 10rpx 0 10rpx 36rpx;
			font-size: $font-lg;
			color: $font-color-light;
			position: relative;

			&:after {
				content: '';
				width: 0;
				height: 30rpx;
				border-left: 1px solid $border-color-dark;
				position: absolute;
				left: 20rpx;
				top: 50%;
				transform: translateY(-50%);
			}
		}
	}

	/* 多条商品 */
	.goods-box {
		height: 160rpx;
		padding: 20rpx 0;
		white-space: nowrap;

		.goods-item {
			width: 120rpx;
			height: 120rpx;
			display: inline-block;
			margin-right: 24rpx;
		}

		.goods-img {
			display: block;
			width: 100%;
			height: 100%;
		}
	}

	/* 单条商品 */
	.goods-box-single {
		display: flex;
		padding: 20rpx 30rpx;
		background: #ffffff;
		.goods-img {
			display: block;
			width: 160rpx;
			height: 160rpx;
		}

		.right {
			flex: 1;
			display: flex;
			flex-direction: column;
			padding: 0 0 0 24rpx;
			overflow: hidden;

			.price {
				margin-top: 30rpx;
				display: inline;
				font-size: $font-base + 8rpx;
				color: #fd3938;

				&:before {
					content: '￥';
					font-size: $font-sm;
				}
			}

			.title {
				font-size: $font-base + 6rpx;
				color: #4f4f4f;
				line-height: 1;
				width: 80%;
			}
			.create-time {
				margin-top: 10rpx;
				font-size: $font-base;
				color: #9d9d9d;
			}
		}
	}
	.price-box {
		display: flex;
		justify-content: flex-end;
		align-items: baseline;
		padding: 20rpx 30rpx;
		font-size: $font-sm + 2rpx;
		color: $font-color-light;

		.num {
			margin: 0 8rpx;
			color: $font-color-dark;
		}

		.price {
			font-size: $font-lg;
			color: $font-color-dark;

			&:before {
				content: '￥';
				font-size: $font-sm;
				margin: 0 2rpx 0 8rpx;
			}
		}
	}

	.action-box {
		padding: 0 30rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		height: 100rpx;
		position: relative;
	}

	.refuse {
		margin: 0;
		padding: 0;
		width: 160rpx;
		height: 60rpx;
		border: 2rpx solid #ebebeb;
		border-radius: 28rpx;
		text-align: center;
		line-height: 60rpx;
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
		&:after {
			border-radius: 100px;
		}

		&.recom {
			color: #999999;

			&:after {
				border-color: #999999;
			}
		}
	}
	.buy-box {
		padding: 10rpx 22rpx;
		background-color: #ffffff;
		.buy-info {
			margin-top: 20rpx;
			.font {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}
		}
	}
	.action-btn {
		width: 160rpx;
		height: 60rpx;
		margin: 0;
		margin-left: 24rpx;
		padding: 0;
		text-align: center;
		line-height: 60rpx;
		font-size: $font-sm + 2rpx;
		color: $font-color-dark;
		background: #fff;
		border-radius: 100px;
		border: 2rpx solid #fd3b39;
		border-radius: 28px;
		&:after {
			border-radius: 100px;
		}

		&.recom {
			color: $base-color;

			&:after {
				border-color: $base-color;
			}
		}

		&.evaluate {
			color: $color-yellow;

			&:after {
				border-color: $color-yellow;
			}
		}
	}
}
</style>
