share.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const core_config_index = require("../config/index.js");
  4. const share = {
  5. data() {
  6. return {
  7. share: {
  8. // 转发的标题 (默认标题)
  9. title: core_config_index.config.get("name"),
  10. // 默认是当前页面,必须是以‘/’开头的完整路径
  11. path: `/pages/home/index`,
  12. //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,
  13. //支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
  14. imageUrl: core_config_index.config.getResource("logo.png")
  15. }
  16. };
  17. },
  18. // 发送给朋友
  19. onShareAppMessage(res) {
  20. let shareInfo = common_vendor.index.getStorageSync("shareInfo");
  21. return {
  22. title: shareInfo.title || this.share.title,
  23. imageUrl: shareInfo.imgUrl || this.share.imageUrl,
  24. path: shareInfo.path || this.share.path
  25. };
  26. },
  27. //分享到朋友圈
  28. onShareTimeline(res) {
  29. let shareInfo = common_vendor.index.getStorageSync("shareInfo");
  30. return {
  31. title: shareInfo.title || this.share.title,
  32. imageUrl: shareInfo.imgUrl || this.share.imageUrl,
  33. path: shareInfo.path || this.share.path
  34. };
  35. }
  36. };
  37. exports.share = share;