duihuanMore.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="content">
  3. <view class="recommend">
  4. <view class="recommend-item" v-for="item in recommendList" :key="item.id">
  5. <view class="image-wrapper"><image :src="item.image" mode="scaleToFill"></image></view>
  6. <view class="info-wrapper">
  7. <text class="title">{{ item.title }}</text>
  8. <view class="price-box">
  9. <view class="price-left">
  10. <view class="price">
  11. <view class="">{{ item.money * 1 }}</view>
  12. <view class="ot_price" >
  13. <view class="price-tip">{{ item.money_type }}</view>
  14. <view class="price-tip" v-if="item.price != 0">+¥{{ item.price }}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="price-right" @click="navToDetailPage(item)">
  19. <view class="buyNow">马上购</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <uni-load-more :status="loadingType"></uni-load-more>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { dhList } from '@/api/user.js';
  30. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  31. export default {
  32. components: {
  33. uniLoadMore
  34. },
  35. data() {
  36. return {
  37. recommendList: [],
  38. type: '',
  39. page: 1,
  40. limit: 10,
  41. loadingType: 'more'
  42. };
  43. },
  44. //监听页面是否滚动到底部加载更多
  45. onReachBottom() {
  46. this.loadData();
  47. },
  48. onLoad(option) {
  49. if (option.type) {
  50. this.type = option.type;
  51. }
  52. this.loadData();
  53. },
  54. methods: {
  55. // 获取首页数据
  56. loadData() {
  57. const obj = this
  58. if (obj.loadingType == 'nomore' || obj.loadingType == 'loading') {
  59. return;
  60. }
  61. obj.loadingType == 'loading';
  62. dhList({ page: obj.page, limit: obj.limit, money_type: this.type }).then(({ data }) => {
  63. this.recommendList = data; // 为你推荐
  64. obj.page++;
  65. if (data.length == obj.limit) {
  66. obj.loadingType == 'more';
  67. } else {
  68. obj.loadingType == 'nomore';
  69. }
  70. });
  71. },
  72. // 跳转热销商品
  73. navToDetailPage(item){
  74. uni.navigateTo({
  75. url: '/pages/product/productDuhuan?id=' + item.id
  76. });
  77. },
  78. }
  79. };
  80. </script>
  81. <style lang="scss">
  82. .content {
  83. width: 100%;
  84. height: 100%;
  85. }
  86. .recommend {
  87. padding: 24rpx;
  88. .recommend-item {
  89. background-color: #FFFFFF;
  90. display: flex;
  91. width: 100%;
  92. padding: 24rpx;
  93. border-bottom: 1rpx solid #f0f0f0;
  94. &:nth-last-child(1) {
  95. border-bottom: none;
  96. }
  97. }
  98. }
  99. .image-wrapper {
  100. width: 168rpx;
  101. height: 168rpx;
  102. border-radius: 3px;
  103. image {
  104. width: 168rpx;
  105. height: 168rpx;
  106. opacity: 1;
  107. }
  108. }
  109. .info-wrapper {
  110. width: 100%;
  111. display: flex;
  112. flex-direction: column;
  113. margin-left: 20rpx;
  114. }
  115. .title {
  116. font-size: 32rpx;
  117. color: $font-color-dark;
  118. word-break: break-all;
  119. display: -webkit-box;
  120. -webkit-line-clamp: 1;
  121. -webkit-box-orient: vertical;
  122. overflow: hidden;
  123. }
  124. .price-box {
  125. margin-top: 10rpx;
  126. display: flex;
  127. justify-content: space-between;
  128. .price-left {
  129. display: flex;
  130. flex-direction: column;
  131. .price {
  132. display: flex;
  133. justify-content: flex-start;
  134. align-items: center;
  135. margin-top: 60rpx;
  136. height: 56rpx;
  137. line-height: 30rpx;
  138. color: #ff0000;
  139. font-size: 56rpx;
  140. font-weight: 700;
  141. .price-tip {
  142. font-size: 28rpx;
  143. }
  144. }
  145. .ot_price {
  146. margin-left: 4rpx;
  147. font-size: 28rpx;
  148. color: #ff0000;
  149. .price-tip {
  150. font-size: 22rpx;
  151. }
  152. }
  153. }
  154. .price-right {
  155. display: flex;
  156. flex-direction: column;
  157. .people {
  158. margin-top: 32rpx;
  159. font-weight: 700;
  160. color: #999999;
  161. font-size: 22rpx;
  162. text-align: right;
  163. margin-right: 4rpx;
  164. }
  165. .buyNow {
  166. margin-top: 68rpx;
  167. background: linear-gradient(180deg, #fd4646, #ff3535);
  168. border-radius: 26rpx;
  169. padding: 6rpx 18rpx;
  170. font-size: 26rpx;
  171. font-weight: 400;
  172. color: #ffffff;
  173. }
  174. }
  175. }
  176. </style>