plantList.vue 3.9 KB

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