<template>
  <div class="plan-container">
    <card
      :title="item.title"
      :content="item.desc"
      v-for="(item, index) in detail"
      :key="index"
      :footer="item.url"
      :class="{ 'no-url': !item.url }"
    >
      <a href="javascript:;" @click="openIframePupop(index)" v-if="item.url" slot="footer">
        {{ item.url }}
      </a>
    </card>
    <protocol-iframe v-model="popupShow" :title="pupopData.title" :content="pupopData.list" />
  </div>
</template>
<script>
import protocolIframe from "./modules/ProtocolIframe";
import card from "@/components/Card";

import detail from "@/api/detail.plan.mock";
export default {
  name: "GoodsDetail",
  components: {
    card,
    protocolIframe
  },
  data() {
    return {
      detail,
      popupShow: false,
      currentPupopIndex: null
    };
  },
  computed: {
    pupopData() {
      const { detail, currentPupopIndex } = this;
      const { title, list } = detail[currentPupopIndex] || { title: "", list: "" };
      return {
        title: title.substring(0, title.length - 3),
        list
      };
    }
  },
  methods: {
    openIframePupop(index) {
      this.currentPupopIndex = index;
      this.popupShow = true;
    }
  }
};
</script>
<style lang="less" src="./plan.less" scoped></style>
