Poster.vue
2.8 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
<van-overlay :show="show">
<!-- z-index="9999999" -->
<div
class="wrapper"
@click.stop
>
<div class="img">
<div
class="sprite-icon icon-poster-close"
@click.prevent="close"
></div>
<van-image
:src="activityData.posterUrl"
width="100%"
height="100%"
>
<template v-slot:loading>
<van-loading
type="spinner"
size="20"
/>
</template>
</van-image>
</div>
<div class="btns flex">
<div
class="save text-center"
@click.prevent="save"
>保存到相册</div>
<div
class="share text-center"
@click.prevent="share"
>分享</div>
</div>
</div>
</van-overlay>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'Poster',
props: ['value', 'apiName', 'currentItem', 'activityData'],
data() {
return {
show: false,
img: null
}
},
mounted() {},
watch: {
value(n) {
this.show = n
}
},
methods: {
close() {
this.show = false
this.$emit('close')
},
save() {
this.showToast('请长按海报保存')
},
share() {
let { currentItem, apiName, activityData } = this
let flag = apiName != 'shopmallApi'
if (currentItem.userId) {
console.log(activityData)
window.$wx
.sendChatMessage({
msgtype: 'image',
image: {
mediaid: activityData.posterMediaId
},
enterChat: false
})
.then(() => {
this.showToast('发送成功')
})
} else {
window.$wx
.shareAppMessage({
imgUrl: flag ? currentItem.shareImgUrl : currentItem.goodsImage,
title: flag ? currentItem.name : currentItem.goodsName,
link: flag ? activityData.pagePath : activityData.url
})
.then(res => {
this.showToast('发送成功')
})
}
}
}
}
</script>
<style scoped lang='scss'>
.van-overlay {
position: absolute;
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
flex-direction: column;
.img {
width: 254px;
height: 452px;
position: relative;
.icon-poster-close {
position: absolute;
top: -10px;
right: -10px;
z-index: 2;
}
}
.btns {
width: 254px;
justify-content: space-between;
margin-top: 16px;
.text-center {
width: 119px;
height: 32px;
border-radius: 16px;
font-size: 14px;
color: #ffffff;
}
.save {
background: rgba(0, 0, 0, 0.3);
}
.share {
background: var(--themeColor);
}
}
}
</style>