recommend.vue 3.5 KB

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