<template>
	<view class="container">
		<view class="title">工单信息</view>
		<view class="box">
			<view class="box_key">工单编号：</view>
			<view class="box_value">{{ detailInfo.order }}</view>
		</view>
		<view class="box_time">
			<view class="time_msg">
				报修时间：
				<text>{{ detailInfo.time }}</text>
			</view>

			<view class="time_type" v-if="detailInfo.type === 1">待接单</view>
			<view class="time_type color_type" v-if="detailInfo.type === 2">维修中</view>
			<view class="time_type" v-if="detailInfo.type === 3">待确认</view>
			<view class="time_type color_type2" v-if="detailInfo.type === 4">已完成</view>
			<view class="time_type" v-if="detailInfo.type === 5">已取消</view>
		</view>

		<view class="box">
			<view class="box_key">报修姓名：</view>
			<view class="box_value">{{ detailInfo.name }}</view>
		</view>
		<view class="box">
			<view class="box_key">报修电话：</view>
			<view class="box_value phone" @click="handleCallPhone('13820846714')">
				{{ detailInfo.phone }}
				<img src="../../static/images/repairsImg/phone.png" />
			</view>
		</view>
		<view class="box">
			<view class="box_key">报修区域：</view>
			<view class="box_value">{{ detailInfo.area }}</view>
		</view>
		<view class="box">
			<view class="box_key">详细地址：</view>
			<view class="box_value">{{ detailInfo.address }}</view>
		</view>
		<view class="box">
			<view class="box_key">报修物品：</view>
			<view class="box_value">{{ detailInfo.goods }}</view>
		</view>
		<view class="box">
			<view class="box_key">故障描述：</view>
			<view class="box_value">{{ detailInfo.description }}</view>
		</view>

		<view class="box_img">
			<view class="img_key">上传图片：</view>
			<img class="img_value" mode="aspectFill" :src="detailInfo.img[0]" @click="handleLookImgs(detailInfo.img)" />
		</view>

		<view class="title top">报修跟踪</view>

		<!-- 步骤条区域 -->
		<!-- activeIcon="checkmark-circle-fill" -->
		<uv-steps activeColor="#6FB6B8" direction="column" current="3">
			<uv-steps-item :customStyle="customStyle" v-for="item in stepsList" :key="item.id">
				<template v-slot:title>
					<view class="steps_title" :class="{ active: item.type }">{{ item.title }}</view>
				</template>
				<template v-slot:desc>
					<view class="steps_desc" v-for="(element, index) in item.desc" :key="index">{{ element }}</view>
				</template>
			</uv-steps-item>
		</uv-steps>
	</view>
</template>

<script>
export default {
	data() {
		return {
			detailInfo: {},
			customStyle: {
				marginBottom: '5px'
			},
			stepsList: [
				{
					id: 1,
					title: '提交订单',
					type: true,
					desc: ['2023-07-05 08:25:25']
				},
				{
					id: 2,
					title: '已接单',
					type: true,
					desc: ['2023-07-05 08:25:25']
				},
				{
					id: 3,
					title: '待确认',
					type: true,
					desc: ['2023-07-05 08:25:25', '张发财转后勤:太贵了', '系统管理员改价：耗材为螺丝刀，价格50元', '系统管理员改价：耗材为螺丝刀，价格50元']
				},
				{
					id: 4,
					title: '待确认',
					type: false,
					desc: ['2023-07-05 08:25:25']
				},
				{
					id: 5,
					title: '已完成',
					type: false,
					desc: ['2023-07-05 08:25:25']
				}
			]
		}
	},
	onLoad(options) {
		this.detailInfo = JSON.parse(decodeURIComponent(options.detailInfo))
		console.log(this.detailInfo)
	},
	methods: {
		// 点击电话号码回调
		handleCallPhone(phone) {
			console.log(phone)
			uni.makePhoneCall({
				phoneNumber: phone
			})
		},
		// 点击图片回调
		handleLookImgs(img) {
			// console.log(img)
			uni.previewImage({
				urls: img
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	padding: 0 30rpx 50rpx;
	height: 100vh;
	overflow-y: auto;

	.title {
		height: 90rpx;
		line-height: 90rpx;
		font-size: 32rpx;
		font-weight: bold;
	}

	.top {
		margin-top: 20rpx;
	}

	.box {
		display: flex;
		height: 60rpx;
		font-size: 28rpx;

		.box_key {
			color: #808080;
		}

		.box_value {
			display: flex;

			img {
				margin-top: 5rpx;
				margin-left: 10rpx;
				width: 28rpx;
				height: 28rpx;
			}
		}

		.phone {
			color: #6fb6b8;
		}
	}

	.box_time {
		display: flex;
		height: 60rpx;

		.time_msg {
			font-size: 28rpx;
			color: #808080;

			text {
				color: #000000;
			}
		}

		.time_type {
			margin-left: 123rpx;
			margin-top: -5rpx;
			font-size: 32rpx;
			color: #ff5733;
		}

		.color_type {
			color: #1e7dfb;
		}
		.color_type2 {
			color: #6fb6b8;
		}
	}

	.box_img {
		display: flex;
		align-items: center;
		height: 120rpx;
		color: #808080;
		font-size: 28rpx;

		.img_key {
		}

		.img_value {
			width: 120rpx;
			height: 120rpx;
			border-radius: 14rpx;
			background-color: salmon;
		}
	}

	.steps_title {
		color: #969799;
		font-size: 28rpx;
	}

	.active {
		color: #6fb6b8;
	}

	.steps_desc {
		line-height: 45rpx;
		font-size: 24rpx;
	}
}
</style>
