<template>
	<view class="apply-history view" :style="winHeight">
		<view class="status_bar" :style="navHeight"></view>
		<view class="apply-history-wrapper view">
			<view class="middle view">
				<!-- <view class="title">发运单号：FH200333222</view> -->
				<view class="steps">
					<view class="steps__row-container">
						<view class="steps__row-line-item">
							<view class="steps__row-check">
								<i class="icon-dot icon-dot-active"></i>
							</view>
							<view class="steps__row-line steps__row-line--after steps__row-line--active"></view>
						</view>
						<uni-cell class="step-style" v-for="(item,index) in dataList" key="index" >
							<view class="steps__row-line-item" v-if="index - 0 !== 0 && index - 0 !== dataList.length - 1">
								<view class="steps__row-line steps__row-line--before"
									:class="{'steps__row-line--active':deliveryListBeforeLineShow}"></view>
								<view class="steps__row-check steps__row-circle">
									<i class="icon-dot" :class="{'icon-dot-active':deliveryListBeforeLineShow}"></i>
								</view>
								<view class="steps__row-line steps__row-line--after"
									:class="{'steps__row-line--active':deliveryListBeforeLineShow}"></view>
							</view>
							<view class="steps__row-line-item" v-if="index - 0 !== 0 && index - 0 === dataList.length - 1">
								<view class="steps__row-line steps__row-line--before"
									:class="{'steps__row-line--active':deliveryListBeforeLineShow}"></view>
								<view class="steps__row-check steps__row-circle">
									<i class="icon-dot " :class="{'icon-dot-active':deliveryListBeforeLineShow}"></i>
								</view>
								<view class="steps__row-line steps__row-line--after steps__row-line--hide"></view>
							</view>
						</uni-cell>
					</view>
					<view class="steps__row-text-container">
					<uni-cell class="step-style" v-for="(item,index) in dataList" key="index" >
							<view class="steps__row-text">
								<text class="steps__row-title" :class="{'steps__row-title--active':deliveryListAfterLineShow}">{{item.nodeStatus}}</text>
								<text class="steps__row-desc">{{item.nodeTime}}</text>
							</view>
					</uni-cell>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex'

	import { queryLogistics } from '@/servers/purchaseList.js'
	export default {
		data() {
			return {
				deliveryStatus: 'doing',
				dataList: [],
				logisticno: ''
			}
		},
		computed: {
			deliveryListBeforeLineShow() {
				return this.deliveryStatus === 'doing'
			},
			deliveryListAfterLineShow() {
				return this.deliveryStatus === 'doing'
			},
			deliveryCheckLineShow() {
				return this.deliveryStatus === 'end'
			},
			...mapState(['sysinfo'])
		},
		onLoad() {
			this.winHeight = `height:${this.sysinfo.safeArea.height}px`;
			this.navHeight = `height:${this.sysinfo.safeArea.top + 44}px`;
		},
		onBackPress() {
			
		},
		created() {
			this.getLogistics()
		},
		onLoad(option) {
			this.logisticno = option.logisticno
		},
		methods: {
			async getLogistics(){
				const formdata = {"wantGoodsId": this.logisticno}
				const res = await queryLogistics(formdata)
				this.dataList = res.data[0].nodes.reverse()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.view {
		flex-direction: column;
	}

	.apply-history {
		width: 750rpx;
		flex: 1;
		background: $background-color-1;
		padding: 0 16rpx;
	}

	.apply-history-wrapper {
		flex: 1;
		background-color: #fff;
		margin-top: 18rpx;
		border-radius: 16rpx;
		box-shadow: 0px 2px 4px 0px #dbe4ee;
	}

	.middle {
		flex: 1;
		padding: 26rpx 32rpx;
	}

	.title {
		font-size: 32rpx;
		color: $text-base-color;
		font-weight: 500;
		margin-bottom: 64rpx;
	}

	.steps {
		flex: 1;
		margin: 28rpx 0 32rpx;
	}

	.steps__row-text-container {
		flex-direction: column;
		align-items: flex-start;
		margin-left: 20rpx;
	}

	.steps__row-text {
		height: 200rpx;
		flex-direction: column;
		align-items: flex-start;
	}

	.steps__row-title {
		font-size: 34rpx;
		line-height: 16px;
		text-align: center;
		color: $text-base-color;
		margin-bottom: 6rpx;
	}

	.steps__row-title--active {
		color: #F62C29;
	}

	.steps__row-desc {
		font-size: 30rpx;
		color: #999;
	}

	.steps__row-container {
		width: 80rpx;
		flex-direction: column;
	}

	.steps__row-line-item {
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}

	.steps__row-line {
		height: 80rpx;
		background-color: #999;
	}

	.icon-dot {
		width: 16rpx;
		height: 16rpx;
		background: #E5E5E5;
		border-radius: 50%;
	}

	.icon-dot-active {
		width: 40rpx;
		height: 40rpx;
		background: #ff1d32;
	}
	
	.steps__row-line {
		width: 1px;
		height: 80rpx;
		background-color: #e5e5e5;
	}

	.steps__row-line--active {
		background: #ff3e61;
		border-radius: 1px;
	}

	.steps__row-line--hide {
		background-color: transparent;
	}
	.steps__row-text{
		flex-direction: column;
	}
	.step-style{
		flex-direction: column;
	}
</style>
