express-order.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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" @change="playGlobalSound">
  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 @focus="playGlobalSound"
  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. function playGlobalSound(){
  40. console.log('playGlobalSound')
  41. uni.$u.playClickSound()
  42. }
  43. // 处理查询
  44. const handleSearch = () => {
  45. playGlobalSound()
  46. if(!form.value.search){
  47. let text = form.value.searchType == '1' ? '请输入订单编号' : '请输入物流单号'
  48. uni.$u.ttsModule.speak(text)
  49. return
  50. }
  51. // TODO: 查询订单
  52. uni.$u.http.get('/app/orderinfo/getOrderInfoForCheck', {
  53. params: {
  54. ...form.value
  55. }
  56. }).then(res => {
  57. if (res.code == 200) {
  58. uni.setStorageSync('orderDetail', res.data)
  59. uni.navigateTo({
  60. url: `/pages/index/detail/index?id=${res.data.orderId}`
  61. })
  62. } else {
  63. let text = form.value.search + res.msg
  64. uni.$u.ttsModule.speak(text)
  65. }
  66. })
  67. };
  68. // 处理扫码
  69. const handleScan = () => {
  70. playGlobalSound()
  71. uni.scanCode({
  72. success: (res) => {
  73. form.value.search = res.result;
  74. handleSearch();
  75. }
  76. });
  77. }
  78. onLoad(() => {
  79. // #ifdef APP-PLUS
  80. uni.$u.useGlobalEvent((e) => {
  81. form.value.search = e.barcode
  82. handleSearch()
  83. })
  84. // #endif
  85. })
  86. onShow(() => {
  87. uni.$u.updateActivePageOnShow()
  88. })
  89. </script>
  90. <style lang="scss" scoped>
  91. @import '../components/common.scss';
  92. </style>