index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <diy ref="diy" v-if="isDiy"></diy>
  3. </template>
  4. <script>
  5. import diy from './diy'
  6. import {
  7. getShare
  8. } from "@/api/public.js";
  9. export default {
  10. data() {
  11. return {
  12. isDiy: uni.getStorageSync('is_diy'),
  13. shareInfo: {}
  14. }
  15. },
  16. components: {
  17. diy
  18. },
  19. onShow() {
  20. uni.$on('is_diy', (data) => {
  21. this.isDiy = data
  22. })
  23. this.setOpenShare();
  24. },
  25. onHide() {
  26. // this.isDiy = -1
  27. },
  28. methods: {
  29. // 微信分享;
  30. setOpenShare: function() {
  31. let that = this;
  32. // getShare().then((res) => {
  33. // let data = res.data;
  34. // this.shareInfo = data;
  35. // // #ifdef H5
  36. // let url = location.href;
  37. // if (this.$store.state.app.uid) {
  38. // url =
  39. // url.indexOf("?") === -1 ?
  40. // url + "?spread=" + this.$store.state.app.uid :
  41. // url + "&spread=" + this.$store.state.app.uid;
  42. // }
  43. // if (that.$wechat.isWeixin()) {
  44. // let configAppMessage = {
  45. // desc: data.synopsis,
  46. // title: data.title,
  47. // link: url,
  48. // imgUrl: data.img,
  49. // };
  50. // that.$wechat.wechatEvevt(
  51. // ["updateAppMessageShareData", "updateTimelineShareData"],
  52. // configAppMessage
  53. // );
  54. // }
  55. // // #endif
  56. // });
  57. },
  58. },
  59. onReachBottom: function() {
  60. if (this.isDiy) {
  61. this.$refs.diy.onsollBotton()
  62. }
  63. },
  64. // #ifdef MP
  65. //发送给朋友
  66. onShareAppMessage(res) {
  67. // 此处的distSource为分享者的部分信息,需要传递给其他人
  68. let that = this;
  69. return {
  70. title: this.shareInfo.title,
  71. path: "/pages/index/index",
  72. imageUrl: this.shareInfo.img,
  73. };
  74. },
  75. //分享到朋友圈
  76. onShareTimeline() {
  77. return {
  78. title: this.shareInfo.title,
  79. imageUrl: this.shareInfo.img,
  80. };
  81. },
  82. // #endif
  83. }
  84. </script>
  85. <style>
  86. </style>