store.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="content">
  3. <view class="goods-list">
  4. <view class="goods-item" v-for="(item, index) in goodsList" :key="index" @click="addCart(item)">
  5. <image :src="item.image" mode="aspectFill" class="goods-image"></image>
  6. <view class="goods-name clamp">{{item.store_name}}</view>
  7. <view class="goods-info">
  8. <text class="goods-points">{{item.price}} 积分</text>
  9. <image src="/static/icon/cart.png" mode="widthFix" class="add-cart" ></image>
  10. </view>
  11. </view>
  12. </view>
  13. <m-tabbar fixed fill current="1" :tabbar="tabbar"></m-tabbar>
  14. </view>
  15. </template>
  16. <script>
  17. import TabbarConfig from '@/config/tabbar.js'
  18. import { getProductList } from '@/api/good.js'
  19. export default {
  20. data() {
  21. return {
  22. tabbar: TabbarConfig,
  23. page: 1,
  24. limit: 20,
  25. list: [],
  26. loaded: false,
  27. status: 'more',
  28. goodsList: []
  29. };
  30. },
  31. methods: {
  32. // 返回
  33. getProductList() {
  34. let that = this
  35. if(that.status == 'noMore' || that.status == 'loading') return;
  36. that.status = 'loading'
  37. getProductList({
  38. page: that.page,
  39. pageSize: that.limit,
  40. }).then(res => {
  41. let list = res.data.list
  42. that.goodsList = that.goodsList.concat(list)
  43. if(that.limit == list.length) {
  44. that.status = 'more'
  45. }else {
  46. that.status = 'noMore'
  47. }
  48. that.loaded = true
  49. })
  50. },
  51. // 添加到购物车
  52. addCart(item) {
  53. uni.navigateTo({
  54. url:'/pages/user/jf/detail?id=' + item.id
  55. })
  56. }
  57. },
  58. onLoad() {
  59. this.getProductList()
  60. },
  61. onReachBottom() {
  62. this.getProductList()
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. page {
  68. height: 100%;
  69. background-color: #F5F5F5;
  70. }
  71. .content {
  72. min-height: 100%;
  73. }
  74. .header {
  75. display: flex;
  76. align-items: center;
  77. justify-content: space-between;
  78. padding: 0 30rpx;
  79. height: 80rpx;
  80. background-color: #FF4444;
  81. .back {
  82. width: 40rpx;
  83. height: 40rpx;
  84. image {
  85. width: 100%;
  86. height: 100%;
  87. }
  88. }
  89. .title {
  90. font-size: 32rpx;
  91. font-weight: bold;
  92. color: #FFFFFF;
  93. }
  94. .right {
  95. width: 40rpx;
  96. }
  97. }
  98. .goods-list {
  99. display: flex;
  100. flex-wrap: wrap;
  101. padding: 0 15rpx;
  102. justify-content: space-between;
  103. padding-top: 20rpx;
  104. .goods-item {
  105. width: 350rpx;
  106. // margin: 1%;
  107. background-color: #FFFFFF;
  108. border-radius: 15rpx;
  109. overflow: hidden;
  110. margin-bottom: 20rpx;
  111. .goods-image {
  112. width: 350rpx;
  113. height: 300rpx;
  114. }
  115. .goods-name {
  116. width: 330rpx;
  117. padding: 15rpx ;
  118. font-size: 26rpx;
  119. color: #333333;
  120. line-height: 36rpx;
  121. height: 72rpx;
  122. // overflow: hidden;
  123. // text-overflow: ellipsis;
  124. // display: -webkit-box;
  125. // -webkit-line-clamp: 2;
  126. // -webkit-box-orient: vertical;
  127. }
  128. .goods-info {
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. padding: 0 15rpx 15rpx;
  133. .goods-points {
  134. font-size: 26rpx;
  135. font-weight: bold;
  136. color: #FF4444;
  137. }
  138. .add-cart {
  139. width: 40rpx;
  140. height: 40rpx;
  141. background-color: #FF4444;
  142. border-radius: 50%;
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. .cart-icon {
  147. width: 24rpx;
  148. height: 24rpx;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. </style>