confirm-receipt.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. const searchKeyword = ref('');
  38. // 处理查询
  39. const handleSubmit = () => {
  40. console.log('查询:', searchKeyword.value);
  41. if(!formData.value.search){
  42. uni.$u.toast('请扫描/输入物流单号')
  43. return
  44. }
  45. uni.$u.http.post('/app/orderinfo/confirmOrder', formData.value).then(res => {
  46. console.log(res)
  47. if (res.code == 200) {
  48. let text = code + '收货成功'
  49. uni.$u.ttsModule.speak(text)
  50. } else {
  51. let text = code + '订单不存在'
  52. uni.$u.ttsModule.speak(text)
  53. }
  54. })
  55. };
  56. // 处理扫码
  57. const handleScan = () => {
  58. uni.scanCode({
  59. success: (res) => {
  60. formData.value.search = res.result;
  61. handleSubmit();
  62. }
  63. });
  64. };
  65. onLoad(() => {
  66. // #ifdef APP-PLUS
  67. uni.$u.useGlobalEvent((e) => {
  68. formData.value.search = e.barcode
  69. handleSubmit()
  70. })
  71. // #endif
  72. })
  73. </script>
  74. <style lang="scss" scoped>
  75. @import '../components/common.scss';
  76. </style>