iceCold.vue 3.9 KB

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