|
@@ -1,7 +1,5 @@
|
|
|
<template>
|
|
|
- <div id="share">
|
|
|
- <van-button @click="test">分享</van-button>
|
|
|
- </div>
|
|
|
+ <div id="share"></div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -14,23 +12,13 @@ export default {
|
|
|
desc: { type: String, default: '内容' },
|
|
|
img: { type: String, default: '' },
|
|
|
route: { type: String, default: '/' },
|
|
|
- type: { type: String, default: 'py' },
|
|
|
},
|
|
|
components: {},
|
|
|
data: function() {
|
|
|
- return {
|
|
|
- config: {
|
|
|
- shareList: ['weixin'],
|
|
|
- common: {
|
|
|
- bdText: '分享测试',
|
|
|
- bdDesc: '分享测试摘要',
|
|
|
- bdUrl: 'http://broadcast.waityou24.cn/api/article/auth?redirect_uri=http://broadcast.waityou24.cn/articlemobile',
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
+ return {};
|
|
|
},
|
|
|
created() {
|
|
|
- // this.init();
|
|
|
+ this.init();
|
|
|
},
|
|
|
methods: {
|
|
|
...weixin(['jsAuth']),
|
|
@@ -49,25 +37,33 @@ export default {
|
|
|
if (this.$checkRes(res)) {
|
|
|
const { data } = res;
|
|
|
const shareUrl = 'http://broadcast.waityou24.cn/api/article/auth?redirect_uri=http://broadcast.waityou24.cn/articlemobile' + this.route;
|
|
|
- // 'updateTimelineShareData', // 朋友圈及QQ空间
|
|
|
this.$wx.config({
|
|
|
debug: false,
|
|
|
appId: data.appid,
|
|
|
timestamp: data.timestamp,
|
|
|
nonceStr: data.noncestr,
|
|
|
signature: data.sign,
|
|
|
- jsApiList: ['updateAppMessageShareData', 'chooseImage', 'onMenuShareAppMessage'],
|
|
|
+ jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'],
|
|
|
});
|
|
|
this.$wx.ready(() => {
|
|
|
this.$wx.updateAppMessageShareData({
|
|
|
title: this.title,
|
|
|
desc: this.desc,
|
|
|
- // imgUrl: this.img,
|
|
|
+ imgUrl: this.img,
|
|
|
link: shareUrl,
|
|
|
success: res => {
|
|
|
- console.log(res);
|
|
|
- console.log(shareUrl);
|
|
|
- console.log('in function:share success');
|
|
|
+ console.log('friend share');
|
|
|
+ },
|
|
|
+ error: err => {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.$wx.updateTimelineShareData({
|
|
|
+ title: this.title,
|
|
|
+ imgUrl: this.img,
|
|
|
+ link: shareUrl,
|
|
|
+ success: res => {
|
|
|
+ console.log('friends share');
|
|
|
},
|
|
|
error: err => {
|
|
|
alert(JSON.stringify(err));
|
|
@@ -75,29 +71,10 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
this.$wx.error(res => {
|
|
|
- console.log('config 有问题');
|
|
|
console.log(res);
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- async test() {
|
|
|
- console.log(WeixinJSBridge);
|
|
|
- WeixinJSBridge.invoke(
|
|
|
- 'sendAppMessage',
|
|
|
- {
|
|
|
- appid: 'wxdf3ed83c095be97a', //appid 设置空就好了。
|
|
|
- // img_url: '',
|
|
|
- // img_width: '120', //图片宽度
|
|
|
- // img_height: '120', //图片高度
|
|
|
- link: 'http://broadcast.waityou24.cn/api/article/auth?redirect_uri=http://broadcast.waityou24.cn/articlemobile', //分享附带链接地址
|
|
|
- desc: '我是一个介绍', //分享内容介绍
|
|
|
- title: '标题,再简单不过了。',
|
|
|
- },
|
|
|
- function(res) {
|
|
|
- /*** 回调函数,最好设置为空 ***/
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user', 'menuParams']),
|