bad-out.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="container flex-d h100" @click="playGlobalSound">
  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, onUnmounted } from "vue";
  30. import { onLoad, onShow } from "@dcloudio/uni-app";
  31. // 搜索文本
  32. const searchText = ref("");
  33. const searchType = ref("1");
  34. // 点击全局音效
  35. function playGlobalSound(){
  36. uni.$u.playClickSound()
  37. }
  38. // 搜索处理
  39. const onSearch = () => {
  40. // 实现搜索逻辑
  41. uni.navigateTo({
  42. url: `/pages/index/wms/bad-out-order?searchText=${searchText.value}&searchType=${searchType.value}`,
  43. });
  44. };
  45. // 打开扫码
  46. const openScan = () => {
  47. // #ifdef APP-PLUS || MP-WEIXIN
  48. uni.scanCode({
  49. success: (res) => {
  50. searchText.value = res.result;
  51. onSearch();
  52. },
  53. fail: (err) => {
  54. uni.showToast({
  55. title: "扫码失败",
  56. icon: "error",
  57. });
  58. },
  59. });
  60. // #endif
  61. // #ifdef H5
  62. uni.showToast({
  63. title: "H5环境不支持扫码",
  64. icon: "none",
  65. });
  66. // #endif
  67. };
  68. // #ifdef APP-PLUS
  69. const { unregister } = uni.$u.useEventListener((e) => {
  70. if (e.barcode) {
  71. searchText.value = e.barcode
  72. onSearch()
  73. }
  74. });
  75. // #endif
  76. onUnmounted(() => {
  77. // #ifdef APP-PLUS
  78. unregister();
  79. // #endif
  80. });
  81. </script>