<template>
  <div class="reportdetail">
    <!-- <nav-header title="自主申报预约详情" @back="$router.go(-1)" /> -->
    <div class="main">
      <div class="reprtInfo">
        <div class="title">
          <div class="icon"></div>
          <p>订单信息</p>
        </div>
        <div class="cell">
          <p class="cell-title">联系人信息</p>
          <div class="cell-detail">
            <p class="label">联系人姓名</p>
            <p class="value">{{ detail.name }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">手机号码</p>
            <p class="value">{{ detail.phone }}</p>
          </div>
        </div>
        <div class="cell">
          <p class="cell-title">车辆信息</p>
          <div class="cell-detail">
            <p class="label">车牌号</p>
            <p class="value">{{ detail.carNumber }}</p>
          </div>
          <div
            v-for="diver in detail.driverSelfList"
            :key="diver.driverSelfCode"
          >
            <div class="cell-detail">
              <p class="label">司机姓名</p>
              <p class="value">{{ diver.driverName }}</p>
            </div>
            <div class="cell-detail">
              <p class="label">联系方式</p>
              <p class="value">{{ diver.driverPhone }}</p>
            </div>
            <div class="cell-detail">
              <p class="label">身份证号码</p>
              <p class="value">{{ diver.idCard }}</p>
            </div>
          </div>
        </div>
        <div
          class="cell"
          v-for="item in detail.goodsList"
          :key="item.goodsSelfCode"
        >
          <p class="cell-title">商品信息</p>
          <div class="cell-detail">
            <p class="label">报关单号(海关编号)</p>
            <p class="value">{{ item.customs }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">货主所属企业名称</p>
            <p class="value">{{ item.shipperEnterprise }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">统一社会信用代码</p>
            <p class="value">{{ item.credit }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">货主联系人</p>
            <p class="value">{{ item.shipper }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">货主联系方式</p>
            <p class="value">{{ item.shipperPhone }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">货主身份证号码</p>
            <p class="value">{{ item.shipperIdCard }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">是否有集装箱</p>
            <p class="value">{{ item.container === "1" ? "是" : "否" }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">商品名称</p>
            <p class="value">{{ item.goodsName }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">原产地</p>
            <p class="value">{{ item.placeOrigin }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">注册编号</p>
            <p class="value">{{ item.register }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">生产日期</p>
            <p class="value">{{ item.productionTime }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">生产批号</p>
            <p class="value">{{ item.productionNumber }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">总重量(KG)</p>
            <p class="value">{{ item.weight }}</p>
          </div>
          <div class="cell-detail">
            <p class="label">是否在镇江销售</p>
            <p class="value">{{ item.goodsState === 1 ? "是" : "否" }}</p>
          </div>
          <div class="photo">
            <div
              class="photo-card"
              v-for="photo in item.pictureList"
              :key="photo.pictureType"
            >
              <img
                :src="photo.picture"
                alt=""
                @click="imgpreview(photo.picture)"
              />
              <p>
                {{
                  photo.pictureType === 1
                    ? "报关单照片"
                    : photo.pictureType === 2
                    ? "货物清单照片"
                    : photo.pictureType === 3
                    ? "检疫证照片"
                    : "有效《出库证明》"
                }}
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
// import NavHeader from "@/components/NavHeader";
import { ImagePreview } from "vant";
import { getSelf } from "@/api/coldfood";
import { encryptByDES } from "@/utils/utils";

Vue.use(ImagePreview);

export default {
  components: {
    // NavHeader
  },
  data() {
    return {
      userInfo: {},
      detail: {}
    };
  },
  methods: {
    init() {
      this.$toast.loading({
        duration: 0, // 持续展示 toast
        forbidClick: true,
        message: "加载中..."
      });
      let params = {
        appId: 1234,
        userId: encryptByDES(this.userInfo.userId, "MnuYbhGv")
      };
      getSelf(params).then(res => {
        this.$toast.clear();
        this.detail = res.data;
        this.detail.name = res.data.name.substring(0,1)+(res.data.name.length == 2 ? '*' : '**');
        this.detail.phone = res.data.phone.substring(0,3)+'****'+res.data.phone.substring(7,12);
        console.log(this.detail);
      });
    },
    imgpreview(url) {
      ImagePreview({
        images: [url]
      });
    }
  },
  created() {
    let res = sessionStorage.getItem("ZJCD-UserInfo");
    this.userInfo = JSON.parse(res);
    if (this.userInfo.userId) {
      this.init();
    }
  }
};
</script>

<style lang="stylus" scoped>
.reportdetail {
  .main {
    height: 100vh
    overflow-y: auto;

    .stateInfo {
      background: #fff;
      height: 80px;
      padding: 0 30px;
      line-height: 80px;
      font-size: 28px;
      color: #666666;

      span {
        color: #EB4E3F;
        font-weight: 600;
      }
    }

    .address {
      margin-top: 6px;
      padding: 20px 30px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #fff;

      .info {
        display: flex;
        align-items: center;

        .label {
          font-size: 28px;
          color: #666666;
        }

        .value {
          width: 448px;
          font-size: 28px;
          color: #333333;
        }
      }

      img {
        width: 72px;
        height: 72px;
      }
    }

    .reason {
      margin-top: 6px;
      padding: 20px 30px;
      background: #fff;
      font-size: 28px;
      color: #666666;

      span {
        color: #EB4E3F;
        font-weight: 600;
      }
    }

    .reprtInfo {
      margin-top: 20px;

      .title {
        height: 80px;
        padding: 0 20px;
        display: flex;
        align-items: center;
        background: #fff;

        .icon {
          width: 6px;
          height: 32px;
          margin-right: 10px;
          background: #EB4E3F;
        }

        p {
          font-size: 32px;
          font-weight: 600;
          color: #333333;
        }
      }

      .prove {
        padding: 0 30px;
        background: #fff;
      }

      .cell {
        margin-top: 6px;
        background: #fff;

        .cell-title {
          height: 80px;
          padding: 0 30px;
          line-height: 80px;
          font-size: 28px;
          font-weight: 600;
          color: #333333;
          border-bottom: 1px solid #eee;
        }

        .cell-detail {
          padding: 30px;
          display: flex;
          border-bottom: 1px solid #eee;

          .label {
            width: 200px;
            font-size: 28px;
            font-weight: 400;
            color: #666666;
          }

          .value {
            margin-left: 30px;
            font-size: 28px;
            color: #333333;
          }
        }

        .cell-detail:last-child {
          border-bottom: 0;
        }

        .photo {
          padding: 30px;
          display: flex;
          flex-wrap: wrap;
          align-items: center;
          justify-content: space-between;

          .photo-card {
            margin-top: 10px;

            img {
              width: 200px;
              height: 200px;
            }

            p {
              margin-top: 20px;
              text-align: center;
              font-size: 28px;
              color: #999999;
            }
          }
        }
      }
    }
  }
}
</style>