ScanCode.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="扫描设备"
  8. @clickLeft="back"
  9. ></uni-nav-bar>
  10. <view class="main">
  11. <view class="ts"> 请将红外设备对准条形码 </view>
  12. <view class="title" v-if="info"> 扫描结果: </view>
  13. <view class="content" v-if="info">
  14. {{ info }}
  15. </view>
  16. </view>
  17. <view class="fixed-bottom-bar">
  18. <view class="item s2" @click="back"> 返回 </view>
  19. <view class="item s1" @click="submit"> 确定 </view>
  20. </view>
  21. <ScanCode @scancodedate="cbScancodedate"></ScanCode>
  22. </view>
  23. </template>
  24. <script>
  25. import ScanCode from '@/components/ScanCode.vue'
  26. import { get, postJ, post } from '@/utils/api.js'
  27. export default {
  28. data () {
  29. return {
  30. info: null
  31. }
  32. },
  33. components: {
  34. ScanCode
  35. },
  36. /* onShow () {
  37. var _this = this
  38. uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
  39. uni.$on('scancodedate', function (data) {
  40. _this.info = data.code
  41. })
  42. }, */
  43. methods: {
  44. submit () {
  45. if (this.info) {
  46. uni.$emit('scancode', { code: this.info })
  47. //this.back()
  48. } else {
  49. uni.showToast({
  50. title: '请先扫描条形码',
  51. icon: 'none'
  52. })
  53. }
  54. },
  55. // 返回
  56. back () {
  57. uni.navigateBack({
  58. delta: 1
  59. })
  60. },
  61. cbScancodedate(data){
  62. this.info = data.code
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. .main {
  69. padding: 30rpx;
  70. padding-bottom: 81rpx;
  71. }
  72. .title {
  73. margin-top: 30rpx;
  74. }
  75. .fixed-bottom-bar {
  76. display: flex;
  77. position: fixed;
  78. bottom: 0;
  79. left: 0;
  80. width: 100%;
  81. height: 80rpx;
  82. box-sizing: border-box;
  83. border-top: 1px solid #f2f2f2;
  84. .item {
  85. flex: 1;
  86. height: 100%;
  87. line-height: 80rpx;
  88. text-align: center;
  89. &.s1 {
  90. background-color: #157a2c;
  91. color: #fff;
  92. }
  93. }
  94. }
  95. </style>