recommend.vue 3.2 KB

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