mixin.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * 全局注入器
  3. */
  4. let page = {
  5. data() {
  6. return {
  7. }
  8. },
  9. methods: {
  10. },
  11. onLoad(options) {
  12. if (!this.$u.test.isEmpty(options.activityId)) {
  13. console.log("**********************activityId",options.activityId);
  14. this.$u.api.activity.detail({id: options.activityId}).then(res => {
  15. let userId=uni.getStorageSync("userId")
  16. console.log("**********************userId",userId);
  17. if (!this.$u.test.isEmpty(userId)) {
  18. let link=window.location.href
  19. if (link.indexOf("?")!=-1) {
  20. link=link+"&agenterId="+userId
  21. }else{
  22. link=link+"?agenterId="+userId
  23. }
  24. let obj={
  25. link,
  26. title:res.shareTitle,
  27. desc:res.shareDesc,
  28. imgUrl: res.shareImg
  29. }
  30. console.log("**********************obj",obj);
  31. this.$shareConfig(obj,this)
  32. }
  33. if (!this.$u.test.isEmpty(options.agenterId)) {
  34. uni.setStorageSync("agenterId",options.agenterId)
  35. let url=window.location.href
  36. let len=url.indexOf("agenterId=")-1
  37. let tmp= url.substring(0,len)
  38. window.location.href=tmp
  39. }
  40. })
  41. }else{
  42. let userId=uni.getStorageSync("userId")
  43. if (!this.$u.test.isEmpty(userId)) {
  44. let link=window.location.href
  45. if (link.indexOf("?")!=-1) {
  46. link=link+"&agenterId="+userId
  47. }else{
  48. link=link+"?agenterId="+userId
  49. }
  50. let obj={
  51. link,
  52. title: '',
  53. desc: link,
  54. }
  55. this.$shareConfig(obj,this)
  56. }
  57. if (!this.$u.test.isEmpty(options.agenterId)) {
  58. uni.setStorageSync("agenterId",options.agenterId)
  59. }
  60. }
  61. }
  62. }
  63. export default page