<template>
	<view class="container">
		<view class="details">
			<view class="detail_msg">
				<view class="info-item status">
					<text class="label">报修状态： </text>
					<text :class="item.statusCode == '11' ? 'infoSpan':'infoSpan2'">{{item.status}}</text>
				</view>
				<view class="info-item">
					<text class="label">报修人： </text>
					<text class="infoSpan">{{item.userName}}</text>
				</view> 
				<view class="info-item">
					<text class="label">报修选项： </text>
					<text class="infoSpan">{{ fixList[item.opt-1].title }}</text>
				</view> 
				<view class="info-item">
					<text class="label">报修位置： </text>
					<text class="infoSpan">{{item.repairAddr}}</text>
				</view>
				<view class="info-item">
					<text class="label">报修描述： </text>	
					<text class="infoSpan">{{item.faultDetail}}</text>
				</view>
				<view class="info-item">
					<text class="label">报修时间： </text>	
					<text class="infoSpan">{{formatDate(item.apply_time, 'dateTime')}}</text>
				</view>
				<view class="img-box" >
					<image v-for="(itemImg,imgIndex) in item.pictures" :key="imgIndex" :src="itemImg" mode=""></image>
				</view>
			</view> 
		</view>
		
		<!-- <view style="clear: both;"></view>
		<view class="occupied"></view> -->
		<!-- <view class="footer-btn" v-if="role=='1' && first_status=='0'">
			<view class="btn">取消</view>
		</view> -->
		<!-- <view class="footer-btn footer-btn-two" v-if="item.statusCode == '10'">
			<view class="btn btn-col" @click="submit(2)">拒绝</view>
			<view class="btn btn-col1" @click="submit(1)">接受</view>
		</view> -->
	</view>
</template>

<script>
	import {
		doHitch,
	} from '@/common/api.js';
	import {
		callbackRequest,
		getStorage,
		alertTip,
		formatDate,
		sureAlterTip
	} from '@/common/util.js';
	export default {
		
		data() {
			return {
				userInfo:'',
				formatDate:formatDate,
				item: {},
				fixList: [{
						title: "空调",
						more: "风系统"
					},
					{
						title: "给排水",
						more: "饮水、清洁、排水"
					},
					{
						title: "电",
						more: "照明、办公、生产"
					},
					{
						title: "木",
						more: "办公桌、椅、门等"
					},
					{
						title: "安保",
						more: "门禁、监控等"
					},
					{
						title: "电梯",
						more: "货运、人员等"
					},
					{
						title: "消防",
						more: "报警、逃生、灭火器"
					},
					{
						title: "其它",
						more: ""
					},
				],
			}
		},
		onLoad(option) {
			this.userInfo = getStorage('userInfo');
			this.item = JSON.parse(decodeURIComponent(option.item));
		    // option.item  && ());
		},
		methods: {
			submit(type){
				if (type != 1 && type != 2 ){ 
					return
				}
				// 1 同意 2 拒绝
				let params = {
					"method": doHitch,
					"data":{
						userId: this.userInfo.id,
						type: type,
						id: this.item.id
					}
				};
				console.log("params:",params);
				callbackRequest(params).then(res => {
					res = res.data;
					console.log("return:", res);
					alertTip(res.returnMsg);
					if ( res.returnCode === "1"){
						// 跳回列表页
						uni.navigateTo({
							url:'/pages/repair-record/repair-record'
						})
					}
				})
			}
				
		}
	}
</script>

<style lang="scss">
	@import '@/static/css/common.scss';
	.container {
		min-height:100vh;
		background: #f8f8f8;
		font-size: 28upx;
		.details{
			// height: 550upx;
			background: white;
			margin: 15upx;
			border-radius: 15upx;
			padding-bottom:15rpx;
			.detail_header {
				border-bottom: #f8f8f8 5upx solid;
				height: 90upx;
				line-height: 90upx;
				margin: 15upx;
				border-radius: 10upx;
				.blueSign {
					height: 28upx;
					width: 5upx;
					background: #00c277;
					display: inline-block;
					margin-left: 20upx;
				}
				.font-tilte {
					font-weight:bold;
					margin-left: 20upx;
				}
			}
			.detail_msg {
				margin-left: 20upx;
				border-radius: 10upx;
				.info-item{
					border-bottom:1px solid #f8f8f8;
					padding:20upx 10upx;
					line-height: 50upx;
					.label{
						display:inline-block;
						width:150upx;
						font-size:28upx;
						color:#333;
						font-weight:bold;
					}
				}
				.status {
					.infoSpan{
						color: #00c277;
					}
					.infoSpan2{
						color: red;
					}
				}
				.img-box {
					// background: #fff;
					image{
						width: 200upx;
						height: 200upx;
						margin:20upx 20upx 0 0;
					}
				}
			}
		}
	}
</style>
