secondRecommend.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template name="recommend">
  2. <!-- 供应商信息 -->
  3. <view class="recommend clearfix">
  4. <view class="recommend-empty" v-if="isEmpty">
  5. <image src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/recmmmd.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. queryProductid: {
  24. // Unistars类型
  25. type: String,
  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.queryProductid
  43. this.infoRecommend(this.queryProductid)
  44. },
  45. methods:{
  46. infoRecommend(id){
  47. this.SellerService.ProductRecommend({productId:id}).then(response =>{
  48. if( response.data && response.data.length > 0){
  49. this.isEmpty = false
  50. this.recommendList = response.data
  51. }else{
  52. this.isEmpty = true
  53. }
  54. }).catch(error =>{
  55. this.$util.msg(error.msg,2000)
  56. })
  57. },
  58. //轮播图切换修改背景色
  59. swiperChange(e) {
  60. const index = e.detail.current;
  61. this.current = index;
  62. },
  63. navToDetailPage(id) {//跳转商品详情页
  64. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss">
  70. .recommend{
  71. width: 100%;
  72. .recommend-empty{
  73. width: 702rpx;
  74. // height: 100rpx;
  75. line-height: 100rpx;
  76. padding: 40rpx 24rpx;
  77. font-size: $font-size-28;
  78. color: #999999;
  79. text-align: center;
  80. image{
  81. width: 360rpx;
  82. height: 360rpx;
  83. }
  84. text{
  85. display: block;
  86. }
  87. }
  88. .recommend-list{
  89. width: 100%;
  90. height: auto;
  91. position: relative;
  92. box-sizing: border-box;
  93. padding: 0rpx 24rpx;
  94. .row-list{
  95. width: 340rpx;
  96. height: auto;
  97. float: left;
  98. margin-right: 20rpx;
  99. margin-bottom: 20rpx;
  100. border-radius: 20rpx;
  101. background: #FFFFFF;
  102. &:nth-child(2n){
  103. margin-right: 0;
  104. }
  105. .list-image{
  106. width: 100%;
  107. height: 340rpx;
  108. border-radius: 20rpx 20rpx 0 0;
  109. image{
  110. width: 100%;
  111. height: 340rpx;
  112. border-radius: 20rpx 20rpx 0 0;
  113. }
  114. }
  115. .list-name{
  116. font-size: $font-size-28;
  117. color: $text-color;
  118. line-height:88rpx;
  119. padding: 0 10rpx;
  120. overflow: hidden;
  121. white-space: nowrap;
  122. text-overflow: ellipsis;
  123. }
  124. }
  125. }
  126. .swiper__recommenddots-box{
  127. position: absolute;
  128. bottom: -20rpx;
  129. left: 0;
  130. right: 0;
  131. /* #ifndef APP-NVUE */
  132. display: flex;
  133. /* #endif */
  134. flex: 1;
  135. flex-direction: row;
  136. justify-content: center;
  137. align-items: center;
  138. height: 60rpx;
  139. background: #FFFFFF;
  140. .swiper__dots-item{
  141. width: 8rpx;
  142. height: 8rpx;
  143. border-radius: 100%;
  144. margin-left: 6px;
  145. background-color:rgba(0,0,0,.3);
  146. }
  147. .swiper__dots-long{
  148. width: 32rpx;
  149. height: 8rpx;
  150. border-radius: 4rpx;
  151. background-color: #000;
  152. transition: all 0.4s;
  153. }
  154. }
  155. }
  156. </style>