activity-item.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. if (!this.checkAuth('pages/activity/index')) {
  51. return
  52. }
  53. if (item.is_collect === 1) {
  54. meetingCancelCollect({ id: item.id }).then(res => {
  55. if (res.code === 0) {
  56. this.$emit('updateItemValue', {
  57. id: item.id,
  58. key: 'is_collect',
  59. value: 0
  60. })
  61. }
  62. })
  63. } else {
  64. meetingCollect({ id: item.id }).then(res => {
  65. if (res.code === 0) {
  66. this.$emit('updateItemValue', {
  67. id: item.id,
  68. key: 'is_collect',
  69. value: 1
  70. })
  71. }
  72. })
  73. }
  74. },
  75. formatDate(dateString) {
  76. const date = new Date(dateString);
  77. const year = date.getFullYear();
  78. const month = date.getMonth() + 1; // 月份从 0 开始
  79. const day = date.getDate();
  80. return `${year}年${month}月${day}日`;
  81. },
  82. onClickActivity(item){
  83. this.saveMeetingView(item)
  84. this.navigateTo(this.websiteUrl + '/' + item.urla)
  85. },
  86. saveMeetingView(item) {
  87. if (this.platform !== 'metting') return
  88. mettingView({ id: item.id }).then(res => {
  89. })
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. </style>