bad-out.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="container flex-d h100">
  3. <!-- 库位列表 -->
  4. <view class="location-list flex-1">
  5. <view class="no-data flex-c mt-60">请输入快递单号/订单编号</view>
  6. </view>
  7. <!-- 底部搜索框 -->
  8. <view class="pad-20 flex flex-column" style="background: #ffffff">
  9. <u-radio-group v-model="searchType" class="mb-20 ml-20">
  10. <u-radio label="查订单" name="1" label-size="17" />
  11. <u-radio label="查物流" custom-style="margin-left:20px" name="2" label-size="17" />
  12. </u-radio-group>
  13. <view class="flex-a">
  14. <u-search
  15. v-model="searchText"
  16. placeholder="请输入快递单号/订单编号"
  17. :show-action="false"
  18. :clearabled="true"
  19. @search="onSearch"
  20. height="40"
  21. >
  22. </u-search>
  23. <u-icon name="scan" size="28" color="#19be6b" @click="openScan"></u-icon>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import { ref, computed, onMounted } from "vue";
  30. import { onLoad, onShow } from "@dcloudio/uni-app";
  31. // 搜索文本
  32. const searchText = ref("");
  33. const searchType = ref("1");
  34. // 搜索处理
  35. const onSearch = () => {
  36. // 实现搜索逻辑
  37. uni.navigateTo({
  38. url: `/pages/index/wms/bad-out-order?searchText=${searchText.value}&searchType=${searchType.value}`,
  39. });
  40. };
  41. // 打开扫码
  42. const openScan = () => {
  43. // #ifdef APP-PLUS || MP-WEIXIN
  44. uni.scanCode({
  45. success: (res) => {
  46. searchText.value = res.result;
  47. onSearch();
  48. },
  49. fail: (err) => {
  50. uni.showToast({
  51. title: "扫码失败",
  52. icon: "error",
  53. });
  54. },
  55. });
  56. // #endif
  57. // #ifdef H5
  58. uni.showToast({
  59. title: "H5环境不支持扫码",
  60. icon: "none",
  61. });
  62. // #endif
  63. };
  64. onLoad(() => {
  65. // #ifdef APP-PLUS
  66. uni.$u.useGlobalEvent((e) => {
  67. if (e.barcode) {
  68. searchText.value = e.barcode
  69. onSearch()
  70. }
  71. })
  72. // #endif
  73. })
  74. onShow(() => {
  75. uni.$u.updateActivePageOnShow()
  76. })
  77. </script>