newArrival.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="new-arrival-page">
  3. <u-navbar title="新品推荐" :autoBack="true" bgColor="#fff" leftIconColor="#333"
  4. titleStyle="color:#333;font-weight:bold;"></u-navbar>
  5. <scroll-view scroll-y class="content-scroll" @scrolltolower="scrolltolower" :refresher-enabled="true"
  6. :refresher-triggered="triggered" @refresherrefresh="handleRefresher">
  7. <view class="goods-list">
  8. <view class="goods-item" v-for="(item, index) in dataList" :key="index" @click="navToGoods(item)">
  9. <image :src="item.imgUrl" mode="aspectFill" class="goods-img"></image>
  10. <view class="info">
  11. <text class="title">{{item.goodsName}}</text>
  12. <view class="price-box">
  13. <text class="price">¥{{item.otPrice || item.price}}</text>
  14. <text class="sales">已售{{item.sales || 0}}件</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <u-loadmore :status="status" marginTop="30"></u-loadmore>
  20. </scroll-view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getIntegralGoodsList
  26. } from '@/api/integral.js'
  27. export default {
  28. data() {
  29. return {
  30. dataList: [],
  31. pageNum: 1,
  32. pageSize: 10,
  33. status: 'loadmore',
  34. totalPage: 1,
  35. triggered: false,
  36. }
  37. },
  38. onLoad() {
  39. this.getList();
  40. },
  41. methods: {
  42. scrolltolower() {
  43. if (this.pageNum > this.totalPage) return
  44. this.pageNum++
  45. this.getList()
  46. },
  47. handleRefresher() {
  48. this.triggered = true;
  49. this.$nextTick(() => {
  50. this.pageNum = 1
  51. this.getList()
  52. })
  53. setTimeout(() => {
  54. this.triggered = false;
  55. }, 500);
  56. },
  57. getList() {
  58. this.status = 'loading';
  59. let data = {
  60. pageNum: this.pageNum,
  61. pageSize: this.pageSize,
  62. isNew: 1
  63. };
  64. getIntegralGoodsList(data).then(res => {
  65. if (res.code == 200) {
  66. let list = res.data.list || [];
  67. if (this.pageNum == 1) {
  68. this.dataList = list
  69. return
  70. }
  71. this.dataList = this.dataList.concat(list);
  72. this.totalPage = Math.ceil(res.data.total / this.pageSize);
  73. if (this.totalPage <= this.pageNum) {
  74. this.status = 'nomore';
  75. } else {
  76. this.status = 'loadmore';
  77. }
  78. }
  79. });
  80. },
  81. navToGoods(item) {
  82. uni.navigateTo({
  83. url: '/pages/user/integral/integralGoodsDetails?goodsId=' + item.goodsId
  84. });
  85. }
  86. }
  87. }
  88. </script>
  89. <style scoped lang="scss">
  90. .new-arrival-page {
  91. height: 100vh;
  92. display: flex;
  93. flex-direction: column;
  94. background: #F5F7FA;
  95. }
  96. .content-scroll {
  97. flex: 1;
  98. height: 0;
  99. padding: 20rpx;
  100. }
  101. .goods-list {
  102. display: flex;
  103. flex-wrap: wrap;
  104. justify-content: space-between;
  105. .goods-item {
  106. width: 48%;
  107. background: #fff;
  108. border-radius: 20rpx;
  109. margin-bottom: 24rpx;
  110. overflow: hidden;
  111. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  112. .goods-img {
  113. width: 100%;
  114. height: 340rpx;
  115. }
  116. .info {
  117. padding: 20rpx;
  118. .title {
  119. font-size: 28rpx;
  120. color: #333;
  121. line-height: 1.4;
  122. height: 80rpx;
  123. overflow: hidden;
  124. text-overflow: ellipsis;
  125. display: -webkit-box;
  126. -webkit-line-clamp: 2;
  127. -webkit-box-orient: vertical;
  128. font-weight: 500;
  129. }
  130. .price-box {
  131. margin-top: 20rpx;
  132. display: flex;
  133. justify-content: space-between;
  134. align-items: flex-end;
  135. .price {
  136. font-size: 34rpx;
  137. color: #FF5000;
  138. font-weight: bold;
  139. &::before {
  140. content: '¥';
  141. font-size: 24rpx;
  142. margin-right: 4rpx;
  143. }
  144. }
  145. .sales {
  146. font-size: 22rpx;
  147. color: #999;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. </style>