<template>
	<view class="progress">
		<view class="top">
			<view class="top-t">
				<view class="top-item">
					<image src="../../static/icon/x1.png" mode=""></image>
					<view class="item-tit">1.项目创建</view>
				</view>
				<view class="top-item">
					<image src="../../static/icon/x2.png" mode=""></image>
					<view class="item-tit">2.项目审核</view>
				</view>
				<view class="top-item">
					<image src="../../static/icon/x3.png" mode=""></image>
					<view class="item-tit">3.捐赠响应</view>
				</view>
				<view class="top-item">
					<image src="../../static/icon/x4.png" mode=""></image>
					<view class="item-tit">4.捐赠审核</view>
				</view>
			</view>
			<view class="top-t">
				<view class="top-item">
					<image src="../../static/icon/x5.png" mode=""></image>
					<view class="item-tit">5.捐赠品入库</view>
				</view>
				<view class="top-item">
					<image src="../../static/icon/x6.png" mode=""></image>
					<view class="item-tit">6.捐赠品出库</view>
				</view>
				<view class="top-item">
					<image src="../../static/icon/x7.png" mode=""></image>
					<view class="item-tit">7.发往受捐者</view>
				</view>
				<view class="top-item">
					<image src="../../static/icon/x8.png" mode=""></image>
					<view class="item-tit">8.受捐者反馈</view>
				</view>
			</view>
		</view>
		<view class="main">
			<view class="item">
				<image src="../../static/icon/xq1.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">响应捐赠</view>
					<view class="item-time">{{info.add_time | time }} {{info.name}}响应捐赠{{info.item | item(typeList)}},提交工作人员审核</view>
				</view>
				<view class="line1"></view>
				<view class="line5"></view>
			</view>
			<!-- <view class="item">
				<image src="../../static/icon/xq2.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">捐赠意向书</view>
					<view class="item-time">2021/06/17 12:20:34 荆州XXX公司签署捐赠意向书</view>
				</view>
				<view class="line5"></view>
			</view> -->
			<view class="item">
				<image src="../../static/icon/xq5.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">用户寄件方式</view>
					<view class="item-time">{{info.logistics | log(logisticsList)}}</view>
				</view>
				<view class="line5"></view>
			</view>
			<view class="item">
				<image src="../../static/icon/xq3.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">捐赠审核</view>
					<view class="item-time" v-if="info.verify_time">{{info.verify_time | time }} {{info.name}}捐赠响应{{info.status_txt==='拒绝'? '未通过': '已通过'}}</view>
				</view>
				<view class="line5"></view>
			</view>
			<!-- <view class="item">
				<image src="../../static/icon/xq4.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">智能合约</view>
					<view class="item-time"></view>
				</view>
				<view class="line5"></view>
			</view> -->
			
			<view class="item">
				<image src="../../static/icon/xq6.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">入库单信息</view>
					<view class="item-time" v-if="info.receiving_time">{{info.receiving_time | time }} {{info.name}}捐赠的{{info.item | item(typeList)}}已入库</view>
				</view>
				<view class="line5"></view>
			</view>
			<view class="item">
				<image src="../../static/icon/xq7.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">出库单信息</view>
					<view class="item-time" v-if="info.out_delivery_time">{{info.out_delivery_time | time }} {{info.name}}捐赠的{{info.item | item(typeList)}}已出库</view>
				</view>
				<view class="line5"></view>
			</view>
		<!-- 	<view class="item">
				<image src="../../static/icon/xq8.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">出库物流信息</view>
					<view class="item-time"></view>
				</view>
				<view class="line5"></view>
			</view> -->
			<view class="item">
				<image src="../../static/icon/xq9.png" mode=""></image>
				<view class="item-info">
					<view class="item-tit">受捐反馈信息</view>
					<view class="item-time" v-if="info.feedback_time">{{info.feedback_time | time }} {{info.feedback}}</view>
				</view>
				<view class="line6"></view>
			</view>
		</view>
	</view>
</template>

<script>
import { getOrderInfo, getDonationInfo, getLogistics } from '../../api/money.js'
export default {
	data() {
		return {
			peopleList: [],
			isShow: false,
			info: {},
			typeList: [],
			logisticsList: [],
		};
	},
	filters: {
		time(val){
			let str = '';
			// console.log(val)
			if (val) {
				let date = new Date(val * 1000);
				let Y = date.getFullYear();
				let M = date.getMonth() + 1 > 9 ? (date.getMonth()+1) : '0' + (date.getMonth()+1);
				let D = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
				let h = date.getHours() > 9 ? date.getHours() : '0' + date.getHours()
				let m = date.getMinutes()  > 9 ?  date.getMinutes() : '0' +  date.getMinutes()
				let s = date.getSeconds() > 9 ? date.getSeconds() : '0' +date.getSeconds()
				str = Y + '/' + M + '/' + D + ' ' + h + ':' + m + ':' + s;
			}
			return str;
		},
		item(val, typeList) {
			let str = '(';
			if (val&&typeList) {
				let arr = val.map(item => {
					for (let i = 0; i < typeList.length; i++) {
						if (item.project_donation_id == typeList[i].id) {
							str = str + typeList[i].name + item.project_donation_num  + '、';
						}
					}
				});
			}
		
			return str.substr(0, str.length - 1) +')';
		},
		log(val,logisticsList) {
			let str = ''
			if(val&&logisticsList) {
				for(let i = 0 ,len = logisticsList.length ; i < len ; i++) {
					if(logisticsList[i].id == val) {
						console.log(logisticsList[i].name)
						return str = logisticsList[i].name
					}
				}
			}
			return str
		}
	},
	onLoad(opt) {
		this.info = JSON.parse(opt.item)
		console.log(this.info)
		this.getDonationInfo()
		this.getLogistics()
	},
	methods: {
		getDonationInfo() {
			getDonationInfo().then(({ data }) => {
				this.typeList = data;
				console.log(this.typeList, '获取所有物资');
			});
		},
		getLogistics() {
			getLogistics().then( ({data}) => {
				console.log('88888888888888888888',data)
				this.logisticsList = data
			})
		}
	}
};
</script>

<style lang="scss" scoped>
.top {
	padding: 40rpx 0;
	background-color: #fff;
	margin: 20rpx 0;
	.top-t {
		display: flex;
		justify-content: space-between;
		padding: 0 55rpx;
		.top-item {
			width: 160rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			margin-bottom: 30rpx;
			image {
				width: 160rpx;
				height: 160rpx;
				background: #ffffff;
				border-radius: 14px;
				margin-bottom: 15rpx;
			}
			.item-tit {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				line-height: 1;
			}
		}
	}
}
.main {
	background-color: #fff;
	padding-right: 30rpx;
	height: 100%;
	position: relative;
	.line {
		width: 2rpx;
		// height: 60rpx;
		height: 100%;
		background-color: #fa7e67;
		position: absolute;
		left: 60rpx;
	}
	.item {
		position: relative;
		image {
			width: 45rpx;
			height: 45rpx;
			background: #fa7e67;
			border-radius: 50%;
			position: absolute;
			top: 49rpx;
			left: 40rpx;
			z-index: 3;
		}
		.item-info {
			width: 600rpx;
			position: relative;
			left: 112rpx;
			padding-bottom: 34rpx;
			border-bottom: 1px solid #ededed;
			.item-tit {
				padding-top: 52rpx;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				line-height: 1;
				text {
					display: inline-block;
					width: 87rpx;
					height: 33rpx;
					border: 1px solid #0ec400;
					border-radius: 5rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #0ec400;
					text-align: center;
					line-height: 30rpx;
					margin-left: 10rpx;
				}
			}

			.item-time {
				padding-top: 17rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #bfbfbf;
				line-height: 1;
			}
			.item-num {
				margin-top: 21rpx;
				height: 392rpx;
				width: 592rpx;
				background-color: red;
			}
			.all-info {
				margin-top: 20rpx;
				width: 601rpx;
				height: 174rpx;
				border: 1px solid #cccccc;
				border-radius: 10rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				align-items: center;
				flex-wrap: wrap;
				view {
					flex-shrink: 0;
					width: 50%;
					padding-left: 20rpx;
					text {
						display: inline-block;
						margin-left: 5rpx;
						color: #000000;
					}
					.jd {
						color: #e80000;
					}
				}
			}
		}
		.line1 {
			position: absolute;
			width: 2rpx;
			height: 61rpx;
			background-color: #fff;
			top: 0;
			left: 60rpx;
			z-index: 2;
		}
		.line2 {
			position: absolute;
			width: 2rpx;
			height: 250rpx;
			background-color: #fff;
			bottom: 0;
			left: 60rpx;
		}
		.line5 {
			position: absolute;
			width: 2rpx;
			height: 100%;
			background-color: #fa7e67;
			top: 0;
			left: 60rpx;
			z-index: 1;
		}
		.line6 {
			position: absolute;
			width: 2rpx;
			height: 61rpx;
			background-color: #fa7e67;
			top: 0;
			left: 60rpx;
		}
	}
}
</style>
