recommend.vue 3.4 KB

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