<template>
  <div class="inform-container">
    <div class="inform-notice">
      <cr-tag type="danger">重要</cr-tag>
      <div class="inform-notice-content">
        为保证被保险人的保险权益在理赔时不受影响，请确认被保险人健康状况是否符合以下投保条件：
      </div>
    </div>
    <card title="true" class="inform-content">
      <span slot="title" class="inform-content-title">
        请如实告知
        <strong>被保人</strong> 是否有以下情形之一
      </span>
      <iframe class="inform-frame" :src="url" frameborder="0" height="100%"></iframe>
    </card>
    <div class="inform-btns">
      <cr-button @click="$router.back()">不符合</cr-button>
      <cr-button type="warning" @click="conform">符合，立即投保</cr-button>
    </div>
  </div>
</template>

<script>
import card from "@/components/Card";
import detailPayMixin from "../Detail/modules/detailPay.mixin";
export default {
  name: "GoodsInform",
  mixins: [detailPayMixin],
  components: {
    card
  },
  data() {
    return {
      formData: JSON.parse(sessionStorage.getItem("policyFormData") || "{}"),
      orderInfo: {},
      tradeType: "JSAPI",
      url: "http://mangguo-contract.qthbx.com/huatai-jian-kang-gao-zhi-v1/"
    };
  },
  methods: {
    conform() {
      // this.$router.push(`/policy/detail/123`);
      this.generateFormData();
      this.generateOrder();
    },
    generateFormData() {
      const subFromData = JSON.parse(JSON.stringify(this.formData));
      const {
        userInfoSecId,
        name,
        idNo,
        relation,
        socialSecurity,
        selfSocialSecurity,
        selfName,
        selfIdNo,
        selfPhone,
        selfSecId,
        payType,
        autoRenewPolicy
      } = subFromData;
      this.subFromData = {
        productNo: this.goodId,
        holderUserInfo: {
          phoneNo: selfPhone,
          userInfoSecId: selfSecId ? selfSecId : null,
          name: selfName,
          idNo: selfIdNo
        },
        productItem: {
          payType
        },
        autoRenewPolicy: autoRenewPolicy
      };
      if (relation === "1") {
        this.subFromData.holderUserInfo.socialSecurity = !!Number(selfSocialSecurity);
      } else {
        this.subFromData.insuredUserInfo = {
          userInfoSecId: userInfoSecId ? userInfoSecId : undefined,
          name,
          idNo,
          relation,
          socialSecurity: !!Number(socialSecurity)
        };
      }
    }
  }
};
</script>
<style lang="less" src="./index.less" scoped></style>
