index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div style="height: 100%;">
  3. <!-- <diy ref="diy" v-if="isDiy"></diy>
  4. <visualization v-else></visualization> -->
  5. <index></index>
  6. </div>
  7. </template>
  8. <script>
  9. // import diy from './diy'
  10. // import visualization from './visualization'
  11. import index from './newindex/index.vue';
  12. import Cache from '@/utils/cache';
  13. import {
  14. getShare
  15. } from "@/api/public.js";
  16. let app = getApp();
  17. export default {
  18. data() {
  19. return {
  20. isDiy: uni.getStorageSync('is_diy'),
  21. shareInfo: {}
  22. }
  23. },
  24. components: {
  25. index
  26. // diy,
  27. // visualization
  28. },
  29. onShow() {
  30. uni.hideTabBar()
  31. // uni.$on('is_diy', (data) => {
  32. // this.isDiy = data
  33. // })
  34. this.setOpenShare();
  35. },
  36. onHide() {
  37. // this.isDiy = -1
  38. },
  39. methods: {
  40. // 微信分享;
  41. setOpenShare: function() {
  42. let that = this;
  43. getShare().then((res) => {
  44. let data = res.data;
  45. this.shareInfo = data;
  46. // #ifdef H5
  47. let url = location.href;
  48. if (this.$store.state.app.uid) {
  49. url =
  50. url.indexOf("?") === -1 ?
  51. url + "?spread=" + this.$store.state.app.uid :
  52. url + "&spread=" + this.$store.state.app.uid;
  53. }
  54. if (that.$wechat.isWeixin()) {
  55. let configAppMessage = {
  56. desc: data.synopsis,
  57. title: data.title,
  58. link: url,
  59. imgUrl: data.img,
  60. };
  61. that.$wechat.wechatEvevt(
  62. ["updateAppMessageShareData", "updateTimelineShareData"],
  63. configAppMessage
  64. );
  65. }
  66. // #endif
  67. });
  68. },
  69. },
  70. onReachBottom: function() {
  71. if (this.isDiy) {
  72. this.$refs.diy.onsollBotton()
  73. }
  74. },
  75. // 滚动监听
  76. onPageScroll(e) {
  77. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  78. uni.$emit('scroll');
  79. },
  80. // #ifdef MP
  81. //发送给朋友
  82. onShareAppMessage(res) {
  83. // 此处的distSource为分享者的部分信息,需要传递给其他人
  84. let that = this;
  85. return {
  86. title: this.shareInfo.title,
  87. path: "/pages/index/index?spid=" + this.$store.state.app.uid || 0,
  88. imageUrl: this.shareInfo.img,
  89. };
  90. },
  91. //分享到朋友圈
  92. onShareTimeline() {
  93. return {
  94. title: this.shareInfo.title,
  95. query: {
  96. spid: this.$store.state.app.uid || 0
  97. },
  98. imageUrl: this.shareInfo.img,
  99. };
  100. },
  101. // #endif
  102. }
  103. </script>
  104. <style>
  105. </style>