<template>
  <cr-popup
    v-model="show"
    :style="{ backgroundColor: 'transparent' }"
    closeable
    get-container="body"
    close-icon="close"
    class="panel-wrap"
  >
    <div class="panel">
      <div class="panel-head">
        <h4>
          立即拥有
          <br />30万重疾轻症保障
        </h4>
      </div>
      <div class="panel-body">
        <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>
        <cr-button type="warning" size="large" block @click="go">好的 继续</cr-button>
      </div>
    </div>
  </cr-popup>
</template>

<script>
import compactCellGroup from "./CompactCellGroup";
const DIALOG_CHANGE_EVENT = "input";
export default {
  name: "GoInsureDialog",
  components: {
    compactCellGroup
  },
  props: {
    value: null
  },
  data() {
    return {
      show: false,
      payCellData: [
        { title: "首月保费", value: "1元" },
        {
          title: "次月保费",
          value: {
            tpl: "100.00元/月（共11期）",
            longTxt: true
          }
        }
      ]
    };
  },
  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>
