activity-item.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. type: String,
  37. // 数据
  38. item: Object,
  39. favoritesHidden: Boolean,
  40. platform: String
  41. },
  42. data() {
  43. return {
  44. websiteUrl: process.env.WEBSITE
  45. }
  46. },
  47. created() {
  48. },
  49. methods: {
  50. onCollect(item) { // 收藏
  51. if (!this.checkAuth('pages/activity/index')) {
  52. return
  53. }
  54. if (item.is_collect === 1) {
  55. meetingCancelCollect({ id: item.id }).then(res => {
  56. if (res.code === 0) {
  57. this.$emit('updateItemValue', {
  58. id: item.id,
  59. key: 'is_collect',
  60. value: 0
  61. })
  62. }
  63. })
  64. } else {
  65. meetingCollect({ id: item.id }).then(res => {
  66. if (res.code === 0) {
  67. this.$emit('updateItemValue', {
  68. id: item.id,
  69. key: 'is_collect',
  70. value: 1
  71. })
  72. }
  73. })
  74. }
  75. },
  76. formatDate(dateString) {
  77. const date = new Date(dateString);
  78. const year = date.getFullYear();
  79. const month = date.getMonth() + 1; // 月份从 0 开始
  80. const day = date.getDate();
  81. return `${year}年${month}月${day}日`;
  82. },
  83. onClickActivity(item){
  84. this.saveMeetingView(item)
  85. if (this.type === 'exhibitor') {
  86. this.webviewTo(this.$store.getters.website_url + '/mini-pro-activity?v=' + this.$store.getters.version)
  87. } else {
  88. this.webviewTo(this.$store.getters.website_url + '/mini-pro-same-detail?v=' + this.$store.getters.version)
  89. }
  90. // this.navigateTo('/pages/activity/detail')
  91. },
  92. saveMeetingView(item) {
  93. if (this.platform !== 'metting') return
  94. mettingView({ id: item.id }).then(res => {
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. </style>