plantList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <scroll-view class="container" scroll-y="true" @scrolltolower="handleLoadMore()">
  3. <view style="padding-top: 20px;background-color: transparent;" v-if="plantList.length<=0">
  4. <u-divider color="#909399" border-color="#909399" bg-color="transparent">没有更多了</u-divider>
  5. </view>
  6. <view class="goods-row" v-for="(item, index) in plantList" :key="index" @click="goToGoodDetail(item)">
  7. <image class="goods-img" :src="item.imgPath" mode="aspectFill"></image>
  8. <view class="goods-info">
  9. <view class="goods-name">{{item.productName}}</view>
  10. <view class="goods-area">面积:{{item.areaSize}}㎡</view>
  11. <view class="goods-number">
  12. <text class="goods-icon">¥</text>
  13. <text class="goods-spec">{{item.bizPrice}}</text>
  14. <text class="goods-price">¥{{item.originalPrice}}</text>
  15. </view>
  16. <view class="goods-date">有效期:{{item.term}}天</view>
  17. </view>
  18. <view class="goods-cart">
  19. <view class="more-button">
  20. <view class="iconfont icongengduo"></view>
  21. </view>
  22. </view>
  23. </view>
  24. <u-top-tips ref="uTips"></u-top-tips>
  25. </scroll-view>
  26. </template>
  27. <script>
  28. const NET = require('@/utils/request')
  29. const API = require('@/config/api')
  30. export default {
  31. data() {
  32. return {
  33. pageIndex: 1,
  34. isOver: false,
  35. plantList: [],
  36. }
  37. },
  38. onLoad() {
  39. this.getGoodsList()
  40. },
  41. onPullDownRefresh() {
  42. this.pageIndex = 1
  43. this.plantList = []
  44. this.getGoodsList('refresh')
  45. },
  46. methods: {
  47. // 懒加载
  48. handleLoadMore() {
  49. if (!this.isOver) {
  50. this.pageIndex++
  51. this.getGoodsList()
  52. }
  53. },
  54. // 获取商品
  55. getGoodsList(refresh) {
  56. NET.request(API.getPlantList, {
  57. pageIndex: this.pageIndex,
  58. pageSize: 10,
  59. }, 'GET').then(res => {
  60. if (refresh == 'refresh') {
  61. uni.stopPullDownRefresh();
  62. }
  63. if (res.isSuccess) {
  64. if (res.data.list && res.data.list.length) {
  65. this.isOver = res.data.list.length != 10
  66. this.plantList = this.plantList.concat(res.data.list)
  67. }
  68. // else {
  69. // this.$refs.uTips.show({
  70. // title: res.msg,
  71. // type: 'warning',
  72. // })
  73. // }
  74. }
  75. }).catch(error => {
  76. console.log(error)
  77. this.$refs.uTips.show({
  78. title: '获取共享种植列表失败',
  79. type: 'warning',
  80. })
  81. })
  82. },
  83. // 跳转详情
  84. goToGoodDetail(item) {
  85. uni.navigateTo({
  86. url: '/pagesGood/goodDetails?minePlant=true&goodId=' + item.id + '&orderId=' + item.orderId
  87. });
  88. },
  89. },
  90. }
  91. </script>
  92. <style>
  93. page {
  94. background-color: #f7f7f7;
  95. }
  96. </style>
  97. <style lang="less" scoped>
  98. page {
  99. width: 100%;
  100. height: 100%;
  101. }
  102. .container {
  103. width: 100%;
  104. height: 100%;
  105. float: left;
  106. background-color: #f7f7f7;
  107. overflow-y: auto;
  108. .goods-row:first-child {
  109. margin-top: 12px;
  110. }
  111. .goods-row {
  112. width: calc(100% - 24px);
  113. height: 104px;
  114. float: left;
  115. padding: 11px 11px 11px 7px;
  116. box-sizing: border-box;
  117. margin: 0 0 12px 12px;
  118. background: #FFFFFF;
  119. box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
  120. border-radius: 15px;
  121. .goods-img {
  122. width: 84px;
  123. height: 84px;
  124. float: left;
  125. }
  126. .goods-info {
  127. width: calc(100% - 108px);
  128. height: 84px;
  129. box-sizing: border-box;
  130. padding-left: 6px;
  131. float: left;
  132. .goods-name {
  133. width: calc(100% + 24px);
  134. height: 20px;
  135. font-size: 16px;
  136. font-family: PingFang SC;
  137. color: #333333;
  138. line-height: 20px;
  139. white-space: nowrap;
  140. text-overflow: ellipsis;
  141. overflow: hidden;
  142. }
  143. .goods-area {
  144. height: 18px;
  145. margin: 6px 0 2px 0;
  146. line-height: 18px;
  147. font-size: 13px;
  148. font-family: PingFang SC;
  149. color: #666666;
  150. }
  151. .goods-number {
  152. height: 18px;
  153. font-family: PingFang SC;
  154. line-height: 18px;
  155. .goods-icon {
  156. font-size: 12px;
  157. color: #52A63A;
  158. }
  159. .goods-spec {
  160. font-size: 15px;
  161. color: #52A63A;
  162. margin-right: 15px;
  163. }
  164. .goods-price {
  165. font-size: 13px;
  166. text-decoration: line-through;
  167. color: #A67954;
  168. }
  169. }
  170. .goods-date {
  171. height: 16px;
  172. margin-top: 4px;
  173. line-height: 16px;
  174. font-size: 13px;
  175. font-family: PingFang SC;
  176. color: #666666;
  177. }
  178. }
  179. .goods-cart {
  180. width: 24px;
  181. height: 84px;
  182. float: left;
  183. .more-button {
  184. width: 24px;
  185. height: 20px;
  186. margin-top: 64px;
  187. .iconfont {
  188. color: #999999;
  189. font-size: 32px;
  190. line-height: 20px;
  191. }
  192. }
  193. }
  194. }
  195. }
  196. </style>