community.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view class="community">
  3. <like-header @change="handleNav" :current="currentNav" />
  4. <view class="container">
  5. <follow :active="currentNav" v-show="currentNav===0" @share="handleShare"></follow>
  6. <!-- 发现 -->
  7. <explore :active="currentNav" v-show="currentNav===1"></explore>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import LikeHeader from "./components/like-header.vue"
  13. import Explore from "./components/explore.vue"
  14. import Follow from "./components/follow.vue"
  15. export default {
  16. components: {
  17. LikeHeader,
  18. Explore,
  19. Follow
  20. },
  21. data() {
  22. return {
  23. currentNav: 1,
  24. communityShareItem: {}
  25. }
  26. },
  27. onUnload() {
  28. uni.$off("changeItem")
  29. uni.$off("hasNew")
  30. },
  31. onShareAppMessage() {
  32. const promise = new Promise(resolve => {
  33. setTimeout(() => {
  34. resolve({
  35. title: `${this.communityShareItem.user.nickname},TA的内容超级棒`,
  36. path: '/bundle_b/pages/community_user/community_user?id=' + this
  37. .communityShareItem.id,
  38. imageUrl: this.communityShareItem.image
  39. })
  40. }, 10)
  41. })
  42. return {
  43. title: '自定义转发标题',
  44. path: '/page/user/user',
  45. promise
  46. }
  47. },
  48. methods: {
  49. handleNav(event) {
  50. this.currentNav = Number(event)
  51. },
  52. // 关注页的分享信息
  53. handleShare(event) {
  54. this.communityShareItem = event
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. page {
  61. padding: 0;
  62. }
  63. .community {
  64. display: flex;
  65. height: calc(100vh - var(--window-bottom));
  66. overflow: hidden;
  67. flex-direction: column;
  68. .container {
  69. flex: 1;
  70. min-height: 0;
  71. overflow: scroll;
  72. }
  73. }
  74. </style>