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
<template>
<div>
<mt-popup
style="background: transparent"
v-model="shareVisible"
class="refer-share"
position="top">
<img style="width: 80vw" :src="shareUrl">
</mt-popup>
<div style="padding: 10px">
<mt-field label="分享标题" type="textarea" placeholder="请输入分享标题" rows="4" v-model="title"></mt-field>
<mt-field label="分享链接" type="textarea" placeholder="请输入分享链接" rows="4" v-model="link"></mt-field>
<mt-field label="分享描述" type="textarea" placeholder="请输入分享描述" rows="4" v-model="desc"></mt-field>
<div style="width: calc(100vw - 20px);margin:0">
<mt-button type="primary" size="large" @click="sharePage()">分享</mt-button>
</div>
</div>
</div>
</template>
<script>
import {getwechatParam} from "../service/api";
import shareUrl from '../assets/Bitmap@2x.png'
import {Popup,Field,Button} from 'mint-ui'
export default {
name: "shareConfig",
components:{
[Popup.name]:Popup,
[Field.name]:Field,
[Button.name]:Button
},
data(){
return {
desc:'赠你1元领取价值398元课程特权,和我一起快乐启蒙英语吧',
shareUrl:shareUrl,
title:'我家宝宝正在【唱唱启蒙英语】挑战童谣,已坚持1天',
link:window.location.href.split('#')[0],
shareVisible:false,
}
},
methods:{
enableShare: function(option) {
getwechatParam({
api_list: 'onMenuShareAppMessage,onMenuShareTimeline',
url:window.location.href.split('#')[0]
}).then(wechatRes => {
wx.config({
debug: false,
appId: wechatRes.appId,
timestamp: parseInt(wechatRes.timestamp),
nonceStr: wechatRes.nonceStr,
signature: wechatRes.signature,
jsApiList: wechatRes.jsApiList
});
wx.ready(function() {
wx.onMenuShareTimeline({
title: option.product_title, // 分享标题
desc: option.desc,// 分享描述
link: option.shareUrl, // 分享链接
imgUrl: option.shareIcon || 'https://cdn.singsingenglish.com/singsing/recommend/logo-refer.png', // 分享图标
success: function() {
},
cancel: function() {
}
});
wx.onMenuShareAppMessage({
title: option.product_title, // 分享标题
desc: option.desc,// 分享描述
link: option.shareUrl, // 分享链接
imgUrl: option.shareIcon || 'https://cdn.singsingenglish.com/singsing/recommend/logo-refer.png', // 分享图标
success: function() {
},
cancel: function() {
}
});
})
})
},
sharePage(){
this.enableShare({
product_title:this.title, // 分享标题
desc: this.desc,//
shareIcon:'https://cdn.singsingenglish.com/logo/logo.jpg',
shareUrl:this.link
});
this.shareVisible=true
}
}
}
</script>
<style scoped>
</style>