plantList.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <scroll-view class="container" scroll-y="true" @scrolltolower="handleLoadMore()">
  3. <view style="padding-top: 20px;background-color: #FFFFFF;" v-if="plantList.length<=0">
  4. <u-divider color="#909399" border-color="#909399">没有更多了</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"></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
  87. });
  88. },
  89. },
  90. }
  91. </script>
  92. <style lang="less" scoped>
  93. page {
  94. width: 100%;
  95. height: 100%;
  96. }
  97. .container {
  98. width: 100%;
  99. height: 100%;
  100. float: left;
  101. background-color: #f7f7f7;
  102. overflow-y: auto;
  103. .goods-row:first-child {
  104. margin-top: 12px;
  105. }
  106. .goods-row {
  107. width: calc(100% - 24px);
  108. height: 104px;
  109. float: left;
  110. padding: 11px 11px 11px 7px;
  111. box-sizing: border-box;
  112. margin: 0 0 12px 12px;
  113. background: #FFFFFF;
  114. box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
  115. border-radius: 15px;
  116. .goods-img {
  117. width: 84px;
  118. height: 84px;
  119. float: left;
  120. }
  121. .goods-info {
  122. width: calc(100% - 108px);
  123. height: 84px;
  124. box-sizing: border-box;
  125. padding-left: 6px;
  126. float: left;
  127. .goods-name {
  128. width: calc(100% + 24px);
  129. height: 20px;
  130. font-size: 16px;
  131. font-family: PingFang SC;
  132. color: #333333;
  133. line-height: 20px;
  134. white-space: nowrap;
  135. text-overflow: ellipsis;
  136. overflow: hidden;
  137. }
  138. .goods-area {
  139. height: 18px;
  140. margin: 6px 0 2px 0;
  141. line-height: 18px;
  142. font-size: 13px;
  143. font-family: PingFang SC;
  144. color: #666666;
  145. }
  146. .goods-number {
  147. height: 18px;
  148. font-family: PingFang SC;
  149. line-height: 18px;
  150. .goods-icon {
  151. font-size: 12px;
  152. color: #52A63A;
  153. }
  154. .goods-spec {
  155. font-size: 15px;
  156. color: #52A63A;
  157. margin-right: 15px;
  158. }
  159. .goods-price {
  160. font-size: 13px;
  161. text-decoration: line-through;
  162. color: #A67954;
  163. }
  164. }
  165. .goods-date {
  166. height: 16px;
  167. margin-top: 4px;
  168. line-height: 16px;
  169. font-size: 13px;
  170. font-family: PingFang SC;
  171. color: #666666;
  172. }
  173. }
  174. .goods-cart {
  175. width: 24px;
  176. height: 84px;
  177. float: left;
  178. .more-button {
  179. width: 24px;
  180. height: 20px;
  181. margin-top: 64px;
  182. .iconfont {
  183. color: #999999;
  184. font-size: 32px;
  185. line-height: 20px;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </style>