route-exception.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="container">
  3. <!-- 列表区域 -->
  4. <page-scroll ref="pageScrollRef" height="100vh" :requestStr="requestStr" @updateList="updateList"
  5. :otherParams="otherParams">
  6. <u-sticky :offset-top="0">
  7. <!-- 顶部标签页 -->
  8. <u-subsection fontSize="16" :list="tabList" :current="curNow" @change="sectionChange" mode="subsection"
  9. class="tabs-list"></u-subsection>
  10. </u-sticky>
  11. <view class="list-container">
  12. <exception-item v-for="item in exceptionList" :key="item.id || item.orderId" :order="item" @refresh="handleRefresh" />
  13. </view>
  14. </page-scroll>
  15. <!-- 底部搜索框 -->
  16. <view class="search-bar fixed-bottom">
  17. <u-search v-model="otherParams.search" placeholder="请输入物流单号/订单编号" :show-action="false"
  18. :inputStyle="{ fontSize: '32rpx' }" @search="handleSearch" height="80rpx" shape="round">
  19. </u-search>
  20. <u-icon name="scan" size="28" color="#19be6b" @click="handleScan" />
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import {
  26. ref,
  27. nextTick,
  28. onUnmounted
  29. } from 'vue';
  30. import { onLoad, onShow } from '@dcloudio/uni-app';
  31. import ExceptionItem from './components/ExceptionItem.vue';
  32. import PageScroll from '@/components/pageScroll/index.vue';
  33. // 标签页配置
  34. const tabList = ['待处理订单', '历史异常签收'];
  35. const curNow = ref(0);
  36. // 列表数据
  37. const exceptionList = ref([]);
  38. let urlList = ['/app/orderexception/pagelist', '/app/orderexception/getPageLoglist'];
  39. //历史 /app/orderexception/getPageLoglist
  40. const requestStr = ref(urlList[0]);
  41. // 定义方法,注意在 setup 中不需要 this,直接访问响应式引用
  42. function sectionChange(index) {
  43. curNow.value = index;
  44. requestStr.value = urlList[index];
  45. handleSearch();
  46. }
  47. // 搜索相关
  48. const pageScrollRef = ref(null);
  49. const otherParams = ref({ search: '' });
  50. const updateList = (list) => {
  51. exceptionList.value = list;
  52. }
  53. // 搜索处理
  54. const handleSearch = () => {
  55. nextTick(() => {
  56. pageScrollRef.value?.resetUpScroll();
  57. });
  58. };
  59. // 操作成功后刷新列表
  60. const handleRefresh = () => {
  61. handleSearch();
  62. };
  63. // 扫码处理
  64. const handleScan = () => {
  65. uni.scanCode({
  66. success: (res) => {
  67. otherParams.value.search = res.result;
  68. handleSearch();
  69. }
  70. });
  71. };
  72. // #ifdef APP-PLUS
  73. const { unregister } = uni.$u.useEventListener((e) => {
  74. otherParams.value.search = e.barcode
  75. handleSearch()
  76. });
  77. // #endif
  78. onUnmounted(() => {
  79. // #ifdef APP-PLUS
  80. unregister();
  81. // #endif
  82. });
  83. </script>
  84. <style lang="scss" scoped>
  85. .container {
  86. display: flex;
  87. flex-direction: column;
  88. height: 100vh;
  89. box-sizing: border-box;
  90. padding-bottom: 140rpx;
  91. :deep(.tabs-list) {
  92. padding: 0 20rpx;
  93. height: 80rpx;
  94. margin-top: 20rpx;
  95. .u-subsection__item {
  96. height: 80rpx
  97. }
  98. }
  99. /* #ifdef H5 */
  100. :deep(.u-sticky){
  101. top: 0 !important;
  102. }
  103. /* #endif */
  104. }
  105. .list-container {
  106. flex: 1;
  107. padding: 24rpx;
  108. box-sizing: border-box;
  109. }
  110. .search-bar {
  111. padding: 12px;
  112. box-sizing: border-box;
  113. background-color: #fff;
  114. border-top: 2rpx solid #eee;
  115. :deep(.u-search) {
  116. background-color: #f5f5f5;
  117. font-size: 32rpx;
  118. }
  119. }
  120. </style>