exhibit-recommend.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="exhibit-recommend" v-if="productList && productList.length > 0">
  3. <view class="exhibit-list">
  4. <template v-for="(item, index) in productList">
  5. <view class="exhibit-item" hover-class="active" :key="index" @click="onClickExhibit(item)">
  6. <view class="exhibit-image">
  7. <image :src="item.pic + '?x-oss-process=image/resize,w_400'" mode="aspectFit"/>
  8. </view>
  9. <view class="exhibit-name">{{ item.name }}</view>
  10. <view v-for="(itempro) in item.product_attr_names" class="exhibit-tag">{{ itempro }}</view>
  11. </view>
  12. </template>
  13. </view>
  14. <view v-if="showExhibitMore" class="click-more">
  15. <van-button type="primary" @click="loadMore()">点击展开更多展品</van-button>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { exhibitorsProductList } from '@/api/exhibitor'
  21. export default {
  22. options: {
  23. styleIsolation: 'shared'
  24. },
  25. components: {
  26. },
  27. props: {
  28. limit: Number,
  29. exhibitorId: Number
  30. },
  31. watch: {
  32. limit(val) {
  33. if (val === 8) {
  34. this.$emit('show-all')
  35. }
  36. },
  37. exhibitorId(val) {
  38. this.productListParams.exhibitors_id = val
  39. this.getProductList()
  40. }
  41. },
  42. data() {
  43. return {
  44. productListParams: {
  45. page: 1,
  46. page_size: 4,
  47. exhibitors_id: 0
  48. },
  49. productList: [],
  50. showExhibitMore: true,
  51. productListLoading: false
  52. }
  53. },
  54. created() {
  55. },
  56. mounted() {
  57. this.getProductList()
  58. },
  59. methods: {
  60. getProductList() {
  61. if (this.productListLoading === true) {
  62. return
  63. }
  64. this.productListLoading = true
  65. if (this.exhibitorId) {
  66. this.productListParams.exhibitors_id = this.exhibitorId
  67. }
  68. exhibitorsProductList(this.productListParams).then(res => {
  69. if (res.code === 0) {
  70. if (this.productListParams.page > 1) {
  71. this.productList = [...this.productList, ...res.data.data]
  72. } else {
  73. this.productList = res.data.data
  74. }
  75. if (this.productListParams.page >= res.data.last_page) {
  76. this.showExhibitMore = false
  77. }
  78. }
  79. this.productListLoading = false
  80. })
  81. },
  82. loadMore() {
  83. this.productListParams.page = this.productListParams.page + 1
  84. this.getProductList()
  85. },
  86. onClickExhibit(item) {
  87. this.navigateTo('/pages/exhibitor/exhibit-detail?id=' + item.id)
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .exhibit-recommend{
  94. .exhibit-list{
  95. display: grid;
  96. grid-template-columns: 1fr 1fr;
  97. grid-column-gap: 18rpx;
  98. grid-row-gap: 30rpx;
  99. .exhibit-item{
  100. position: relative;
  101. &.active{
  102. .exhibit-tag{
  103. background-color: #FCEDE1;
  104. color: #E57519;
  105. }
  106. .exhibit-name{
  107. color: #E57519;
  108. }
  109. .exhibit-image{
  110. border: 1rpx solid #E57519;
  111. }
  112. }
  113. }
  114. .exhibit-image{
  115. width: 100%;
  116. height: 178rpx;
  117. border: 1rpx solid #D9D9D9;
  118. image{
  119. width: 100%;
  120. height: 100%;
  121. }
  122. }
  123. .exhibit-name {
  124. font-size: $fontSize1;
  125. color: #333333;
  126. margin-top: 12rpx;
  127. }
  128. .exhibit-tag{
  129. position: absolute;
  130. top: 20rpx;
  131. left: 31rpx;
  132. font-size: 10rpx;
  133. border-radius: 4rpx;
  134. padding: 5rpx 8rpx;
  135. background-color: #FCEDE1;
  136. color: #E57519;
  137. }
  138. }
  139. }
  140. </style>