recommend.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template name="recommend">
  2. <!-- 供应商信息 -->
  3. <view class="recommend clearfix">
  4. <view class="recommend-empty" v-if="isEmpty">暂无相关推荐商品</view>
  5. <view class="recommend-list" v-else>
  6. <view class="row-list" v-for="(pros, idx) in recommendList" :key="idx" @click.stop="navToDetailPage(pros.id)">
  7. <view class="list-image"><image :src="pros.image" mode=""></image></view>
  8. <view class="list-name">{{pros.name}}</view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import authorize from '@/common/config/authorize.js'
  15. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  16. import tuiNomore from "@/components/tui-components/nomore/nomore"
  17. export default{
  18. name:'recommend',
  19. props:{
  20. queryProductid: {
  21. type: Number,
  22. default: 0
  23. },
  24. queryType:{
  25. type: String,
  26. default: '0'
  27. }
  28. },
  29. components:{
  30. tuiLoadmore,
  31. tuiNomore,
  32. },
  33. data() {
  34. return{
  35. current:0,
  36. recommendList:[],
  37. isEmpty:false,
  38. pageSize:4,
  39. productID:'',
  40. }
  41. },
  42. created() {
  43. this.productID = this.queryProductid
  44. this.infoRecommend(this.queryProductid,this.queryType)
  45. },
  46. methods:{
  47. infoRecommend(id,type){
  48. this.ProductService.queryProductDetilsRelevant({ productId:id,recommendType:type ? type : 0 }).then(response =>{
  49. if( response.data && response.data.length > 0){
  50. this.isEmpty = false
  51. this.recommendList = response.data
  52. }else{
  53. this.isEmpty = true
  54. }
  55. }).catch(error =>{
  56. this.$util.msg(error.msg,2000)
  57. })
  58. },
  59. //轮播图切换修改背景色
  60. swiperChange(e) {
  61. const index = e.detail.current;
  62. this.current = index;
  63. },
  64. navToDetailPage(id) {//跳转商品详情页
  65. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss">
  71. .recommend{
  72. background: #F7F7F7;
  73. width: 100%;
  74. .recommend-empty{
  75. width: 702rpx;
  76. height: 100rpx;
  77. line-height: 100rpx;
  78. padding: 0 24rpx;
  79. font-size: $font-size-28;
  80. color: #999999;
  81. text-align: center;
  82. }
  83. .recommend-list{
  84. width: 100%;
  85. height: auto;
  86. position: relative;
  87. box-sizing: border-box;
  88. padding: 0rpx 24rpx;
  89. .row-list{
  90. width: 340rpx;
  91. height: auto;
  92. float: left;
  93. margin-right: 20rpx;
  94. margin-bottom: 20rpx;
  95. border-radius: 2rpx;
  96. background: #FFFFFF;
  97. &:nth-child(2n){
  98. margin-right: 0;
  99. }
  100. .list-image{
  101. width: 100%;
  102. height: 340rpx;
  103. border-radius: 2rpx 2rpx 0 0;
  104. image{
  105. width: 100%;
  106. height: 340rpx;
  107. border-radius: 2rpx 2rpx 0 0;
  108. }
  109. }
  110. .list-name{
  111. font-size: $font-size-28;
  112. color: $text-color;
  113. line-height:88rpx;
  114. padding: 0 10rpx;
  115. overflow: hidden;
  116. white-space: nowrap;
  117. text-overflow: ellipsis;
  118. }
  119. }
  120. }
  121. .swiper__recommenddots-box{
  122. position: absolute;
  123. bottom: -20rpx;
  124. left: 0;
  125. right: 0;
  126. /* #ifndef APP-NVUE */
  127. display: flex;
  128. /* #endif */
  129. flex: 1;
  130. flex-direction: row;
  131. justify-content: center;
  132. align-items: center;
  133. height: 60rpx;
  134. background: #FFFFFF;
  135. .swiper__dots-item{
  136. width: 8rpx;
  137. height: 8rpx;
  138. border-radius: 100%;
  139. margin-left: 6px;
  140. background-color:rgba(0,0,0,.3);
  141. }
  142. .swiper__dots-long{
  143. width: 32rpx;
  144. height: 8rpx;
  145. border-radius: 4rpx;
  146. background-color: #000;
  147. transition: all 0.4s;
  148. }
  149. }
  150. }
  151. </style>