<!--
  @description: 物流详情
  @Modifier：dijia
  @routerPath: /logisticsDetails
  @date：2021/08/16
-->
<template>
  <div class="shop_order">
    <!--当前位置-面包屑-->
    <div class="nav">
      <div class="crumbs_nav_main">
        <span class="pos_title">
          <i class="iconfont icon-dizhi" />当前位置：
        </span>
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="toBack()">
            {{ breadcrumbTitle }}
          </el-breadcrumb-item>
          <el-breadcrumb-item>
            <span>物流详情</span>
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <i class="el-icon-close cursor" title="关闭详情" style="font-size:20px;" @click="closePage" />
    </div>
    <!-- 物流详情 -->
    <div class="order_title">
      物流详情
    </div>
    <div class="logis_detail clearfix">
      <div class="fl logis_status">
        <p>订单编号：{{ orderDetailObj.orderNo }}</p>
        <span>运输中</span>
      </div>
      <div class="fl logis_steps">
        <el-steps :active="3" align-center>
          <el-step
            v-for="(el,i) in stepsList"
            :key="i"
            :title="el.title"
          >
            <template slot="icon">
              <img :src="el.img" alt="" width="30px" height="30px">
            </template>
          </el-step>
        </el-steps>
      </div>
    </div>
    <div class="title-con">
      <div class="order_title rivinfo">
        发货信息
      </div>
      <div class="order_title loginfo">
        收货信息
      </div>
    </div>
    <div class="m track-cont">
      <!-- 发货信息 -->
      <div class="detail-left">
        <div class="flex-box">
          <img src="@/assets/img/shopmall/deliver.png" width="18px" height="18px">
          <div>发货方式：</div>
          <span>普通快递</span>
        </div>
        <div v-if="orderDetailObj.orderProductList" class="flex-box">
          <img src="@/assets/img/shopmall/goods.png" width="18px" height="18px">
          <div>发货商品：</div>
          <span :title="orderDetailObj.orderProductList[0].goodsName" class="cursor">{{ orderDetailObj.orderProductList[0].goodsName }}</span>
        </div>
        <div class="flex-box">
          <img src="@/assets/img/shopmall/logistics.png" width="18px" height="18px">
          <div>物流公司：</div>
          <span>{{ orderDetailObj.trackingDepartName || '无' }}</span>
        </div>
        <div class="flex-box">
          <img src="@/assets/img/shopmall/truck.png" width="18px" height="18px">
          <div>运单号：</div>
          <span>{{ orderDetailObj.trackingNumber || '无' }}</span>
        </div>
      </div>
      <!-- 收货信息 -->
      <div class="order-track-content">
        <div>
          <div class="item">
            <img src="@/assets/img/shopmall/name.png" width="16px" height="16px">
            <div>
              姓名：
            </div>
            <span>{{ orderDetailObj.receiverName ? orderDetailObj.receiverName : '暂无' }}</span>
          </div>
          <div class="item">
            <img src="@/assets/img/shopmall/phoneno.png" width="16px" height="16px">
            <div>
              手机号：
            </div>
            <span>
              {{ orderDetailObj.phoneNumber ? orderDetailObj.phoneNumber : '暂无' }}
            </span>
          </div>
          <div class="item">
            <img src="@/assets/img/shopmall/addr.png" class="align-self mt3" width="16px" height="16px">
            <div class="align-self">
              收货地址：
            </div>
            <span class="align-self cursor" :title="orderDetailObj.addressDetail">
              {{ orderDetailObj.addressDetail ? orderDetailObj.addressDetail : '暂无' }}
            </span>
          </div>
        </div>
      </div>
    </div>
    <!-- 物流信息 -->
    <div class="track_container">
      <div class="goods_detail">
        <el-scrollbar style="height:100%">
          <div v-for="(item, index) in orderDetailObj.orderProductList" :key="index" class="goods_box">
            <div class="img_box">
              <img :src="item.productPicture" alt="" width="109px" height="109px">
            </div>
            <div class="goods_name" @click="goToDetail(item)">
              {{ item.goodsName }}
            </div>
            <div class="total_price">
              ¥{{ item.totalPrice }}
            </div>
          </div>
        </el-scrollbar>
      </div>
      <div class="detail-right">
        <div class="flex-box-right">
          运输中
        </div>
        <div class="progress-content">
          <el-scrollbar style="height:100%">
            <ul v-if="orderWlObj.length">
              <li v-for="(item,index) in orderWlObj" :key="index" class="first">
                <i class="node-icon" />
                <span class="time">{{ item.date }}</span>
                <span class="mon">{{ item.day }}</span>
                <span class="s">{{ item.time }}</span>
                <span class="txt">{{ item.content }}</span>
              </li>
            </ul>
            <span v-else>暂无物流信息</span>
          </el-scrollbar>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 接口
import {
  getOrderDetatils,
  logistics
} from '@/api/shoppingmall/order'
export default {
  name: 'LogisticsDetails',
  components: {
  },
  props: {
  },
  data() {
    return {
      type: '',
      orderDetailObj: {},
      orderWlObj: [],
      stepsList: [
        { img: require('@/assets/img/shopmall/yxd.png'), title: '待揽件' },
        { img: require('@/assets/img/shopmall/dfh.png'), title: '运输中' },
        { img: require('@/assets/img/shopmall/yqx.png'), title: '派送' },
        { img: require('@/assets/img/shopmall/sjsd.png'), title: '签收' }
      ]
    }
  },
  computed: {
    // 面包屑标题
    breadcrumbTitle() {
      if (this.$route.query.from === '/personalCenter/myorder') {
        return '我的订单'
      } else if (this.$route.query.from === '/personalCenter/myorderDital') {
        return '订单管理'
      } else {
        return '订单列表'
      }
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      let status = this.$route.query.status
      const orderId = this.$route.query.orderId
      const supplierOrderId = this.$route.query.supplierOrderId
      const supplierOrderId1 = this.$route.query.supplierOrderId1
      // 00:未拆单 11:拆单
      if (status === '00') {
        status = ''
      }
      getOrderDetatils(orderId, status)
        .then(res => {
          if (res.header.ret === '0') {
            this.orderDetailObj = res.data
            this.type = res.data.goodsDepartName
            logistics(supplierOrderId, this.type, supplierOrderId1)
              .then(res => {
                if (res.header.ret === '0') {
                  // /* eslint-disable */
                  // res.data = [{"operateTime":"2021-03-11 09:05:38","content":"您提交了订单，请等待系统确认","operator":"客户"},{"operateTime":"2021-03-11 09:10:10","content":"您的订单已经进入京东广州仓库准备出库","operator":"系统"},{"operateTime":"2021-03-11 09:10:10","content":"您的订单预计2021-03-11 09:10开始处理，请您耐心等待","operator":"系统"},{"operateTime":"2021-03-11 09:10:11","content":"温馨提示：您的订单预计3月11日送达您手中","operator":"系统"},{"operateTime":"2021-03-11 10:00:12","content":"您的订单已经打印完成","operator":"huangzhixun1"},{"operateTime":"2021-03-11 10:12:35","content":"拣货完成","operator":"张朝彬"},{"operateTime":"2021-03-11 10:38:43","content":"扫描完成","operator":"黄锦丽"},{"operateTime":"2021-03-11 10:47:47","content":"打包完成","operator":"京东打包员"},{"operateTime":"2021-03-11 11:03:35","content":"您的订单在京东【佛山狮山分拣中心】分拣完成","operator":"廖志林"},{"operateTime":"2021-03-11 11:15:24","content":"您的订单由京东【佛山狮山分拣中心】送往【深圳民治分拣中心】","operator":"赖文月"},{"operateTime":"2021-03-11 14:14:41","content":"您的订单在京东【深圳民治分拣中心】分拣完成","operator":"张杰"},{"operateTime":"2021-03-11 14:24:09","content":"您的订单由京东【深圳民治分拣中心】送往【深圳石厦营业部】","operator":"刘云风"},{"operateTime":"2021-03-11 16:08:57","content":"您的订单已到达京东【深圳石厦营业部】","operator":"彭志坚"},{"operateTime":"2021-03-11 16:22:47","content":"您的订单正在配送途中（快递员：蔡振威，电话：18148519297），请您耐心等待。 ","operator":"蔡振威"},{"operateTime":"2021-03-11 17:25:54","content":"您的订单已由公司前台代收。如有疑问您可以联系配送员【蔡振威，18148519297】确认。感谢您在京东购物，欢迎再次光临。","operator":"蔡振威"}]
                  // /* eslint-enable */
                  this.orderWlObj = res.data || []
                  this.logisFormat()
                }
              })
              .catch(err => {
                throw new Error('查看物流信息失败' + err)
              })
          }
        })
        .catch(err => {
          throw new Error('查看订单详情失败' + err)
        })
    },
    logisFormat() {
      this.orderWlObj.forEach((item, index) => {
        item.day = this.$Moment(item.operateTime).day()
        switch (item.day) {
          case 1:
            item.day = '周一'
            break
          case 2:
            item.day = '周二'
            break
          case 3:
            item.day = '周三'
            break
          case 4:
            item.day = '周四'
            break
          case 5:
            item.day = '周五'
            break
          case 6:
            item.day = '周六'
            break
          case 7:
            item.day = '周日'
            break
        }
        item.date = this.$Moment(item.operateTime).format('YYYY-MM-DD')
        item.time = this.$Moment(item.operateTime).format('HH:mm:ss')
      })
    },
    // 面包屑跳转
    toBack() {
      const type = { path: this.$route.query.from, query: { menuIndex: this.$route.query.menuIndex }}
      return type
    },
    // 点右上角关闭时跳转
    closePage() {
      this.$router.push(this.toBack())
    },
    goToDetail(val) {
      this.$router.push({
        path: '/shop/goodsClassDetail',
        query: { id: val.goodsId }
      })
    }
  }
}
</script>

<style scoped lang="less">
.logis_detail {
  box-shadow: 2px 2px 5px #dcd8d8;
  padding: 10px;
  .logis_status {
    width: 35%;
    text-align: center;
    padding: 20px 0;
    border-right: 1px solid #dcd8d8;
    p {
      font-size: 14px;
      color: #AAA;
      margin-bottom: 5px;
    }
    span {
      font-family: 'PingFangSC-Medium', 'PingFang SC Medium', 'PingFang SC';
      font-weight: 500;
      font-style: normal;
      font-size: 24px;
      color: #F59A23;
    }
  }
  .logis_steps {
    width: 65%;
    padding: 20px 0;
    /deep/.el-step__head {
      margin-bottom: 5px;
        .el-step__line{
          margin-left: 20px;
          width: 50%;
          border: none;
          position: relative;
          left: 60%;
          height: 1px;
        }
        img {
          border-radius: 50%;
        }
    }
    /deep/.el-step__icon.is-text {
      border: none;
    }
    /deep/.el-step__line-inner {
      border: none;
      border-bottom: 1px dashed #555;
    }
    /deep/.el-step .el-step__title {
      font-family: 'PingFangSC-Regular', 'PingFang SC';
      font-weight: 400;
      font-style: normal;
      font-size: 12px;
    }
    /deep/.el-step .el-step__head.is-process {
      transform: scale(1.2);
    }
  }
}
.shop_order{
  margin: 0 26px;
  .nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .crumbs_nav_main {
    padding: 10px 0;
    font-size: 14px;
  }

  .crumbs_nav_main .pos_title {
      display: inline-block;
      vertical-align: middle;
      color: #666;
  }

  .crumbs_nav_main .pos_title .iconfont {
      margin-right: 8px;
      color: #00AACA;
  }

  .crumbs_nav_main .el-breadcrumb {
      vertical-align: middle;
      display: inline-block;
  }
  .m{
    margin-bottom: 20px;
  }
}
.title-con{
  width: 100%;
  display: flex;
  justify-content: space-between;
  .rivinfo{
    width: 30%;
  }
  .loginfo{
    width: 50%;
  }
}
.order_title{
    font-family: 'PingFangSC-Regular', 'PingFang SC';
    font-style: normal;
    padding-top: 15px;
    margin-bottom: 15px;
    font-weight: 500;
    font-size: 16px;
  }
.track-cont{
    // box-shadow: 2px 2px 5px #ccc;
    display: flex;
    justify-content: space-between;
    font-family: 'PingFangSC-Regular', 'PingFang SC';
    font-style: normal;
    font-size: 12px;
    margin-bottom: 20px;
    .order-track-content{
      width: 50%;
      padding: 30px 20px 40px 40px;
      box-shadow: 2px 2px 5px #dcd8d8;
      .item {
        display: flex;
        margin-top: 25px;
        padding-right: 10px;
        align-items: center;
        >div {
          width: 70px;
          margin-left: 10px;
        }
        >span {
          flex: 1;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          overflow: hidden;
        }
        >i {
          color: #007CCC;
          font-size: 16px;
        }
        .align-self {
          align-self: flex-start;
        }
        .mt3 {
          margin-top: 0px;
        }
      }
    }
    .detail-left {
      width: 46%;
      padding: 20px 0 40px 40px;
      box-shadow: 2px 2px 5px #dcd8d8;
      font-family: 'PingFangSC-Regular', 'PingFang SC';
      font-style: normal;
      font-size: 12px;
      .flex-box {
        display: flex;
        margin-top: 20px;
        padding-right: 10px;
        padding-bottom: 6px;
        align-items: center;
        &:last-of-type{
          padding-bottom: 0;
          >div {
            padding-left: 12px;
          }
        }
        >div {
          width: 70px;
          margin-left: 10px;
        }
        >span {
          flex: 1;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          overflow: hidden;
        }
        >i {
          color: #007CCC;
          font-size: 16px;
        }
      }
    }
  }
.track_container {
  padding: 20px 0 20px 0;
  box-shadow: 2px 2px 5px #dcd8d8;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-around;
  font-family: 'PingFangSC-Regular', 'PingFang SC';
  font-style: normal;
  font-size: 12px;
  .goods_detail {
    width: 40%;
    height: 302px;
    .goods_box {
      padding-top: 50px;
      text-align: center;
      .img_box {
        margin: 0 auto;
        width: 125px;
        height: 125px;
        padding: 8px;
        border: 1px solid #dcd8d8;
        margin-bottom: 10px;
      }
      .goods_name {
        display: inline-block;
        font-family: 'PingFangSC-Regular', 'PingFang SC';
        font-weight: 400;
        font-style: normal;
        font-size: 12px;
        color: #7F7F7F;
        max-width: 210px;
        margin: 0 auto;
        margin-bottom: 10px;
        text-align: justify;
        cursor: pointer;
        &:hover {
          color: #00aaca;
        }
      }
      .total_price {
        font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC';
        font-weight: 650;
        font-style: normal;
        font-size: 12px;
        letter-spacing: 1.2px;
      }
    }
  }
  .detail-right {
    width: 60%;
    padding-right: 20px;
    .flex-box-right {
      color: #333;
      font-size: 14px;
      font-family: 'PingFangSC-Regular', 'PingFang SC';
      margin-top: 5px;
      padding-bottom: 20px;
      border-bottom: 1px solid #dcd8d8;
    }
  }
}
.progress-content {
    width: 100%;
    height: 250px;
    // overflow-y: auto;
    margin-top: 5px;
    padding-left: 5px;
    position: relative;
    padding-top: 15px;
    ul {
      padding: 0 10px;
    }
  }
  /deep/.el-scrollbar__wrap {
    overflow-x: hidden;
  }
  .progress-content li {
    position: relative;
    padding: 9px 0 0 14px;
    line-height: 35px;
    border-left: 1px solid #d9d9d9;
    color: #999;
    &:last-of-type{
      border: none;
    }
  }

  .progress-content li.first {
    padding-top: 0;
    // border-left-color: #fff;
  }

  .progress-content li .node-icon {
    position: absolute;
    left: -6px;
    top: 0;
    width: 11px;
    height: 11px;
    background: #000000;
    background: url(http://hovertree.com/texiao/css/25/img/order-icons.png) -21px -72px
      no-repeat;
  }

  .progress-content li.first .node-icon {
    background-position: 0 -72px;
  }

  .progress-content li .time {
    margin-right: 15px;
    position: relative;
    top: -14px;
    display: inline-block;
    vertical-align: middle;
  }

  .progress-content li .mon {
    margin-right: 10px;
    position: relative;
    top: -13px;
    display: inline-block;
    vertical-align: middle;
  }
  .progress-content li .s {
    margin-right: 15px;
    position: relative;
    top: -13px;
    display: inline-block;
    vertical-align: middle;
  }

  .progress-content li .txt {
    position: relative;
    top: -12px;
    vertical-align: middle;
  }

  .progress-content li.first .txt {
    max-width: 600px;
  }
</style>
