<template>
  <el-dialog class="express dialog__body__nopadding" title="查看详情" :visible.sync="show" width="40%" :before-close="close">
    <div class="express--info">
      <div v-if="infoStatus === 3">
        <p>
          收件人：<span style="color:#606266">{{ info.consignee || '--' }}</span>
        </p>
        <p>
          联系方式：<span style="color:#606266">{{ info.consigneePhone || '--' }}</span>
        </p>
        <p>
          收货地址：<span style="color:#606266">{{ info.receivingAddress || '--' }}</span>
        </p>
      </div>
      <div v-if="infoStatus === 1">
        <p>发货时间：{{ formateDateTimeByType(info.deliveryTime, 'yyyy-MM-dd-HH-mm') || '--' }}</p>
        <p>操作人员：{{ info.clerkName || '--' }}</p>
        <p>发货内容：{{ info.deliveryContent || '--' }}</p>
      </div>
      <div v-if="infoStatus !== 1">
        <p>取消时间：{{ formateDateTimeByType(info.cancelTime, 'yyyy-MM-dd-HH-mm') || '--' }}</p>
        <p>操作人员：{{ info.clerkName || '--' }}</p>
        <p>取消原因：{{ info.cancelReason || '--' }}</p>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close">关 闭</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { getLogisticsInfo } from '@/service/api/mallApi.js';
import { formateDateTimeByType } from '@/utils/index.js';

export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    id: {
      type: String,
      default: ''
    },
    infoStatus: {
      type: Number,
      default: 0
    }
  },
  watch: {
    show(val) {
      if (val) {
        this.getLogisticsInfo();
      }
    }
  },
  data() {
    return {
      formateDateTimeByType,
      loading: false,
      info: {}
    };
  },
  methods: {
    close() {
      this.$emit('update:show', false);
    },
    async getLogisticsInfo() {
      this.loading = true;
      let res = await getLogisticsInfo({ integralMallProExchangeId: this.id });
      if (res.errorCode === 0) {
        this.info = res.result.changeLog || {};
      }
      this.loading = false;
    }
  }
};
</script>

<style lang="scss" scoped>
.express {
  &--info {
    p {
      line-height: 30px;
      word-break: break-all;
    }
  }
}
</style>
