recommend.vue 3.2 KB

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