express-order.vue 2.8 KB

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