hotgoods.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. loadIndexs
  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. loadIndexs({}).then(({
  46. data
  47. }) => {
  48. this.recommendList = data.info.firstList; // 热销产品
  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. padding-bottom: 108rpx;
  69. .recommend-item{
  70. width: 100%;
  71. display: flex;
  72. background-color: #fff;
  73. align-items: center;
  74. margin-top: 24rpx;
  75. border-radius: 12rpx;
  76. // padding: ;
  77. }
  78. }
  79. .image-wrapper{
  80. margin-left: 20rpx;
  81. width: 190rpx;
  82. height: 190rpx;
  83. // background-color: pink;
  84. // flex-shrink: 0;
  85. // padding: 24rpx;
  86. image{
  87. width: 190rpx;
  88. height: 190rpx;
  89. opacity: 1;
  90. }
  91. }
  92. .info-wrapper{
  93. width: 100%;
  94. margin-left: 24rpx;
  95. display: flex;
  96. flex-direction: column;
  97. padding: 33rpx 18rpx 28rpx 0;
  98. }
  99. .title{
  100. font-size: 30rpx;
  101. color: #333;
  102. font-weight: 700;
  103. word-break: break-all;
  104. display: -webkit-box;
  105. -webkit-line-clamp: 1;
  106. -webkit-box-orient: vertical;
  107. overflow: hidden;
  108. }
  109. .details{
  110. color: #FE6A42;
  111. font-size: 24rpx;
  112. margin-top: 6rpx;
  113. }
  114. .price-box{
  115. display: flex;
  116. margin-top: 38rpx;
  117. justify-content: space-between;
  118. }
  119. .price{
  120. display: flex;
  121. margin-top: 12rpx;
  122. }
  123. .current-price{
  124. color: #FF0000;
  125. font-size: 32rpx;
  126. }
  127. .old-price{
  128. color:#999999;
  129. font-size: 24rpx;
  130. margin-top: 8rpx;
  131. margin-left: 12rpx;
  132. text-decoration: line-through;
  133. }
  134. .buyNow{
  135. background: linear-gradient(180deg, #FD4646, #FF3535);
  136. box-shadow: 0px 2rpx 20rpx 0px rgba(253, 67, 67, 0.5);
  137. border-radius: 30rpx;
  138. color: #FFFFFF;
  139. padding: 12rpx 24rpx;
  140. }
  141. </style>