<template>
	<view class="detail" v-if="detail!=null">
		<view class="feedback-info">
			<view class="title">
				<text>处理反馈</text>
				<text v-if="detail.status==1" class="processed">已处理</text>
				<text v-else class="pending">待处理</text>
			</view>
			<view v-if="detail.status==1">
				<!-- 你反馈的问题，已经处理，设备已进行升级 -->
				{{detail.feedback}}
			</view>
			<view v-else>
				你反馈的问题正在处理中，请耐心等待~~~
			</view>
		</view>
		<view class="submit-info">
			<view class="title">
				<text>提交信息</text>
			</view>
			<view>
				<text>联系人:</text>
				<text>{{detail.contact}}</text>
			</view>
			<view>
				<text>联系电话:</text>
				<text>{{detail.contactNumber}}</text>
			</view>
			<view>
				<text>关键词:</text>
				<text>{{detail.keyWords}}</text>
			</view>
			<view>
				<text>问题反馈:</text>
				<text>{{detail.desc}}</text>
			</view>
			<view>
				<text>照片:</text>
				<view class="photos">
					<image @tap="previewImg(photoUrls,index)" v-for="(img,index) in photoUrls" :src="basePath+img"
						mode="aspectFill"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		complaintDetail
	} from '@/api/OneStopCommunity/complaint.js';
	import {
		baseUrl
	} from "@/config.js";
	import {
		previewImg
	} from "@/utils/uploadImg.js"
	export default {
		data() {
			return {
				detail: null,
				id: "",
				photoUrls: [],
				basePath: baseUrl
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.getDetail();
		},
		methods: {
			async getDetail() {
				let res = await complaintDetail(this.id)
				if (res.code == 200) {
					this.detail = res.data;
					if (this.detail.photos != null) {
						this.photoUrls = this.detail.photos.split(',');
					}
				}
			},
			previewImg(imgs,index) {
				let images = imgs.map(img => {
					return {
						path: baseUrl + img
					}
				})
				previewImg(images,index);
			}
		}
	}
</script>

<style scoped lang="scss">
	.detail {
		background-color: #F5F5F7;
		padding: 40rpx;
		height: calc(100vh - 44px);

		.feedback-info {
			padding: 40rpx;
			border-radius: 20rpx;
			background-color: white;

			.title {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-bottom: 26rpx;
				margin-bottom: 26rpx;
				border-bottom: 1px solid #F5F5F7;

				text:first-child {
					font-weight: bold;
				}

				text:last-child {

					padding: 4rpx 10rpx;
				}

				.processed {
					border: 1px solid #D0F5E0;
					color: #71E2A3;
					background-color: #E7FAF0;
				}

				.pending {
					border: 1px solid #FFE399;
					color: #FFBA00;
					background-color: #FFF8E6;
				}
			}
		}

		.submit-info {
			margin-top: 40rpx;
			border-radius: 20rpx;
			padding: 40rpx;
			background-color: white;

			&>view {
				margin-bottom: 20rpx;
			}

			.photos {
				margin-top: 10rpx;
				display: flex;
				flex-wrap: wrap;

				image {
					margin-bottom: 10rpx;
					width: 23.5%;
					border-radius: 8rpx;
					height: 136rpx;

					&:not(:nth-child(4n)) {
						margin-right: 2%;
					}
				}
			}

			.title {
				font-weight: bold;
				padding-bottom: 15rpx;
				margin-bottom: 15rpx;
				border-bottom: 1px solid #F5F5F7;
			}
			
		}
	}
</style>