secondRecommend.vue 3.5 KB

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