printScan.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="saleSelfMachine">
  3. <div class="background">
  4. <img :src="backgroundImgURL" width="100%" height="100%" />
  5. </div>
  6. <div class="orderNumberData">
  7. <el-input
  8. placeholder="请将二维码放置在扫描区"
  9. v-model="orderNumber"
  10. :focus="true"
  11. ref="inputs"
  12. :disabled="!isEdit"
  13. >
  14. </el-input>
  15. <div style="display:block;width:120px">
  16. 手动输入开关:
  17. </div>
  18. <el-switch
  19. v-model="isEdit"
  20. active-color="#66ccff"
  21. inactive-color="#ffffff"
  22. >
  23. </el-switch>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. orderNumber: null,
  32. isEdit: true,
  33. backgroundImgURL: require("@/assets/saleSelfMachine/scanCode.jpg")
  34. };
  35. },
  36. created() {
  37. this.changfouce();
  38. },
  39. // watch:{
  40. // data:"toSaleSelfMachine"
  41. // },
  42. methods: {
  43. //输入框自动聚焦
  44. changfouce() {
  45. this.$nextTick(x => {
  46. this.$refs.inputs.focus();
  47. });
  48. }
  49. //失去焦点后自动执行获得焦点事件
  50. // onInputBlur(){
  51. // console.log("获取焦点")
  52. // this.changfouce();
  53. // }
  54. // toSaleSelfMachine(){
  55. // this.$router.push({
  56. // path:'/saleSelfMachine',
  57. // })
  58. // }
  59. },
  60. mounted() {
  61. // this.changfouce();
  62. const timer = setInterval(() => {
  63. // if(this.$refs.inputs.focus==false){
  64. // console.log("false")
  65. this.changfouce();
  66. //}
  67. if (this.orderNumber != null && this.orderNumber.length == 21) {
  68. if (
  69. this.orderNumber.startsWith("WYSDD") == true ||
  70. this.orderNumber.startsWith("wysdd") == true
  71. ) {
  72. this.$router.push({
  73. path: "/saleSelfMachine?orderNumber=" + this.orderNumber
  74. });
  75. }
  76. } else if (this.orderNumber.length > 21) {
  77. //清空输入框,免得一次多个重复订单还无法删除
  78. this.orderNumber = null;
  79. }
  80. }, 3000);
  81. this.$once("hook:beforeDestroy", () => {
  82. clearInterval(timer);
  83. });
  84. }
  85. };
  86. </script>
  87. <style lang="scss">
  88. .saleSelfMachine {
  89. width: 100vh;
  90. height: 100vh;
  91. .background {
  92. width: 100%;
  93. height: 100%;
  94. z-index: -1;
  95. position: absolute;
  96. overflow: hidden;
  97. }
  98. .orderNumberData {
  99. width: 100%;
  100. color: #fff;
  101. position: absolute;
  102. display: flex;
  103. justify-content: center;
  104. align-items: center;
  105. }
  106. }
  107. </style>