景徳镇旅游微信小程序
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.

67 lines
1.5 KiB

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