<template>
  <div class="application_info" v-if="data">
    <div class="main_container">
      <div class="main_container-left" v-if="data.logo">
        <el-avatar shape="square" :size="144" fit="cover" :src="data.logo" />
      </div>
      <div class="main_container-right">
        <div class="application_title">
          <span class="application_name" v-text="data.app_name"></span>
        </div>
        <div class="application_base_container">
          <ul class="application_base_info">
            <li>
              <span>应用开发者：</span>
              <span v-text="data.username"> </span>
            </li>
            <li>
              <span>应用类型：</span>
              <span v-html="data.type_name"></span>
            </li>
          </ul>
          <ul class="application_base_info">
            <li>
              <span>部署次数：</span>
              <span v-text="data.deploy_times"></span>
            </li>
            <li>
              <span>业务领域：</span>
              <span v-text="data.ywly_name"></span>
            </li>
          </ul>
          <ul class="application_base_info">
            <li>
              <span>上线时间：</span>
              <span v-text="data.create_date"></span>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="commodity_information">
      <span>规&emsp;&emsp;格：</span>
      <div class="btn_container">
        <el-button
          v-for="(item, index) in specifications"
          :key="'specifications_' + index"
          :type="
            item.value === commodityData.specification ? 'primary' : 'default'
          "
          @click="changeSpecification(item)"
        >
          {{ item.name }}
        </el-button>
      </div>
    </div>
    <div class="commodity_action">
      <el-button type="warning" plain @click="addToCart">
        加入购物车
      </el-button>
      <el-button type="warning" @click="applyImmediately">
        立即申请
      </el-button>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default: () => null,
    },
  },
  data: () => ({
    specifications: [
      {
        name: "1.申请获取应用镜像部署权限",
        value: 1,
      },
      {
        name: "2.申请获取应用二次开发权限（需要先行升级为开发者用户）",
        value: 2,
      },
    ],
    commodityData: {
      specification: 1,
    },
  }),
  methods: {
    changeSpecification({ value }) {
      this.commodityData.specification = value;
    },
    addToCart() {
      console.log("addToCart");
      console.log(this.commodityData);
    },
    applyImmediately() {
      console.log("applyImmediately");
      console.log(this.commodityData);
    },
  },
};
</script>

<style scoped>
.application_info {
  padding: 20px;
  background-color: #fff;
  margin-bottom: 20px;
}
.main_container {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 25px;
}
.main_container-left {
  padding: 3px;
  background-color: #f9fafc;
  margin-right: 10px;
}
.main_container-right {
  flex-grow: 1;
}
.application_title > .application_name {
  font-size: 22px;
  font-weight: bold;
  color: #0d1847;
  line-height: 36px;
}
.application_base_container {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  background-color: #f9fafc;
  padding: 18px;
  margin-top: 15px;
}
.application_base_info:not(:last-child) {
  margin-right: 50px;
}
.application_base_info > li {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  font-size: 14px;
  color: #242c43;
  line-height: 20px;
}
.application_base_info > li > span:first-child {
  width: 6em;
  flex-shrink: 0;
  white-space: nowrap;
  color: #8890a7;
  text-align: right;
}
.application_base_info > li:not(:first-child) {
  margin-top: 20px;
}
.application_base_info > li > span:nth-child(2) {
  color: #242c43;
}
.commodity_information {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 30px;
}
.commodity_information > span:first-child {
  flex-shrink: 0;
  width: 6em;
  font-size: 14px;
  color: #8890a7;
  line-height: 40px;
}
.commodity_information > .btn_container {
  margin-bottom: -15px;
}
.commodity_information > .btn_container > .el-button {
  margin: 0 30px 15px 0;
}
.commodity_action {
  margin-top: 50px;
  text-align: right;
}
.commodity_action > .el-button {
  width: 220px;
  margin-left: 20px;
}
.application_info .el-button--primary {
  background-color: #515fe7;
  border-color: #515fe7;
}
.application_info .el-button--warning.is-plain {
  background-color: #fcefd6;
  border-color: #fac266;
  color: #e56600;
}
.application_info .el-button--warning {
  background-color: #e56600;
  border-color: #e56600;
}
</style>
