confirm-receipt.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="container">
  3. <!-- 底部按钮 -->
  4. <view class="footer">
  5. <!-- 查询区域 -->
  6. <view class="query-section">
  7. <u-radio-group v-model="formData.searchType">
  8. <u-radio label="查订单" name="1" labelSize="16px" iconSize="16px" />
  9. <u-radio label="查物流" custom-style="margin-left:20px" name="2" labelSize="16px" iconSize="16px" />
  10. </u-radio-group>
  11. <view class="search-box">
  12. <u-input
  13. custom-style="font-size:32rpx"
  14. placeholder-style="fong-size:32rpx"
  15. v-model="formData.search"
  16. :placeholder="formData.searchType == '1' ? '扫描/输入订单号' : '扫描/输入物流单号'"
  17. border="surround"
  18. clearable
  19. >
  20. </u-input>
  21. <u-button color="#c8c8c8" text="查询" @click="handleSubmit" />
  22. </view>
  23. </view>
  24. <u-divider></u-divider>
  25. <view style="display: flex">
  26. <u-button size="large" type="success" text="确认收货扫码" @click="handleScan" />
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { ref } from "vue";
  33. import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
  34. const formData = ref({
  35. searchType: "2",
  36. search: "",
  37. });
  38. // 处理查询
  39. const handleSubmit = () => {
  40. if (!formData.value.search) {
  41. uni.$u.toast("请扫描/输入物流单号");
  42. return;
  43. }
  44. uni.$u.http.post("/app/orderinfo/confirmOrder", formData.value).then((res) => {
  45. if (res.code == 200) {
  46. let text = formData.value.search + "收货成功";
  47. uni.$u.ttsModule.speak(text);
  48. } else {
  49. let text = formData.value.search + "订单不存在";
  50. uni.$u.ttsModule.speak(text);
  51. }
  52. });
  53. };
  54. // 处理扫码
  55. const handleScan = () => {
  56. uni.scanCode({
  57. success: (res) => {
  58. formData.value.search = res.result;
  59. handleSubmit();
  60. },
  61. });
  62. };
  63. onLoad(() => {
  64. // #ifdef APP-PLUS
  65. uni.$u.useGlobalEvent((e) => {
  66. formData.value.search = e.barcode;
  67. handleSubmit();
  68. });
  69. // #endif
  70. });
  71. onShow(() => {
  72. uni.$u.updateActivePageOnShow();
  73. });
  74. onUnload(() => {
  75. uni.$u.cleanupOnPageUnload();
  76. });
  77. </script>
  78. <style lang="scss" scoped>
  79. @import "../components/common.scss";
  80. </style>