search-store.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view>
  3. <view class="px3 py2 p-fixed left0 right0 bg-color-white ">
  4. <u-search placeholder="请输入名称" v-model="keyword" @search="search" @custom="search">
  5. </u-search>
  6. </view>
  7. <view style="padding-top: 104rpx;">
  8. <template v-if="listData.length > 0">
  9. <view class="py2 px3 one-ellipsis border-bottom" v-for="(item,index) in listData" :key="index" @click="handleBack(item)">
  10. {{ item.name }}
  11. </view>
  12. <view class="py3">
  13. <u-loadmore :status="status" />
  14. </view>
  15. </template>
  16. <template v-else>
  17. <view class="empty">
  18. <u-empty text="暂无数据" mode="list"></u-empty>
  19. </view>
  20. </template>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. keyword: '',
  29. listData: [],
  30. status: 'loadmore',
  31. page: 1,
  32. limit: 20,
  33. loadMore: true
  34. }
  35. },
  36. onLoad() {
  37. this.initData()
  38. },
  39. onPullDownRefresh() {
  40. // 请求结束取消刷新
  41. this.page = 1;
  42. this.loadMore = true;
  43. this.listData = [];
  44. this.initData();
  45. uni.stopPullDownRefresh();
  46. },
  47. onReachBottom() {
  48. if (this.loadMore) {
  49. this.page++;
  50. this.initData();
  51. }
  52. },
  53. methods: {
  54. handleBack(item) {
  55. if(item.level == 1){
  56. uni.showToast({ icon: 'none', title: '请选择库位!', duration: 2000 });
  57. return;
  58. }
  59. const pages = getCurrentPages();
  60. const prevPage = pages[pages.length - 2];
  61. prevPage.backId = item.id
  62. prevPage.backName = item.name
  63. console.log(item.name)
  64. // prevPage.setData({
  65. // "ceshiId":item.id,
  66. // })
  67. // console.log(prevPage);
  68. uni.navigateBack();
  69. },
  70. search(value) {
  71. console.log(value);
  72. this.page = 1;
  73. this.loadMore = true;
  74. this.listData = [];
  75. this.initData();
  76. },
  77. initData() {
  78. const that = this
  79. that.status = 'loading';
  80. this.$Http
  81. .getStorePage({
  82. pageNum: that.page,
  83. pageSize: that.limit,
  84. filter: -1,
  85. keyword: that.keyword
  86. })
  87. .then((res) => {
  88. const data = res.data.rows;
  89. if (data && data.length > 0 && data.length < that.limit) {
  90. that.status = 'nomore';
  91. that.loadMore = false;
  92. } else if (data.length == that.limit) {
  93. that.status = 'loadmore';
  94. } else {
  95. that.status = 'nomore';
  96. }
  97. that.listData = [...that.listData, ...data];
  98. console.log(that.listData);
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. page{
  106. background-color: #FFFFFF;
  107. }
  108. </style>