<template>
  <d2-container v-loading="isLoading">
    <div>
      <div class="providerOrderList-container"
           style="margin-top:20px">
        <div class="d-f-j"
             style="  background: #f2f3f5;">
          <div style=""
               class="d-f-j">
            <div class="name">商家名称：</div>
            <div class="name">{{datas.companyName}}</div>
          </div>
          <div class="name modify"></div>
        </div>
      </div>

      <div class="providerOrderList-container"
           style="margin-top:20px">
        <div class="d-f-j"
             style="  background: #f2f3f5;">
          <div style=""
               class="d-f-j">
            <div class="name">截止时间：</div>
            <div class="name">{{datas.dataTime}}</div>
          </div>
          <div class="name modify"></div>
        </div>
      </div>

      <div class="providerOrderList-container"
           style="margin-top:20px">
        <div class="d-f-j"
             style="  background: #f2f3f5;">
          <div style=""
               class="d-f-j">
            <div class="name">商家图片</div>
          </div>
          <div class="name modify"></div>
        </div>
      </div>
      <div class="image">
        <img :src="image"
             alt="">
      </div>

      <div class="providerOrderList-container">
        <div class="d-f-j"
             style="  background: #f2f3f5;">
          <div>
            <div class="name"> 介绍信息</div>
          </div>
          <div class="name modify"></div>
        </div>
      </div>
      <div class="input-box">
        <el-input type="textarea"
                  :disabled="true"
                  :autosize="{ minRows: 6, maxRows: 11}"
                  placeholder="请输入内容"
                  height='200'
                  v-model="textarea2">
        </el-input>
      </div>
    </div>
  </d2-container>
</template>

<script>
import {
  getBusinessImg,
  getBusinessInit,
  getBusiness,
  getBusinessSupplierDeadline,
} from "@/libs/common/constant";

export default {
  data() {
    return {
      isLoading: false,
      openId: this.$route.params.id,
      textarea2: "",
      image: "",
      datas: {},
    };
  },
  async created() {
    this.isLoading = true;
    await this.obtain();
  },

  methods: {
    async obtain() {
      await this.getBusiness();
      await this.getBusinessImg();
      await this.getBusinessInit();
      await this.getBusinessSupplierDeadline();
      this.isLoading = false;
    },
    async getBusiness() {
      const res = await this.$api.GET(`${getBusiness.url}${this.openId}`);
      this.datas = { ...res.info, ...res.company };
    },
    async getBusinessImg() {
      const res = await this.$api.GET(`${getBusinessImg.url}${this.openId}`);
      if (res.length > 0) {
        this.image = res[0].url || "";
      }
    },
    async getBusinessInit() {
      const res = await this.$api.GET(`${getBusinessInit.url}${this.openId}`);
      if (res) {
        this.textarea2 = res || "";
      }
    },
    async getBusinessSupplierDeadline() {
      const res = await this.$api.GET(
        `${getBusinessSupplierDeadline.url}${this.openId}`
      );
      var lunchTime = "";
      var dinnerTime = "";
      for (var i = 0; i < res.length; i++) {
        if (res[i].type === 2) {
          lunchTime = res[i].deadline;
        }
        if (res[i].type === 3) {
          dinnerTime = res[i].deadline;
        }
      }
      var dataTime = `午餐：${lunchTime}   晚餐：${dinnerTime}`;
      this.datas.dataTime = dataTime;
    },
  },
};
</script>

<style lang="scss" scoped>
.d-f-j {
  display: flex;
  justify-content: space-between;
}
.df {
  display: flex;
}
.name {
  height: 50px;
  line-height: 50px;
  margin-left: 10px;
}
.modify {
  margin-right: 20px;
  color: blue;
  cursor: pointer;
}
.button {
  margin-top: 20px;
  margin-right: 10px;
}
.left {
  width: 200px;
  line-height: 40px;
  margin-left: 30px;
}
.right {
  line-height: 40px;
  margin-right: 30px;
}
.input-box {
  margin-top: 20px;
  margin-left: 10px;
  width: 400px;
  // height: 200px;
}
.image {
  margin-top: 20px;
  margin-left: 10px;
  margin-bottom: 20px;
  img {
    width: 350px;
  }
}
</style>
