<template>
	<view class="container">
		<!-- 投诉列表区域 -->
		<view class="body">
			<!-- 每一个投诉订单区域 -->
			<view class="box" v-for="item in list" :key="item.id" @click="handleGoPage(item)">
				<!-- 标题区域 -->
				<view class="box_header">
					<view class="header_left">{{ item.title }}</view>
					<view class="header_right">{{ item.progressType }}</view>
				</view>
				<!-- 信息区域 -->
				<view class="box_info">
					<img mode="aspectFill" :src="item.url" />
					<view class="info_center">
						<view class="center_name">{{ item.hotelName }}</view>
						<view class="center_time">{{ item.orderStartTime.slice(0, 10) }} - {{ item.orderEndTime.slice(0, 10) }}</view>
						<view class="center_tags">{{ item.houseOrderNumber }}间 {{ item.houseName }}</view>
						<view class="center_price">¥{{ item.payAccount }}</view>
					</view>
					<view class="info_right">{{ item.orderStatus }}</view>
				</view>

				<!-- 反馈时间区域 -->
				<view class="box_time">
					<view class="time_left">反馈时间</view>
					<view class="time_right">{{ item.dateTime.slice(0, 19) }}</view>
				</view>
			</view>
		</view>

		<view class="noData" v-if="list.length === 0">
			<img lazy-load :lazy-load-margin="0" src="../../static/images/noData.png" />
			暂无数据
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 投诉列表数据
			list: [],
			// 当前页
			page: 1,
			// 每页多少条
			rows: 6,
			// 总条数
			total: null
		}
	},
	onLoad() {
		this.getData()
	},
	onReachBottom() {
		if (this.list.length < this.total) {
			this.page++
			this.getData()
		} else {
			uni.showToast({
				title: '没有更多数据了',
				icon: 'none'
			})
		}
	},
	methods: {
		async getData() {
			const res = await this.$myRequest({
				url: '/mhotel/complaintcomplaintPage.action',
				data: {
					usersId: uni.getStorageSync('userInfo').id,
					page: this.page,
					rows: this.rows
				}
			})
			// console.log(res)
			if (res.code === 200 && res.page.pageList) {
				this.total = res.page.total
				this.list = [...this.list, ...res.page.pageList]
			}
		},
		// 点击每一个投诉订单的回调
		handleGoPage(item) {
			uni.navigateTo({
				url: `/pagesSub/complaintProgress/complaintProgress?id=${item.id}`
			})
		}
	}
}
</script>

<style lang="scss">
.container {
	box-sizing: border-box;
	padding: 20rpx;
	min-height: 100vh;
	overflow-y: auto;
	background-color: #f7f7f7;

	.body {
		.box {
			box-sizing: border-box;
			padding: 0 20rpx 0 30rpx;
			margin-bottom: 20rpx;
			width: 710rpx;
			height: 390rpx;
			border-radius: 15rpx;
			background-color: #fff;

			.box_header {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 98rpx;
				border-bottom: 1rpx solid #e6e6e6;

				.header_left {
					flex: 4;
					font-size: 32rpx;
					font-weight: bold;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
				.header_right {
					flex: 1;
					font-size: 28rpx;
					color: #808080;
					text-align: end;
				}
			}

			.box_info {
				display: flex;
				margin: 34rpx 0 27rpx 0;
				height: 143rpx;

				img {
					width: 143rpx;
					height: 143rpx;
					border-radius: 9rpx;
				}

				.info_center {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					margin-top: -5rpx;
					margin-left: 17rpx;
					height: 150rpx;
					color: #808080;
					font-size: 24rpx;
					overflow: hidden;

					.center_name {
						font-size: 28rpx;
						font-weight: bold;
						color: #000;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					.center_time {
					}
					.center_tags {
					}
					.center_price {
					}
				}

				.info_right {
					width: 185rpx;
					text-align: end;
					font-size: 24rpx;
					color: #808080;
				}
			}

			.box_time {
				display: flex;
				align-items: center;
				height: 58rpx;
				font-size: 24rpx;
				border-radius: 9rpx;
				background-color: #f2f2f2;

				.time_left {
					margin: 0 20rpx;
				}
				.time_right {
					color: #808080;
				}
			}
		}
	}

	.noData {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		padding-bottom: 20rpx;

		img {
			margin-top: 160rpx;
			width: 600rpx;
			height: 600rpx;
		}
	}
}
</style>
