<template>
  <div class="insurance-bindCode-success">
    <page-model
      v-if="picaWechat != 'wechat'"
      ref="PageModel"
      :header-info="headerInfo"
    />
    <div class="detail-box">
      <div class="status">
        <img
          src="https://files.yunqueyi.com/image/png/common/20230301101427839.png"
          alt="success"
        >
        <div class="text">
          提交成功
        </div>
      </div>
      <div class="content">
        <div class="info">
          <div class="blue-wrap">
            <div class="list">
              <div class="l-left">
                条形码:
              </div>
              <div class="l-right">
                {{ dataDetail.sampleCode || '--' }}
                <div
                  class="l-copy"
                  @click="copyText(dataDetail.sampleCode)"
                >
                  复制
                </div>
              </div>
            </div>
            <div class="list">
              <p class="l-left">
                受检人:
              </p>
              <p class="l-right">
                <span>{{ dataDetail.patientName || '--' }}</span><span>{{ dataDetail.sex | sexFilter }}</span><span class="font">{{
                  dataDetail.ageMonth
                    ? dataDetail.ageMonth + '月'
                    : dataDetail.patientAge + '岁'
                }}</span>
              </p>
            </div>
            <div class="list">
              <p class="l-left">
                检测项目:
              </p>
              <p class="l-right">
                {{ dataDetail.checkName || '--' }}
              </p>
            </div>
            <!--            <div class="list">-->
            <!--              <p class="l-left">-->
            <!--                检测编号:-->
            <!--              </p>-->
            <!--              <p class="l-right">-->
            <!--                {{ dataDetail.recordNo || '&#45;&#45;' }}-->
            <!--              </p>-->
            <!--            </div>-->
          </div>
        </div>
      </div>
    </div>

    <div
      class="sumbit-container"
    >
      <div
        class="sumbit-button"
        @click="bottomBtnFun"
      >
        查看我的检测
      </div>
    </div>
    <div
      class="wechat-wrap"
      @click="towechat"
    >
      <img
        src="https://files.yunqueyi.com/image/gif/common/20230301171528895.gif"
        alt=""
      >
    </div>
  </div>
</template>
<script>
import { detectionRecordInfo } from '@/api/detection';
import {mapGetters} from 'vuex';
import store from 'storejs';
export default {
  filters: {
    sexFilter(val) {
      const str = val == 2 ? '女' : '男';
      return str;
    },
  },
  data() {
    return {
      picaWechat:window._picaWechat,
      status: '',
      headerInfo: {
        title: '检测服务',
        isBlack: true,
        backMethod: 'web',
        style: 'backgroundColor:#ffffff;zIndex:100;',
        background: '',
      },
      dataDetail: {},
      detectionRecordId: '',
      yunOrderNo: ''
    };
  },
  computed: {
    ...mapGetters('home', ['insuranceInfo']),
  },
  created() {
    const {detectionRecordId, yunOrderNo} = this.$route.query;
    this.detectionRecordId = detectionRecordId;
    this.yunOrderNo = yunOrderNo;
    this.detectionRecordInfo();
  },
  mounted() {
    this.$sendBuriedData({
      action: 'ACTION_WEB_AFTER',
      component_tag: '7802847#0#0#绑定成功页面',
      web_data:{yunOrderNo: this.yunOrderNo},
    });
  },
  methods: {

    detectionRecordInfo() {
      const in_info = store.get('insuranceInfo');
      const o = {
        detectionRecordId: this.detectionRecordId,
        detectionKind: in_info.detectionKind
      };
      detectionRecordInfo(o).then((res) => {
        if (res.code === '000000') {
          this.dataDetail = res.data;
        } else {
          this.$toast(res.message);
        }
      });
    },
    // 检测详情
    bottomBtnFun() {
      const in_info = store.get('insuranceInfo');
      const url = in_info.detectionKind == 1 ? '/insuranceQuickDetectionDetail' : '/insuranceDetectionDetail';
      this.$sendBuriedData({
        action: 'ACTION_WEB_CLICK',
        component_tag: '7802847#0#0#查看我的检测',
        web_data:{yunOrderNo: this.yunOrderNo},
      });
      const u = window.location.origin + '/pica-insurance' + url + `?detectionRecordId=${this.detectionRecordId}&yunOrderNo=${this.yunOrderNo}`;
      window.location.href = u;
      // this.$router.push({
      //   path: url,
      //   query: {
      //     detectionRecordId: this.detectionRecordId,
      //     yunOrderNo: this.yunOrderNo
      //   },
      // });
    },
    copyText(item) {
      const input = document.createElement('input');
      input.value = item;
      document.body.appendChild(input);
      input.select();
      input.setSelectionRange(0, input.value.length);
      document.execCommand('Copy');
      document.body.removeChild(input);
      this.$toast('已复制');
    },
    towechat() {
      window.location.href = 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzIyOTY2MTI0MQ==#wechat_redirect';
    }
  },
};
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
