<template>
  <div class="page-section">
    <div class="app-container">
      <div class="row">
        <div class="col">货物名称：</div>
        <div class="col">{{ detailData.authParty }}授权牌</div>
      </div>
      <div class="row">
        <div class="col">物流公司：</div>
        <div class="col">{{ detailData.companyName }}</div>
      </div>
      <div class="row">
        <div class="col">物流单号：</div>
        <div class="col">{{ detailData.logisticsNumber }}</div>
      </div>

      <div class="title">物流详情</div>
      <el-divider />
      <div class="info">
        <div v-for="(item, index) in logisticInfo" :key="index" class="row">
          <span class="time">[{{ item.time | formatTime }}]</span>
          <span class="content">{{ item.context }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { logisticsDetails } from '@/api/logistics'
export default {
  data() {
    return {
      authId: '',
      detailData: {},
      logisticInfo: []
    }
  },
  created() {
    this.authId = this.$route.query.id
    this.fetchLogisticsDetails()
  },
  methods: {
    async fetchLogisticsDetails() {
      try {
        const res = await logisticsDetails({ authId: this.authId })
        this.detailData = { ...this.detailData, ...res.data }
        this.logisticInfo = res.data.info && JSON.parse(res.data.info)
        console.log(this.logisticInfo)
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.page-section {
  width: 100%;
  height: calc(100vh - 84px);
  background: #f7f7f7;
  box-sizing: border-box;
  padding: 20px;
}

.app-container {
  background: #fff;
  box-sizing: border-box;
  .row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    .col {
      line-height: 36px;
      font-size: 14px;
      color: #333;
    }
  }

  .title {
    font-size: 28px;
    color: #409eff;
    margin-top: 35px;
  }

  .info {
    font-size: 14px;
    line-height: 1.6;
    .row {
      margin: 12px 0;
      .time {
        margin-right: 16px;
        white-space: nowrap;
      }
    }
  }
}
</style>
