favorites.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <page-layout class="user-favorites user-like">
  3. <nav-bar title="我的收藏" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view>
  5. <view class="user-favorites-tabs-wrapper user-like-tabs-wrapper">
  6. <view class="user-favorites-tabs user-like-tabs">
  7. <u-tabs :active.sync="tabActive" :tabs="tabs" @change="tabChange"/>
  8. </view>
  9. </view>
  10. <view class="main-container">
  11. <view class="user-favorites-list user-like-list" v-if="!loading">
  12. <template v-for="(item, index) in favoritesList">
  13. <template v-if="tabActive === 'exhibitor'">
  14. <exhibitor-item :item="item" :footer-hidden="true" :key="index"/>
  15. </template>
  16. <template v-else-if="tabActive === 'exhibit'">
  17. <exhibit-item :item="item" :footer-hidden="true" :key="index"/>
  18. </template>
  19. <template v-else-if="tabActive === 'activity'">
  20. <activity-item :item="item" :favorites-hidden="true" :key="index"/>
  21. </template>
  22. </template>
  23. </view>
  24. </view>
  25. </u-scroll-view>
  26. </page-layout>
  27. </template>
  28. <script>
  29. import NavBar from '@/components/layout/nav-bar'
  30. import UTabs from '@/components/common/u-tabs'
  31. import UScrollView from '@/components/common/u-scroll-view'
  32. import ExhibitItem from '@/pages/exhibitor/components/exhibit-item.vue'
  33. import ExhibitorItem from '@/pages/exhibitor/components/exhibitor-item.vue'
  34. import ActivityItem from '@/pages/activity/components/activity-item.vue'
  35. import {
  36. getExhibitorCollectList,
  37. getExhibitCollectList,
  38. getActivityCollectList
  39. } from '@/api/user'
  40. import PageLayout from "@/components/layout/page-layout";
  41. export default {
  42. options: {
  43. styleIsolation: 'shared'
  44. },
  45. components: {
  46. PageLayout,
  47. NavBar,
  48. UTabs,
  49. UScrollView,
  50. ExhibitItem,
  51. ExhibitorItem,
  52. ActivityItem
  53. },
  54. computed: {},
  55. data() {
  56. return {
  57. tabActive: 'exhibitor',
  58. loading: false,
  59. tabs: [{
  60. label: '展商',
  61. value: 'exhibitor'
  62. }, {
  63. label: '展品',
  64. value: 'exhibit'
  65. }, {
  66. label: '同期活动',
  67. value: 'activity'
  68. }],
  69. favoritesList: [],
  70. }
  71. },
  72. created() {
  73. this.checkAuth('/pages/user/favorites')
  74. this.loadFontFace('Poppins')
  75. this.getExhibitorCollectInfo()
  76. },
  77. onShow() {
  78. },
  79. methods: {
  80. tabChange(e) {
  81. this.tabActive = e.detail.value
  82. if (this.tabActive === 'exhibitor') {
  83. this.getExhibitorCollectInfo()
  84. } else if (this.tabActive === 'exhibit') {
  85. this.getExhibitCollectInfo()
  86. } else {
  87. this.getActivityCollectInfo()
  88. }
  89. },
  90. getExhibitorCollectInfo() {
  91. this.loading = true
  92. getExhibitorCollectList().then(res => {
  93. this.favoritesList = res.data.data
  94. this.loading = false
  95. })
  96. },
  97. getExhibitCollectInfo() {
  98. this.loading = true
  99. getExhibitCollectList().then(res => {
  100. this.favoritesList = res.data.data
  101. this.loading = false
  102. })
  103. },
  104. getActivityCollectInfo() {
  105. this.loading = true
  106. getActivityCollectList().then(res => {
  107. this.favoritesList = res.data.data
  108. this.loading = false
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. @import "@/static/style/pages/user-like.scss";
  116. </style>