activity-item.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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="onCollect(item)" class="activity-favourites" :class="{ 'active': index === 1 }">
  6. <view v-if="item.favourited" 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. }
  55. })
  56. } else {
  57. meetingCollect({ id: item.id }).then(res => {
  58. if (res.code === 0) {
  59. item.is_collect = 1
  60. }
  61. })
  62. }
  63. },
  64. formatDate(dateString) {
  65. const date = new Date(dateString);
  66. const year = date.getFullYear();
  67. const month = date.getMonth() + 1; // 月份从 0 开始
  68. const day = date.getDate();
  69. return `${year}年${month}月${day}日`;
  70. },
  71. onClickActivity(item){
  72. this.navigateTo(this.websiteUrl + '/' + item.urla)
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. </style>