敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
  1. // 这个已经在全局混入了
  2. import { mapState } from 'vuex'
  3. export default {
  4. data() {
  5. return {
  6. // 默认的全局分享内容
  7. Gshare: {
  8. // title: '三只青蛙',
  9. path: '/pages_order/auth/wxLogin', // 全局分享的路径,比如 首页
  10. // imageUrl: '/static/image/login/logo.png', // 全局分享的图片(可本地可网络)
  11. }
  12. }
  13. },
  14. computed: {
  15. ...mapState(['configList', 'userInfo']),
  16. // currentPagePath() {
  17. // const pages = getCurrentPages();
  18. // const currentPage = pages[pages.length - 1];
  19. // let path = `/${currentPage.route}`;
  20. // // 获取当前页面的参数
  21. // const options = currentPage.options;
  22. // if (options && Object.keys(options).length > 0) {
  23. // const params = this.$utils.objectToUrlParams(options);
  24. // path += `?${params}`;
  25. // }
  26. // return path;
  27. // },
  28. },
  29. // 定义全局分享
  30. // 1.发送给朋友
  31. onShareAppMessage(res) {
  32. let o = {
  33. title : this.configList.logo_name,
  34. ...this.Gshare,
  35. }
  36. if(this.userInfo.id){
  37. if(this.Gshare.path.includes('?')){
  38. o.path += '&shareId=' + this.userInfo.id
  39. }else{
  40. o.path += '?shareId=' + this.userInfo.id
  41. }
  42. }
  43. return o
  44. },
  45. //2.分享到朋友圈
  46. onShareTimeline(res) {
  47. let o = {
  48. ...this.Gshare,
  49. title : this.configList.logo_name,
  50. }
  51. if(this.userInfo.id){
  52. o.path = this.Gshare.path + '?shareId=' + this.userInfo.id
  53. }
  54. return o
  55. },
  56. methods: {
  57. }
  58. }