//首先在html页面中引入jssdk脚本,然后wx对象就可以通过window.wx来获得
//<script src='https://res.wx.qq.com/open/js/jweixin-1.0.0.js'></script>
//下面是js文件中和本功能有关的所有代码段
import axios from 'axios';
const shareJs = function(jssdk, options) {
window.wx.config({
debug: false,
appId: jssdk.appId,
timestamp: parseInt(jssdk.timestamp),
nonceStr: jssdk.nonceStr,
signature: jssdk.signature,
jsApiList: [
"onMenuShareTimeline",
"onMenuShareAppMessage"
]
});
var defaults = {
title: "分享的标题",
imgUrl: 'https://tup.iheima.com/sport.png', //分享是封面图片,不能为空
success: function() {}, //分享成功触发
cancel: function() {} //分享取消触发,需要时可以调用
}
options = Object.assign({}, defaults, options);
window.wx.ready(function() {
var thatopts = options;
window.wx.onMenuShareTimeline({
title: thatopts.title, // 分享标题
imgUrl: thatopts.imgUrl, // 分享图标
success: function() {
/