activity-item.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.pub_date) }} | {{ item.address }}</view>
  12. <view class="activity-views">浏览:{{ item.view }}</view>
  13. <view class="activity-desc">
  14. <view>
  15. {{ item.description }}
  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, meetingView } 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. },
  40. data() {
  41. return {
  42. websiteUrl: process.env.WEBSITE
  43. }
  44. },
  45. created() {
  46. },
  47. methods: {
  48. onCollect(item) { // 收藏
  49. this.checkAuth('pages/activity/index')
  50. if (item.is_collect === 1) {
  51. meetingCancelCollect({ id: item.id }).then(res => {
  52. if (res.code === 0) {
  53. item.is_collect = 0
  54. this.$emit('updateItemCollect', {
  55. id: item.id
  56. })
  57. }
  58. })
  59. } else {
  60. meetingCollect({ id: item.id }).then(res => {
  61. if (res.code === 0) {
  62. item.is_collect = 1
  63. this.$emit('updateItemCollect', {
  64. id: item.id
  65. })
  66. }
  67. })
  68. }
  69. },
  70. formatDate(dateString) {
  71. const date = new Date(dateString);
  72. const year = date.getFullYear();
  73. const month = date.getMonth() + 1; // 月份从 0 开始
  74. const day = date.getDate();
  75. return `${year}年${month}月${day}日`;
  76. },
  77. onClickActivity(item){
  78. this.navigateTo(this.websiteUrl + '/' + item.urla)
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. </style>