Incubator.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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>
  17. <view style="margin-top: 20%;" v-else>
  18. <u-empty mode="list" text="暂无保温箱"></u-empty>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. keyword: '',
  27. currentPage: 1,
  28. pageSize: 15,
  29. loadingMore: true,
  30. incubatorValue: '',
  31. orderList: [],
  32. }
  33. },
  34. onReachBottom() {
  35. if (!this.loadingMore) {
  36. this.getIncubator()
  37. }
  38. },
  39. mounted() {
  40. this.getIncubator()
  41. },
  42. methods: {
  43. // 搜索
  44. searchChange(value) {
  45. this.currentPage = 1
  46. this.orderList = []
  47. this.loadingMore = true
  48. this.getIncubator()
  49. },
  50. // 获取保温箱
  51. getIncubator() {
  52. this.loadingMore = true
  53. this.$api.get('/api/cooler-box', {
  54. page: this.currentPage,
  55. pageSize: this.pageSize,
  56. name: this.keyword,
  57. status: '2',
  58. }).then(res => {
  59. if (res.code == 200) {
  60. const data = res.data.list
  61. if (this.loadingMore == true && data) {
  62. this.orderList = this.orderList.concat(data);
  63. }
  64. if (data.length < this.pageSize) {
  65. this.loadingMore = true
  66. this.loading = '没有更多了'
  67. } else {
  68. this.loading = '加载中'
  69. this.loadingMore = false
  70. this.currentPage++
  71. }
  72. }
  73. })
  74. },
  75. // 选择保温箱
  76. selectIncubator(value) {
  77. uni.setStorageSync('incubatorValue', value)
  78. uni.navigateBack({
  79. delta: 1
  80. });
  81. },
  82. navbarHeight() {
  83. let systemInfo = uni.getSystemInfoSync();
  84. /* (750 / systemInfo.windowWidth) */
  85. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  86. let topHeight = 0
  87. // #ifdef APP-PLUS
  88. topHeight = 44 + systemInfo.statusBarHeight;
  89. // #endif
  90. // #ifdef MP
  91. let height = systemInfo.platform == 'ios' ? 44 : 48;
  92. topHeight = height + systemInfo.statusBarHeight
  93. // #endif
  94. /* 最后一步将px转为rpx */
  95. return topHeight * (750 / systemInfo.windowWidth) / 2
  96. },
  97. },
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .card_incubator {
  102. display: flex;
  103. flex-direction: column;
  104. margin-top: 10rpx;
  105. }
  106. .search_card {
  107. background-color: #fff;
  108. padding: 20rpx;
  109. }
  110. .item_bator {
  111. display: flex;
  112. align-items: center;
  113. background-color: #fff;
  114. border-radius: 10rpx;
  115. padding: 30rpx;
  116. margin: 10rpx 20rpx;
  117. }
  118. .imagebwx {
  119. color: #2b85e4;
  120. font-size: 60rpx;
  121. margin-right: 20rpx;
  122. }
  123. </style>