<template>
  <div class="view-code">
    <!-- {{hash}} -->
    <div class="container">
      <VueQr
        class="qr-code"
        :text="locationUrl"
        :size="220"
        :callback="vueQrCb"
      />
      <div>
        <a class="btn-save" download="存证二维码.png" :href="dataUrl"
          >保存二维码</a
        >
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import VueQr from 'vue-qr';

import { Component, Prop, Vue } from 'vue-property-decorator';

@Component({
  components: {
    VueQr,
  },
})
export default class ViewCode extends Vue {
  @Prop() locationUrl!: string;

  private dataUrl = '';

  get hash() {
    return this.$route.query.hash;
  }
  private vueQrCb(dataUrl: string) {
    this.dataUrl = dataUrl;
  }
}
</script>
<style lang="scss" scoped>
.view-code {
  min-height: 100vh;
  background: #333648;
  display: flex;
  justify-content: center;
  padding-top: 52px;
  .container {
    text-align: center;
    width: 332px;
    height: 408px;
    background: #ffffff;
    box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.09);
    border-radius: 5px;
    border-radius: 10px;
    .qr-code {
      margin-top: 45px;
      margin-bottom: 33px;
    }
    .btn-save {
      display: inline-block;
      width: 200px;
      height: 40px;
      background: linear-gradient(180deg, #4667fa 0%, #5b77f4 100%);
      box-shadow: 0px 2px 15px 0px rgba(63, 121, 254, 0.42);
      border-radius: 4px;
      line-height: 40px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
    }
  }
}
</style>
