exhibitor-item.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="exhibitor-item" hover-class="active" @click="onClickExhibitor(item)">
  3. <view class="exhibitor-body">
  4. <view class="exhibitor-logo">
  5. <image v-if="item && item.logo" :src="item.logo + '?x-oss-process=image/resize,w_400'" mode="aspectFit" />
  6. <image v-else src="https://onlinecatelogue.productronicachina.com.cn/assets/image/normal-logo.jpg" mode="aspectFit" />
  7. </view>
  8. <view class="exhibitor-name">
  9. <view class="exhibitor-name-cn">{{ item.name_zh_cn }}</view>
  10. <view class="exhibitor-name-en">{{ item.name_en_us }}</view>
  11. </view>
  12. <view class="exhibitor-number">
  13. <view class="exhibitor-number-label">展位号:</view>
  14. <view class="exhibitor-number-text">{{ item.hall_booth_no }}</view>
  15. </view>
  16. </view>
  17. <view v-if="!footerHidden" class="exhibitor-footer">
  18. <view class="exhibitor-views">
  19. <view class="iconfont icon-View"></view>{{ item.pv }}</view>
  20. <view class="exhibitor-action">
  21. <view>
  22. <button :plain="true" @click.stop="onShare(item)">
  23. <view>
  24. <view class="iconfont icon-zhuanfa"></view>
  25. <view>分享</view>
  26. </view>
  27. </button>
  28. </view>
  29. <view @click.stop="onCollect()">
  30. <view v-if="item.is_collect" class="iconfont icon-favourites-filled-star-symbol active"></view>
  31. <view v-else class="iconfont icon-Favourites-Add-Large"></view>
  32. <view>收藏</view>
  33. </view>
  34. <view @click.stop="onLike()">
  35. <view v-if="item.is_like" class="iconfont icon-aixin active"></view>
  36. <view v-else class="iconfont icon-heart1"></view>
  37. <view>点赞</view>
  38. </view>
  39. <view v-if="pollShow" @click.stop="onPoll()">
  40. <view v-if="item.is_poll" class="iconfont icon-Ticket1 active"></view>
  41. <view v-else class="iconfont icon-xiaochengxu-toupiaoicon"></view>
  42. <view>投票</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { exhibitorsCollect, exhibitorsLike, exhibitorsPoll } from '@/api/exhibitor'
  50. export default {
  51. options: {
  52. styleIsolation: 'shared'
  53. },
  54. components: {
  55. },
  56. props: {
  57. // 数据
  58. item: Object,
  59. footerHidden: Boolean,
  60. pollShow: Number
  61. },
  62. data() {
  63. return {
  64. }
  65. },
  66. created() {
  67. },
  68. methods: {
  69. onCollect() { // 收藏
  70. if (!this.checkAuth('/pages/exhibitor/index')) {
  71. return
  72. }
  73. exhibitorsCollect({ id: this.item.id }).then(res => {
  74. if (res.code === 0) {
  75. let is_collect = this.item.is_collect === 0 ? 1 : 0
  76. this.$emit('updateItemValue', {
  77. id: this.item.id,
  78. key: 'is_collect',
  79. value: is_collect
  80. })
  81. }
  82. })
  83. },
  84. onLike() { // 点赞
  85. if (!this.checkAuth('/pages/exhibitor/index')) {
  86. return
  87. }
  88. exhibitorsLike({ id: this.item.id }).then(res => {
  89. if (res.code === 0) {
  90. let is_like = this.item.is_like === 0 ? 1 : 0
  91. this.$emit('updateItemValue', {
  92. id: this.item.id,
  93. key: 'is_like',
  94. value: is_like
  95. })
  96. }
  97. })
  98. },
  99. onPoll() { // 投票
  100. if (!this.checkAuth('/pages/exhibitor/index')) {
  101. return
  102. }
  103. exhibitorsPoll({ id: this.item.id }).then(res => {
  104. if (res.code === 0) {
  105. let is_poll = this.item.is_poll === 0 ? 1 : 0
  106. this.$emit('updateItemValue', {
  107. id: this.item.id,
  108. key: 'is_poll',
  109. value: is_poll
  110. })
  111. }
  112. })
  113. },
  114. onShare(item) {
  115. const shareInfo = {
  116. title: item.name,
  117. path: `/pages/exhibitor/detail?id=` + item.id,
  118. imageUrl: item.logo + '?x-oss-process=image/resize,w_600,h_600,limit_0,m_pad'
  119. }
  120. this.$emit('share', {
  121. detail: shareInfo
  122. })
  123. },
  124. onClickExhibitor(item) {
  125. let path = getCurrentPages()
  126. let current_path = path[path.length - 1].route
  127. if (current_path === 'pages/user/like' || current_path === 'pages/user/favorites' || current_path === 'pages/user/vote') {
  128. this.navigateTo('/pages/exhibitor/detail?id=' + item.exhibitors_id)
  129. } else {
  130. this.navigateTo('/pages/exhibitor/detail?id=' + item.id)
  131. }
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss">
  137. </style>