express-order.vue 2.4 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"
  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. onShow
  33. } from '@dcloudio/uni-app'
  34. const form = ref({
  35. searchType: '2',
  36. search: ''
  37. });
  38. // 处理查询
  39. const handleSearch = () => {
  40. console.log('查询:', form.value.search);
  41. // TODO: 查询订单
  42. uni.$u.http.get('/app/orderinfo/getOrderInfoForCheck', {
  43. params: {
  44. ...form.value
  45. }
  46. }).then(res => {
  47. if (res.code == 200) {
  48. uni.setStorageSync('orderDetail', res.data)
  49. uni.navigateTo({
  50. url: `/pages/index/detail/index?id=${res.data.orderId}`
  51. })
  52. } else {
  53. let text = form.value.search + res.msg
  54. uni.$u.ttsModule.speak(text)
  55. }
  56. })
  57. };
  58. // 处理扫码
  59. const handleScan = () => {
  60. uni.scanCode({
  61. success: (res) => {
  62. form.value.search = res.result;
  63. handleSearch();
  64. }
  65. });
  66. }
  67. onLoad(() => {
  68. // #ifdef APP-PLUS
  69. uni.$u.useGlobalEvent((e) => {
  70. form.value.search = e.barcode
  71. handleSearch()
  72. })
  73. // #endif
  74. })
  75. onShow(() => {
  76. uni.$u.updateActivePageOnShow()
  77. })
  78. </script>
  79. <style lang="scss" scoped>
  80. @import '../components/common.scss';
  81. </style>