<template>
  <div class="preview-protocol-wrapper dialog-title-border">
    <el-dialog
      title="用户协议"
      :visible="dialogVisible"
      @close="close"
      center
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      width="800px"
    > 
      <div slot="title" style="text-align: left;">
        <span style="font-weight: 700;">用户协议</span>
      </div>
      <div style="margin: 20px 20px;height: 400px;padding: 10px 0;" v-html="protocolContent"></div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close(false)">不同意</el-button>
        <el-button type="primary" @click="signProtocol">同意</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {

    };
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    protocolId: {
      type: String | Number,
      default: 1
    },
    protocolContent: {
      type: String,
      default: ''
    }
  },
  computed: {

  },
  mounted() {
    // this.getProtocolInfoById();
  },
  methods: {
    
    // 签署协议
    signProtocol() {
      let req = {
        setEntry: true,
      };
      this.POST("smartcontract/protocol/sign?type=" + this.protocolId, req).then(res => {
        if (res.code == "000000") {
          this.close(true);
        } else {
          vm.$message.info(res.message);
          this.close(false);
        }
      }).catch(err => {
        vm.$message.warning("请稍后重试");
        this.close(false);
      });
    },

    close(status) {
      this.$emit('close', status);
    },
  }
};
</script>
<style scoped lang="scss">
</style>
