exhibit-item.vue 4.2 KB

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