shareDialog.vue 2.8 KB
<!-- 分享弹窗 -->
<template>
  <glsx-dialog title="分享" width="806px" :noCancel="true" btnOkLabel="关闭" :isVisible="isShareVisible" @closeDialog="handleShareClose" @confirmDialog="handleShareClose">
    <div class="share-dialog">
      <div class="flex">
        <div class="flex box poster">
          <div>
            <p class="share-txt">海报</p>
            <!-- <p>小程序码不带参数</p> -->
            <el-button :size="size" type="primary" @click="handleSaveImg(shareForm.posterUrl)">保存图片</el-button>
          </div>
          <img :src="shareForm.posterUrl" />
        </div>
        <div class="flex box poster">
          <div>
            <p class="share-txt">小程序码</p>
            <!-- <p>小程序码不带参数</p> -->
            <el-button :size="size" type="primary" @click="handleSaveImg(shareForm.qrCodeUrl)">保存图片</el-button>
          </div>
          <img style="width: 180px; height: 180px" :src="shareForm.qrCodeUrl" />
        </div>
      </div>
      <div class="box page-route">
        <div>
          <p class="route-txt">短链</p>
          <div class="flex">
            <p style="width: 426px;">{{ shareForm.linkUrl }}</p>
            <el-button :size="size" type="primary" @click="handleSaveTxt(shareForm.linkUrl)">复制链接</el-button>
            <!-- <p>链接是直播间原始页面路径,如需加入参数,详见使用方法</p> -->
          </div>
        </div>
      </div>
    </div>
  </glsx-dialog>
</template>

<script>
export default {
  name: 'share',
  data() {
    return {
    }
  },

  props: {
    isShareVisible: {
      type: Boolean,
      default: false
    },
    shareForm: {
      type: Object,
      default: () => {}
    }
  },

  mounted() {},

  methods: {
    handleSaveImg(url) {
      var alink = document.createElement("a")
      alink.href = url
      alink.setAttribute('target', '_blank')
      alink.download = '海报'
      alink.click()
      alink.remove()
    },
    handleSaveTxt(txt) {
      this.$message({
        message: '复制成功',
        type: 'success',
        customClass: 'message-Z-zinde'
      })
      const input = document.createElement('input')
      document.body.appendChild(input)
      input.setAttribute('value', txt)
      input.select()
      document.execCommand('Copy')
      document.body.removeChild(input)
    },
    handleShareClose() {
      this.$emit('handleShareClose')
    }
  }
}

</script>
<style scoped>
.share-dialog .box {
  background: #f7f7f7;
  border-radius: 6px;
  padding: 30px;
}
.share-dialog .poster img {
  width: 180px;
  height: 297px;
  margin-left: 45px;
}
.share-dialog .page-route {
  margin-top: 16px;
}
.share-dialog .page-route .route-txt {
  font-weight: bold;
  padding-bottom: 10px;
}
.share-dialog .share-txt {
  font-weight: bold;
  margin-bottom: 50px;
}
</style>