activity-recommend.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="activity-recommend">
  3. <view class="activity-list" v-if="activityList && activityList.length > 0">
  4. <template v-for="(item, index) in activityList">
  5. <view class="activity-item" :key="index" @click="onClickActivity(item)">
  6. <view class="activity-title">{{ item.title }}</view>
  7. <view class="activity-time">{{ formatDate(item.start_time) }} | {{ item.address }}</view>
  8. <view class="activity-summary">
  9. <view class="text">{{ item.content }}</view>
  10. <van-button class="btn-to-detail" type="primary">
  11. <template>
  12. <view>了解详情</view> <view class="arrow iconfont icon-right-s"></view>
  13. </template>
  14. </van-button>
  15. </view>
  16. </view>
  17. </template>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { exhibitorsBoothActivityList } from '@/api/exhibitor'
  23. import { link } from '@/utils/request'
  24. export default {
  25. options: {
  26. styleIsolation: 'shared'
  27. },
  28. components: {
  29. },
  30. props: {
  31. // 特定的展商ID
  32. exhibitorId: Number
  33. },
  34. watch: {
  35. exhibitorId(val) {
  36. this.activityListParams.exhibitors_id = val
  37. console.log(val,'exhibitors_id')
  38. this.getActivityList()
  39. }
  40. },
  41. data() {
  42. return {
  43. activityList: [],
  44. activityListParams: {
  45. page: 1,
  46. page_size: 3,
  47. exhibitors_id: 0
  48. },
  49. activityListLoading: false
  50. }
  51. },
  52. created() {
  53. },
  54. mounted() {
  55. this.getActivityList()
  56. },
  57. methods: {
  58. getActivityList() {
  59. if (this.activityListLoading === true) {
  60. return
  61. }
  62. this.activityListLoading = true
  63. if (this.exhibitorId) {
  64. this.activityListParams.exhibitors_id = this.exhibitorId
  65. }
  66. exhibitorsBoothActivityList(this.activityListParams).then(res => {
  67. if (res.code === 0) {
  68. if (this.activityListParams.page > 1) {
  69. this.activityList = [...this.activityList, ...res.data.data]
  70. } else {
  71. this.activityList = res.data.data
  72. }
  73. }
  74. this.activityListLoading = false
  75. })
  76. },
  77. formatDate(dateString) {
  78. const date = new Date(dateString);
  79. const year = date.getFullYear();
  80. const month = date.getMonth() + 1; // 月份从 0 开始
  81. const day = date.getDate();
  82. return `${year}年${month}月${day}日`;
  83. },
  84. onClickActivity(item) {
  85. this.navigateTo('/pages/exhibitor/exhibitor-activity?id=' + item.id)
  86. // this.navigateTo(this.$store.getters.website_url + '/mini-pro-activity?v=' + this.$store.getters.version)
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. .activity-list{
  93. display: grid;
  94. grid-template-columns: 1fr;
  95. grid-row-gap: 18rpx;
  96. margin-top: 28rpx;
  97. }
  98. .activity-item{
  99. display: flex;
  100. flex-direction: column;
  101. height: 210rpx;
  102. background-color: #F6F6F6;
  103. border-radius: 10rpx;
  104. padding: 24rpx 30rpx;
  105. }
  106. .activity-title{
  107. @include text-ellipsis-line;
  108. font-weight: bold;
  109. font-size: $fontSize3;
  110. line-height: 35rpx;
  111. }
  112. .activity-time{
  113. font-size: $fontSize2;
  114. color: #333333;
  115. margin: 12rpx 0;
  116. }
  117. .activity-summary{
  118. display: flex;
  119. align-items: center;
  120. font-size: $fontSize1;
  121. line-height: 25rpx;
  122. .btn-to-detail{
  123. flex-shrink: 0;
  124. .van-button__text{
  125. display: flex!important;
  126. align-items: center;
  127. font-size: $fontSize0;
  128. }
  129. }
  130. .text{
  131. padding-right: 30rpx;
  132. color: #555555;
  133. @include text-ellipsis-line;
  134. -webkit-line-clamp: 2;
  135. }
  136. .arrow{
  137. margin-left: 12rpx;
  138. font-size: $fontSize0;
  139. }
  140. }
  141. .activity-tab{
  142. van-button{
  143. margin-right: 13rpx;
  144. }
  145. }
  146. </style>