<template>
  <modal v-model="show" :closeable="true" cancel-btn="" confirm-btn="好的 继续" @confirm="go">
    <h4 slot="title">立即拥有<br />{{ title }}</h4>
    <compactCellGroup class="pay-det" :cell-data="payCellData" :text-bold="true" />
    <div class="pay-tip">*不满意可随时退保</div>
    <div class="pay-protocol">
      <div class="pay-protocol-tip">投保前请阅读</div>
      <div class="pay-protocol-link">
        <a href="javascript:;" @click="openIframePupop(0)">保险条款</a>
        <i></i>
        <a href="javascript:;" @click="openIframePupop(1)">健康告知</a>
        <i></i>
        <a href="javascript:;" @click="openIframePupop(2)">投保须知与声明</a>
        <i></i>
        <a href="javascript:;" @click="openIframePupop(3)">服务协议</a>
      </div>
    </div>
  </modal>
</template>

<script>
import CompactCellGroup from "@/components/CompactCellGroup";
import Modal from "@/components/Modal";
const DIALOG_CHANGE_EVENT = "input";
export default {
  name: "GoInsureDialog",
  components: {
    CompactCellGroup,
    Modal
  },
  props: {
    value: null,
    title: {
      type: String,
      default: ""
    },
    payData: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      show: false,
      payCellData: [
        { title: "首月保费", value: "3元" },
        {
          title: "次月保费",
          value: "5.6元/月起（共11期）"
        }
      ]
    };
  },
  watch: {
    value(val) {
      this.show = val;
    },
    show(val) {
      this.$emit(DIALOG_CHANGE_EVENT, val);
    }
  },
  methods: {
    openIframePupop(index) {
      this.$parent.openIframePupop(index);
    },
    go() {
      this.$router.push("/goods/inform");
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../../../style/var.less";
.panel {
  background-color: @white;
  border-radius: @border-radius-md;
  width: 300px;
  &-wrap {
    overflow: initial;
    @{deep} .cr-popup--close {
      top: -36px;
      right: 0;
      color: @white;
      font-size: 24px;
    }
  }
  &-head {
    border-top-left-radius: @border-radius-md;
    border-top-right-radius: @border-radius-md;
    padding: @padding-lg @padding-lg 5px @padding-lg;
    background: url("../../../../assets/dialog-header-bg.png") right no-repeat;
    background-size: 34px 25px;
    background-position: right center;
    h4 {
      color: @black;
      font-size: @font-size-18;
      font-weight: @font-weight-bold;
      line-height: @line-height-lg + 1;
    }
  }
  &-body {
    padding: @padding-lg;
  }
  &-foot {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: @padding-lg;
  }
}
.pay {
  &-det {
    padding-left: 34px;
    position: relative;
    &::after,
    &::before {
      content: " ";
      display: block;
      position: absolute;
      left: 18px;
      width: 8px;
      height: 8px;
      border-radius: @border-radius-max;
      border: 1px solid @black;
    }
    &::before {
      background-color: @orange-light;
      top: 24px;
    }
    &::after {
      bottom: 26.5px;
    }
    @{deep} & > div:first-child {
      position: absolute;
      left: 22.5px;
      top: 35px;
      height: 14px;
      width: 0;
      border-right: 1px dotted @gray-4;
    }
  }
  &-tip {
    font-size: @font-size-12;
    color: @gray-4;
    line-height: @line-height-lg;
    margin: 12px 0;
  }
  &-protocol {
    margin-bottom: 18px;
    &-tip {
      font-size: @font-size-12;
      color: @gray-4;
      line-height: @line-height-lg;
      margin-bottom: 4px;
    }
    &-link {
      a {
        font-size: @font-size-12;
        vertical-align: middle;
      }
      i {
        display: inline-block;
        width: 0;
        height: 12px;
        border-right: 1px @blue solid;
        vertical-align: middle;
        margin: 0 3px;
      }
    }
  }
}
</style>
