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

			<view class="time_type" v-if="detailInfo.state === '待接单'">待接单</view>
			<view class="time_type color_type" v-if="detailInfo.state === '维修中'">维修中</view>
			<view class="time_type" v-if="detailInfo.state === '待确认'">待确认</view>
			<view class="time_type color_type2" v-if="detailInfo.state === '已完成'">已完成</view>
			<view class="time_type" v-if="detailInfo.state === '已取消'">已取消</view>
		</view>

		<view class="box">
			<view class="box_key">报修姓名：</view>
			<view class="box_value">{{ detailInfo.userName }}</view>
		</view>
		<view class="box">
			<view class="box_key">报修电话：</view>
			<view class="box_value phone" @click="handleCallPhone(detailInfo.userPhone)">
				{{ detailInfo.userPhone }}
				<img src="../../static/images/repairsImg/phone.png" />
			</view>
		</view>
		<view class="box">
			<view class="box_key">报修区域：</view>
			<view class="box_value">{{ detailInfo.areaName }}</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.articleName }}</view>
		</view>
		<view class="box">
			<view class="box_key">故障描述：</view>
			<view class="box_value">{{ detailInfo.descript }}</view>
		</view>

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

		<view class="box top" v-if="detailInfo.workerName">
			<view class="box_key">维修师傅：</view>
			<view class="box_value">{{ detailInfo.workerName }}</view>
		</view>

		<view class="box" v-if="detailInfo.workerPhone">
			<view class="box_key">师傅电话：</view>
			<view class="box_value phone" @click="handleCallPhone(detailInfo.workerPhone)">
				{{ detailInfo.workerPhone }}
				<img src="../../static/images/repairsImg/phone.png" />
			</view>
		</view>

		<view class="box" v-if="detailInfo.money">
			<view class="box_key">维修费用：</view>
			<view class="box_value2 phone" @click="checkFeeDetail">
				{{ detailInfo.money }}元
				<img src="../../static/images/repairsImg/eye.png" />
			</view>
		</view>

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

		<!-- 步骤条区域 -->
		<!-- activeIcon="checkmark-circle-fill" -->
		<uv-steps activeColor="#6FB6B8" direction="column" current="4">
			<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 class="gap"></view>

		<!-- 维修费用弹窗 -->
		<uni-popup :is-mask-click="false" ref="popup_fee">
			<view class="pop_fee">
				<view class="fee_title">
					维修费用
					<text @click="$refs.popup_fee.close()">×</text>
				</view>
				<view class="fee_box">
					耗材：
					<text>螺丝刀</text>
				</view>
				<view class="fee_box">
					耗材单价：
					<text>1元</text>
				</view>
				<view class="fee_box">
					耗材数量：
					<text>2</text>
				</view>
				<view class="fee_box">
					耗材费用：
					<text>2元</text>
				</view>
			</view>
		</uni-popup>
	</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: {
		// 查看维修费用回调
		checkFeeDetail() {
			this.$refs.popup_fee.open('center')
		},
		// 点击电话号码回调
		handleCallPhone(phone) {
			uni.makePhoneCall({
				phoneNumber: phone
			})
		},
		// 点击图片回调
		handleLookImgs(img) {
			uni.previewImage({
				urls: img
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	padding: 0 30rpx;
	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;
			}
		}

		.box_value2 {
			display: flex;

			img {
				margin-top: -2rpx;
				margin-left: 14rpx;
				width: 46rpx;
				height: 46rpx;
			}
		}

		.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;
		}
	}

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

	.active {
		color: #6fb6b8;
	}

	.steps_desc {
		line-height: 45rpx;
		font-size: 24rpx;
	}

	.gap {
		height: 20rpx;
	}

	.pop_fee {
		padding-bottom: 50rpx;
		border-radius: 19rpx;
		background-color: #fff;

		.fee_title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 31rpx 0 42rpx;
			width: 690rpx;
			height: 110rpx;
			font-size: 32rpx;
			font-weight: bold;
			border-radius: 19rpx 19rpx 0 0;
			border-bottom: 1rpx solid #e6e6e6;

			text {
				font-size: 45rpx;
				font-weight: 400;
				color: #808080;
			}
		}

		.fee_box {
			display: flex;
			align-items: center;
			padding-left: 42rpx;
			height: 80rpx;
			font-size: 28rpx;
			color: #808080;

			text {
				color: #000000;
			}
		}
	}
}
</style>
