exhibit-recommend.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="exhibit-recommend">
  3. <view class="exhibit-list">
  4. <template v-for="(item, index) in productList">
  5. <view v-if="index < limit" 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. console.log("limit")
  34. if (val === 8) {
  35. this.$emit('show-all')
  36. }
  37. },
  38. exhibitorId(val) {
  39. this.productListParams.exhibitors_id = val
  40. this.getProductList()
  41. }
  42. },
  43. data() {
  44. return {
  45. productListParams: {
  46. page: 1,
  47. page_size: 4,
  48. exhibitors_id: 0
  49. },
  50. productList: [],
  51. showExhibitMore: true,
  52. productListLoading: false
  53. }
  54. },
  55. created() {
  56. },
  57. methods: {
  58. getProductList() {
  59. if (this.productListLoading === true) {
  60. return
  61. }
  62. this.productListLoading = true
  63. exhibitorsProductList(this.productListParams).then(res => {
  64. if (res.code === 0) {
  65. if (this.productListParams.page > 1) {
  66. this.productList = [...this.productList, ...res.data.data]
  67. } else {
  68. this.productList = res.data.data
  69. }
  70. if (this.productListParams.page <= res.data.last_page) {
  71. this.showExhibitMore = false
  72. }
  73. }
  74. this.productListLoading = false
  75. })
  76. },
  77. loadMore() {
  78. this.productListParams.page = this.productListParams.page + 1
  79. this.getProductList()
  80. },
  81. onClickExhibit(item) {
  82. this.navigateTo('/pages/exhibitor/exhibit-detail?id=' + item.id)
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. .exhibit-recommend{
  89. .exhibit-list{
  90. display: grid;
  91. grid-template-columns: 1fr 1fr;
  92. grid-column-gap: 18rpx;
  93. grid-row-gap: 30rpx;
  94. .exhibit-item{
  95. position: relative;
  96. &.active{
  97. .exhibit-tag{
  98. background-color: #FCEDE1;
  99. color: #E57519;
  100. }
  101. .exhibit-name{
  102. color: #E57519;
  103. }
  104. .exhibit-image{
  105. border: 1rpx solid #E57519;
  106. }
  107. }
  108. }
  109. .exhibit-image{
  110. width: 100%;
  111. height: 178rpx;
  112. border: 1rpx solid #D9D9D9;
  113. image{
  114. width: 100%;
  115. height: 100%;
  116. }
  117. }
  118. .exhibit-name {
  119. font-family: Poppins, Poppins;
  120. font-size: $fontSize0;
  121. color: #333333;
  122. margin-top: 12rpx;
  123. }
  124. .exhibit-tag{
  125. position: absolute;
  126. top: 20rpx;
  127. left: 31rpx;
  128. font-size: 10rpx;
  129. color: #333333;
  130. background-color: #E2E8F0;
  131. border-radius: 4rpx;
  132. padding: 5rpx 8rpx;
  133. }
  134. }
  135. }
  136. </style>