activity-item.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="activity-item" hover-class="active" @click="onClickActivity(item)">
  3. <view class="activity-title">
  4. <view>{{ item.title }}</view>
  5. <view v-if="!favoritesHidden" @click.stop="onCollect(item)" class="activity-favourites" :class="{ 'active': index === 1 }">
  6. <view v-if="item.is_collect" class="iconfont icon-favourites-filled-star-symbol active"></view>
  7. <view v-else class="iconfont icon-Favourites-Add-Large"></view>
  8. <view class="activity-favourites-text">收藏</view>
  9. </view>
  10. </view>
  11. <view class="activity-time">{{ formatDate(item.start_date || item.start_time || '') }} | {{ item.address }}</view>
  12. <view class="activity-views">浏览:{{ item.view || item.pv || 0 }}</view>
  13. <view class="activity-desc">
  14. <view>
  15. {{ item.description || item.content || '' }}
  16. </view>
  17. <view>
  18. <van-button class="activity-detail-link" type="primary">
  19. <template>
  20. <view>了解详情</view> <view class="arrow iconfont icon-right-s"></view>
  21. </template>
  22. </van-button>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { meetingCollect, meetingCancelCollect, mettingView } from '@/api/exhibitor'
  29. export default {
  30. options: {
  31. styleIsolation: 'shared'
  32. },
  33. components: {
  34. },
  35. props: {
  36. // 数据
  37. item: Object,
  38. favoritesHidden: Boolean,
  39. platform: String
  40. },
  41. data() {
  42. return {
  43. websiteUrl: process.env.WEBSITE
  44. }
  45. },
  46. created() {
  47. },
  48. methods: {
  49. onCollect(item) { // 收藏
  50. this.checkAuth('pages/activity/index')
  51. if (item.is_collect === 1) {
  52. meetingCancelCollect({ id: item.id }).then(res => {
  53. if (res.code === 0) {
  54. this.$emit('updateItemValue', {
  55. id: item.id,
  56. key: 'is_collect',
  57. value: 0
  58. })
  59. }
  60. })
  61. } else {
  62. meetingCollect({ id: item.id }).then(res => {
  63. if (res.code === 0) {
  64. this.$emit('updateItemValue', {
  65. id: item.id,
  66. key: 'is_collect',
  67. value: 1
  68. })
  69. }
  70. })
  71. }
  72. },
  73. formatDate(dateString) {
  74. const date = new Date(dateString);
  75. const year = date.getFullYear();
  76. const month = date.getMonth() + 1; // 月份从 0 开始
  77. const day = date.getDate();
  78. return `${year}年${month}月${day}日`;
  79. },
  80. onClickActivity(item){
  81. this.saveMeetingView(item)
  82. this.navigateTo(this.websiteUrl + '/' + item.urla)
  83. },
  84. saveMeetingView(item) {
  85. if (this.platform !== 'metting') return
  86. mettingView({ id: item.id }).then(res => {
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. </style>