Incubator.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <!-- 选择保温箱、 -->
  3. <view>
  4. <u-navbar autoBack placeholder></u-navbar>
  5. <u-sticky :customNavHeight="navbarHeight()">
  6. <view class="search_card">
  7. <u-search :showAction="false" v-model="keyword" @change="searchChange"
  8. placeholder="输入关键字快速查找"></u-search>
  9. </view>
  10. </u-sticky>
  11. <view class="card_incubator" v-if="orderList.length > 0">
  12. <view class="item_bator" v-for="(item,index) in orderList" :key="index" @click="selectIncubator(item)">
  13. <span class="iconfont imagebwx icon-incubator"></span>
  14. <view>{{item.name}}</view>
  15. </view>
  16. <view style="width: 100%;">
  17. <u-loadmore lineColor="#ffffff" :status="loadStatus" :key="Math.random()" />
  18. </view>
  19. </view>
  20. <view style="margin-top: 20%;" v-else>
  21. <u-empty mode="list" text="暂无保温箱"></u-empty>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. keyword: '',
  30. currentPage: 1,
  31. pageSize: 15,
  32. loadingMore: true,
  33. loadStatus: 'loadmore', //loading 、nomore
  34. incubatorValue: '',
  35. orderList: [],
  36. detailsFlag: false,
  37. }
  38. },
  39. onReachBottom() {
  40. if (!this.loadingMore) {
  41. this.getIncubator()
  42. }
  43. },
  44. onLoad(option) {
  45. if (option.detailsFlag) {
  46. this.detailsFlag = true
  47. }
  48. console.log(option, 25)
  49. },
  50. mounted() {
  51. this.getIncubator()
  52. },
  53. methods: {
  54. // 搜索
  55. searchChange(value) {
  56. this.currentPage = 1
  57. this.orderList = []
  58. this.loadingMore = true
  59. this.getIncubator()
  60. },
  61. // 获取保温箱
  62. getIncubator() {
  63. this.loadStatus = 'loading'
  64. this.loadingMore = true
  65. this.$api.get('/api/cooler-box', {
  66. page: this.currentPage,
  67. pageSize: this.pageSize,
  68. name: this.keyword,
  69. status: '2',
  70. }).then(res => {
  71. if (res.code == 200) {
  72. const data = res.data.list
  73. if (this.loadingMore == true && data) {
  74. this.orderList = this.orderList.concat(data);
  75. }
  76. if (data.length < this.pageSize) {
  77. this.loadingMore = true
  78. this.loading = '没有更多了'
  79. this.loadStatus = 'nomore'
  80. } else {
  81. this.loading = '加载中'
  82. this.loadStatus = 'loading'
  83. this.loadingMore = false
  84. this.currentPage++
  85. }
  86. }
  87. })
  88. },
  89. // 选择保温箱
  90. selectIncubator(value) {
  91. if (this.detailsFlag) {
  92. console.log('详情')
  93. } else {
  94. uni.setStorageSync('incubatorValue', value)
  95. uni.navigateBack({
  96. delta: 1
  97. });
  98. }
  99. },
  100. navbarHeight() {
  101. let systemInfo = uni.getSystemInfoSync();
  102. /* (750 / systemInfo.windowWidth) */
  103. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  104. let topHeight = 0
  105. // #ifdef APP-PLUS
  106. topHeight = 44 + systemInfo.statusBarHeight;
  107. // #endif
  108. // #ifdef MP
  109. let height = systemInfo.platform == 'ios' ? 44 : 48;
  110. topHeight = height + systemInfo.statusBarHeight
  111. // #endif
  112. /* 最后一步将px转为rpx */
  113. return topHeight * (750 / systemInfo.windowWidth) / 2
  114. },
  115. },
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .card_incubator {
  120. display: flex;
  121. flex-direction: column;
  122. margin-top: 10rpx;
  123. }
  124. .search_card {
  125. background-color: #fff;
  126. padding: 20rpx;
  127. }
  128. .item_bator {
  129. display: flex;
  130. align-items: center;
  131. background-color: #fff;
  132. border-radius: 10rpx;
  133. padding: 30rpx;
  134. margin: 10rpx 20rpx;
  135. }
  136. .imagebwx {
  137. color: #2b85e4;
  138. font-size: 60rpx;
  139. margin-right: 20rpx;
  140. }
  141. </style>