express-order.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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" :placeholder="form.searchType == '1' ? '扫描/输入订单编号' : '扫描/输入物流单号'" border="surround"
  13. clearable placeholder-style="font-size:32rpx" :custom-style="{ 'font-size': '32rpx' }">
  14. </u-input>
  15. <u-button color="#c8c8c8" text="查询" @click="handleSearch" />
  16. </view>
  17. </view>
  18. <u-divider></u-divider>
  19. <view style="display: flex;">
  20. <u-button size="large" type="success" text="扫码" @click="handleScan" />
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script setup>
  26. import {
  27. ref
  28. } from 'vue';
  29. import {
  30. onLoad
  31. } from '@dcloudio/uni-app'
  32. const form = ref({
  33. searchType: '2',
  34. search: ''
  35. });
  36. // 处理查询
  37. const handleSearch = () => {
  38. console.log('查询:', form.value.search);
  39. // TODO: 查询订单
  40. uni.$u.http.get('/app/orderinfo/getOrderInfoForCheck', {
  41. params: {
  42. ...form.value
  43. }
  44. }).then(res => {
  45. if (res.code == 200) {
  46. uni.setStorageSync('orderDetail', res.data)
  47. uni.navigateTo({
  48. url: `/pages/index/detail/index?id=${res.data.orderId}`
  49. })
  50. } else {
  51. if (res.code == 500) {
  52. let text = form.value.search + '订单不存在'
  53. uni.$u.ttsModule.speak(text)
  54. } else {
  55. uni.$u.toast(res.msg)
  56. uni.$u.ttsModule.speak(res.msg)
  57. }
  58. }
  59. })
  60. };
  61. // 处理扫码
  62. const handleScan = () => {
  63. uni.scanCode({
  64. success: (res) => {
  65. form.value.search = res.result;
  66. handleSearch();
  67. }
  68. });
  69. }
  70. onLoad(() => {
  71. // #ifdef APP-PLUS
  72. uni.$u.useGlobalEvent((e) => {
  73. form.value.search = e.barcode
  74. handleSearch()
  75. })
  76. // #endif
  77. })
  78. </script>
  79. <style lang="scss" scoped>
  80. @import '../components/common.scss';
  81. </style>