// import wx from 'weixin-js-sdk' var wx = require('weixin-js-sdk'); // import api from "@/api"; const wxApi = { /** * [wxRegister 微信Api初始化] * @param {Function} callback [ready回调函数] */ wxRegister () { $.ajax({ url:'http://sf-college.szbiu.com/zgame/', data: { m: 'biu_common', a: 'get_share_info', nowurl: location.href.split('#')[0] }, withCredentials: true, success:function (result) { let tmp = JSON.parse(result); let jssdk_info = tmp.other_info.jssdkinfo; wx.config({ debug: false, appId: jssdk_info.appId, timestamp: jssdk_info.timestamp, nonceStr: jssdk_info.nonceStr, signature: jssdk_info.signature, jsApiList: [ 'onMenuShareTimeline', 'onMenuShareAppMessage', 'hideMenuItems', ] }); wx.ready( function () { wx.onMenuShareAppMessage({ title: '南头街道党史学习教育知识竞答', desc: '学党史 悟思想 办实事 开新局', link:'http://polymers.szbiu.com/nantou_H5/index.html', imgUrl: 'http://polymers.szbiu.com/nantou_H5/static/images/wxshare.jpg', type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success: function () { // 用户确认分享后执行的回调函数 // api.post('todayshare').then(response => { // console.log('分享成功的返回',response.data); // // }); }, cancel: function () { } }); wx.onMenuShareTimeline({ title: '南头街道党史学习教育知识竞答', desc: '学党史 悟思想 办实事 开新局', link:'http://polymers.szbiu.com/nantou_H5/index.html', imgUrl: 'http://polymers.szbiu.com/nantou_H5/static/images/wxshare.jpg', type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success: function () { // 用户确认分享后执行的回调函数 // api.post('todayshare').then(response => { // console.log('分享成功的返回',response.data); // // }); }, cancel: function () { } }); wx.hideMenuItems({ menuList: ['menuItem:share:qq', 'menuItem:share:weiboApp', 'menuItem:share:QZone', 'menuItem:copyUrl', 'menuItem:originPage', 'menuItem:openWithQQBrowser', 'menuItem:openWithSafari', 'menuItem:share:email'], }); }) }}); } /** * [ShareTimeline 微信分享到朋友圈] * @param {[type]} option [分享信息] * @param {[type]} success [成功回调] * @param {[type]} error [失败回调] */ } export default wxApi
wxapi ,分享到朋友圈,分享到给别人
最新推荐文章于 2024-05-17 09:39:07 发布