<template>
  <el-dialog
    :title="modalTitle"
    :visible.sync="modalVisible"
    :width="formLabelWidth"
    top="2vh"
    @close="handleCancel">
    <div class="mobile">
        <iframe
        v-if="showStatus"
        :src="cardShowUrl
        + 'credentialNo=' + datas.credentialNo
        + '&certName=' + datas.certName
        + '&carbonAmount=' + datas.carbonAmount
        + '&orderAmount=' + datas.orderAmount
        + '&buyDate=' + datas.buyDate
        + '&year=' + datas.year
        + '&farmerName=' + datas.farmerName
        + '&isH5=false'"
        frameborder="0"
        width="100%"
        height="500px"></iframe>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { cardshowInfo } from "@/api/cardshow";
export default {
  name: 'cardshow',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: 'title'
    },
    selectRow: {
      type: Object,
      default:null
    }
  },
  watch: {
    visible(newVal, oldVal) {
      this.modalVisible = newVal;
    },
    title(newVal, oldVal) {
      this.modalTitle = newVal;
    },
    selectRow(newVal, oldVal) {
      this.modalSelectRow = newVal;
    }
  },
  data() {
    return {
      modalTitle: this.title,
      modalVisible: this.visible,
      modalAction: this.action,
      modalSelectRow: this.selectRow,
      formLabelWidth: '424px',
      showStatus:false,
      //窗口权限
      limit: {
        isRead: false, //是否只读
        isAdd: false //是否可写
      },
      datas:{
        credentialNo:''
      }
    };
  },
  created() {
    this.initDatas(this.modalSelectRow)
  },
  methods: {
    //数据初始化
    initDatas(item){
      let params = {
        guid:item.guid
      }
      cardshowInfo(params).then(res => {
          if(res.retHead.errCode == 0){
            this.datas = res.retBody
            this.datas.certName = this.datas.certType == 1 ? this.datas.customerName : this.datas.companyName //1普通用户 2企业用户
            this.showStatus = true
          }
        }
      );
    },
    //窗口关闭
    handleCancel() {
      this.$emit('closeCardShowModal', false);
    }
  }
};
</script>

<style lang="scss" scoped>

</style>
