confirm-receipt.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 custom-style="font-size:32rpx" placeholder-style="fong-size:32rpx" v-model="formData.search"
  13. :placeholder="formData.searchType == '1' ? '扫描/输入订单号' : '扫描/输入物流单号'" border="surround"
  14. clearable>
  15. </u-input>
  16. <u-button color="#c8c8c8" text="查询" @click="handleSubmit" />
  17. </view>
  18. </view>
  19. <u-divider></u-divider>
  20. <view style="display: flex;">
  21. <u-button size="large" type="success" text="确认收货扫码" @click="handleScan" />
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script setup>
  27. import {
  28. ref
  29. } from 'vue';
  30. import {
  31. onLoad
  32. } from '@dcloudio/uni-app';
  33. const formData = ref({
  34. searchType: '2',
  35. search: '',
  36. });
  37. // 处理查询
  38. const handleSubmit = () => {
  39. if(!formData.value.search){
  40. uni.$u.toast('请扫描/输入物流单号')
  41. return
  42. }
  43. uni.$u.http.post('/app/orderinfo/confirmOrder', formData.value).then(res => {
  44. if (res.code == 200) {
  45. let text = formData.value.search + '收货成功'
  46. uni.$u.ttsModule.speak(text)
  47. } else {
  48. let text = formData.value.search + '订单不存在'
  49. uni.$u.ttsModule.speak(text)
  50. }
  51. })
  52. };
  53. // 处理扫码
  54. const handleScan = () => {
  55. uni.scanCode({
  56. success: (res) => {
  57. formData.value.search = res.result;
  58. handleSubmit();
  59. }
  60. });
  61. };
  62. onLoad(() => {
  63. // #ifdef APP-PLUS
  64. uni.$u.useGlobalEvent((e) => {
  65. formData.value.search = e.barcode
  66. handleSubmit()
  67. })
  68. // #endif
  69. })
  70. </script>
  71. <style lang="scss" scoped>
  72. @import '../components/common.scss';
  73. </style>