route-exception.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="container">
  3. <!-- 顶部标签页 -->
  4. <u-subsection :list="tabList" :current="curNow" @change="sectionChange" mode="subsection"></u-subsection>
  5. <!-- 列表区域 -->
  6. <scroll-view scroll-y class="list-container" @scrolltolower="loadMore" refresher-enabled
  7. @refresherrefresh="onRefresh" :refresher-triggered="isRefreshing">
  8. <exception-item v-for="item in exceptionList" :key="item.orderNo" :order="item" />
  9. <!-- 加载更多 -->
  10. <u-loadmore :status="loadMoreStatus" @loadmore="loadMore" />
  11. </scroll-view>
  12. <!-- 底部搜索框 -->
  13. <view class="search-bar fixed-bottom">
  14. <u-search v-model="searchKeyword" placeholder="请输入物流单号/订单编号" :show-action="false" @search="handleSearch"
  15. height="80rpx" shape="round">
  16. </u-search>
  17. <u-icon name="scan" size="28" color="#19be6b" @click="handleScan" />
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import {
  23. ref,
  24. onMounted
  25. } from 'vue';
  26. import ExceptionItem from './components/ExceptionItem.vue';
  27. // 标签页配置
  28. const tabList = ['待处理订单', '历史异常签收'];
  29. const curNow = ref(0);
  30. // 定义方法,注意在 setup 中不需要 this,直接访问响应式引用
  31. function sectionChange(index) {
  32. curNow.value = index;
  33. }
  34. // 列表数据
  35. const exceptionList = ref([]);
  36. const page = ref(1);
  37. const loadMoreStatus = ref('loadmore'); // loadmore, loading, nomore
  38. const isRefreshing = ref(false);
  39. // 搜索相关
  40. const searchKeyword = ref('');
  41. // 初始化数据
  42. onMounted(() => {
  43. loadData();
  44. });
  45. // 加载数据
  46. const loadData = async (reset = false) => {
  47. if (reset) {
  48. page.value = 1;
  49. exceptionList.value = [];
  50. }
  51. // 模拟数据
  52. const mockData = [{
  53. orderNo: '5698542',
  54. expressNo: 'JDX0010258745151',
  55. estimatedPrice: '16.8',
  56. pusher: '涨涨涨',
  57. pushTime: '2024-06-15 15:00:00'
  58. }];
  59. // 这里替换为实际的API调用
  60. setTimeout(() => {
  61. exceptionList.value = [...exceptionList.value, ...mockData];
  62. loadMoreStatus.value = 'nomore';
  63. }, 1000);
  64. };
  65. // 下拉刷新
  66. const onRefresh = async () => {
  67. isRefreshing.value = true;
  68. await loadData(true);
  69. isRefreshing.value = false;
  70. };
  71. // 加载更多
  72. const loadMore = () => {
  73. if (loadMoreStatus.value === 'nomore') return;
  74. loadMoreStatus.value = 'loading';
  75. page.value++;
  76. loadData();
  77. };
  78. // 搜索处理
  79. const handleSearch = () => {
  80. loadData(true);
  81. };
  82. // 扫码处理
  83. const handleScan = () => {
  84. uni.scanCode({
  85. success: (res) => {
  86. searchKeyword.value = res.result;
  87. handleSearch();
  88. }
  89. });
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .container {
  94. display: flex;
  95. flex-direction: column;
  96. height: 100vh;
  97. box-sizing: border-box;
  98. }
  99. .list-container {
  100. flex: 1;
  101. padding: 12px;
  102. box-sizing: border-box;
  103. }
  104. .search-bar {
  105. padding: 12px;
  106. box-sizing: border-box;
  107. background-color: #fff;
  108. border-top: 1px solid #eee;
  109. :deep(.u-search) {
  110. background-color: #f5f5f5;
  111. }
  112. }
  113. </style>