secondRecommend.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template name="recommend">
  2. <!-- 供应商信息 -->
  3. <view class="recommend clearfix">
  4. <view class="recommend-empty" v-if="isEmpty">
  5. <image src="https://static.caimei365.com/app/img/icon/icon-prnone.png"></image>
  6. <text>暂无相关推荐商品</text>
  7. </view>
  8. <view class="recommend-list" v-else>
  9. <view class="row-list" v-for="(pros, idx) in recommendList" :key="idx" @click.stop="navToDetailPage(pros.productID)">
  10. <view class="list-image"><image :src="pros.mainImage" mode=""></image></view>
  11. <view class="list-name">{{pros.name}}</view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import authorize from '@/common/config/authorize.js'
  18. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  19. import tuiNomore from "@/components/tui-components/nomore/nomore"
  20. export default{
  21. name:'recommend',
  22. props:{
  23. productId: {
  24. // Unistars类型
  25. type: Number,
  26. }
  27. },
  28. components:{
  29. tuiLoadmore,
  30. tuiNomore,
  31. },
  32. data() {
  33. return{
  34. current:0,
  35. recommendList:[],
  36. isEmpty:false,
  37. pageSize:4,
  38. productID:'',
  39. }
  40. },
  41. created() {
  42. this.productID = this.productId
  43. console.log('productID',this.productID)
  44. this.infoRecommend(this.productID)
  45. },
  46. methods:{
  47. infoRecommend(id){
  48. this.SellerService.ProductRecommend({productId:id}).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. console.log('error',error)
  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. width: 100%;
  73. .recommend-empty{
  74. width: 100%;
  75. // height: 100rpx;
  76. line-height: 100rpx;
  77. padding: 40rpx 24rpx;
  78. box-sizing: border-box;
  79. font-size: $font-size-28;
  80. color: #999999;
  81. text-align: center;
  82. image{
  83. width: 360rpx;
  84. height: 360rpx;
  85. }
  86. text{
  87. display: block;
  88. }
  89. }
  90. .recommend-list{
  91. width: 100%;
  92. height: auto;
  93. position: relative;
  94. box-sizing: border-box;
  95. padding: 0rpx 24rpx;
  96. .row-list{
  97. width: 340rpx;
  98. height: auto;
  99. float: left;
  100. margin-right: 20rpx;
  101. margin-bottom: 20rpx;
  102. border-radius: 20rpx;
  103. background: #FFFFFF;
  104. &:nth-child(2n){
  105. margin-right: 0;
  106. }
  107. .list-image{
  108. width: 100%;
  109. height: 340rpx;
  110. border-radius: 20rpx 20rpx 0 0;
  111. image{
  112. width: 100%;
  113. height: 340rpx;
  114. border-radius: 20rpx 20rpx 0 0;
  115. }
  116. }
  117. .list-name{
  118. font-size: $font-size-28;
  119. color: $text-color;
  120. line-height:88rpx;
  121. padding: 0 10rpx;
  122. overflow: hidden;
  123. white-space: nowrap;
  124. text-overflow: ellipsis;
  125. }
  126. }
  127. }
  128. .swiper__recommenddots-box{
  129. position: absolute;
  130. bottom: -20rpx;
  131. left: 0;
  132. right: 0;
  133. /* #ifndef APP-NVUE */
  134. display: flex;
  135. /* #endif */
  136. flex: 1;
  137. flex-direction: row;
  138. justify-content: center;
  139. align-items: center;
  140. height: 60rpx;
  141. background: #FFFFFF;
  142. .swiper__dots-item{
  143. width: 8rpx;
  144. height: 8rpx;
  145. border-radius: 100%;
  146. margin-left: 6px;
  147. background-color:rgba(0,0,0,.3);
  148. }
  149. .swiper__dots-long{
  150. width: 32rpx;
  151. height: 8rpx;
  152. border-radius: 4rpx;
  153. background-color: #000;
  154. transition: all 0.4s;
  155. }
  156. }
  157. }
  158. </style>