mixin.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const wx = require('weixin-js-sdk');
  2. const config = require('@/static/config.js');
  3. export default {
  4. install(Vue){
  5. Vue.mixin({
  6. data(){
  7. return {
  8. }
  9. },
  10. onLoad() {
  11. },
  12. methods:{
  13. config(title,desc,link,imgUrl){
  14. wx.showMenuItems({
  15. menuList: [ "menuItem:share:appMessage","menuItem:share:timeline"] // 要显示的菜单项,所有menu项见附录3
  16. });
  17. wx.hideMenuItems({
  18. menuList: ['menuItem:share:qq','menuItem:share:QZone','menuItem:favorite','menuItem:originPage','menuItem:copyUrl','menuItem:openWithSafari','menuItem:openWithQQBrowser'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
  19. });
  20. wx.updateAppMessageShareData({ //分享给朋友
  21. title: title, // 分享标题
  22. desc: desc, // 分享描述
  23. link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  24. imgUrl: imgUrl, // 分享图标
  25. success: function() {
  26. // 设置成功
  27. }
  28. });
  29. wx.updateTimelineShareData({ //分享到朋友圈
  30. title: title, // 分享标题
  31. link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  32. imgUrl: imgUrl, // 分享图标
  33. success: function() {
  34. // 设置成功
  35. }
  36. });
  37. }
  38. }
  39. })
  40. }
  41. }