shareDialog.vue
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!-- 分享弹窗 -->
<template>
<GLDialog title="分享" mode="mid" okText="关闭" :visible.sync="isShareVisible" :before-close="handleShareClose" :hasFooter="false">
<div class="share-dialog flex">
<div class="flex box poster">
<div>
<p class="share-txt">海报</p>
<!-- <p>小程序码不带参数</p> -->
<img style="width: 170px; height: 271px;" :src="shareForm.posterUrl" />
<el-button style="display: block;margin-top: 16px;" :size="size" type="primary" @click="handleSaveImg(shareForm.posterUrl)">保存图片</el-button>
</div>
</div>
<div style="margin-left: 10px;">
<div class="flex box code">
<div>
<p class="share-txt">小程序码</p>
<!-- <p>小程序码不带参数</p> -->
<img style="width: 120px; height: 120px" :src="shareForm.qrCodeUrl" />
<el-button style="display: block;margin-top: 16px;" :size="size" type="primary" @click="handleSaveImg(shareForm.qrCodeUrl, '小程序码')">保存图片</el-button>
</div>
</div>
<div class="box page-route">
<div>
<p class="share-txt">短链</p>
<div>
<p class="link">{{ shareForm.linkUrl }}</p>
<el-button style="display: block;margin-top: 16px;" :size="size" type="primary" @click="handleSaveTxt(shareForm.linkUrl)">复制链接</el-button>
<!-- <p>链接是直播间原始页面路径,如需加入参数,详见使用方法</p> -->
</div>
</div>
</div>
</div>
</div>
</GLDialog>
</template>
<script>
export default {
name: 'share',
data() {
return {}
},
props: {
isShareVisible: {
type: Boolean,
default: false
},
shareForm: {
type: Object,
default: () => { }
}
},
mounted() { },
methods: {
handleSaveImg(url, downloadTxt = '海报') {
var alink = document.createElement('a')
alink.href = url
alink.setAttribute('target', '_blank')
alink.download = downloadTxt
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: #F8F8F8;
border-radius: 2px;
padding: 20px;
}
.share-dialog .poster {
width: 295px;
height: 425px;
}
.share-dialog .code {
width: 295px;
height: 194px;
}
.share-dialog .page-route {
margin-top: 10px;
width: 295px;
height: 179px;
}
.share-dialog .page-route .link {
width: 295px;
font-family: PingFangSC-Medium;
font-size: 14px;
color: #5092FF;
font-weight: 500;
}
.share-dialog .share-txt {
font-family: PingFangSC-Medium;
font-size: 14px;
color: #333;
font-weight: 500;
margin-bottom: 8px;
}
</style>