recommend.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="content">
  3. <view class="recommend">
  4. <view class="recommend-item" v-for="item in recommendList" :key="item.id" @click="navToDetailPage(item)">
  5. <view class="image-wrapper">
  6. <image :src="item.image" mode=""></image>
  7. </view>
  8. <view class="info-wrapper">
  9. <view class="title">{{ item.store_name}}</view>
  10. <view class="details">{{ item.details }}</view>
  11. <view class="price-box">
  12. <view class="price">
  13. <view class="current-price">
  14. ¥{{item.vip_price}}
  15. </view>
  16. <view class="old-price">
  17. ¥{{item.price}}
  18. </view>
  19. </view>
  20. <view class="buyNow">
  21. 立即购买
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. productIndexs
  32. } from '@/api/index.js';
  33. export default{
  34. data(){
  35. return{
  36. recommendList:[]
  37. }
  38. },
  39. onLoad() {
  40. this.loadData()
  41. },
  42. methods:{
  43. // 获取首页数据
  44. loadData() {
  45. productIndexs({},1).then(({
  46. data
  47. }) => {
  48. this.recommendList = data.list; // 为你推荐
  49. console.log('为你推荐',this.recommendList)
  50. })
  51. },
  52. // 跳转热销商品
  53. navToDetailPage(item) {
  54. uni.navigateTo({
  55. url: '/pages/product/product?id=' + item.id
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss">
  62. .content{
  63. width: 100%;
  64. height: 100%;
  65. }
  66. .recommend{
  67. padding: 0 24rpx;
  68. .recommend-item{
  69. width: 100%;
  70. display: flex;
  71. background-color: #fff;
  72. align-items: center;
  73. margin-top: 16rpx;
  74. border-radius: 12rpx;
  75. // padding: ;
  76. }
  77. }
  78. .image-wrapper{
  79. margin-left: 20rpx;
  80. width: 160rpx;
  81. height: 160rpx;
  82. // background-color: pink;
  83. flex-shrink: 0;
  84. // padding: 24rpx;
  85. image{
  86. width: 160rpx;
  87. height: 160rpx;
  88. opacity: 1;
  89. }
  90. }
  91. .info-wrapper{
  92. margin-left: 24rpx;
  93. width: 100%;
  94. display: flex;
  95. flex-direction: column;
  96. padding: 33rpx 18rpx 28rpx 0;
  97. }
  98. .title{
  99. font-size: 30rpx;
  100. color: #333;
  101. font-weight: 700;
  102. word-break: break-all;
  103. display: -webkit-box;
  104. -webkit-line-clamp: 1;
  105. -webkit-box-orient: vertical;
  106. overflow: hidden;
  107. }
  108. .details{
  109. color: #FE6A42;
  110. font-size: 24rpx;
  111. margin-top: 6rpx;
  112. }
  113. .price-box{
  114. display: flex;
  115. margin-top: 38rpx;
  116. justify-content: space-between;
  117. }
  118. .price{
  119. display: flex;
  120. margin-top: 12rpx;
  121. }
  122. .current-price{
  123. color: #FF0000;
  124. font-size: 32rpx;
  125. }
  126. .old-price{
  127. color:#999999;
  128. font-size: 24rpx;
  129. margin-top: 8rpx;
  130. margin-left: 12rpx;
  131. text-decoration: line-through;
  132. }
  133. .buyNow{
  134. background: linear-gradient(180deg, #FD4646, #FF3535);
  135. box-shadow: 0px 2rpx 20rpx 0px rgba(253, 67, 67, 0.5);
  136. border-radius: 30rpx;
  137. color: #FFFFFF;
  138. padding: 12rpx 24rpx;
  139. }
  140. </style>