recommend.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="all">
  3. <image src="@/static/img/i-t.png"></image>
  4. <view class="title">
  5. <text>为你推荐</text>
  6. </view>
  7. <view class="list">
  8. <view class="item" v-for="b in bastList">
  9. <view class="item-img">
  10. <!-- <image :src=b.image mode="" v-if="b.image"></image> -->
  11. <image :src = "b.image" :onerror="defaultImg"></image>
  12. </view>
  13. <view class="item-right">
  14. <view class="name">
  15. {{b.store_name}}
  16. </view>
  17. <view class="item-price">
  18. <view class="">
  19. <text class="ot-price">¥{{b.ot_price}}</text>
  20. <image src="../../../static/icon/decline.png" v-if="b.ot_price - b.price > 0"></image>
  21. <text v-if="b.ot_price - b.price > 0">直降{{b.ot_price - b.price}}元</text><br>
  22. <text class="price">¥{{b.price}}</text>
  23. </view>
  24. <view class="button" @click="navToDetailPage(b)">立即购买</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { getHot } from '@/api/index.js';
  33. export default {
  34. data() {
  35. return {
  36. defaultImg: 'this.src="' + require('@/static/error/errorImage.jpg') + '"',
  37. page: 1,
  38. limit: 10,
  39. bastList: []
  40. }
  41. },
  42. mounted() {
  43. this.loadData()
  44. },
  45. methods: {
  46. //详情页
  47. navToDetailPage(item) {
  48. this.$parent.$parent.$parent.navToDetailPage(item)
  49. },
  50. // 为你推荐
  51. async loadData() {
  52. let obj = this;
  53. let data = {
  54. page: obj.page,
  55. limit: obj.limit
  56. }
  57. getHot({data}).then(res => {
  58. console.log(res.data)
  59. this.bastList = res.data
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .all {
  67. text-align: center;
  68. padding-bottom: 30rpx;
  69. }
  70. image {
  71. width: 350rpx;
  72. height: 30rpx;
  73. }
  74. .title {
  75. position: relative;
  76. top: -45rpx;
  77. color: #438BED ;
  78. font-size: 30rpx;
  79. font-weight: bold;
  80. }
  81. .list {
  82. padding: 0 5%;
  83. .item {
  84. display: flex;
  85. padding: 20rpx;
  86. box-shadow:0 0 20rpx 6rpx #f1f1f1;
  87. border-radius: 20rpx;
  88. margin-bottom: 20rpx;
  89. .item-img {
  90. margin-right: 40rpx;
  91. image {
  92. width: 200rpx;
  93. height: 200rpx;
  94. }
  95. }
  96. .item-right {
  97. width: 100%;
  98. text-align: left;
  99. display: grid;
  100. align-content: space-between;
  101. .name {
  102. color: #333333;
  103. font-size: 30rpx;
  104. font-weight: bold;
  105. font-family: PingFang-SC-Bold;
  106. overflow: hidden;
  107. text-overflow: ellipsis;
  108. display: -webkit-box;
  109. -webkit-box-orient: vertical;
  110. -webkit-line-clamp: 2;
  111. }
  112. text {
  113. color: #FFB238;
  114. font-size: 20rpx;
  115. }
  116. .item-price {
  117. display: flex;
  118. justify-content: space-between;
  119. image {
  120. width: 20rpx;
  121. height: 20rpx;
  122. margin-right: 5rpx;
  123. }
  124. .ot-price {
  125. color: #999999;
  126. text-decoration: line-through;
  127. margin-right: 5rpx;
  128. }
  129. .price {
  130. color: #EF3A55;
  131. font-size: 35rpx;
  132. }
  133. .button {
  134. min-width: 125rpx;
  135. background: linear-gradient(90deg, #438BED 0%, #44BFEC 100%);
  136. background-color: #438BED;
  137. height: 50rpx;
  138. border-radius: 20rpx;
  139. padding: 10rpx 15rpx;
  140. color: #fff;
  141. font-size: 25rpx;
  142. position: relative;
  143. top: 30rpx;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. </style>