express-order.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="container">
  3. <!-- 底部按钮 -->
  4. <view class="footer">
  5. <!-- 查询区域 -->
  6. <view class="query-section">
  7. <u-radio-group v-model="form.searchType">
  8. <u-radio label="查订单" name="1" label-size="17" />
  9. <u-radio label="查物流" custom-style="margin-left:20px" name="2" label-size="17" />
  10. </u-radio-group>
  11. <view class="search-box">
  12. <u-input custom-style="width:100rpx" v-model="form.search"
  13. :placeholder="form.searchType == '1' ? '扫描/输入订单编号' : '扫描/输入物流单号'" border="surround" clearable
  14. placeholder-style="font-size:32rpx" :custom-style="{ 'font-size': '32rpx' }">
  15. </u-input>
  16. <u-button color="#c8c8c8" text="查询" @click="handleSearch" />
  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 form = ref({
  34. searchType: '2',
  35. search: ''
  36. });
  37. // 处理查询
  38. const handleSearch = () => {
  39. console.log('查询:', form.value.search);
  40. // TODO: 查询订单
  41. uni.$u.http.get('/app/orderinfo/getOrderInfoForCheck', {
  42. params: {
  43. ...form.value
  44. }
  45. }).then(res => {
  46. if (res.code == 200) {
  47. uni.setStorageSync('orderDetail', res.data)
  48. uni.navigateTo({
  49. url: `/pages/index/detail/index?id=${res.data.orderId}`
  50. })
  51. } else {
  52. let text = form.value.search + res.msg
  53. uni.$u.ttsModule.speak(text)
  54. }
  55. })
  56. };
  57. // 处理扫码
  58. const handleScan = () => {
  59. uni.scanCode({
  60. success: (res) => {
  61. form.value.search = res.result;
  62. handleSearch();
  63. }
  64. });
  65. }
  66. onLoad(() => {
  67. // #ifdef APP-PLUS
  68. uni.$u.useGlobalEvent((e) => {
  69. form.value.search = e.barcode
  70. handleSearch()
  71. })
  72. // #endif
  73. })
  74. </script>
  75. <style lang="scss" scoped>
  76. @import '../components/common.scss';
  77. </style>