bad-out.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 } 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. onLoad(() => {
  69. // #ifdef APP-PLUS
  70. uni.$u.useGlobalEvent((e) => {
  71. if (e.barcode) {
  72. searchText.value = e.barcode
  73. onSearch()
  74. }
  75. })
  76. // #endif
  77. })
  78. onShow(() => {
  79. uni.$u.updateActivePageOnShow()
  80. })
  81. </script>