mixin.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. this.$u.api.activity.detail({
  14. id: options.activityId
  15. }).then(res => {
  16. let userId = uni.getStorageSync("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. let url = window.location.href
  60. let len = url.indexOf("agenterId=") - 1
  61. let tmp = url.substring(0, len)
  62. window.location.href = tmp
  63. }
  64. }
  65. }
  66. }
  67. export default page