建材商城系统20241014
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.

69 lines
1.6 KiB

2 weeks ago
2 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', 'riceInfo', 'selectCity']),
  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. // 定义全局分享
  29. // 1.发送给朋友
  30. onShareAppMessage(res) {
  31. let o = {
  32. title : this.configList.logo_name,
  33. ...this.Gshare,
  34. }
  35. if(this.userInfo.id){
  36. if(this.Gshare.path.includes('?')){
  37. o.path += '&shareId=' + this.userInfo.id
  38. }else{
  39. o.path += '?shareId=' + this.userInfo.id
  40. }
  41. }
  42. return o
  43. },
  44. //2.分享到朋友圈
  45. onShareTimeline(res) {
  46. let o = {
  47. ...this.Gshare,
  48. title : this.configList.logo_name,
  49. }
  50. if(this.userInfo.id){
  51. if(this.Gshare.path.includes('?')){
  52. o.path += '&shareId=' + this.userInfo.id
  53. }else{
  54. o.path += '?shareId=' + this.userInfo.id
  55. }
  56. }
  57. return o
  58. },
  59. onLoad(query) {
  60. if (query.shareId) {
  61. uni.setStorageSync('shareId', query.shareId)
  62. }
  63. },
  64. methods: {
  65. }
  66. }